[llvm-branch-commits] [llvm-branch] r71298 - in /llvm/branches/Apple/Dib: include/llvm/CodeGen/Passes.h lib/CodeGen/CMakeLists.txt lib/CodeGen/CodePlacementOpt.cpp lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/LoopAligner.cpp lib/Target/PowerPC/PPCInstrInfo.cpp lib/Target/X86/X86InstrInfo.cpp test/CodeGen/X86/code_placement.ll

Bill Wendling isanbard at gmail.com
Fri May 8 16:58:14 PDT 2009


Author: void
Date: Fri May  8 18:58:14 2009
New Revision: 71298

URL: http://llvm.org/viewvc/llvm-project?rev=71298&view=rev
Log:
--- Merging r71150 into '.':
U    include/llvm/CodeGen/Passes.h
U    lib/CodeGen/LLVMTargetMachine.cpp
A    lib/CodeGen/CodePlacementOpt.cpp
U    lib/CodeGen/CMakeLists.txt
D    lib/CodeGen/LoopAligner.cpp
--- Merging r71151 into '.':
U    lib/CodeGen/CodePlacementOpt.cpp
--- Merging r71209 into '.':
A    test/CodeGen/X86/code_placement.ll
G    lib/CodeGen/CodePlacementOpt.cpp
U    lib/Target/X86/X86InstrInfo.cpp
--- Merging r71214 into '.':
G    lib/CodeGen/CodePlacementOpt.cpp
--- Merging r71242 into '.':
G    lib/CodeGen/CodePlacementOpt.cpp
--- Merging r71282 into '.':
U    lib/Target/PowerPC/PPCInstrInfo.cpp
--- Merging r71291 into '.':
U    test/CodeGen/X86/code_placement.ll
G    lib/CodeGen/CodePlacementOpt.cpp


Added:
    llvm/branches/Apple/Dib/lib/CodeGen/CodePlacementOpt.cpp
      - copied, changed from r71150, llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp
    llvm/branches/Apple/Dib/test/CodeGen/X86/code_placement.ll
      - copied, changed from r71209, llvm/trunk/test/CodeGen/X86/code_placement.ll
Removed:
    llvm/branches/Apple/Dib/lib/CodeGen/LoopAligner.cpp
Modified:
    llvm/branches/Apple/Dib/include/llvm/CodeGen/Passes.h
    llvm/branches/Apple/Dib/lib/CodeGen/CMakeLists.txt
    llvm/branches/Apple/Dib/lib/CodeGen/LLVMTargetMachine.cpp
    llvm/branches/Apple/Dib/lib/Target/PowerPC/PPCInstrInfo.cpp
    llvm/branches/Apple/Dib/lib/Target/X86/X86InstrInfo.cpp

Modified: llvm/branches/Apple/Dib/include/llvm/CodeGen/Passes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/include/llvm/CodeGen/Passes.h?rev=71298&r1=71297&r2=71298&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/CodeGen/Passes.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/CodeGen/Passes.h Fri May  8 18:58:14 2009
@@ -146,9 +146,9 @@
   /// IfConverter Pass - This pass performs machine code if conversion.
   FunctionPass *createIfConverterPass();
 
-  /// LoopAligner Pass - This pass aligns loop headers to target specific
-  /// alignment boundary.
-  FunctionPass *createLoopAlignerPass();
+  /// Code Placement Pass - This pass optimize code placement and aligns loop
+  /// headers to target specific alignment boundary.
+  FunctionPass *createCodePlacementOptPass();
 
   /// DebugLabelFoldingPass - This pass prunes out redundant debug labels.  This
   /// allows a debug emitter to determine if the range of two labels is empty,

Modified: llvm/branches/Apple/Dib/lib/CodeGen/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/CMakeLists.txt?rev=71298&r1=71297&r2=71298&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/CMakeLists.txt (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/CMakeLists.txt Fri May  8 18:58:14 2009
@@ -1,5 +1,6 @@
 add_llvm_library(LLVMCodeGen
   BranchFolding.cpp
+  CodePlacementOpt.cpp
   DeadMachineInstructionElim.cpp
   ELFWriter.cpp
   GCMetadata.cpp
@@ -13,7 +14,6 @@
   LiveIntervalAnalysis.cpp
   LiveStackAnalysis.cpp
   LiveVariables.cpp
-  LoopAligner.cpp
   LowerSubregs.cpp
   MachOWriter.cpp
   MachineBasicBlock.cpp

Copied: llvm/branches/Apple/Dib/lib/CodeGen/CodePlacementOpt.cpp (from r71150, llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/CodePlacementOpt.cpp?p2=llvm/branches/Apple/Dib/lib/CodeGen/CodePlacementOpt.cpp&p1=llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp&r1=71150&r2=71298&rev=71298&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/CodePlacementOpt.cpp Fri May  8 18:58:14 2009
@@ -16,14 +16,35 @@
 #include "llvm/CodeGen/MachineLoopInfo.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/Passes.h"
+#include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetLowering.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/ADT/Statistic.h"
 using namespace llvm;
 
+STATISTIC(NumHeaderAligned, "Number of loop header aligned");
+STATISTIC(NumIntraElim,     "Number of intra loop branches eliminated");
+STATISTIC(NumIntraMoved,    "Number of intra loop branches moved");
+
 namespace {
   class CodePlacementOpt : public MachineFunctionPass {
+    const MachineLoopInfo *MLI;
+    const TargetInstrInfo *TII;
+    const TargetLowering  *TLI;
+
+    /// ChangedMBBs - BBs which are modified by OptimizeIntraLoopEdges.
+    SmallPtrSet<MachineBasicBlock*, 8> ChangedMBBs;
+
+    /// UncondJmpMBBs - A list of BBs which are in loops and end with
+    /// unconditional branches.
+    SmallVector<std::pair<MachineBasicBlock*,MachineBasicBlock*>, 4>
+    UncondJmpMBBs;
+
+    /// LoopHeaders - A list of BBs which are loop headers.
+    SmallVector<MachineBasicBlock*, 4> LoopHeaders;
+
   public:
     static char ID;
     CodePlacementOpt() : MachineFunctionPass(&ID) {}
@@ -35,10 +56,13 @@
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.addRequired<MachineLoopInfo>();
-      AU.addPreserved<MachineLoopInfo>();
       AU.addPreservedID(MachineDominatorsID);
       MachineFunctionPass::getAnalysisUsage(AU);
     }
+
+  private:
+    bool OptimizeIntraLoopEdges();
+    bool AlignLoops(MachineFunction &MF);
   };
 
   char CodePlacementOpt::ID = 0;
@@ -48,35 +72,254 @@
   return new CodePlacementOpt();
 }
 
-bool CodePlacementOpt::runOnMachineFunction(MachineFunction &MF) {
-  const MachineLoopInfo *MLI = &getAnalysis<MachineLoopInfo>();
+/// OptimizeBackEdges - Place loop back edges to move unconditional branches
+/// out of the loop.
+///
+///       A:
+///       ...
+///       <fallthrough to B>
+///
+///       B:  --> loop header
+///       ...
+///       jcc <cond> C, [exit]
+///
+///       C:
+///       ...
+///       jmp B
+///
+/// ==>
+///
+///       A:
+///       ...
+///       jmp B
+///
+///       C:  --> new loop header
+///       ...
+///       <fallthough to B>
+///       
+///       B:
+///       ...
+///       jcc <cond> C, [exit]
+///
+bool CodePlacementOpt::OptimizeIntraLoopEdges() {
+  bool Changed = false;
+  for (unsigned i = 0, e = UncondJmpMBBs.size(); i != e; ++i) {
+    MachineBasicBlock *MBB = UncondJmpMBBs[i].first;
+    MachineBasicBlock *SuccMBB = UncondJmpMBBs[i].second;
+    MachineLoop *L = MLI->getLoopFor(MBB);
+    assert(L && "BB is expected to be in a loop!");
+
+    if (ChangedMBBs.count(MBB)) {
+      // BB has been modified, re-analyze.
+      MachineBasicBlock *TBB = 0, *FBB = 0;
+      SmallVector<MachineOperand, 4> Cond;
+      if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond) || !Cond.empty())
+        continue;
+      if (MLI->getLoopFor(TBB) != L || TBB->isLandingPad())
+        continue;
+      SuccMBB = TBB;
+    } else {
+      assert(MLI->getLoopFor(SuccMBB) == L &&
+             "Successor is not in the same loop!");
+    }
 
-  if (MLI->empty())
-    return false;  // No loops.
+    if (MBB->isLayoutSuccessor(SuccMBB)) {
+      // Successor is right after MBB, just eliminate the unconditional jmp.
+      // Can this happen?
+      TII->RemoveBranch(*MBB);
+      ChangedMBBs.insert(MBB);
+      ++NumIntraElim;
+      continue;
+    }
+
+    // Now check if the predecessor is fallthrough from any BB. If there is,
+    // that BB should be from outside the loop since edge will become a jmp.
+    bool OkToMove = true;
+    MachineBasicBlock *FtMBB = 0, *FtTBB = 0, *FtFBB = 0;
+    SmallVector<MachineOperand, 4> FtCond;    
+    for (MachineBasicBlock::pred_iterator PI = SuccMBB->pred_begin(),
+           PE = SuccMBB->pred_end(); PI != PE; ++PI) {
+      MachineBasicBlock *PredMBB = *PI;
+      if (PredMBB->isLayoutSuccessor(SuccMBB)) {
+        if (TII->AnalyzeBranch(*PredMBB, FtTBB, FtFBB, FtCond)) {
+          OkToMove = false;
+          break;
+        }
+        if (!FtTBB)
+          FtTBB = SuccMBB;
+        else if (!FtFBB) {
+          assert(FtFBB != SuccMBB && "Unexpected control flow!");
+          FtFBB = SuccMBB;
+        }
+        
+        // A fallthrough.
+        FtMBB = PredMBB;
+        MachineLoop *PL = MLI->getLoopFor(PredMBB);
+        if (PL && (PL == L || PL->getLoopDepth() >= L->getLoopDepth())) {
+          OkToMove = false;
+          break;
+        }
+      }
+    }
+
+    if (!OkToMove)
+      continue;
+
+    // Is it profitable? If SuccMBB can fallthrough itself, that can be changed
+    // into a jmp.
+    MachineBasicBlock *TBB = 0, *FBB = 0;
+    SmallVector<MachineOperand, 4> Cond;
+    if (TII->AnalyzeBranch(*SuccMBB, TBB, FBB, Cond))
+      continue;
+    if (!TBB && Cond.empty())
+      TBB = next(MachineFunction::iterator(SuccMBB));
+    else if (!FBB && !Cond.empty())
+      FBB = next(MachineFunction::iterator(SuccMBB));
+
+    // This calculate the cost of the transformation. Also, it finds the *only*
+    // intra-loop edge if there is one.
+    int Cost = 0;
+    bool HasOneIntraSucc = true;
+    MachineBasicBlock *IntraSucc = 0;
+    for (MachineBasicBlock::succ_iterator SI = SuccMBB->succ_begin(),
+           SE = SuccMBB->succ_end(); SI != SE; ++SI) {
+      MachineBasicBlock *SSMBB = *SI;
+      if (MLI->getLoopFor(SSMBB) == L) {
+        if (!IntraSucc)
+          IntraSucc = SSMBB;
+        else
+          HasOneIntraSucc = false;
+      }
+
+      if (SuccMBB->isLayoutSuccessor(SSMBB))
+        // This will become a jmp.
+        ++Cost;
+      else if (MBB->isLayoutSuccessor(SSMBB))
+        // One of the successor will become the new fallthrough.
+        if (SSMBB == FBB) {
+          FBB = 0;
+          --Cost;
+        } else if (!FBB && SSMBB == TBB && Cond.empty()) {
+          TBB = 0;
+          --Cost;
+        } else if (!Cond.empty() && !TII->ReverseBranchCondition(Cond)) {
+          assert(SSMBB == TBB);
+          TBB = FBB;
+          FBB = 0;
+          --Cost;
+        }
+    }
+    if (Cost)
+      continue;
+
+    // Now, let's move the successor to below the BB to eliminate the jmp.
+    SuccMBB->moveAfter(MBB);
+    TII->RemoveBranch(*MBB);
+    TII->RemoveBranch(*SuccMBB);
+    if (TBB)
+      TII->InsertBranch(*SuccMBB, TBB, FBB, Cond);
+    ChangedMBBs.insert(MBB);
+    ChangedMBBs.insert(SuccMBB);
+    if (FtMBB) {
+      TII->RemoveBranch(*FtMBB);
+      TII->InsertBranch(*FtMBB, FtTBB, FtFBB, FtCond);
+      ChangedMBBs.insert(FtMBB);
+    }
+
+    // If BB is the loop latch, we may have a new loop headr.
+    if (MBB == L->getLoopLatch()) {
+      assert(MLI->isLoopHeader(SuccMBB) &&
+             "Only succ of loop latch is not the header?");
+      if (HasOneIntraSucc && IntraSucc)
+        std::replace(LoopHeaders.begin(),LoopHeaders.end(), SuccMBB, IntraSucc);
+    }
+  }
+
+  ++NumIntraMoved;
+  return Changed;
+}
 
-  const TargetLowering *TLI = MF.getTarget().getTargetLowering();
-  if (!TLI)
+/// HeaderShouldBeAligned - Return true if the specified loop header block
+/// should be aligned. For now, we will not align it if all the predcessors
+/// (i.e. loop back edges) are laid out above the header. FIXME: Do not
+/// align small loops.
+static bool HeaderShouldBeAligned(MachineBasicBlock *MBB) {
+  for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(),
+         PE = MBB->pred_end(); PI != PE; ++PI) {
+    MachineBasicBlock *PredMBB = *PI;
+    if (PredMBB->getNumber() > MBB->getNumber())
+      return true;
+  }
+  return false;
+}
+
+/// AlignLoops - Align loop headers to target preferred alignments.
+///
+bool CodePlacementOpt::AlignLoops(MachineFunction &MF) {
+  const Function *F = MF.getFunction();
+  if (F->hasFnAttr(Attribute::OptimizeForSize))
     return false;
 
   unsigned Align = TLI->getPrefLoopAlignment();
   if (!Align)
     return false;  // Don't care about loop alignment.
 
-  const Function *F = MF.getFunction();
-  if (F->hasFnAttr(Attribute::OptimizeForSize))
-    return false;
+  // Make sure blocks are numbered in order
+  MF.RenumberBlocks();
+
+  bool Changed = false;
+  for (unsigned i = 0, e = LoopHeaders.size(); i != e; ++i) {
+    MachineBasicBlock *HeaderMBB = LoopHeaders[i];
+    MachineBasicBlock *PredMBB = prior(MachineFunction::iterator(HeaderMBB));
+    if (MLI->getLoopFor(HeaderMBB) == MLI->getLoopFor(PredMBB))
+      // If previously BB is in the same loop, don't align this BB. We want
+      // to prevent adding noop's inside a loop.
+      continue;
+    if (HeaderShouldBeAligned(HeaderMBB)) {
+      HeaderMBB->setAlignment(Align);
+      Changed = true;
+      ++NumHeaderAligned;
+    }
+  }
 
+  return Changed;
+}
+
+bool CodePlacementOpt::runOnMachineFunction(MachineFunction &MF) {
+  MLI = &getAnalysis<MachineLoopInfo>();
+  if (MLI->empty())
+    return false;  // No loops.
+
+  TLI = MF.getTarget().getTargetLowering();
+  TII = MF.getTarget().getInstrInfo();
+
+  // Analyze the BBs first and keep track of loop headers and BBs that
+  // end with an unconditional jmp to another block in the same loop.
   for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
     MachineBasicBlock *MBB = I;
-    if (MLI->isLoopHeader(MBB)) {
-      MachineBasicBlock *PredBB = prior(I);
-      if (MLI->getLoopFor(MBB) == MLI->getLoopFor(PredBB))
-        // If previously BB is in the same loop, don't align this BB. We want
-        // to prevent adding noop's inside a loop.
-        continue;
-      MBB->setAlignment(Align);
-    }
+    if (MBB->isLandingPad())
+      continue;
+    MachineLoop *L = MLI->getLoopFor(MBB);
+    if (!L)
+      continue;
+    if (MLI->isLoopHeader(MBB))
+      LoopHeaders.push_back(MBB);
+
+    MachineBasicBlock *TBB = 0, *FBB = 0;
+    SmallVector<MachineOperand, 4> Cond;
+    if (TII->AnalyzeBranch(*MBB, TBB, FBB, Cond) || !Cond.empty())
+      continue;
+    if (MLI->getLoopFor(TBB) == L && !TBB->isLandingPad())
+      UncondJmpMBBs.push_back(std::make_pair(MBB, TBB));
   }
 
-  return true;
+  bool Changed = OptimizeIntraLoopEdges();
+
+  Changed |= AlignLoops(MF);
+
+  ChangedMBBs.clear();
+  UncondJmpMBBs.clear();
+  LoopHeaders.clear();
+
+  return Changed;
 }

Modified: llvm/branches/Apple/Dib/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/LLVMTargetMachine.cpp?rev=71298&r1=71297&r2=71298&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/LLVMTargetMachine.cpp Fri May  8 18:58:14 2009
@@ -70,7 +70,7 @@
     PM.add(createMachineFunctionPrinterPass(cerr));
 
   if (OptLevel != CodeGenOpt::None)
-    PM.add(createLoopAlignerPass());
+    PM.add(createCodePlacementOptPass());
 
   switch (FileType) {
   default:

Removed: llvm/branches/Apple/Dib/lib/CodeGen/LoopAligner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/LoopAligner.cpp?rev=71297&view=auto

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/LoopAligner.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/LoopAligner.cpp (removed)
@@ -1,78 +0,0 @@
-//===-- LoopAligner.cpp - Loop aligner pass. ------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the pass that align loop headers to target specific
-// alignment boundary.
-//
-//===----------------------------------------------------------------------===//
-
-#define DEBUG_TYPE "loopalign"
-#include "llvm/CodeGen/MachineLoopInfo.h"
-#include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/CodeGen/Passes.h"
-#include "llvm/Target/TargetLowering.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/Debug.h"
-using namespace llvm;
-
-namespace {
-  class LoopAligner : public MachineFunctionPass {
-  public:
-    static char ID;
-    LoopAligner() : MachineFunctionPass(&ID) {}
-
-    virtual bool runOnMachineFunction(MachineFunction &MF);
-    virtual const char *getPassName() const { return "Loop aligner"; }
-
-    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.addRequired<MachineLoopInfo>();
-      AU.addPreserved<MachineLoopInfo>();
-      AU.addPreservedID(MachineDominatorsID);
-      MachineFunctionPass::getAnalysisUsage(AU);
-    }
-  };
-
-  char LoopAligner::ID = 0;
-} // end anonymous namespace
-
-FunctionPass *llvm::createLoopAlignerPass() { return new LoopAligner(); }
-
-bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
-  const MachineLoopInfo *MLI = &getAnalysis<MachineLoopInfo>();
-
-  if (MLI->empty())
-    return false;  // No loops.
-
-  const TargetLowering *TLI = MF.getTarget().getTargetLowering();
-  if (!TLI)
-    return false;
-
-  unsigned Align = TLI->getPrefLoopAlignment();
-  if (!Align)
-    return false;  // Don't care about loop alignment.
-
-  const Function *F = MF.getFunction();
-  if (F->hasFnAttr(Attribute::OptimizeForSize))
-    return false;
-
-  for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
-    MachineBasicBlock *MBB = I;
-    if (MLI->isLoopHeader(MBB)) {
-      MachineBasicBlock *PredBB = prior(I);
-      if (MLI->getLoopFor(MBB) == MLI->getLoopFor(PredBB))
-        // If previously BB is in the same loop, don't align this BB. We want
-        // to prevent adding noop's inside a loop.
-        continue;
-      MBB->setAlignment(Align);
-    }
-  }
-
-  return true;
-}

Modified: llvm/branches/Apple/Dib/lib/Target/PowerPC/PPCInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Target/PowerPC/PPCInstrInfo.cpp?rev=71298&r1=71297&r2=71298&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Target/PowerPC/PPCInstrInfo.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Target/PowerPC/PPCInstrInfo.cpp Fri May  8 18:58:14 2009
@@ -220,9 +220,13 @@
   // If there is only one terminator instruction, process it.
   if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
     if (LastInst->getOpcode() == PPC::B) {
+      if (!LastInst->getOperand(0).isMBB())
+        return true;
       TBB = LastInst->getOperand(0).getMBB();
       return false;
     } else if (LastInst->getOpcode() == PPC::BCC) {
+      if (!LastInst->getOperand(2).isMBB())
+        return true;
       // Block ends with fall-through condbranch.
       TBB = LastInst->getOperand(2).getMBB();
       Cond.push_back(LastInst->getOperand(0));
@@ -244,6 +248,9 @@
   // If the block ends with PPC::B and PPC:BCC, handle it.
   if (SecondLastInst->getOpcode() == PPC::BCC && 
       LastInst->getOpcode() == PPC::B) {
+    if (!SecondLastInst->getOperand(2).isMBB() ||
+        !LastInst->getOperand(0).isMBB())
+      return true;
     TBB =  SecondLastInst->getOperand(2).getMBB();
     Cond.push_back(SecondLastInst->getOperand(0));
     Cond.push_back(SecondLastInst->getOperand(1));
@@ -255,6 +262,8 @@
   // executed, so remove it.
   if (SecondLastInst->getOpcode() == PPC::B && 
       LastInst->getOpcode() == PPC::B) {
+    if (!SecondLastInst->getOperand(0).isMBB())
+      return true;
     TBB = SecondLastInst->getOperand(0).getMBB();
     I = LastInst;
     if (AllowModify)

Modified: llvm/branches/Apple/Dib/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Target/X86/X86InstrInfo.cpp?rev=71298&r1=71297&r2=71298&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Target/X86/X86InstrInfo.cpp Fri May  8 18:58:14 2009
@@ -1508,7 +1508,7 @@
     if (I->getOpcode() == X86::JMP) {
       if (!AllowModify) {
         TBB = I->getOperand(0).getMBB();
-        return false;
+        continue;
       }
 
       // If the block has any instructions after a JMP, delete them.

Copied: llvm/branches/Apple/Dib/test/CodeGen/X86/code_placement.ll (from r71209, llvm/trunk/test/CodeGen/X86/code_placement.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/CodeGen/X86/code_placement.ll?p2=llvm/branches/Apple/Dib/test/CodeGen/X86/code_placement.ll&p1=llvm/trunk/test/CodeGen/X86/code_placement.ll&r1=71209&r2=71298&rev=71298&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/code_placement.ll (original)
+++ llvm/branches/Apple/Dib/test/CodeGen/X86/code_placement.ll Fri May  8 18:58:14 2009
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | llc -march=x86 -opt-loop-bb-placement | %prcontext jmp 1 | grep align
+; RUN: llvm-as < %s | llc -march=x86 | %prcontext jmp 1 | grep align
 
 @Te0 = external global [256 x i32]		; <[256 x i32]*> [#uses=5]
 @Te1 = external global [256 x i32]		; <[256 x i32]*> [#uses=4]





More information about the llvm-branch-commits mailing list