mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
Add support to preserve type info for the variables that are removed by the optimizer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103798 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -677,7 +677,7 @@ namespace llvm {
|
|||||||
DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
|
DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
|
||||||
StringRef Name,
|
StringRef Name,
|
||||||
DIFile F, unsigned LineNo,
|
DIFile F, unsigned LineNo,
|
||||||
DIType Ty);
|
DIType Ty, bool OptimizedBuild = false);
|
||||||
|
|
||||||
/// CreateComplexVariable - Create a new descriptor for the specified
|
/// CreateComplexVariable - Create a new descriptor for the specified
|
||||||
/// variable which has a complex address expression for its address.
|
/// variable which has a complex address expression for its address.
|
||||||
|
@ -1028,7 +1028,7 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
|
|||||||
StringRef Name,
|
StringRef Name,
|
||||||
DIFile F,
|
DIFile F,
|
||||||
unsigned LineNo,
|
unsigned LineNo,
|
||||||
DIType Ty) {
|
DIType Ty, bool OptimizedBuild) {
|
||||||
Value *Elts[] = {
|
Value *Elts[] = {
|
||||||
GetTagConstant(Tag),
|
GetTagConstant(Tag),
|
||||||
Context,
|
Context,
|
||||||
@ -1037,7 +1037,12 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
|
|||||||
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
||||||
Ty,
|
Ty,
|
||||||
};
|
};
|
||||||
return DIVariable(MDNode::get(VMContext, &Elts[0], 6));
|
MDNode *Node = MDNode::get(VMContext, &Elts[0], 6);
|
||||||
|
if (OptimizedBuild) {
|
||||||
|
NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.lv");
|
||||||
|
NMD->addOperand(Node);
|
||||||
|
}
|
||||||
|
return DIVariable(Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,6 +193,9 @@ public:
|
|||||||
DbgVariable *getAbstractVariable() const { return AbstractVar; }
|
DbgVariable *getAbstractVariable() const { return AbstractVar; }
|
||||||
void setDIE(DIE *D) { TheDIE = D; }
|
void setDIE(DIE *D) { TheDIE = D; }
|
||||||
DIE *getDIE() const { return TheDIE; }
|
DIE *getDIE() const { return TheDIE; }
|
||||||
|
bool hasLocation() {
|
||||||
|
return DbgValueMInsn || FrameIndex != ~0U;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -1632,16 +1635,18 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, DbgScope *Scope) {
|
|||||||
MachineLocation Location;
|
MachineLocation Location;
|
||||||
unsigned FrameReg;
|
unsigned FrameReg;
|
||||||
const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
|
const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
|
||||||
int Offset = RI->getFrameIndexReference(*Asm->MF, DV->getFrameIndex(),
|
if (DV->hasLocation()) {
|
||||||
FrameReg);
|
int Offset = RI->getFrameIndexReference(*Asm->MF, DV->getFrameIndex(),
|
||||||
Location.set(FrameReg, Offset);
|
FrameReg);
|
||||||
|
Location.set(FrameReg, Offset);
|
||||||
if (VD.hasComplexAddress())
|
|
||||||
addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
|
if (VD.hasComplexAddress())
|
||||||
else if (VD.isBlockByrefVariable())
|
addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
|
||||||
addBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
|
else if (VD.isBlockByrefVariable())
|
||||||
else
|
addBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location);
|
||||||
addAddress(VariableDie, dwarf::DW_AT_location, Location);
|
else
|
||||||
|
addAddress(VariableDie, dwarf::DW_AT_location, Location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2122,14 +2127,15 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// collectVariableInfo - Populate DbgScope entries with variables' info.
|
/// collectVariableInfo - Populate DbgScope entries with variables' info.
|
||||||
void DwarfDebug::collectVariableInfo() {
|
void DwarfDebug::collectVariableInfo(const MachineFunction *MF) {
|
||||||
const LLVMContext &Ctx = Asm->MF->getFunction()->getContext();
|
const LLVMContext &Ctx = Asm->MF->getFunction()->getContext();
|
||||||
|
SmallPtrSet<const MDNode *, 16> Processed;
|
||||||
MachineModuleInfo::VariableDbgInfoMapTy &VMap = MMI->getVariableDbgInfo();
|
MachineModuleInfo::VariableDbgInfoMapTy &VMap = MMI->getVariableDbgInfo();
|
||||||
for (MachineModuleInfo::VariableDbgInfoMapTy::iterator VI = VMap.begin(),
|
for (MachineModuleInfo::VariableDbgInfoMapTy::iterator VI = VMap.begin(),
|
||||||
VE = VMap.end(); VI != VE; ++VI) {
|
VE = VMap.end(); VI != VE; ++VI) {
|
||||||
const MDNode *Var = VI->first;
|
const MDNode *Var = VI->first;
|
||||||
if (!Var) continue;
|
if (!Var) continue;
|
||||||
|
Processed.insert(Var);
|
||||||
DIVariable DV(Var);
|
DIVariable DV(Var);
|
||||||
const std::pair<unsigned, DebugLoc> &VP = VI->second;
|
const std::pair<unsigned, DebugLoc> &VP = VI->second;
|
||||||
|
|
||||||
@ -2184,12 +2190,27 @@ void DwarfDebug::collectVariableInfo() {
|
|||||||
if (Scope == 0)
|
if (Scope == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Processed.insert(DV);
|
||||||
DbgVariable *AbsDbgVariable = findAbstractVariable(DV, MInsn, DL);
|
DbgVariable *AbsDbgVariable = findAbstractVariable(DV, MInsn, DL);
|
||||||
DbgVariable *RegVar = new DbgVariable(DV, MInsn, AbsDbgVariable);
|
DbgVariable *RegVar = new DbgVariable(DV, MInsn, AbsDbgVariable);
|
||||||
DbgValueStartMap[MInsn] = RegVar;
|
DbgValueStartMap[MInsn] = RegVar;
|
||||||
Scope->addVariable(RegVar);
|
Scope->addVariable(RegVar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Collect info for variables that were optimized out.
|
||||||
|
if (NamedMDNode *NMD =
|
||||||
|
MF->getFunction()->getParent()->getNamedMetadata("llvm.dbg.lv")) {
|
||||||
|
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
||||||
|
DIVariable DV(cast_or_null<MDNode>(NMD->getOperand(i)));
|
||||||
|
if (!Processed.insert(DV))
|
||||||
|
continue;
|
||||||
|
DbgScope *Scope = DbgScopeMap.lookup(DV.getContext());
|
||||||
|
if (Scope)
|
||||||
|
Scope->addVariable(new DbgVariable(DV, ~0U, NULL));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// beginScope - Process beginning of a scope.
|
/// beginScope - Process beginning of a scope.
|
||||||
@ -2542,7 +2563,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
|
|||||||
if (!MMI->hasDebugInfo()) return;
|
if (!MMI->hasDebugInfo()) return;
|
||||||
if (!extractScopeInformation()) return;
|
if (!extractScopeInformation()) return;
|
||||||
|
|
||||||
collectVariableInfo();
|
collectVariableInfo(MF);
|
||||||
|
|
||||||
FunctionBeginSym = Asm->GetTempSymbol("func_begin",
|
FunctionBeginSym = Asm->GetTempSymbol("func_begin",
|
||||||
Asm->getFunctionNumber());
|
Asm->getFunctionNumber());
|
||||||
|
@ -545,7 +545,7 @@ private:
|
|||||||
bool extractScopeInformation();
|
bool extractScopeInformation();
|
||||||
|
|
||||||
/// collectVariableInfo - Populate DbgScope entries with variables' info.
|
/// collectVariableInfo - Populate DbgScope entries with variables' info.
|
||||||
void collectVariableInfo();
|
void collectVariableInfo(const MachineFunction *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
Reference in New Issue
Block a user