[llvm] [Attributor] Change allocation size and load/store offsets using AAPointerInfo for Alloca instructions and keep track of instructions causing an Access (PR #72029)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 12:07:46 PST 2025
================
@@ -10,11 +10,11 @@ define void @foo(ptr %ptr) {
; TUNIT-LABEL: define {{[^@]+}}@foo
; TUNIT-SAME: (ptr nofree readnone captures(none) [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {
; TUNIT-NEXT: entry:
-; TUNIT-NEXT: [[TMP0:%.*]] = alloca [[STRUCT_TEST_A:%.*]], align 8
+; TUNIT-NEXT: [[TMP0:%.*]] = alloca [8 x i8], align 1
; TUNIT-NEXT: br label [[CALL_BR:%.*]]
; TUNIT: call.br:
-; TUNIT-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_TEST_A]], ptr [[TMP0]], i64 0, i32 2
-; TUNIT-NEXT: tail call void @bar(ptr noalias nofree noundef nonnull readonly byval([[STRUCT_TEST_A]]) align 8 captures(none) dereferenceable(24) [[TMP0]]) #[[ATTR2:[0-9]+]]
+; TUNIT-NEXT: [[NEWGEP:%.*]] = getelementptr [8 x i8], ptr [[TMP0]], i64 0
+; TUNIT-NEXT: tail call void @bar(ptr noalias nofree noundef nonnull readonly byval([[STRUCT_TEST_A:%.*]]) align 8 captures(none) dereferenceable(24) [[TMP0]]) #[[ATTR2:[0-9]+]]
----------------
shiltian wrote:
I don't think it is safe to do so, because the alloca here is aligned to 1, but in the callee, it is used as if the alignment is 8, because it tries to access it as a pointer to `%struct.test.a`.
https://github.com/llvm/llvm-project/pull/72029
More information about the llvm-commits
mailing list