[llvm-commits] [llvm] r67829 - in /llvm/branches/Apple/Dib/lib: CodeGen/SelectionDAG/SelectionDAGBuild.cpp Transforms/Scalar/CodeGenPrepare.cpp

Bill Wendling isanbard at gmail.com
Thu Mar 26 23:18:09 PDT 2009


Author: void
Date: Fri Mar 27 01:18:09 2009
New Revision: 67829

URL: http://llvm.org/viewvc/llvm-project?rev=67829&view=rev
Log:
--- Merging (from foreign repository) r67692 into '.':
U    lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
--- Merging (from foreign repository) r67724 into '.':
U    lib/Transforms/Scalar/CodeGenPrepare.cpp
--- Merging (from foreign repository) r67811 into '.':
G    lib/Transforms/Scalar/CodeGenPrepare.cpp


Modified:
    llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
    llvm/branches/Apple/Dib/lib/Transforms/Scalar/CodeGenPrepare.cpp

Modified: llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=67829&r1=67828&r2=67829&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Fri Mar 27 01:18:09 2009
@@ -3905,10 +3905,11 @@
     DbgStopPointInst &SPI = cast<DbgStopPointInst>(I);
     if (DW && DW->ValidDebugInfo(SPI.getContext())) {
       MachineFunction &MF = DAG.getMachineFunction();
-      DAG.setRoot(DAG.getDbgStopPoint(getRoot(),
-                                      SPI.getLine(),
-                                      SPI.getColumn(),
-                                      SPI.getContext()));
+      if (Fast)
+        DAG.setRoot(DAG.getDbgStopPoint(getRoot(),
+                                        SPI.getLine(),
+                                        SPI.getColumn(),
+                                        SPI.getContext()));
       DICompileUnit CU(cast<GlobalVariable>(SPI.getContext()));
       std::string Dir, FN;
       unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir),

Modified: llvm/branches/Apple/Dib/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=67829&r1=67828&r2=67829&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Transforms/Scalar/CodeGenPrepare.cpp Fri Mar 27 01:18:09 2009
@@ -20,6 +20,7 @@
 #include "llvm/Function.h"
 #include "llvm/InlineAsm.h"
 #include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/Pass.h"
 #include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/TargetData.h"
@@ -144,10 +145,11 @@
   return EverMadeChange;
 }
 
-/// EliminateMostlyEmptyBlocks - eliminate blocks that contain only PHI nodes
-/// and an unconditional branch.  Passes before isel (e.g. LSR/loopsimplify)
-/// often split edges in ways that are non-optimal for isel.  Start by
-/// eliminating these blocks so we can split them the way we want them.
+/// EliminateMostlyEmptyBlocks - eliminate blocks that contain only PHI nodes,
+/// debug info directives, and an unconditional branch.  Passes before isel
+/// (e.g. LSR/loopsimplify) often split edges in ways that are non-optimal for
+/// isel.  Start by eliminating these blocks so we can split them the way we
+/// want them.
 bool CodeGenPrepare::EliminateMostlyEmptyBlocks(Function &F) {
   bool MadeChange = false;
   // Note that this intentionally skips the entry block.
@@ -159,12 +161,18 @@
     if (!BI || !BI->isUnconditional())
       continue;
 
-    // If the instruction before the branch isn't a phi node, then other stuff
-    // is happening here.
+    // If the instruction before the branch (skipping debug info) isn't a phi
+    // node, then other stuff is happening here.
     BasicBlock::iterator BBI = BI;
     if (BBI != BB->begin()) {
       --BBI;
-      if (!isa<PHINode>(BBI)) continue;
+      while (isa<DbgInfoIntrinsic>(BBI)) {
+        if (BBI == BB->begin())
+          break;
+        --BBI;
+      }
+      if (!isa<DbgInfoIntrinsic>(BBI) && !isa<PHINode>(BBI))
+        continue;
     }
 
     // Do not break infinite loops.
@@ -350,15 +358,20 @@
       BasicBlock *Pred = *PI;
       // To be usable, the pred has to end with an uncond branch to the dest.
       BranchInst *PredBr = dyn_cast<BranchInst>(Pred->getTerminator());
-      if (!PredBr || !PredBr->isUnconditional() ||
-          // Must be empty other than the branch.
-          &Pred->front() != PredBr ||
-          // Cannot be the entry block; its label does not get emitted.
-          Pred == &(Dest->getParent()->getEntryBlock()))
+      if (!PredBr || !PredBr->isUnconditional())
+        continue;
+      // Must be empty other than the branch and debug info.
+      BasicBlock::iterator I = Pred->begin();
+      while (isa<DbgInfoIntrinsic>(I))
+        I++;
+      if (dyn_cast<Instruction>(I) != PredBr)
+        continue;
+      // Cannot be the entry block; its label does not get emitted.
+      if (Pred == &(Dest->getParent()->getEntryBlock()))
         continue;
 
       // Finally, since we know that Dest has phi nodes in it, we have to make
-      // sure that jumping to Pred will have the same affect as going to Dest in
+      // sure that jumping to Pred will have the same effect as going to Dest in
       // terms of PHI values.
       PHINode *PN;
       unsigned PHINo = 0;





More information about the llvm-commits mailing list