summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2016-09-07 21:38:22 +0000
committerHal Finkel <hfinkel@anl.gov>2016-09-07 21:38:22 +0000
commitac5803ba918eeb133b1a0665eaf0e430f714b4d1 (patch)
treee31abd2f48fd2834fa908a91515d80b6d08806bb /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent109f4f35095dece3a05c88f6a40a7ad6ad07951f (diff)
downloadbcm5719-llvm-ac5803ba918eeb133b1a0665eaf0e430f714b4d1.tar.gz
bcm5719-llvm-ac5803ba918eeb133b1a0665eaf0e430f714b4d1.zip
[SimplifyCFG] Don't try to create metadata-valued PHIs
We can't create metadata-valued PHIs; don't try to do so when sinking. I created a test case for this using the @llvm.type.test intrinsic, because it takes a metadata parameter and does not have severe side effects (thus SimplifyCFG is willing to otherwise sink it). Previously, running the test case would crash with: Invalid use of metadata! %.sink = select i1 %flag, metadata <...>, metadata <0x4e45dc0> LLVM ERROR: Broken function found, compilation aborted! llvm-svn: 280866
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index e5da77e6319..5785968114c 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1338,6 +1338,10 @@ HoistTerminator:
// FIXME: This should be promoted to Instruction.
static bool canReplaceOperandWithVariable(const Instruction *I,
unsigned OpIdx) {
+ // We can't have a PHI with a metadata type.
+ if (I->getOperand(OpIdx)->getType()->isMetadataTy())
+ return false;
+
// Early exit.
if (!isa<Constant>(I->getOperand(OpIdx)))
return true;
OpenPOWER on IntegriCloud