[llvm] 97efd8a - [InstCombine] Preserve inalloca tag when transforming alloca
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 05:27:09 PST 2023
Author: Nikita Popov
Date: 2023-12-11T14:27:00+01:00
New Revision: 97efd8aa435c07aac5676d30e0311e9c05fb12c7
URL: https://github.com/llvm/llvm-project/commit/97efd8aa435c07aac5676d30e0311e9c05fb12c7
DIFF: https://github.com/llvm/llvm-project/commit/97efd8aa435c07aac5676d30e0311e9c05fb12c7.diff
LOG: [InstCombine] Preserve inalloca tag when transforming alloca
This is not meaningful in any practical sense, and just makes sure
we don't cause verifier failures.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/alloca.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index f8fae773e476d4..bb2a77daa60a76 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -213,6 +213,7 @@ static Instruction *simplifyAllocaArraySize(InstCombinerImpl &IC,
AllocaInst *New = IC.Builder.CreateAlloca(NewTy, AI.getAddressSpace(),
nullptr, AI.getName());
New->setAlignment(AI.getAlign());
+ New->setUsedWithInAlloca(AI.isUsedWithInAlloca());
replaceAllDbgUsesWith(AI, *New, *New, DT);
return IC.replaceInstUsesWith(AI, New);
diff --git a/llvm/test/Transforms/InstCombine/alloca.ll b/llvm/test/Transforms/InstCombine/alloca.ll
index a64de28ee83977..4247d6a3019312 100644
--- a/llvm/test/Transforms/InstCombine/alloca.ll
+++ b/llvm/test/Transforms/InstCombine/alloca.ll
@@ -248,3 +248,14 @@ entry:
call void (...) @use(ptr nonnull @int) [ "blah"(ptr %y) ]
ret void
}
+
+define void @test_inalloca_with_element_count(ptr %a) {
+; ALL-LABEL: @test_inalloca_with_element_count(
+; ALL-NEXT: [[ALLOCA1:%.*]] = alloca inalloca [10 x %struct_type], align 4
+; ALL-NEXT: call void @test9_aux(ptr nonnull inalloca([[STRUCT_TYPE:%.*]]) [[ALLOCA1]])
+; ALL-NEXT: ret void
+;
+ %alloca = alloca inalloca %struct_type, i32 10, align 4
+ call void @test9_aux(ptr inalloca(%struct_type) %alloca)
+ ret void
+}
More information about the llvm-commits
mailing list