diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-06-04 23:50:03 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-06-04 23:50:03 +0000 |
commit | 2482e1c01754210b197293ef50bafc72a166df10 (patch) | |
tree | 25b0bd1832b5a388a42ce9e715e8fc65178b6e07 /llvm/lib/Transforms | |
parent | e1979aed0a153d690bfaf4abfd9ed62d63439ecb (diff) | |
download | bcm5719-llvm-2482e1c01754210b197293ef50bafc72a166df10.tar.gz bcm5719-llvm-2482e1c01754210b197293ef50bafc72a166df10.zip |
[SimplifyCFG] Don't kill empty cleanuppads with multiple uses
A basic block could contain:
%cp = cleanuppad []
cleanupret from %cp unwind to caller
This basic block is empty and is thus a candidate for removal. However,
there can be other uses of %cp outside of this basic block. This is
only possible in unreachable blocks.
Make our transform more correct by checking that the pad has a single
user before removing the BB.
This fixes PR28005.
llvm-svn: 271816
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 25baf1bf640..ec2c1af97ea 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3424,6 +3424,11 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI) { // This isn't an empty cleanup. return false; + // We cannot kill the pad if it has multiple uses. This typically arises + // from unreachable basic blocks. + if (!CPInst->hasOneUse()) + return false; + // Check that there are no other instructions except for benign intrinsics. BasicBlock::iterator I = CPInst->getIterator(), E = RI->getIterator(); while (++I != E) { |