[llvm] [Instrumentation] Add TSan instrumentation for AMDGPU targets (PR #207713)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 05:43:15 PDT 2026


================
@@ -100,6 +103,30 @@ STATISTIC(NumOmittedNonCaptured, "Number of accesses ignored due to capturing");
 const char kTsanModuleCtorName[] = "tsan.module_ctor";
 const char kTsanInitName[] = "__tsan_init";
 
+// The scope values are hard-coded here just like the atomic ordering.
+static ConstantInt *createScope(IRBuilder<> *IRB, const Triple &T,
+                                LLVMContext &Ctx, SyncScope::ID SSID) {
+  if (T.isAMDGPU()) {
+    auto Name = Ctx.getSyncScopeName(SSID);
+    if (!Name)
+      return IRB->getInt32(0);
+    uint32_t V = StringSwitch<uint32_t>(*Name)
----------------
jhuber6 wrote:

I couldn't figure out where to put it. I originally had it in the AMDGPU header somewhere but it pulled in some other crap. Do you know a good place? The problem is that it's trying to undo the clang-level scope, which unlike the memory order, isn't fixed in the language.

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


More information about the llvm-commits mailing list