From fcf1c75c71c5246afd5dd3f6fcddf259233d8b22 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 13 Jan 2009 00:35:13 +0000 Subject: Use DebugInfo interface to lower dbg_* intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62127 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen/SelectionDAG/LegalizeDAG.cpp') 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(Node); - if (MMI && (useDEBUG_LOC || useLABEL)) { - const CompileUnitDesc *CompileUnit = DSP->getCompileUnit(); - unsigned SrcFile = MMI->RecordSource(CompileUnit); - + GlobalVariable *CU_GV = cast(DSP->getCompileUnit()); + if (DW && (useDEBUG_LOC || useLABEL) && !CU_GV->isDeclaration()) { + DICompileUnit CU(cast(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 { -- cgit v1.1