aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-04-28 23:08:54 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-04-28 23:08:54 +0000
commit2ad0fcf794924f618a7240741cc14a39be99d0f2 (patch)
tree9f91b7f71e5c3f8e3872306ac0a0f3c5047b9422 /lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
parentc1c4595d1f5ea83ea45e448544a64263f62bc17f (diff)
downloadexternal_llvm-2ad0fcf794924f618a7240741cc14a39be99d0f2.zip
external_llvm-2ad0fcf794924f618a7240741cc14a39be99d0f2.tar.gz
external_llvm-2ad0fcf794924f618a7240741cc14a39be99d0f2.tar.bz2
Replace r102368 with code that's less fragile. This creates DBG_VALUE instructions for function arguments early and insert them after instruction selection is done.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 2cdd1cc..adb321d 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -212,14 +212,28 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
SelectAllBasicBlocks(Fn);
- // Release function-specific state. SDB and CurDAG are already cleared
- // at this point.
- FuncInfo->clear();
-
// If the first basic block in the function has live ins that need to be
// copied into vregs, emit the copies into the top of the block before
// emitting the code for the block.
- RegInfo->EmitLiveInCopies(MF->begin(), TRI, TII);
+ MachineBasicBlock *EntryMBB = MF->begin();
+ RegInfo->EmitLiveInCopies(EntryMBB, TRI, TII);
+
+ // Insert DBG_VALUE instructions for function arguments to the entry block.
+ for (unsigned i = 0, e = FuncInfo->ArgDbgValues.size(); i != e; ++i) {
+ MachineInstr *MI = FuncInfo->ArgDbgValues[e-i-1];
+ unsigned Reg = MI->getOperand(0).getReg();
+ if (TargetRegisterInfo::isPhysicalRegister(Reg))
+ EntryMBB->insert(EntryMBB->begin(), MI);
+ else {
+ MachineInstr *Def = RegInfo->getVRegDef(Reg);
+ MachineBasicBlock::iterator InsertPos = Def;
+ EntryMBB->insert(llvm::next(InsertPos), MI);
+ }
+ }
+
+ // Release function-specific state. SDB and CurDAG are already cleared
+ // at this point.
+ FuncInfo->clear();
return true;
}