diff options
author | Jim Laskey <jlaskey@mac.com> | 2006-01-26 20:21:46 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2006-01-26 20:21:46 +0000 |
commit | b3e789ac2548a4382d0db03b573fd8a127617f8f (patch) | |
tree | a521e43b703e2c7efefa89d933b62982913c5b54 /lib/CodeGen/DwarfWriter.cpp | |
parent | e4a359e43b7af7db24482f1da3303c0bb7c9f425 (diff) |
Set up MachineDebugInfo to scan for debug information form "llvm.db"g globals.
Global Variable information is now pulled from "llvm.dbg.globals"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25655 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/DwarfWriter.cpp')
-rw-r--r-- | lib/CodeGen/DwarfWriter.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index c11c52f08c..512f479fdd 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -18,6 +18,7 @@ #include "llvm/Type.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineDebugInfo.h" +#include "llvm/Support/Dwarf.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Mangler.h" #include "llvm/Target/TargetMachine.h" @@ -1719,28 +1720,26 @@ void DwarfWriter::ConstructCompileUnitDIEs() { /// variables. void DwarfWriter::ConstructGlobalDIEs(Module &M) { const TargetData &TD = Asm->TM.getTargetData(); - - // Iterate throu each of the globals. - for (Module::const_global_iterator GI = M.global_begin(), GE = M.global_end(); - GI != GE; ++GI) { - if (!GI->hasInitializer()) continue; // External global require no code + + std::vector<GlobalWrapper> GlobalVariables = DebugInfo->getGlobalVariables(M); + + for (unsigned i = 0, N = GlobalVariables.size(); i < N; ++i) { + GlobalWrapper &GW = GlobalVariables[i]; + GlobalVariable *GV = GW.getGlobalVariable(); - // Check to see if this is a special global used by LLVM, if so, emit it. - if (GI->hasAppendingLinkage() && (GI->getName() == "llvm.global_ctors" || - GI->getName() == "llvm.global_dtors")) - continue; + if (!GV->hasInitializer()) continue; // External global require no code - std::string Name = Asm->Mang->getValueName(GI); - Constant *C = GI->getInitializer(); + // FIXME - Use global info type information when available. + std::string Name = Asm->Mang->getValueName(GV); + Constant *C = GV->getInitializer(); const Type *Ty = C->getType(); unsigned Size = TD.getTypeSize(Ty); unsigned Align = TD.getTypeAlignmentShift(Ty); if (C->isNullValue() && /* FIXME: Verify correct */ - (GI->hasInternalLinkage() || GI->hasWeakLinkage() || - GI->hasLinkOnceLinkage())) { + (GV->hasInternalLinkage() || GV->hasWeakLinkage() || + GV->hasLinkOnceLinkage())) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - } /// FIXME - Get correct compile unit context. @@ -1748,7 +1747,7 @@ void DwarfWriter::ConstructGlobalDIEs(Module &M) { DWContext *Context = CompileUnits[0]->getContext(); /// Create new global. - NewGlobalVariable(Context, GI->getName(), Name, Ty, Size, Align); + NewGlobalVariable(Context, GV->getName(), Name, Ty, Size, Align); } } |