[llvm] 9179715 - [ArgPromotion] Pass context instruction to dereferenceability check (#202305)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 05:36:49 PDT 2026
Author: Nikita Popov
Date: 2026-06-08T14:36:44+02:00
New Revision: 91797152d96713a46f4ca604d191f144cbb48659
URL: https://github.com/llvm/llvm-project/commit/91797152d96713a46f4ca604d191f144cbb48659
DIFF: https://github.com/llvm/llvm-project/commit/91797152d96713a46f4ca604d191f144cbb48659.diff
LOG: [ArgPromotion] Pass context instruction to dereferenceability check (#202305)
This is necessary for argument promotion to work under deref-at-point
semantics. For the primary case, specify the context instruction as the
first instruction in the function, which should effectively disable the
check for frees.
Added:
Modified:
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/test/Transforms/ArgumentPromotion/align.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index cfbf9dec01619..6ef7323364907 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -456,7 +456,8 @@ static bool allCallersPassValidPointerForArgument(
APInt Bytes(64, NeededDerefBytes);
// Check if the argument itself is marked dereferenceable and aligned.
- if (isDereferenceableAndAlignedPointer(Arg, NeededAlign, Bytes, DL))
+ if (isDereferenceableAndAlignedPointer(Arg, NeededAlign, Bytes, DL,
+ &Callee->getEntryBlock().front()))
return true;
// Look at all call sites of the function. At this point we know we only have
@@ -491,7 +492,7 @@ static bool allCallersPassValidPointerForArgument(
return true;
return isDereferenceableAndAlignedPointer(CB.getArgOperand(Arg->getArgNo()),
- NeededAlign, Bytes, DL);
+ NeededAlign, Bytes, DL, &CB);
});
}
diff --git a/llvm/test/Transforms/ArgumentPromotion/align.ll b/llvm/test/Transforms/ArgumentPromotion/align.ll
index 656c7c9da5b4a..62dd1dcc478c4 100644
--- a/llvm/test/Transforms/ArgumentPromotion/align.ll
+++ b/llvm/test/Transforms/ArgumentPromotion/align.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
; RUN: opt -S -passes=argpromotion < %s | FileCheck %s
+; RUN: opt -S -passes=argpromotion -use-dereferenceable-at-point-semantics < %s | FileCheck %s
define internal i32 @callee_must_exec(ptr %p) {
; CHECK-LABEL: define {{[^@]+}}@callee_must_exec
More information about the llvm-commits
mailing list