summaryrefslogtreecommitdiff
path: root/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
commit9df72a93ef27a27c6853eed3ed92c9e0b62c9ca6 (patch)
tree6af1907b215463aeb652ff2bc6488082e0ff23d5 /lib/VMCore/Instruction.cpp
parentb88e8dd31d1364d288d970f9187342a33b8de149 (diff)
downloadllvm-9df72a93ef27a27c6853eed3ed92c9e0b62c9ca6.tar.gz
llvm-9df72a93ef27a27c6853eed3ed92c9e0b62c9ca6.tar.bz2
llvm-9df72a93ef27a27c6853eed3ed92c9e0b62c9ca6.tar.xz
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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156548 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instruction.cpp')
-rw-r--r--lib/VMCore/Instruction.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 5449714280..c1d6387757 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/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;
}