Sink the CopyToExportRegsIfNeeded calls out of SelectionDAGISel
authorDan Gohman <gohman@apple.com>
Tue, 20 Apr 2010 15:03:56 +0000 (15:03 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 20 Apr 2010 15:03:56 +0000 (15:03 +0000)
into SelectionDAGBuilder. This avoids a separate pass over the
instructions, and has the side effect of providing debug location
information to the copy.

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

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 054174f037e9902d7642411f968633f365069ffe..ce5a65b7a17950d3098e0f66c13fe912278d401f 100644 (file)
@@ -618,6 +618,9 @@ void SelectionDAGBuilder::visit(const Instruction &I) {
 
   visit(I.getOpcode(), I);
 
+  if (!isa<TerminatorInst>(&I) && !HasTailCall)
+    CopyToExportRegsIfNeeded(&I);
+
   CurDebugLoc = DebugLoc();
 }
 
index 2a27d1b59a2c0099598befeecaf31201c7412e88..7c2c5282f297e8a86eb2fe7acb84f534c5419e3d 100644 (file)
@@ -239,12 +239,6 @@ SelectionDAGISel::SelectBasicBlock(MachineBasicBlock *BB,
     SDB->visit(*I);
 
   if (!SDB->HasTailCall) {
-    // Ensure that all instructions which are used outside of their defining
-    // blocks are available as virtual registers.  Invoke is handled elsewhere.
-    for (BasicBlock::const_iterator I = Begin; I != End; ++I)
-      if (!isa<PHINode>(I) && !isa<InvokeInst>(I))
-        SDB->CopyToExportRegsIfNeeded(I);
-
     // Handle PHI nodes in successor blocks.
     if (End == LLVMBB->end()) {
       HandlePHINodesInSuccessorBlocks(LLVMBB);