[compiler-rt] [llvm] [compiler-rt][asan] Add asan checks for __builtin_assume_dereferencable (PR #190871)
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 17:02:18 PDT 2026
================
@@ -3189,6 +3209,28 @@ bool AddressSanitizer::instrumentFunction(Function &F,
FunctionModified = true;
}
+ for (auto *AI : DerefAssumptions) {
+ if (auto Bundle = AI->getOperandBundle("dereferenceable")) {
+ Value *Ptr = Bundle->Inputs[0];
+ Value *Size = Bundle->Inputs[1];
+
+ InstrumentationIRBuilder IRB(AI);
+ Value *AddrLong = IRB.CreatePointerCast(Ptr, IntptrTy);
+ Value *SizeExt = IRB.CreateZExtOrTrunc(Size, IntptrTy);
+
+ // Skip if size is exactly 0.
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(SizeExt)) {
----------------
fmayer wrote:
Can we do this check without using IRB? otherwise we are inserting casts and then ignoring them.
https://github.com/llvm/llvm-project/pull/190871
More information about the llvm-commits
mailing list