diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2016-11-28 21:50:34 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2016-11-28 21:50:34 +0000 |
commit | 5096775393b8509922bfc562ad497f1313cef3af (patch) | |
tree | d31c8136347d926383bbc93b0dfb8d4ad2fe9931 /llvm/lib/Transforms/Scalar | |
parent | 1cf9aff65952c7eb1bea7ecfd76a7dd5b0c6f450 (diff) | |
download | bcm5719-llvm-5096775393b8509922bfc562ad497f1313cef3af.tar.gz bcm5719-llvm-5096775393b8509922bfc562ad497f1313cef3af.zip |
[SROA] Drop lifetime.start/end intrinsics when they block promotion.
Preserving lifetime markers isn't as important as allowing promotion,
so just drop the lifetime markers if necessary.
This also fixes an assertion failure where other parts of SROA assumed
that lifetime markers never block promotion.
Fixes https://llvm.org/bugs/show_bug.cgi?id=29139.
Differential Revision: https://reviews.llvm.org/D24854
llvm-svn: 288074
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SROA.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index 19078669110..54ce1d8fb60 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -2876,6 +2876,17 @@ private: // 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? + if (NewBeginOffset != NewAllocaBeginOffset || + NewEndOffset != NewAllocaEndOffset) + return true; + ConstantInt *Size = ConstantInt::get(cast<IntegerType>(II.getArgOperand(0)->getType()), NewEndOffset - NewBeginOffset); @@ -2889,12 +2900,7 @@ private: (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) { |