Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread cf & must edges #494

Merged
merged 11 commits into from
Aug 3, 2023
Merged

Conversation

ThomasHaas
Copy link
Collaborator

@ThomasHaas ThomasHaas commented Aug 1, 2023

This PR adds proper control-flow dependencies between spawned threads and their spawners/creators.

  • Each thread's entry event is now a ThreadStart event that may have a ThreadCreate event as a creator. If creator == null, the thread is executed unconditionally (e.g, the main thread, init threads, and all threads in litmus tests).
  • The control-flow encoding now allows the execution of ThreadStart only if its associated creator (if any) gets executed.
  • BranchEquivalence has been reworked to respect this new control-flow and consider the control-flow relationship between a thread and its creator.
  • Synchronization events between spawning thread and spawned thread have been simplified.
  • We now generate must-rf edges for synchronizing events.

Minor side changes:

  • SCCP now properly recognizes AbortIf (true) for dead code detection
  • SCCP now eliminates trivial casts that do not change types (e.g., i64 to i64 casts).
  • Thread.getEntry and Thread.getExit now return ThreadStart resp. Label.

Updated control-flow encoding to connect control-flow of ThreadStart with ThreadCreate if possible.
…uivalence.

- Updated BranchEquivalence to correctly merge branches of threads that have a creator. Also removed functions related to reachability queries.
- Updated ThreadCreation's thread-synchronization code. Also added a missing store for thread ids.
Fixed LogThreadStatistics's detection of init threads (which now have an extra event).
  - Needs updating of its documentation
  - Now always merges branches (cannot be disabled)
  - Propagation of mutual exclusive branch classes can be improved
public ThreadStart(ThreadCreate creator) {
this.creator = creator;

mayFailSpuriously = (creator != null);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if I use the CLI option to force thread creation? If that is the case do we call setMayFailSpuriously()?

Copy link
Collaborator Author

@ThomasHaas ThomasHaas Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ThreadCreation will spawn threads and set the option based on whether thread creation is forced to succeed.
At some point, I will probably get rid of this flag again and instead let ThreadCreation generate a non-deterministic choice between success and failure like so:

// compiling "int success = pthread_create(&t, NULL; worker, arg);" to
if (*) {
    ThreadCreate(worker, arg);
    store (&t, TID);
    success = 1;
} else {
    // store (&t, -1);
    success = 0;
}

Then ThreadCreate/ThreadStart can always be assumed to succeed if executed.

@hernanponcedeleon
Copy link
Owner

LGTM

@hernanponcedeleon hernanponcedeleon merged commit 16d4e0e into development_rework Aug 3, 2023
1 check passed
@hernanponcedeleon hernanponcedeleon deleted the threadCf&mustEdges branch August 3, 2023 17:29
hernanponcedeleon added a commit that referenced this pull request Aug 8, 2023
* Function passes & Thread creation after unrolling #492
* Thread cf & must edges #494
* Dynamic Pthread join #496

---------

Signed-off-by: Hernan Ponce de Leon <[email protected]>
Co-authored-by: Thomas Haas <[email protected]>
Co-authored-by: René Pascal Maseli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants