mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-06 20:32:19 +00:00
Do not held on to DenseMap slot accross map insertion. The insertion may cause the map to grow rending the slot invalid.
Use this opportunity to use ValueMap instead of DenseMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85298 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eadeffb306
commit
bdf45cbe15
@ -1304,15 +1304,16 @@ DIE *DwarfDebug::CreateDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit) {
|
|||||||
///
|
///
|
||||||
DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr *MI,
|
DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr *MI,
|
||||||
MDNode *InlinedAt) {
|
MDNode *InlinedAt) {
|
||||||
DbgScope *&Slot = DbgScopeMap[N];
|
ValueMap<MDNode *, DbgScope *>::iterator VI = DbgScopeMap.find(N);
|
||||||
if (Slot) return Slot;
|
if (VI != DbgScopeMap.end())
|
||||||
|
return VI->second;
|
||||||
|
|
||||||
DbgScope *Parent = NULL;
|
DbgScope *Parent = NULL;
|
||||||
|
|
||||||
if (InlinedAt) {
|
if (InlinedAt) {
|
||||||
DILocation IL(InlinedAt);
|
DILocation IL(InlinedAt);
|
||||||
assert (!IL.isNull() && "Invalid InlindAt location!");
|
assert (!IL.isNull() && "Invalid InlindAt location!");
|
||||||
DenseMap<MDNode *, DbgScope *>::iterator DSI =
|
ValueMap<MDNode *, DbgScope *>::iterator DSI =
|
||||||
DbgScopeMap.find(IL.getScope().getNode());
|
DbgScopeMap.find(IL.getScope().getNode());
|
||||||
assert (DSI != DbgScopeMap.end() && "Unable to find InlineAt scope!");
|
assert (DSI != DbgScopeMap.end() && "Unable to find InlineAt scope!");
|
||||||
Parent = DSI->second;
|
Parent = DSI->second;
|
||||||
@ -1334,17 +1335,18 @@ DbgScope *DwarfDebug::getDbgScope(MDNode *N, const MachineInstr *MI,
|
|||||||
assert (0 && "Unexpected scope info");
|
assert (0 && "Unexpected scope info");
|
||||||
}
|
}
|
||||||
|
|
||||||
Slot = new DbgScope(Parent, DIDescriptor(N), InlinedAt);
|
DbgScope *NScope = new DbgScope(Parent, DIDescriptor(N), InlinedAt);
|
||||||
Slot->setFirstInsn(MI);
|
NScope->setFirstInsn(MI);
|
||||||
|
|
||||||
if (Parent)
|
if (Parent)
|
||||||
Parent->AddScope(Slot);
|
Parent->AddScope(NScope);
|
||||||
else
|
else
|
||||||
// First function is top level function.
|
// First function is top level function.
|
||||||
if (!FunctionDbgScope)
|
if (!FunctionDbgScope)
|
||||||
FunctionDbgScope = Slot;
|
FunctionDbgScope = NScope;
|
||||||
|
|
||||||
return Slot;
|
DbgScopeMap.insert(std::make_pair(N, NScope));
|
||||||
|
return NScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1812,7 +1814,7 @@ void DwarfDebug::CollectVariableInfo() {
|
|||||||
if (DV.isNull()) continue;
|
if (DV.isNull()) continue;
|
||||||
unsigned VSlot = VI->second;
|
unsigned VSlot = VI->second;
|
||||||
DbgScope *Scope = NULL;
|
DbgScope *Scope = NULL;
|
||||||
DenseMap<MDNode *, DbgScope *>::iterator DSI =
|
ValueMap<MDNode *, DbgScope *>::iterator DSI =
|
||||||
DbgScopeMap.find(DV.getContext().getNode());
|
DbgScopeMap.find(DV.getContext().getNode());
|
||||||
if (DSI != DbgScopeMap.end())
|
if (DSI != DbgScopeMap.end())
|
||||||
Scope = DSI->second;
|
Scope = DSI->second;
|
||||||
@ -1884,8 +1886,10 @@ bool DwarfDebug::ExtractScopeInformation(MachineFunction *MF) {
|
|||||||
|
|
||||||
// If a scope's last instruction is not set then use its child scope's
|
// If a scope's last instruction is not set then use its child scope's
|
||||||
// last instruction as this scope's last instrunction.
|
// last instruction as this scope's last instrunction.
|
||||||
for (DenseMap<MDNode *, DbgScope *>::iterator DI = DbgScopeMap.begin(),
|
for (ValueMap<MDNode *, DbgScope *>::iterator DI = DbgScopeMap.begin(),
|
||||||
DE = DbgScopeMap.end(); DI != DE; ++DI) {
|
DE = DbgScopeMap.end(); DI != DE; ++DI) {
|
||||||
|
DbgScope *S = DI->second;
|
||||||
|
if (!S) continue;
|
||||||
assert (DI->second->getFirstInsn() && "Invalid first instruction!");
|
assert (DI->second->getFirstInsn() && "Invalid first instruction!");
|
||||||
DI->second->FixInstructionMarkers();
|
DI->second->FixInstructionMarkers();
|
||||||
assert (DI->second->getLastInsn() && "Invalid last instruction!");
|
assert (DI->second->getLastInsn() && "Invalid last instruction!");
|
||||||
@ -1895,10 +1899,10 @@ bool DwarfDebug::ExtractScopeInformation(MachineFunction *MF) {
|
|||||||
// and end of a scope respectively. Create an inverse map that list scopes
|
// and end of a scope respectively. Create an inverse map that list scopes
|
||||||
// starts (and ends) with an instruction. One instruction may start (or end)
|
// starts (and ends) with an instruction. One instruction may start (or end)
|
||||||
// multiple scopes.
|
// multiple scopes.
|
||||||
for (DenseMap<MDNode *, DbgScope *>::iterator DI = DbgScopeMap.begin(),
|
for (ValueMap<MDNode *, DbgScope *>::iterator DI = DbgScopeMap.begin(),
|
||||||
DE = DbgScopeMap.end(); DI != DE; ++DI) {
|
DE = DbgScopeMap.end(); DI != DE; ++DI) {
|
||||||
DbgScope *S = DI->second;
|
DbgScope *S = DI->second;
|
||||||
assert (S && "DbgScope is missing!");
|
if (!S) continue;
|
||||||
const MachineInstr *MI = S->getFirstInsn();
|
const MachineInstr *MI = S->getFirstInsn();
|
||||||
assert (MI && "DbgScope does not have first instruction!");
|
assert (MI && "DbgScope does not have first instruction!");
|
||||||
|
|
||||||
@ -2172,7 +2176,7 @@ void DwarfDebug::RecordVariable(MDNode *N, unsigned FrameIndex) {
|
|||||||
if (!SP.isNull()) {
|
if (!SP.isNull()) {
|
||||||
// SP is inserted into DbgAbstractScopeMap when inlined function
|
// SP is inserted into DbgAbstractScopeMap when inlined function
|
||||||
// start was recorded by RecordInlineFnStart.
|
// start was recorded by RecordInlineFnStart.
|
||||||
DenseMap<MDNode *, DbgScope *>::iterator
|
ValueMap<MDNode *, DbgScope *>::iterator
|
||||||
I = DbgAbstractScopeMap.find(SP.getNode());
|
I = DbgAbstractScopeMap.find(SP.getNode());
|
||||||
if (I != DbgAbstractScopeMap.end()) {
|
if (I != DbgAbstractScopeMap.end()) {
|
||||||
InlinedVar = true;
|
InlinedVar = true;
|
||||||
@ -2249,7 +2253,7 @@ unsigned DwarfDebug::RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU,
|
|||||||
LexicalScopeStack.back()->AddConcreteInst(ConcreteScope);
|
LexicalScopeStack.back()->AddConcreteInst(ConcreteScope);
|
||||||
|
|
||||||
// Keep track of the concrete scope that's inlined into this function.
|
// Keep track of the concrete scope that's inlined into this function.
|
||||||
DenseMap<MDNode *, SmallVector<DbgScope *, 8> >::iterator
|
ValueMap<MDNode *, SmallVector<DbgScope *, 8> >::iterator
|
||||||
SI = DbgConcreteScopeMap.find(Node);
|
SI = DbgConcreteScopeMap.find(Node);
|
||||||
|
|
||||||
if (SI == DbgConcreteScopeMap.end())
|
if (SI == DbgConcreteScopeMap.end())
|
||||||
@ -2258,7 +2262,7 @@ unsigned DwarfDebug::RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU,
|
|||||||
SI->second.push_back(ConcreteScope);
|
SI->second.push_back(ConcreteScope);
|
||||||
|
|
||||||
// Track the start label for this inlined function.
|
// Track the start label for this inlined function.
|
||||||
DenseMap<MDNode *, SmallVector<unsigned, 4> >::iterator
|
ValueMap<MDNode *, SmallVector<unsigned, 4> >::iterator
|
||||||
I = InlineInfo.find(Node);
|
I = InlineInfo.find(Node);
|
||||||
|
|
||||||
if (I == InlineInfo.end())
|
if (I == InlineInfo.end())
|
||||||
@ -2281,7 +2285,7 @@ unsigned DwarfDebug::RecordInlinedFnEnd(DISubprogram &SP) {
|
|||||||
DebugTimer->startTimer();
|
DebugTimer->startTimer();
|
||||||
|
|
||||||
MDNode *Node = SP.getNode();
|
MDNode *Node = SP.getNode();
|
||||||
DenseMap<MDNode *, SmallVector<DbgScope *, 8> >::iterator
|
ValueMap<MDNode *, SmallVector<DbgScope *, 8> >::iterator
|
||||||
I = DbgConcreteScopeMap.find(Node);
|
I = DbgConcreteScopeMap.find(Node);
|
||||||
|
|
||||||
if (I == DbgConcreteScopeMap.end()) {
|
if (I == DbgConcreteScopeMap.end()) {
|
||||||
@ -2989,7 +2993,7 @@ void DwarfDebug::EmitDebugInlineInfo() {
|
|||||||
Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("Dwarf Version");
|
Asm->EmitInt16(dwarf::DWARF_VERSION); Asm->EOL("Dwarf Version");
|
||||||
Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
|
Asm->EmitInt8(TD->getPointerSize()); Asm->EOL("Address Size (in bytes)");
|
||||||
|
|
||||||
for (DenseMap<MDNode *, SmallVector<unsigned, 4> >::iterator
|
for (ValueMap<MDNode *, SmallVector<unsigned, 4> >::iterator
|
||||||
I = InlineInfo.begin(), E = InlineInfo.end(); I != E; ++I) {
|
I = InlineInfo.begin(), E = InlineInfo.end(); I != E; ++I) {
|
||||||
MDNode *Node = I->first;
|
MDNode *Node = I->first;
|
||||||
SmallVector<unsigned, 4> &Labels = I->second;
|
SmallVector<unsigned, 4> &Labels = I->second;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "llvm/CodeGen/MachineLocation.h"
|
#include "llvm/CodeGen/MachineLocation.h"
|
||||||
#include "llvm/Analysis/DebugInfo.h"
|
#include "llvm/Analysis/DebugInfo.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/ValueMap.h"
|
||||||
#include "llvm/ADT/FoldingSet.h"
|
#include "llvm/ADT/FoldingSet.h"
|
||||||
#include "llvm/ADT/SmallSet.h"
|
#include "llvm/ADT/SmallSet.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
@ -139,7 +139,7 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
|
|||||||
DbgScope *FunctionDbgScope;
|
DbgScope *FunctionDbgScope;
|
||||||
|
|
||||||
/// DbgScopeMap - Tracks the scopes in the current function.
|
/// DbgScopeMap - Tracks the scopes in the current function.
|
||||||
DenseMap<MDNode *, DbgScope *> DbgScopeMap;
|
ValueMap<MDNode *, DbgScope *> DbgScopeMap;
|
||||||
|
|
||||||
/// ScopedGVs - Tracks global variables that are not at file scope.
|
/// ScopedGVs - Tracks global variables that are not at file scope.
|
||||||
/// For example void f() { static int b = 42; }
|
/// For example void f() { static int b = 42; }
|
||||||
@ -156,16 +156,16 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
|
|||||||
|
|
||||||
/// DbgAbstractScopeMap - Tracks abstract instance scopes in the current
|
/// DbgAbstractScopeMap - Tracks abstract instance scopes in the current
|
||||||
/// function.
|
/// function.
|
||||||
DenseMap<MDNode *, DbgScope *> DbgAbstractScopeMap;
|
ValueMap<MDNode *, DbgScope *> DbgAbstractScopeMap;
|
||||||
|
|
||||||
/// DbgConcreteScopeMap - Tracks concrete instance scopes in the current
|
/// DbgConcreteScopeMap - Tracks concrete instance scopes in the current
|
||||||
/// function.
|
/// function.
|
||||||
DenseMap<MDNode *,
|
ValueMap<MDNode *,
|
||||||
SmallVector<DbgScope *, 8> > DbgConcreteScopeMap;
|
SmallVector<DbgScope *, 8> > DbgConcreteScopeMap;
|
||||||
|
|
||||||
/// InlineInfo - Keep track of inlined functions and their location. This
|
/// InlineInfo - Keep track of inlined functions and their location. This
|
||||||
/// information is used to populate debug_inlined section.
|
/// information is used to populate debug_inlined section.
|
||||||
DenseMap<MDNode *, SmallVector<unsigned, 4> > InlineInfo;
|
ValueMap<MDNode *, SmallVector<unsigned, 4> > InlineInfo;
|
||||||
|
|
||||||
/// AbstractInstanceRootMap - Map of abstract instance roots of inlined
|
/// AbstractInstanceRootMap - Map of abstract instance roots of inlined
|
||||||
/// functions. These are subroutine entries that contain a DW_AT_inline
|
/// functions. These are subroutine entries that contain a DW_AT_inline
|
||||||
|
Loading…
Reference in New Issue
Block a user