diff options
author | Yussur Mustafa Oraji <yussur.oraji@tu-darmstadt.de> | 2025-08-06 15:47:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-06 15:47:33 +0200 |
commit | ded1f3ec96bc3de2951094dff5a8d2e12f7402c8 (patch) | |
tree | eaf4556e896a00bb30c1b74335cb6e9bae6b0f92 /llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp | |
parent | e80e7e717e8c2efe2c1712dc3bb4f25ba7ed11f6 (diff) | |
download | llvm-ded1f3ec96bc3de2951094dff5a8d2e12f7402c8.zip llvm-ded1f3ec96bc3de2951094dff5a8d2e12f7402c8.tar.gz llvm-ded1f3ec96bc3de2951094dff5a8d2e12f7402c8.tar.bz2 |
[TSan] Add option to ignore capturing behavior when instrumenting (#148156)
While not needed for most applications, some tools such as
[MUST](https://www.i12.rwth-aachen.de/cms/i12/forschung/forschungsschwerpunkte/lehrstuhl-fuer-hochleistungsrechnen/~nrbe/must/)
depend on the instrumentation being present.
MUST uses the ThreadSanitizer annotation interface to detect data races
in MPI programs, where the capture tracking is detrimental as it has no
bearing on MPI data races, leading to missed races.
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp index 5485998..0d48a35 100644 --- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -80,6 +80,10 @@ static cl::opt<bool> ClCompoundReadBeforeWrite( "tsan-compound-read-before-write", cl::init(false), cl::desc("Emit special compound instrumentation for reads-before-writes"), cl::Hidden); +static cl::opt<bool> + ClOmitNonCaptured("tsan-omit-by-pointer-capturing", cl::init(true), + cl::desc("Omit accesses due to pointer capturing"), + cl::Hidden); STATISTIC(NumInstrumentedReads, "Number of instrumented reads"); STATISTIC(NumInstrumentedWrites, "Number of instrumented writes"); @@ -450,7 +454,8 @@ void ThreadSanitizer::chooseInstructionsToInstrument( const AllocaInst *AI = findAllocaForValue(Addr); // Instead of Addr, we should check whether its base pointer is captured. - if (AI && !PointerMayBeCaptured(AI, /*ReturnCaptures=*/true)) { + if (AI && !PointerMayBeCaptured(AI, /*ReturnCaptures=*/true) && + ClOmitNonCaptured) { // The variable is addressable but not captured, so it cannot be // referenced from a different thread and participate in a data race // (see llvm/Analysis/CaptureTracking.h for details). |