forked from OSchip/llvm-project
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:
parent
c4744b9e22
commit
8e8028eac3
|
@ -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.
|
||||||
// FIXME : What if more then one CUs are present in a module ?
|
SmallVector<GlobalVariable *, 2> CUs;
|
||||||
GlobalVariable *CU = M.getNamedGlobal("llvm.dbg.compile_unit");
|
SmallVector<GlobalVariable *, 4> GVs;
|
||||||
if (CU) {
|
SmallVector<GlobalVariable *, 4> SPs;
|
||||||
|
CollectDebugInfoAnchors(M, CUs, GVs, SPs);
|
||||||
|
if (!CUs.empty()) {
|
||||||
|
// FIXME : What if more then one CUs are present in a module ?
|
||||||
|
GlobalVariable *CU = CUs[0];
|
||||||
EmitDebugDirectives = true;
|
EmitDebugDirectives = true;
|
||||||
SwitchToCU(CU);
|
SwitchToCU(CU);
|
||||||
}
|
}
|
||||||
|
@ -427,32 +431,30 @@ 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();
|
DIType Ty = DIGV.getType();
|
||||||
UUI != UUE; ++UUI) {
|
unsigned short TypeNo = 0;
|
||||||
DIGlobalVariable DIGV(cast<GlobalVariable>(*UUI));
|
bool HasAux = false;
|
||||||
DIType Ty = DIGV.getType();
|
int Aux[PIC16Dbg::AuxSize] = { 0 };
|
||||||
unsigned short TypeNo = 0;
|
std::string TagName = "";
|
||||||
bool HasAux = false;
|
std::string VarName = TAI->getGlobalPrefix()+DIGV.getGlobal()->getName();
|
||||||
int Aux[PIC16Dbg::AuxSize] = { 0 };
|
PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName);
|
||||||
std::string TagName = "";
|
// Emit debug info only if type information is availaible.
|
||||||
std::string VarName = TAI->getGlobalPrefix()+DIGV.getGlobal()->getName();
|
if (TypeNo != PIC16Dbg::T_NULL) {
|
||||||
PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName);
|
O << "\n\t.type " << VarName << ", " << TypeNo;
|
||||||
// Emit debug info only if type information is availaible.
|
short ClassNo = getStorageClass(DIGV);
|
||||||
if (TypeNo != PIC16Dbg::T_NULL) {
|
O << "\n\t.class " << VarName << ", " << ClassNo;
|
||||||
O << "\n\t.type " << VarName << ", " << TypeNo;
|
if (HasAux)
|
||||||
short ClassNo = getStorageClass(DIGV);
|
EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName);
|
||||||
O << "\n\t.class " << VarName << ", " << ClassNo;
|
|
||||||
if (HasAux)
|
|
||||||
EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
O << "\n";
|
O << "\n";
|
||||||
|
|
Loading…
Reference in New Issue