aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/MergeFunctions.cpp
diff options
context:
space:
mode:
authorMark Lacey <mark.lacey@apple.com>2016-05-20 18:39:11 +0000
committerMark Lacey <mark.lacey@apple.com>2016-05-20 18:39:11 +0000
commit9b5fcf65ecffdde3983ffd9ab3f0e79e89794235 (patch)
tree0b89733ad74464a4e071b952ae03fe3a2560701f /llvm/lib/Transforms/IPO/MergeFunctions.cpp
parent79fe1bea6bde1a937c6469cb1735a6cf6e493c46 (diff)
downloadllvm-9b5fcf65ecffdde3983ffd9ab3f0e79e89794235.zip
llvm-9b5fcf65ecffdde3983ffd9ab3f0e79e89794235.tar.gz
llvm-9b5fcf65ecffdde3983ffd9ab3f0e79e89794235.tar.bz2
Functions with differing phis should not be merged.
Check that the incoming blocks of phi nodes are identical, and block function merging if they are not. rdar://problem/26255167 Differential Revision: http://reviews.llvm.org/D20462 llvm-svn: 270250
Diffstat (limited to 'llvm/lib/Transforms/IPO/MergeFunctions.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/MergeFunctions.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index e16749c..bb0ab84 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -1050,6 +1050,17 @@ int FunctionComparator::cmpOperations(const Instruction *L,
return cmpNumbers(RMWI->getSynchScope(),
cast<AtomicRMWInst>(R)->getSynchScope());
}
+ if (const PHINode *PNL = dyn_cast<PHINode>(L)) {
+ const PHINode *PNR = cast<PHINode>(R);
+ // Ensure that in addition to the incoming values being identical
+ // (checked by the caller of this function), the incoming blocks
+ // are also identical.
+ for (unsigned i = 0, e = PNL->getNumIncomingValues(); i != e; ++i) {
+ if (int Res =
+ cmpValues(PNL->getIncomingBlock(i), PNR->getIncomingBlock(i)))
+ return Res;
+ }
+ }
return 0;
}