Skip to content

Commit 8962031

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 8962031

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp

Lines changed: 6 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>
84+
ClOmitNonCaptured("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,8 @@ 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) &&
458+
ClOmitNonCaptured) {
454459
// The variable is addressable but not captured, so it cannot be
455460
// referenced from a different thread and participate in a data race
456461
// (see llvm/Analysis/CaptureTracking.h for details).

0 commit comments

Comments
 (0)