[llvm-commits] [llvm] r55496 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGISel.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Dan Gohman gohman at apple.com
Thu Aug 28 13:28:56 PDT 2008


Author: djg
Date: Thu Aug 28 15:28:56 2008
New Revision: 55496

URL: http://llvm.org/viewvc/llvm-project?rev=55496&view=rev
Log:
Fix a FastISel bug where the instructions from lowering the arguments
were being emitted after the first instructions of the entry block.

Modified:
    llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=55496&r1=55495&r2=55496&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Thu Aug 28 15:28:56 2008
@@ -110,8 +110,7 @@
 
   void SelectBasicBlock(BasicBlock *LLVMBB,
                         BasicBlock::iterator Begin,
-                        BasicBlock::iterator End,
-                        bool DoArgs);
+                        BasicBlock::iterator End);
   void CodeGenAndEmitDAG();
   void LowerArguments(BasicBlock *BB);
   

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=55496&r1=55495&r2=55496&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Aug 28 15:28:56 2008
@@ -5479,12 +5479,7 @@
 
 void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
                                         BasicBlock::iterator Begin,
-                                        BasicBlock::iterator End,
-                                        bool DoArgs) {
-  // Lower any arguments needed in this block if this is the entry block.
-  if (DoArgs)
-    LowerArguments(LLVMBB);
-
+                                        BasicBlock::iterator End) {
   SDL->setCurrentBasicBlock(BB);
 
   MachineModuleInfo *MMI = CurDAG->getMachineModuleInfo();
@@ -5744,12 +5739,23 @@
 
     BasicBlock::iterator Begin = LLVMBB->begin();
     BasicBlock::iterator End = LLVMBB->end();
-    bool DoArgs = LLVMBB == &Fn.getEntryBlock();
+
+    // Lower any arguments needed in this block if this is the entry block.
+    if (LLVMBB == &Fn.getEntryBlock())
+      LowerArguments(LLVMBB);
 
     // Before doing SelectionDAG ISel, see if FastISel has been requested.
     // FastISel doesn't support EH landing pads, which require special handling.
     if (EnableFastISel && !BB->isLandingPad()) {
       if (FastISel *F = TLI.createFastISel(*FuncInfo->MF)) {
+        // Emit code for any incoming arguments. This must happen before
+        // beginning FastISel on the entry block.
+        if (LLVMBB == &Fn.getEntryBlock()) {
+          CurDAG->setRoot(SDL->getControlRoot());
+          CodeGenAndEmitDAG();
+          SDL->clear();
+        }
+        // Do FastISel on as many instructions as possible.
         while (Begin != End) {
           Begin = F->SelectInstructions(Begin, End, FuncInfo->ValueMap,
                                         FuncInfo->MBBMap, BB);
@@ -5767,10 +5773,8 @@
                 R = FuncInfo->CreateRegForValue(Begin);
             }
 
-            SelectBasicBlock(LLVMBB, Begin, next(Begin), DoArgs);
-
+            SelectBasicBlock(LLVMBB, Begin, next(Begin));
             ++Begin;
-            DoArgs = false;
             continue;
           }
 
@@ -5792,8 +5796,8 @@
       }
     }
 
-    if (Begin != End || DoArgs)
-      SelectBasicBlock(LLVMBB, Begin, End, DoArgs);
+    if (Begin != End)
+      SelectBasicBlock(LLVMBB, Begin, End);
 
     FinishBasicBlock();
   }





More information about the llvm-commits mailing list