[PATCH] D24854: [SROA] Drop lifetime.start/end intrinsics when they block promotion.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 5 12:22:33 PDT 2016
efriedma retitled this revision from "[SROA] Expand lifetime.start/end offset checks to a couple more places." to "[SROA] Drop lifetime.start/end intrinsics when they block promotion.".
efriedma updated this revision to Diff 73682.
efriedma added a comment.
New approach which drops lifetime intrinsics instead of trying to preserve them.
Repository:
rL LLVM
https://reviews.llvm.org/D24854
Files:
lib/Transforms/Scalar/SROA.cpp
test/Transforms/SROA/basictest.ll
Index: test/Transforms/SROA/basictest.ll
===================================================================
--- test/Transforms/SROA/basictest.ll
+++ test/Transforms/SROA/basictest.ll
@@ -1672,9 +1672,8 @@
define void @PR27999() unnamed_addr {
; CHECK-LABEL: @PR27999(
-; CHECK: alloca [2 x i64], align 8
-; CHECK: call void @llvm.lifetime.start(i64 16,
-; CHECK: call void @llvm.lifetime.end(i64 8,
+; CHECK: entry-block:
+; CHECK-NEXT: ret void
entry-block:
%0 = alloca [2 x i64], align 8
%1 = bitcast [2 x i64]* %0 to i8*
@@ -1684,3 +1683,15 @@
call void @llvm.lifetime.end(i64 8, i8* %3)
ret void
}
+
+define void @PR29139() {
+; CHECK-LABEL: @PR29139(
+; CHECK: bb1:
+; CHECK-NEXT: ret void
+bb1:
+ %e.7.sroa.6.i = alloca i32, align 1
+ %e.7.sroa.6.0.load81.i = load i32, i32* %e.7.sroa.6.i, align 1
+ %0 = bitcast i32* %e.7.sroa.6.i to i8*
+ call void @llvm.lifetime.end(i64 2, i8* %0)
+ ret void
+}
Index: lib/Transforms/Scalar/SROA.cpp
===================================================================
--- lib/Transforms/Scalar/SROA.cpp
+++ lib/Transforms/Scalar/SROA.cpp
@@ -2875,6 +2875,18 @@
// Record this instruction for deletion.
Pass.DeadInsts.insert(&II);
+ // Lifetime intrinsics are only promotable if they cover the whole alloca.
+ // Therefore, we drop lifetime intrinsics which don't cover the whole
+ // alloca.
+ // (In theory, intrinsics which partially cover an alloca could be
+ // promoted, but PromoteMemToReg doesn't handle that case.)
+ // FIXME: Check whether the alloca is promotable before dropping the
+ // lifetime intrinsics?
+ bool IsWholeAlloca = NewBeginOffset == NewAllocaBeginOffset &&
+ NewEndOffset == NewAllocaEndOffset;
+ if (!IsWholeAlloca)
+ return true;
+
ConstantInt *Size =
ConstantInt::get(cast<IntegerType>(II.getArgOperand(0)->getType()),
NewEndOffset - NewBeginOffset);
@@ -2888,12 +2900,7 @@
(void)New;
DEBUG(dbgs() << " to: " << *New << "\n");
- // Lifetime intrinsics are only promotable if they cover the whole alloca.
- // (In theory, intrinsics which partially cover an alloca could be
- // promoted, but PromoteMemToReg doesn't handle that case.)
- bool IsWholeAlloca = NewBeginOffset == NewAllocaBeginOffset &&
- NewEndOffset == NewAllocaEndOffset;
- return IsWholeAlloca;
+ return true;
}
bool visitPHINode(PHINode &PN) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24854.73682.patch
Type: text/x-patch
Size: 2490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161005/a40583ba/attachment.bin>
More information about the llvm-commits
mailing list