summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-01-05 23:11:11 +0000
committerDevang Patel <dpatel@apple.com>2009-01-05 23:11:11 +0000
commitc452324f60561bdc1a3f90b8f7d085beb9487f36 (patch)
treee85a828a9bceb25f0ae86e9d8c5f2609a1974b2d /lib
parentd1ca925093b410a60e84cff2ceda7101ba4a1ce7 (diff)
downloadllvm-c452324f60561bdc1a3f90b8f7d085beb9487f36.tar.gz
llvm-c452324f60561bdc1a3f90b8f7d085beb9487f36.tar.bz2
llvm-c452324f60561bdc1a3f90b8f7d085beb9487f36.tar.xz
Construct global variable DIEs using DebugInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61771 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfWriter.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
index 401252460c..026671436c 100644
--- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
@@ -3116,7 +3116,7 @@ private:
Asm->EOL();
}
- /// ConstructCompileUnitDIEs - Create a compile unit DIEs.
+ /// ConstructCompileUnits - Create a compile unit DIEs.
void ConstructCompileUnits() {
std::string CUName = "llvm.dbg.compile_units";
std::vector<GlobalVariable*> Result;
@@ -3155,6 +3155,53 @@ private:
}
}
+ /// ConstructGlobalVariableDIEs - Create DIEs for each of the externally
+ /// visible global variables.
+ void ConstructGlobalVariableDIEs() {
+ std::string GVName = "llvm.dbg.global_variables";
+ std::vector<GlobalVariable*> Result;
+ getGlobalVariablesUsing(*M, GVName, Result);
+ for (std::vector<GlobalVariable *>::iterator GVI = Result.begin(),
+ GVE = Result.end(); GVI != GVE; ++GVI) {
+ DIGlobalVariable *DI_GV = new DIGlobalVariable(*GVI);
+ CompileUnit *DW_Unit = FindCompileUnit(DI_GV->getCompileUnit());
+
+ // Check for pre-existence.
+ DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV->getGV());
+ if (Slot) continue;
+
+ DIE *VariableDie = new DIE(DW_TAG_variable);
+ AddString(VariableDie, DW_AT_name, DW_FORM_string, DI_GV->getName());
+ const std::string &LinkageName = DI_GV->getLinkageName();
+ if (!LinkageName.empty())
+ AddString(VariableDie, DW_AT_MIPS_linkage_name, DW_FORM_string,
+ LinkageName);
+ AddType(DW_Unit, VariableDie, DI_GV->getType());
+
+ if (!DI_GV->isLocalToUnit())
+ AddUInt(VariableDie, DW_AT_external, DW_FORM_flag, 1);
+
+ // Add source line info, if available.
+ AddSourceLine(VariableDie, DI_GV);
+
+ // Add address.
+ DIEBlock *Block = new DIEBlock();
+ AddUInt(Block, 0, DW_FORM_data1, DW_OP_addr);
+ AddObjectLabel(Block, 0, DW_FORM_udata,
+ Asm->getGlobalLinkName(DI_GV->getGV()));
+ AddBlock(VariableDie, DW_AT_location, 0, Block);
+
+ //Add to map.
+ Slot = VariableDie;
+
+ //Add to context owner.
+ DW_Unit->getDie()->AddChild(VariableDie);
+
+ //Expose as global. FIXME - need to check external flag.
+ DW_Unit->AddGlobal(DI_GV->getName(), VariableDie);
+ }
+ }
+
/// ConstructGlobalDIEs - Create DIEs for each of the externally visible
/// global variables.
void ConstructGlobalDIEs() {