diff options
Diffstat (limited to 'lib/CodeGen/SelectionDAG')
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 45 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 17 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 50 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp | 4 |
6 files changed, 69 insertions, 56 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index bcba151..5dd0afb 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -47,6 +47,8 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/DwarfWriter.h" +#include "llvm/Analysis/DebugInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetLowering.h" @@ -315,14 +317,13 @@ bool FastISel::SelectCall(User *I) { default: break; case Intrinsic::dbg_stoppoint: { DbgStopPointInst *SPI = cast<DbgStopPointInst>(I); - if (MMI && SPI->getContext() && MMI->Verify(SPI->getContext())) { - DebugInfoDesc *DD = MMI->getDescFor(SPI->getContext()); - assert(DD && "Not a debug information descriptor"); - const CompileUnitDesc *CompileUnit = cast<CompileUnitDesc>(DD); - unsigned SrcFile = MMI->RecordSource(CompileUnit); + if (DW && SPI->getContext()) { + DICompileUnit CU(cast<GlobalVariable>(SPI->getContext())); + unsigned SrcFile = DW->RecordSource(CU.getDirectory(), + CU.getFilename()); unsigned Line = SPI->getLine(); unsigned Col = SPI->getColumn(); - unsigned ID = MMI->RecordSourceLine(Line, Col, SrcFile); + unsigned ID = DW->RecordSourceLine(Line, Col, SrcFile); const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); BuildMI(MBB, II).addImm(ID); } @@ -330,8 +331,9 @@ bool FastISel::SelectCall(User *I) { } case Intrinsic::dbg_region_start: { DbgRegionStartInst *RSI = cast<DbgRegionStartInst>(I); - if (MMI && RSI->getContext() && MMI->Verify(RSI->getContext())) { - unsigned ID = MMI->RecordRegionStart(RSI->getContext()); + if (DW && RSI->getContext()) { + unsigned ID = + DW->RecordRegionStart(cast<GlobalVariable>(RSI->getContext())); const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); BuildMI(MBB, II).addImm(ID); } @@ -339,30 +341,31 @@ bool FastISel::SelectCall(User *I) { } case Intrinsic::dbg_region_end: { DbgRegionEndInst *REI = cast<DbgRegionEndInst>(I); - if (MMI && REI->getContext() && MMI->Verify(REI->getContext())) { - unsigned ID = MMI->RecordRegionEnd(REI->getContext()); + if (DW && REI->getContext()) { + unsigned ID = + DW->RecordRegionEnd(cast<GlobalVariable>(REI->getContext())); const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); BuildMI(MBB, II).addImm(ID); } return true; } case Intrinsic::dbg_func_start: { - if (!MMI) return true; + if (!DW) return true; DbgFuncStartInst *FSI = cast<DbgFuncStartInst>(I); Value *SP = FSI->getSubprogram(); - if (SP && MMI->Verify(SP)) { + if (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); + DISubprogram Subprogram(cast<GlobalVariable>(SP)); + DICompileUnit CompileUnit = Subprogram.getCompileUnit(); + unsigned SrcFile = DW->RecordSource(CompileUnit.getDirectory(), + CompileUnit.getFilename()); // Record the source line but does not create a label for the normal // function start. It will be emitted at asm emission time. However, // create a label if this is a beginning of inlined function. - unsigned LabelID = MMI->RecordSourceLine(Subprogram->getLine(), 0, SrcFile); - if (MMI->getSourceLines().size() != 1) { + unsigned LabelID = + DW->RecordSourceLine(Subprogram.getLineNumber(), 0, SrcFile); + if (DW->getRecordSourceLineCount() != 1) { const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); BuildMI(MBB, II).addImm(LabelID); } @@ -372,7 +375,7 @@ bool FastISel::SelectCall(User *I) { case Intrinsic::dbg_declare: { DbgDeclareInst *DI = cast<DbgDeclareInst>(I); Value *Variable = DI->getVariable(); - if (MMI && Variable && MMI->Verify(Variable)) { + if (DW && Variable) { // Determine the address of the declared object. Value *Address = DI->getAddress(); if (BitCastInst *BCI = dyn_cast<BitCastInst>(Address)) @@ -682,6 +685,7 @@ FastISel::SelectOperator(User *I, unsigned Opcode) { FastISel::FastISel(MachineFunction &mf, MachineModuleInfo *mmi, + DwarfWriter *dw, DenseMap<const Value *, unsigned> &vm, DenseMap<const BasicBlock *, MachineBasicBlock *> &bm, DenseMap<const AllocaInst *, int> &am @@ -698,6 +702,7 @@ FastISel::FastISel(MachineFunction &mf, #endif MF(mf), MMI(mmi), + DW(dw), MRI(MF.getRegInfo()), MFI(*MF.getFrameInfo()), MCP(*MF.getConstantPool()), diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index c535f3a..18edb40 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -16,6 +16,8 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h" +#include "llvm/CodeGen/DwarfWriter.h" +#include "llvm/Analysis/DebugInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetLowering.h" @@ -26,6 +28,7 @@ #include "llvm/CallingConv.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/GlobalVariable.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/MathExtras.h" @@ -1258,15 +1261,17 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { case TargetLowering::Promote: default: assert(0 && "This action is not supported yet!"); case TargetLowering::Expand: { - MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + DwarfWriter *DW = DAG.getDwarfWriter(); bool useDEBUG_LOC = TLI.isOperationLegal(ISD::DEBUG_LOC, MVT::Other); bool useLABEL = TLI.isOperationLegal(ISD::DBG_LABEL, MVT::Other); const DbgStopPointSDNode *DSP = cast<DbgStopPointSDNode>(Node); - if (MMI && (useDEBUG_LOC || useLABEL)) { - const CompileUnitDesc *CompileUnit = DSP->getCompileUnit(); - unsigned SrcFile = MMI->RecordSource(CompileUnit); - + GlobalVariable *CU_GV = cast<GlobalVariable>(DSP->getCompileUnit()); + if (DW && (useDEBUG_LOC || useLABEL) && !CU_GV->isDeclaration()) { + DICompileUnit CU(cast<GlobalVariable>(DSP->getCompileUnit())); + unsigned SrcFile = DW->RecordSource(CU.getDirectory(), + CU.getFilename()); + unsigned Line = DSP->getLine(); unsigned Col = DSP->getColumn(); @@ -1276,7 +1281,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { DAG.getConstant(SrcFile, MVT::i32) }; Result = DAG.getNode(ISD::DEBUG_LOC, MVT::Other, Ops, 4); } else { - unsigned ID = MMI->RecordSourceLine(Line, Col, SrcFile); + unsigned ID = DW->RecordSourceLine(Line, Col, SrcFile); Result = DAG.getLabel(ISD::DBG_LABEL, Tmp1, ID); } } else { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index c755eac..324b070 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1137,8 +1137,8 @@ SDValue SelectionDAG::getRegister(unsigned RegNo, MVT VT) { } SDValue SelectionDAG::getDbgStopPoint(SDValue Root, - unsigned Line, unsigned Col, - const CompileUnitDesc *CU) { + unsigned Line, unsigned Col, + Value *CU) { SDNode *N = NodeAllocator.Allocate<DbgStopPointSDNode>(); new (N) DbgStopPointSDNode(Root, Line, Col, CU); AllNodes.push_back(N); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index 294acd8..d786e5e 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -37,6 +37,8 @@ #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/SelectionDAG.h" +#include "llvm/CodeGen/DwarfWriter.h" +#include "llvm/Analysis/DebugInfo.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" @@ -3742,67 +3744,65 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { return 0; } case Intrinsic::dbg_stoppoint: { - MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + DwarfWriter *DW = DAG.getDwarfWriter(); DbgStopPointInst &SPI = cast<DbgStopPointInst>(I); - if (MMI && SPI.getContext() && MMI->Verify(SPI.getContext())) { - DebugInfoDesc *DD = MMI->getDescFor(SPI.getContext()); - assert(DD && "Not a debug information descriptor"); + if (DW && SPI.getContext()) DAG.setRoot(DAG.getDbgStopPoint(getRoot(), SPI.getLine(), SPI.getColumn(), - cast<CompileUnitDesc>(DD))); - } - + SPI.getContext())); return 0; } case Intrinsic::dbg_region_start: { - MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + DwarfWriter *DW = DAG.getDwarfWriter(); DbgRegionStartInst &RSI = cast<DbgRegionStartInst>(I); - if (MMI && RSI.getContext() && MMI->Verify(RSI.getContext())) { - unsigned LabelID = MMI->RecordRegionStart(RSI.getContext()); + if (DW && RSI.getContext()) { + unsigned LabelID = + DW->RecordRegionStart(cast<GlobalVariable>(RSI.getContext())); DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getRoot(), LabelID)); } return 0; } case Intrinsic::dbg_region_end: { - MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + DwarfWriter *DW = DAG.getDwarfWriter(); DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I); - if (MMI && REI.getContext() && MMI->Verify(REI.getContext())) { - unsigned LabelID = MMI->RecordRegionEnd(REI.getContext()); + if (DW && REI.getContext()) { + unsigned LabelID = + DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext())); DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getRoot(), LabelID)); } return 0; } case Intrinsic::dbg_func_start: { - MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); - if (!MMI) return 0; + DwarfWriter *DW = DAG.getDwarfWriter(); + if (!DW) return 0; DbgFuncStartInst &FSI = cast<DbgFuncStartInst>(I); Value *SP = FSI.getSubprogram(); - if (SP && MMI->Verify(SP)) { + if (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); + DISubprogram Subprogram(cast<GlobalVariable>(SP)); + DICompileUnit CompileUnit = Subprogram.getCompileUnit(); + unsigned SrcFile = DW->RecordSource(CompileUnit.getDirectory(), + CompileUnit.getFilename()); // Record the source line but does not create a label for the normal // function start. It will be emitted at asm emission time. However, // create a label if this is a beginning of inlined function. - unsigned LabelID = MMI->RecordSourceLine(Subprogram->getLine(), 0, SrcFile); - if (MMI->getSourceLines().size() != 1) + unsigned LabelID = + DW->RecordSourceLine(Subprogram.getLineNumber(), 0, SrcFile); + if (DW->getRecordSourceLineCount() != 1) DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getRoot(), LabelID)); } return 0; } case Intrinsic::dbg_declare: { - MachineModuleInfo *MMI = DAG.getMachineModuleInfo(); + DwarfWriter *DW = DAG.getDwarfWriter(); DbgDeclareInst &DI = cast<DbgDeclareInst>(I); Value *Variable = DI.getVariable(); - if (MMI && Variable && MMI->Verify(Variable)) + if (DW && Variable) DAG.setRoot(DAG.getNode(ISD::DECLARE, MVT::Other, getRoot(), getValue(DI.getAddress()), getValue(Variable))); return 0; diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 4eb7019..3688a13 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -327,7 +327,7 @@ bool SelectionDAGISel::runOnFunction(Function &Fn) { // Mark landing pad. FuncInfo->MBBMap[Invoke->getSuccessor(1)]->setIsLandingPad(); - SelectAllBasicBlocks(Fn, MF, MMI, TII); + SelectAllBasicBlocks(Fn, MF, MMI, DW, TII); // 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 @@ -696,11 +696,12 @@ void SelectionDAGISel::CodeGenAndEmitDAG() { void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF, MachineModuleInfo *MMI, + DwarfWriter *DW, const TargetInstrInfo &TII) { // Initialize the Fast-ISel state, if needed. FastISel *FastIS = 0; if (EnableFastISel) - FastIS = TLI.createFastISel(*FuncInfo->MF, MMI, + FastIS = TLI.createFastISel(*FuncInfo->MF, MMI, DW, FuncInfo->ValueMap, FuncInfo->MBBMap, FuncInfo->StaticAllocaMap diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp index a528c80..9396f16 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -20,6 +20,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" +#include "llvm/Analysis/DebugInfo.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/Debug.h" @@ -177,7 +178,8 @@ std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node, Op += " #" + utostr(R->getReg()); } } else if (const DbgStopPointSDNode *D = dyn_cast<DbgStopPointSDNode>(Node)) { - Op += ": " + D->getCompileUnit()->getFileName(); + DICompileUnit CU(cast<GlobalVariable>(D->getCompileUnit())); + Op += ": " + CU.getFilename(); Op += ":" + utostr(D->getLine()); if (D->getColumn() != 0) Op += ":" + utostr(D->getColumn()); |