Avoid directly relying on llvm.dbg.compile_unit and llvm.dbg.global_variables.

PIC16 developers, please verify. Thanks.

llvm-svn: 74880
This commit is contained in:
Devang Patel 2009-07-06 23:28:36 +00:00
parent c4744b9e22
commit 8e8028eac3
1 changed files with 29 additions and 27 deletions

View File

@ -200,9 +200,13 @@ short PIC16DbgInfo::getStorageClass(DIGlobalVariable DIGV) {
/// required initializations. /// required initializations.
void PIC16DbgInfo::BeginModule(Module &M) { void PIC16DbgInfo::BeginModule(Module &M) {
// Emit file directive for module. // Emit file directive for module.
SmallVector<GlobalVariable *, 2> CUs;
SmallVector<GlobalVariable *, 4> GVs;
SmallVector<GlobalVariable *, 4> SPs;
CollectDebugInfoAnchors(M, CUs, GVs, SPs);
if (!CUs.empty()) {
// FIXME : What if more then one CUs are present in a module ? // FIXME : What if more then one CUs are present in a module ?
GlobalVariable *CU = M.getNamedGlobal("llvm.dbg.compile_unit"); GlobalVariable *CU = CUs[0];
if (CU) {
EmitDebugDirectives = true; EmitDebugDirectives = true;
SwitchToCU(CU); SwitchToCU(CU);
} }
@ -427,17 +431,16 @@ void PIC16DbgInfo::EmitSymbol(std::string Name, short Class, unsigned short
/// EmitVarDebugInfo - Emit debug information for all variables. /// EmitVarDebugInfo - Emit debug information for all variables.
/// ///
void PIC16DbgInfo::EmitVarDebugInfo(Module &M) { void PIC16DbgInfo::EmitVarDebugInfo(Module &M) {
// FIXME : This anchor has been removed. SmallVector<GlobalVariable *, 2> CUs;
GlobalVariable *Root = M.getGlobalVariable("llvm.dbg.global_variables"); SmallVector<GlobalVariable *, 4> GVs;
if (!Root) SmallVector<GlobalVariable *, 4> SPs;
CollectDebugInfoAnchors(M, CUs, GVs, SPs);
if (GVs.empty())
return; return;
Constant *RootC = cast<Constant>(*Root->use_begin()); for (SmallVector<GlobalVariable *, 4>::iterator I = GVs.begin(),
for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end(); E = GVs.end(); I != E; ++I) {
UI != UE; ++UI) { DIGlobalVariable DIGV(*I);
for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
UUI != UUE; ++UUI) {
DIGlobalVariable DIGV(cast<GlobalVariable>(*UUI));
DIType Ty = DIGV.getType(); DIType Ty = DIGV.getType();
unsigned short TypeNo = 0; unsigned short TypeNo = 0;
bool HasAux = false; bool HasAux = false;
@ -454,7 +457,6 @@ void PIC16DbgInfo::EmitVarDebugInfo(Module &M) {
EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName); EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName);
} }
} }
}
O << "\n"; O << "\n";
} }