Skip to content

Commit 3acc0c0

Browse files
committed
[TSan] Add option to ignore capturing behavior when instrumenting
Required for some tools depending on the annotation interface
1 parent d679dc7 commit 3acc0c0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ static cl::opt<bool> ClCompoundReadBeforeWrite(
8080
"tsan-compound-read-before-write", cl::init(false),
8181
cl::desc("Emit special compound instrumentation for reads-before-writes"),
8282
cl::Hidden);
83+
static cl::opt<bool> ClOmitNonCaptured(
84+
"tsan-omit-by-pointer-capturing", cl::init(true),
85+
cl::desc("Omit accesses due to pointer capturing"),
86+
cl::Hidden);
8387

8488
STATISTIC(NumInstrumentedReads, "Number of instrumented reads");
8589
STATISTIC(NumInstrumentedWrites, "Number of instrumented writes");
@@ -450,7 +454,7 @@ void ThreadSanitizer::chooseInstructionsToInstrument(
450454

451455
const AllocaInst *AI = findAllocaForValue(Addr);
452456
// Instead of Addr, we should check whether its base pointer is captured.
453-
if (AI && !PointerMayBeCaptured(AI, /*ReturnCaptures=*/true)) {
457+
if (AI && !PointerMayBeCaptured(AI, /*ReturnCaptures=*/true) && ClOmitNonCaptured) {
454458
// The variable is addressable but not captured, so it cannot be
455459
// referenced from a different thread and participate in a data race
456460
// (see llvm/Analysis/CaptureTracking.h for details).

0 commit comments

Comments
 (0)