diff options
author | Devang Patel <dpatel@apple.com> | 2009-04-11 00:16:47 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-04-11 00:16:47 +0000 |
commit | 2057532679fc1045cfeb38b477ac9e749e6b1dd8 (patch) | |
tree | 12744ff1819cbe961dd7bb2cd639bb1003045508 /lib/CodeGen/SelectionDAG | |
parent | dbf1e2b08b534c32743aa7ea8ef7d6f5cee6234b (diff) | |
download | external_llvm-2057532679fc1045cfeb38b477ac9e749e6b1dd8.zip external_llvm-2057532679fc1045cfeb38b477ac9e749e6b1dd8.tar.gz external_llvm-2057532679fc1045cfeb38b477ac9e749e6b1dd8.tar.bz2 |
Keep track of inlined functions and their locations. This information is collected when nested llvm.dbg.func.start intrinsics are seen. (Right now, inliner removes nested llvm.dbg.func.start intrinisics during inlining.)
Create debug_inlined dwarf section using these information. This info is used by gdb, at least on Darwin, to enable better experience debugging inlined functions. See DwarfWriter.cpp for more information on structure of debug_inlined section.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68847 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG')
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 18 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 22 |
2 files changed, 37 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 8467330..617f6e4 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -372,11 +372,23 @@ bool FastISel::SelectCall(User *I) { // Record the source line. unsigned Line = Subprogram.getLineNumber(); - DW->RecordSourceLine(Line, 0, SrcFile); + unsigned LabelID = DW->RecordSourceLine(Line, 0, SrcFile); setCurDebugLoc(DebugLoc::get(MF.getOrCreateDebugLocID(SrcFile, Line, 0))); - // llvm.dbg.func_start also defines beginning of function scope. - DW->RecordRegionStart(cast<GlobalVariable>(FSI->getSubprogram())); + std::string SPName; + Subprogram.getLinkageName(SPName); + if (!SPName.empty() + && strcmp(SPName.c_str(), MF.getFunction()->getNameStart())) { + // This is a beginning of inlined function. + DW->RecordRegionStart(cast<GlobalVariable>(FSI->getSubprogram()), + LabelID); + const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); + BuildMI(MBB, DL, II).addImm(LabelID); + DW->RecordInlineInfo(Subprogram.getGV(), LabelID); + } else { + // llvm.dbg.func_start also defines beginning of function scope. + DW->RecordRegionStart(cast<GlobalVariable>(FSI->getSubprogram())); + } } return true; diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index effb215..b596643 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -3955,6 +3955,18 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { DwarfWriter *DW = DAG.getDwarfWriter(); DbgRegionEndInst &REI = cast<DbgRegionEndInst>(I); if (DW && DW->ValidDebugInfo(REI.getContext())) { + + MachineFunction &MF = DAG.getMachineFunction(); + DISubprogram Subprogram(cast<GlobalVariable>(REI.getContext())); + std::string SPName; + Subprogram.getLinkageName(SPName); + if (!SPName.empty() + && strcmp(SPName.c_str(), MF.getFunction()->getNameStart())) { + // This is end of inlined function. Debugging information for + // inlined function is not handled yet (only supported by FastISel). + return 0; + } + unsigned LabelID = DW->RecordRegionEnd(cast<GlobalVariable>(REI.getContext())); if (Fast) @@ -3974,6 +3986,16 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { // what (most?) gdb expects. MachineFunction &MF = DAG.getMachineFunction(); DISubprogram Subprogram(cast<GlobalVariable>(SP)); + + std::string SPName; + Subprogram.getLinkageName(SPName); + if (!SPName.empty() + && strcmp(SPName.c_str(), MF.getFunction()->getNameStart())) { + // This is beginning of inlined function. Debugging information for + // inlined function is not handled yet (only supported by FastISel). + return 0; + } + DICompileUnit CompileUnit = Subprogram.getCompileUnit(); std::string Dir, FN; unsigned SrcFile = DW->getOrCreateSourceID(CompileUnit.getDirectory(Dir), |