mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
Extract scope information from the variable itself, instead of relying on alloca or llvm.dbg.declare location.
While recording beginning of a function, use scope info from the first location entry instead of just relying on first location entry itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83684 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c89d27a440
commit
ac1ceb3dd3
@ -42,6 +42,7 @@
|
|||||||
#include "llvm/CodeGen/MachineLocation.h"
|
#include "llvm/CodeGen/MachineLocation.h"
|
||||||
#include "llvm/GlobalValue.h"
|
#include "llvm/GlobalValue.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
|
#include "llvm/Metadata.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ class MachineModuleInfo : public ImmutablePass {
|
|||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
|
|
||||||
typedef DenseMap<MDNode *, std::pair<MDNode *, unsigned> > VariableDbgInfoMapTy;
|
typedef SmallVector< std::pair< WeakMetadataVH, unsigned>, 4 > VariableDbgInfoMapTy;
|
||||||
VariableDbgInfoMapTy VariableDbgInfo;
|
VariableDbgInfoMapTy VariableDbgInfo;
|
||||||
|
|
||||||
MachineModuleInfo();
|
MachineModuleInfo();
|
||||||
@ -332,9 +333,8 @@ public:
|
|||||||
|
|
||||||
/// setVariableDbgInfo - Collect information used to emit debugging information
|
/// setVariableDbgInfo - Collect information used to emit debugging information
|
||||||
/// of a variable.
|
/// of a variable.
|
||||||
void setVariableDbgInfo(MDNode *N, MDNode *L, unsigned S) {
|
void setVariableDbgInfo(MDNode *N, unsigned S) {
|
||||||
if (N && L)
|
VariableDbgInfo.push_back(std::make_pair(N, S));
|
||||||
VariableDbgInfo[N] = std::make_pair(L, S);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfo; }
|
VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfo; }
|
||||||
|
@ -1784,23 +1784,19 @@ void DwarfDebug::EndModule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// CollectVariableInfo - Populate DbgScope entries with variables' info.
|
/// CollectVariableInfo - Populate DbgScope entries with variables' info.
|
||||||
bool DwarfDebug::CollectVariableInfo() {
|
void DwarfDebug::CollectVariableInfo() {
|
||||||
if (!MMI) return false;
|
if (!MMI) return;
|
||||||
bool ArgsCollected = false;
|
|
||||||
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) {
|
||||||
MDNode *Var = VI->first;
|
MetadataBase *MB = VI->first;
|
||||||
|
MDNode *Var = dyn_cast_or_null<MDNode>(MB);
|
||||||
DIVariable DV (Var);
|
DIVariable DV (Var);
|
||||||
if (DV.isNull()) continue;
|
if (DV.isNull()) continue;
|
||||||
if (DV.getTag() == dwarf::DW_TAG_arg_variable)
|
unsigned VSlot = VI->second;
|
||||||
ArgsCollected = true;
|
DbgScope *Scope = getDbgScope(DV.getContext().getNode(), NULL);
|
||||||
DILocation VLoc(VI->second.first);
|
|
||||||
unsigned VSlot = VI->second.second;
|
|
||||||
DbgScope *Scope = getDbgScope(VLoc.getScope().getNode(), NULL);
|
|
||||||
Scope->AddVariable(new DbgVariable(DV, VSlot, false));
|
Scope->AddVariable(new DbgVariable(DV, VSlot, false));
|
||||||
}
|
}
|
||||||
return ArgsCollected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SetDbgScopeBeginLabels - Update DbgScope begin labels for the scopes that
|
/// SetDbgScopeBeginLabels - Update DbgScope begin labels for the scopes that
|
||||||
@ -1911,7 +1907,7 @@ void DwarfDebug::BeginFunction(MachineFunction *MF) {
|
|||||||
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
|
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
if (!ExtractScopeInformation(MF))
|
if (!ExtractScopeInformation(MF))
|
||||||
return;
|
return;
|
||||||
bool ArgsCollected = CollectVariableInfo();
|
CollectVariableInfo();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Begin accumulating function debug information.
|
// Begin accumulating function debug information.
|
||||||
@ -1923,18 +1919,27 @@ void DwarfDebug::BeginFunction(MachineFunction *MF) {
|
|||||||
// Emit label for the implicitly defined dbg.stoppoint at the start of the
|
// Emit label for the implicitly defined dbg.stoppoint at the start of the
|
||||||
// function.
|
// function.
|
||||||
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
|
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
if (!ArgsCollected) {
|
DebugLoc FDL = MF->getDefaultDebugLoc();
|
||||||
#else
|
if (!FDL.isUnknown()) {
|
||||||
if (1) {
|
DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
|
||||||
#endif
|
unsigned LabelID = 0;
|
||||||
DebugLoc FDL = MF->getDefaultDebugLoc();
|
DISubprogram SP(DLT.CompileUnit);
|
||||||
if (!FDL.isUnknown()) {
|
if (!SP.isNull())
|
||||||
DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
|
LabelID = RecordSourceLine(SP.getLineNumber(), 0, DLT.CompileUnit);
|
||||||
unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.CompileUnit);
|
else
|
||||||
Asm->printLabel(LabelID);
|
LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.CompileUnit);
|
||||||
O << '\n';
|
Asm->printLabel(LabelID);
|
||||||
}
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
DebugLoc FDL = MF->getDefaultDebugLoc();
|
||||||
|
if (!FDL.isUnknown()) {
|
||||||
|
DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
|
||||||
|
unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col, DLT.CompileUnit);
|
||||||
|
Asm->printLabel(LabelID);
|
||||||
|
O << '\n';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (TimePassesIsEnabled)
|
if (TimePassesIsEnabled)
|
||||||
DebugTimer->stopTimer();
|
DebugTimer->stopTimer();
|
||||||
}
|
}
|
||||||
@ -1947,6 +1952,10 @@ void DwarfDebug::EndFunction(MachineFunction *MF) {
|
|||||||
if (TimePassesIsEnabled)
|
if (TimePassesIsEnabled)
|
||||||
DebugTimer->startTimer();
|
DebugTimer->startTimer();
|
||||||
|
|
||||||
|
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
|
if (DbgScopeMap.empty())
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
// Define end label for subprogram.
|
// Define end label for subprogram.
|
||||||
EmitLabel("func_end", SubprogramCount);
|
EmitLabel("func_end", SubprogramCount);
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ public:
|
|||||||
bool ExtractScopeInformation(MachineFunction *MF);
|
bool ExtractScopeInformation(MachineFunction *MF);
|
||||||
|
|
||||||
/// CollectVariableInfo - Populate DbgScope entries with variables' info.
|
/// CollectVariableInfo - Populate DbgScope entries with variables' info.
|
||||||
bool CollectVariableInfo();
|
void CollectVariableInfo();
|
||||||
|
|
||||||
/// SetDbgScopeBeginLabels - Update DbgScope begin labels for the scopes that
|
/// SetDbgScopeBeginLabels - Update DbgScope begin labels for the scopes that
|
||||||
/// start with this machine instruction.
|
/// start with this machine instruction.
|
||||||
|
@ -417,14 +417,8 @@ bool FastISel::SelectCall(User *I) {
|
|||||||
StaticAllocaMap.find(AI);
|
StaticAllocaMap.find(AI);
|
||||||
if (SI == StaticAllocaMap.end()) break; // VLAs.
|
if (SI == StaticAllocaMap.end()) break; // VLAs.
|
||||||
int FI = SI->second;
|
int FI = SI->second;
|
||||||
if (MMI) {
|
if (MMI)
|
||||||
MetadataContext &TheMetadata = AI->getContext().getMetadata();
|
MMI->setVariableDbgInfo(DI->getVariable(), FI);
|
||||||
unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
|
|
||||||
MDNode *AllocaLocation =
|
|
||||||
dyn_cast_or_null<MDNode>(TheMetadata.getMD(MDDbgKind, AI));
|
|
||||||
if (AllocaLocation)
|
|
||||||
MMI->setVariableDbgInfo(DI->getVariable(), AllocaLocation, FI);
|
|
||||||
}
|
|
||||||
#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN
|
#ifndef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
DW->RecordVariable(DI->getVariable(), FI);
|
DW->RecordVariable(DI->getVariable(), FI);
|
||||||
#endif
|
#endif
|
||||||
|
@ -3970,7 +3970,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
|
|||||||
if (!isValidDebugInfoIntrinsic(DI, CodeGenOpt::None))
|
if (!isValidDebugInfoIntrinsic(DI, CodeGenOpt::None))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Value *Variable = DI.getVariable();
|
MDNode *Variable = DI.getVariable();
|
||||||
Value *Address = DI.getAddress();
|
Value *Address = DI.getAddress();
|
||||||
if (BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
|
if (BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
|
||||||
Address = BCI->getOperand(0);
|
Address = BCI->getOperand(0);
|
||||||
@ -3983,7 +3983,13 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
|
|||||||
if (SI == FuncInfo.StaticAllocaMap.end())
|
if (SI == FuncInfo.StaticAllocaMap.end())
|
||||||
return 0; // VLAs.
|
return 0; // VLAs.
|
||||||
int FI = SI->second;
|
int FI = SI->second;
|
||||||
DW->RecordVariable(cast<MDNode>(Variable), FI);
|
#ifdef ATTACH_DEBUG_INFO_TO_AN_INSN
|
||||||
|
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
|
||||||
|
if (MMI)
|
||||||
|
MMI->setVariableDbgInfo(Variable, FI);
|
||||||
|
#else
|
||||||
|
DW->RecordVariable(Variable, FI);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case Intrinsic::eh_exception: {
|
case Intrinsic::eh_exception: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user