Duncan pointed out that the LandingPadInst might read memory. (It might also
authorBill Wendling <isanbard@gmail.com>
Mon, 15 Aug 2011 21:14:31 +0000 (21:14 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 15 Aug 2011 21:14:31 +0000 (21:14 +0000)
write to memory.) Marking it as such makes some checks for immobility go away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137655 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LoopInfo.cpp
lib/Transforms/InstCombine/InstructionCombining.cpp
lib/VMCore/Instruction.cpp

index 36fd598d13c4cc19f657b9cd198ced7a1032f3d3..9a7c50d7fa4492506069bf6534497b3806dfd8f6 100644 (file)
@@ -99,9 +99,6 @@ bool Loop::makeLoopInvariant(Instruction *I, bool &Changed,
     return false;
   if (I->mayReadFromMemory())
     return false;
-  // The landingpad instruction is immobile.
-  if (isa<LandingPadInst>(I))
-    return false;
   // Determine the insertion point, unless one was given.
   if (!InsertPt) {
     BasicBlock *Preheader = getLoopPreheader();
index 32c55a3408d23b6d2a7404eaa60337798ba763f5..41d542af685aee7bad14d24e8440209426b8ea60 100644 (file)
@@ -1417,9 +1417,8 @@ Instruction *InstCombiner::visitExtractValueInst(ExtractValueInst &EV) {
 static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
   assert(I->hasOneUse() && "Invariants didn't hold!");
 
-  // Cannot move control-flow-involving, volatile loads, vaarg, landingpad, etc.
-  if (isa<PHINode>(I) || isa<LandingPadInst>(I) || I->mayHaveSideEffects() ||
-      isa<TerminatorInst>(I))
+  // Cannot move control-flow-involving, volatile loads, vaarg, etc.
+  if (isa<PHINode>(I) || I->mayHaveSideEffects() || isa<TerminatorInst>(I))
     return false;
 
   // Do not sink alloca instructions out of the entry block.
index 22656f3353d1d0ddf31b7a722f33a69363e4027c..9e55a083db0cc5f08cb839acd120e64f835836f7 100644 (file)
@@ -320,6 +320,7 @@ bool Instruction::mayReadFromMemory() const {
   case Instruction::Fence: // FIXME: refine definition of mayReadFromMemory
   case Instruction::AtomicCmpXchg:
   case Instruction::AtomicRMW:
+  case Instruction::LandingPad:
     return true;
   case Instruction::Call:
     return !cast<CallInst>(this)->doesNotAccessMemory();
@@ -340,6 +341,7 @@ bool Instruction::mayWriteToMemory() const {
   case Instruction::VAArg:
   case Instruction::AtomicCmpXchg:
   case Instruction::AtomicRMW:
+  case Instruction::LandingPad:
     return true;
   case Instruction::Call:
     return !cast<CallInst>(this)->onlyReadsMemory();