aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-02-01 09:10:45 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-02-01 09:10:45 +0000
commit1b08bbca5592351a940bcd164bdec724ee954326 (patch)
treef11d5f22e3bcdf9bd067d3e90ba002e1e2557c42 /lib/CodeGen
parenta647c92ec2b3c91e1e6de25cc5c7860912c7626b (diff)
Remove the nasty LABEL hack with a much less evil one. Now llvm.dbg.func.start implies a stoppoint is set. SelectionDAGISel records a new source line but does not create a ISD::LABEL node for this special stoppoint. Asm printer will magically print this label. This ensures nothing is emitted before.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46635 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter.cpp4
-rw-r--r--lib/CodeGen/DwarfWriter.cpp5
-rw-r--r--lib/CodeGen/PrologEpilogInserter.cpp7
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAG.cpp23
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp20
5 files changed, 24 insertions, 35 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index 2b83588f9e..2acf287988 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -1285,6 +1285,10 @@ void AsmPrinter::printLabel(const MachineInstr *MI) const {
<< "label" << MI->getOperand(0).getImm() << ":\n";
}
+void AsmPrinter::printLabel(unsigned Id) const {
+ O << "\n" << TAI->getPrivateGlobalPrefix() << "label" << Id << ":\n";
+}
+
/// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
/// instruction, using the specified assembler variant. Targets should
/// overried this to format as appropriate.
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp
index de5709622b..96f7c191df 100644
--- a/lib/CodeGen/DwarfWriter.cpp
+++ b/lib/CodeGen/DwarfWriter.cpp
@@ -2721,6 +2721,11 @@ public:
// Assumes in correct section after the entry point.
EmitLabel("func_begin", ++SubprogramCount);
+
+ // Emit label for the implicitly defined dbg.stoppoint at the start of
+ // the function.
+ const SourceLineInfo &LineInfo = MMI->getSourceLines()[0];
+ Asm->printLabel(LineInfo.getLabelID());
}
/// EndFunction - Gather and emit post-function debug information.
diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp
index 34cbb2b077..41efbef54e 100644
--- a/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/lib/CodeGen/PrologEpilogInserter.cpp
@@ -249,13 +249,6 @@ void PEI::saveCalleeSavedRegisters(MachineFunction &Fn) {
MachineBasicBlock *MBB = Fn.begin();
MachineBasicBlock::iterator I = MBB->begin();
- // Do not insert prologue code before debug LABELs at the start of the
- // entry block.
- MachineModuleInfo *MMI = FFI->getMachineModuleInfo();
- if (MMI && MMI->hasDebugInfo())
- while (I != MBB->end() && I->isDebugLabel())
- ++I;
-
if (!TII.spillCalleeSavedRegisters(*MBB, I, CSI)) {
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
// Add the callee-saved register as live-in. It's killed at the spill.
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index aad1f87ed9..3ecd623c81 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -711,28 +711,7 @@ void ScheduleDAG::EmitNode(SDNode *Node, unsigned InstanceNo,
}
}
- // Now that we have emitted all operands, emit this instruction itself.
- if (ISD::isDebugLabel(Node) &&
- !BB->empty() && &MF->front() == BB) {
- // If we are inserting a debug label and this happens to be the first
- // debug label in the entry block, it is the "function start" label.
- // Make sure there are no other instructions before it.
- unsigned NumLabels = 0;
- MachineBasicBlock::iterator MBBI = BB->begin();
- while (MBBI != BB->end()) {
- // FIXME: This is a nasty short term workaround. For now, we are
- // assuming there are two debug labels at the beginning of the
- // entry block: one for dbg_func_start, one for the first
- // dbg_stoppoint before actual code.
- if (!MBBI->isDebugLabel() || ++NumLabels > 1)
- break;
- ++MBBI;
- }
- if (NumLabels <= 1)
- BB->insert(BB->begin(), MI);
- else
- BB->push_back(MI);
- } else if (II.usesCustomDAGSchedInsertionHook())
+ if (II.usesCustomDAGSchedInsertionHook())
// Insert this instruction into the basic block using a target
// specific inserter which may returns a new basic block.
BB = DAG.getTargetLoweringInfo().EmitInstrWithCustomInserter(MI, BB);
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 4d1e7ebefb..2d883878ce 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -2641,13 +2641,21 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
}
case Intrinsic::dbg_func_start: {
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
+ if (!MMI) return 0;
DbgFuncStartInst &FSI = cast<DbgFuncStartInst>(I);
- if (MMI && FSI.getSubprogram() &&
- MMI->Verify(FSI.getSubprogram())) {
- unsigned LabelID = MMI->RecordRegionStart(FSI.getSubprogram());
- DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
- DAG.getConstant(LabelID, MVT::i32),
- DAG.getConstant(0, MVT::i32)));
+ Value *SP = FSI.getSubprogram();
+ if (SP && MMI->Verify(SP)) {
+ // llvm.dbg.func.start implicitly defines a dbg_stoppoint which is
+ // what (most?) gdb expects.
+ DebugInfoDesc *DD = MMI->getDescFor(SP);
+ assert(DD && "Not a debug information descriptor");
+ SubprogramDesc *Subprogram = cast<SubprogramDesc>(DD);
+ const CompileUnitDesc *CompileUnit = Subprogram->getFile();
+ unsigned SrcFile = MMI->RecordSource(CompileUnit->getDirectory(),
+ CompileUnit->getFileName());
+ // Record the source line but does create a label. It will be emitted
+ // at asm emission time.
+ MMI->RecordSourceLine(Subprogram->getLine(), 0, SrcFile);
}
return 0;