summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-05-21 05:12:32 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-05-21 05:12:32 +0000
commit9f92f4c497734abc8104a3b2219fdae765691e13 (patch)
tree20f73c40ba9e751f44ff9450e4b239e20b25d7c5 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent73f48f4662f30b837743a02ab9256558521fb20a (diff)
downloadbcm5719-llvm-9f92f4c497734abc8104a3b2219fdae765691e13.tar.gz
bcm5719-llvm-9f92f4c497734abc8104a3b2219fdae765691e13.zip
[SimplifyCFG] Remove cleanuppads which are empty except for calls to lifetime.end
A cleanuppad is not cheap, they turn into many instructions and result in additional spills and fills. It is not worth keeping a cleanuppad around if all it does is hold a lifetime.end instruction. N.B. We first try to merge the cleanuppad with another cleanuppad to avoid dropping the lifetime and debug info markers. llvm-svn: 270314
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index fb6a13fadc5..25baf1bf640 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3424,11 +3424,23 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI) {
// This isn't an empty cleanup.
return false;
- // Check that there are no other instructions except for debug intrinsics.
+ // Check that there are no other instructions except for benign intrinsics.
BasicBlock::iterator I = CPInst->getIterator(), E = RI->getIterator();
- while (++I != E)
- if (!isa<DbgInfoIntrinsic>(I))
+ while (++I != E) {
+ auto *II = dyn_cast<IntrinsicInst>(I);
+ if (!II)
+ return false;
+
+ Intrinsic::ID IntrinsicID = II->getIntrinsicID();
+ switch (IntrinsicID) {
+ case Intrinsic::dbg_declare:
+ case Intrinsic::dbg_value:
+ case Intrinsic::lifetime_end:
+ break;
+ default:
return false;
+ }
+ }
// If the cleanup return we are simplifying unwinds to the caller, this will
// set UnwindDest to nullptr.
@@ -3567,10 +3579,10 @@ bool SimplifyCFGOpt::SimplifyCleanupReturn(CleanupReturnInst *RI) {
if (isa<UndefValue>(RI->getOperand(0)))
return false;
- if (removeEmptyCleanup(RI))
+ if (mergeCleanupPad(RI))
return true;
- if (mergeCleanupPad(RI))
+ if (removeEmptyCleanup(RI))
return true;
return false;
OpenPOWER on IntegriCloud