don't eliminate load from volatile value on paths where the load is dead.
This fixes the second half of PR2262
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50430 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 86aca07..82c67d0 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -9396,6 +9396,15 @@
LI->getParent() != PN.getIncomingBlock(i) ||
!isSafeToSinkLoad(LI))
return 0;
+
+ // If the PHI is volatile and its block has multiple successors, sinking
+ // it would remove a load of the volatile value from the path through the
+ // other successor.
+ if (isVolatile &&
+ LI->getParent()->getTerminator()->getNumSuccessors() != 1)
+ return 0;
+
+
} else if (I->getOperand(1) != ConstantOp) {
return 0;
}