[llvm-branch-commits] [LowerAllowCheck] Add llvm.allow.sanitize.* intrinsics (PR #172029)

Alexander Potapenko via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 18 03:01:13 PST 2025


================
@@ -123,26 +124,41 @@ static bool lowerAllowChecks(Function &F, const BlockFrequencyInfo &BFI,
     switch (ID) {
     case Intrinsic::allow_ubsan_check:
     case Intrinsic::allow_runtime_check: {
-      ++NumChecksTotal;
-
       bool ToRemove = ShouldRemove(II);
 
       ReplaceWithValue.push_back({
           II,
-          ToRemove,
+          !ToRemove,
       });
-      if (ToRemove)
-        ++NumChecksRemoved;
       emitRemark(II, ORE, ToRemove);
       break;
     }
+    case Intrinsic::allow_sanitize_address:
+      ReplaceWithValue.push_back(
+          {II, F.hasFnAttribute(Attribute::SanitizeAddress)});
+      break;
+    case Intrinsic::allow_sanitize_thread:
+      ReplaceWithValue.push_back(
+          {II, F.hasFnAttribute(Attribute::SanitizeThread)});
+      break;
+    case Intrinsic::allow_sanitize_memory:
+      ReplaceWithValue.push_back(
+          {II, F.hasFnAttribute(Attribute::SanitizeMemory)});
+      break;
+    case Intrinsic::allow_sanitize_hwaddress:
+      ReplaceWithValue.push_back(
+          {II, F.hasFnAttribute(Attribute::SanitizeHWAddress)});
+      break;
     default:
       break;
     }
   }
 
   for (auto [I, V] : ReplaceWithValue) {
-    I->replaceAllUsesWith(ConstantInt::getBool(I->getType(), !V));
+    ++NumChecksTotal;
+    if (!V) // If the final value is false, the check is considered removed
----------------
ramosian-glider wrote:

Nit: period at the end of the line.

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


More information about the llvm-branch-commits mailing list