summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instruction.cpp
diff options
context:
space:
mode:
authorJoel Jones <joel_k_jones@apple.com>2012-05-10 15:59:41 +0000
committerJoel Jones <joel_k_jones@apple.com>2012-05-10 15:59:41 +0000
commit3d90a9ae65cff5c9ac1ef009dcff5179000e1d9d (patch)
treef20f6de6bc10ad9521c9aba19832f2fa26980f3f /llvm/lib/VMCore/Instruction.cpp
parent5b7cb1db61c81c87136f65e936d29326de8d65e9 (diff)
downloadbcm5719-llvm-3d90a9ae65cff5c9ac1ef009dcff5179000e1d9d.tar.gz
bcm5719-llvm-3d90a9ae65cff5c9ac1ef009dcff5179000e1d9d.zip
Fix a problem with incomplete equality testing of PHINodes in
Instruction::IsIdenticalToWhenDefined. This manifested itself when inlining two calls to the same function. The inlined function had a switch statement that returned one of a set of global variables. Without this modification, the two phi instructions that chose values from the branches of the switch instruction inlined from the callee were considered equivalent and jump-threading replaced a load for the first switch value with a phi selecting from the second switch, thereby producing incorrect code. This patch has been tested with "make check-all", "lnt runteste nt", and llvm self-hosted, and on the original program that had this problem, wireshark. <rdar://problem/11025519> llvm-svn: 156548
Diffstat (limited to 'llvm/lib/VMCore/Instruction.cpp')
-rw-r--r--llvm/lib/VMCore/Instruction.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/Instruction.cpp b/llvm/lib/VMCore/Instruction.cpp
index 5449714280d..c1d63877575 100644
--- a/llvm/lib/VMCore/Instruction.cpp
+++ b/llvm/lib/VMCore/Instruction.cpp
@@ -226,7 +226,14 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {
RMWI->isVolatile() == cast<AtomicRMWInst>(I)->isVolatile() &&
RMWI->getOrdering() == cast<AtomicRMWInst>(I)->getOrdering() &&
RMWI->getSynchScope() == cast<AtomicRMWInst>(I)->getSynchScope();
-
+ if (const PHINode *thisPHI = dyn_cast<PHINode>(this)) {
+ const PHINode *otherPHI = cast<PHINode>(I);
+ for (unsigned i = 0, e = thisPHI->getNumOperands(); i != e; ++i) {
+ if (thisPHI->getIncomingBlock(i) != otherPHI->getIncomingBlock(i))
+ return false;
+ }
+ return true;
+ }
return true;
}
OpenPOWER on IntegriCloud