Skip to content

Implement lock summaries for interprocedural analysis in LockOwnership#55

Open
michael-schwarz wants to merge 7 commits intofocs-lab:tsan-with-ea-IPAfrom
michael-schwarz:tsan-with-ea-IPA
Open

Implement lock summaries for interprocedural analysis in LockOwnership#55
michael-schwarz wants to merge 7 commits intofocs-lab:tsan-with-ea-IPAfrom
michael-schwarz:tsan-with-ea-IPA

Conversation

@michael-schwarz
Copy link
Member

Replaces full exit state propagation at call sites with precise lock summaries tracking which locks a function may release and which it must acquire.

Changes

  • Data structures: Extended FuncStateTy with MayUnlock and MustLock sets

    • MayUnlock: Locks held at entry but not at exit (released on some path)
    • MustLock: Locks held at exit but not at entry (newly acquired on all paths)
  • Summary computation: In buildSummary(), compute summaries by comparing entry and exit states

    • Handles both absent locks and explicitly unlocked locks in state maps
  • Call edge handling: In applyTransferFunc(), apply summaries instead of full exit state

    • Remove locks in callee's MayUnlock from current lockset
    • Add locks in callee's MustLock to current lockset

Example

// Before: Replaced entire lockset with callee's exit state
for (const auto &[Lock, State] : FuncStateIt->second.ExitState) {
  if (State.IsLocked) handleLock(InState, I, Lock);
  else handleUnlock(InState, I, Lock);
}

// After: Selectively apply lock changes
for (const Value *Lock : FuncStateIt->second.MayUnlock) {
  if (InState.find(Lock) != InState.end())
    handleUnlock(InState, I, Lock);
}
for (const Value *Lock : FuncStateIt->second.MustLock) {
  handleLock(InState, I, Lock);
}

This enables more precise tracking of lock state changes across function boundaries, particularly for functions that partially modify the lockset.

Original prompt

This section details on the original issue you should resolve

<issue_title>Use lock summaries in LockOwnership.cpp</issue_title>
<issue_description>Make a PR against the branch tsan-with-ea-IPA. In this PR, on top of computing the currently held lockset, for each procedure also compute a summary consisting of two sets:

  • A set of mutexes that may be unlocked anywhere in the function and not relocked
  • A set of mutexes that were not known to locked at the start of the function but are known to be locked now.

Then, we computing the effect of a call edge to f, take the current lockset, remove any mutexes that f may unlock and add those that f must lock.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 7 commits February 19, 2026 08:25
Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
Co-authored-by: michael-schwarz <13812333+michael-schwarz@users.noreply.github.com>
…-in-lockownership-again

Implement lock summaries for interprocedural analysis in LockOwnership
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