aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-04-15 00:10:26 +0000
committerDevang Patel <dpatel@apple.com>2009-04-15 00:10:26 +0000
commit1be3eccecbd2fa50ed9008ffee01f6351df5d8f7 (patch)
treec27337a942e36a3dd2d628d2e1779ca0b21ba294 /lib/CodeGen/SelectionDAG
parentaaa1fdb271073893699f3af57f5439dae35a8f59 (diff)
downloadexternal_llvm-1be3eccecbd2fa50ed9008ffee01f6351df5d8f7.zip
external_llvm-1be3eccecbd2fa50ed9008ffee01f6351df5d8f7.tar.gz
external_llvm-1be3eccecbd2fa50ed9008ffee01f6351df5d8f7.tar.bz2
Construct and emit DW_TAG_inlined_subroutine DIEs for inlined subroutine scopes (only in FastISel mode).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG')
-rw-r--r--lib/CodeGen/SelectionDAG/FastISel.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index f48ff52..e9cc391 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -47,6 +47,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/DebugLoc.h"
#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Target/TargetData.h"
@@ -354,10 +355,18 @@ bool FastISel::SelectCall(User *I) {
case Intrinsic::dbg_region_end: {
DbgRegionEndInst *REI = cast<DbgRegionEndInst>(I);
if (DW && DW->ValidDebugInfo(REI->getContext(), true)) {
- unsigned ID =
- DW->RecordRegionEnd(cast<GlobalVariable>(REI->getContext()));
- const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
- BuildMI(MBB, DL, II).addImm(ID);
+ unsigned ID = 0;
+ DISubprogram Subprogram(cast<GlobalVariable>(REI->getContext()));
+ if (!Subprogram.describes(MF.getFunction())) {
+ // This is end of an inlined function.
+ const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
+ ID = DW->RecordInlinedFnEnd(Subprogram);
+ BuildMI(MBB, DL, II).addImm(ID);
+ } else {
+ const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
+ ID = DW->RecordRegionEnd(cast<GlobalVariable>(REI->getContext()));
+ BuildMI(MBB, DL, II).addImm(ID);
+ }
}
return true;
}
@@ -369,6 +378,7 @@ bool FastISel::SelectCall(User *I) {
if (DW->ValidDebugInfo(SP, true)) {
// llvm.dbg.func.start implicitly defines a dbg_stoppoint which is what
// (most?) gdb expects.
+ DebugLoc PrevLoc = DL;
DISubprogram Subprogram(cast<GlobalVariable>(SP));
DICompileUnit CompileUnit = Subprogram.getCompileUnit();
std::string Dir, FN;
@@ -379,17 +389,15 @@ bool FastISel::SelectCall(User *I) {
unsigned Line = Subprogram.getLineNumber();
unsigned LabelID = DW->RecordSourceLine(Line, 0, SrcFile);
setCurDebugLoc(DebugLoc::get(MF.getOrCreateDebugLocID(SrcFile, Line, 0)));
-
- 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);
+ if (!Subprogram.describes(MF.getFunction())) {
+ // This is a beginning of an inlined function.
const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
BuildMI(MBB, DL, II).addImm(LabelID);
- DW->RecordInlineInfo(Subprogram.getGV(), LabelID);
+ DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc);
+ DW->RecordInlinedFnStart(FSI, Subprogram, LabelID,
+ PrevLocTpl.Src,
+ PrevLocTpl.Line,
+ PrevLocTpl.Col);
} else {
// llvm.dbg.func_start also defines beginning of function scope.
DW->RecordRegionStart(cast<GlobalVariable>(FSI->getSubprogram()));
@@ -419,7 +427,13 @@ bool FastISel::SelectCall(User *I) {
// Build the DECLARE instruction.
const TargetInstrDesc &II = TII.get(TargetInstrInfo::DECLARE);
- BuildMI(MBB, DL, II).addFrameIndex(FI).addGlobalAddress(GV);
+ MachineInstr *DeclareMI
+ = BuildMI(MBB, DL, II).addFrameIndex(FI).addGlobalAddress(GV);
+ DIVariable DV(cast<GlobalVariable>(GV));
+ if (!DV.isNull()) {
+ // This is a local variable
+ DW->RecordVariableScope(DV, DeclareMI);
+ }
}
return true;
}