[llvm] [TSan] Add option to ignore capturing behavior when instrumenting (PR #148156)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 01:54:55 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
index d24ee09ab..0d48a3502 100644
--- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -80,10 +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);
+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");
@@ -454,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) && ClOmitNonCaptured) {
+    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).

``````````

</details>


https://github.com/llvm/llvm-project/pull/148156


More information about the llvm-commits mailing list