aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorAndy Kaylor <andrew.kaylor@intel.com>2020-01-23 16:37:24 -0800
committerAndy Kaylor <andrew.kaylor@intel.com>2020-01-23 18:18:50 -0800
commitc467faf23c7abda60cfd5486a39ffadd6f546d5c (patch)
tree52bf653f68a9db10a4e1d079403e6c011ce57371 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent580d7838dd08e13dac6caf4ab3142c9381bc7ad0 (diff)
downloadllvm-c467faf23c7abda60cfd5486a39ffadd6f546d5c.zip
llvm-c467faf23c7abda60cfd5486a39ffadd6f546d5c.tar.gz
llvm-c467faf23c7abda60cfd5486a39ffadd6f546d5c.tar.bz2
[WinEH] Ignore lifetime.end PHI nodes in empty cleanuppads
This fixes a bug where a PHI node that is only referenced by a lifetime.end intrinsic in an otherwise empty cleanuppad can cause SimplyCFG to create an SSA violation while removing the empty cleanuppad. Theoretically the same problem can occur with debug intrinsics. Differential Revision: https://reviews.llvm.org/D72540
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index d93ca4f..222f8af 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4083,9 +4083,10 @@ static bool removeEmptyCleanup(CleanupReturnInst *RI) {
// The iterator must be incremented here because the instructions are
// being moved to another block.
PHINode *PN = cast<PHINode>(I++);
- if (PN->use_empty())
- // If the PHI node has no uses, just leave it. It will be erased
- // when we erase BB below.
+ if (PN->use_empty() || !PN->isUsedOutsideOfBlock(BB))
+ // If the PHI node has no uses or all of its uses are in this basic
+ // block (meaning they are debug or lifetime intrinsics), just leave
+ // it. It will be erased when we erase BB below.
continue;
// Otherwise, sink this PHI node into UnwindDest.