[PATCH] D106950: Fixing an infinite loop problem in InstCombine
Andy Kaylor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 29 13:05:11 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4d945bacdaf: Fixing an infinite loop problem in InstCombine (authored by andrew.w.kaylor).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106950/new/
https://reviews.llvm.org/D106950
Files:
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/memcpy-from-global.ll
Index: llvm/test/Transforms/InstCombine/memcpy-from-global.ll
===================================================================
--- llvm/test/Transforms/InstCombine/memcpy-from-global.ll
+++ llvm/test/Transforms/InstCombine/memcpy-from-global.ll
@@ -342,4 +342,22 @@
ret float %r
}
+; If the memcpy is volatile, it should not be removed
+define float @test11_volatile(i64 %i) {
+; CHECK-LABEL: @test11_volatile(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: alloca
+; CHECK: call void @llvm.lifetime.start.p0i8
+; CHECK: call void @llvm.memcpy
+
+entry:
+ %a = alloca [4 x float], align 4
+ %b = bitcast [4 x float]* %a to i8*
+ call void @llvm.lifetime.start.p0i8(i64 16, i8* %b)
+ call void @llvm.memcpy.p0i8.p1i8.i64(i8* align 4 %b, i8 addrspace(1)* align 4 bitcast ([4 x float] addrspace(1)* @I to i8 addrspace(1)*), i64 16, i1 true)
+ %g = getelementptr inbounds [4 x float], [4 x float]* %a, i64 0, i64 %i
+ %r = load float, float* %g, align 4
+ ret float %r
+}
+
attributes #0 = { null_pointer_is_valid }
Index: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -261,8 +261,8 @@
bool PointerReplacer::collectUsers(Instruction &I) {
for (auto U : I.users()) {
- Instruction *Inst = cast<Instruction>(&*U);
- if (LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
+ auto *Inst = cast<Instruction>(&*U);
+ if (auto *Load = dyn_cast<LoadInst>(Inst)) {
if (Load->isVolatile())
return false;
Worklist.insert(Load);
@@ -270,7 +270,9 @@
Worklist.insert(Inst);
if (!collectUsers(*Inst))
return false;
- } else if (isa<MemTransferInst>(Inst)) {
+ } else if (auto *MI = dyn_cast<MemTransferInst>(Inst)) {
+ if (MI->isVolatile())
+ return false;
Worklist.insert(Inst);
} else if (Inst->isLifetimeStartOrEnd()) {
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106950.362855.patch
Type: text/x-patch
Size: 2037 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/f4a6d5b0/attachment.bin>
More information about the llvm-commits
mailing list