diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-01 00:37:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-01 00:37:44 +0000 |
commit | b227925fa313428045f554187b0136d084d723f6 (patch) | |
tree | 5b7ae32a91579be0fcec63a30360e360b402aaaf /lib/VMCore/LLVMContextImpl.h | |
parent | 1118b5e490717fc13895e1307a15eb663d3758d1 (diff) |
Add a new "NewDebugLoc" class which will eventually replace DebugLoc,
and will replace the 'DbgInfo' member in Instruction.
The benefit of NewDebugLoc is that it is compact (8 bytes vs 12/24
bytes for the DbgInfo member in Instruction on a 32/64 bit system),
it means that we will end up not having to allocate MDNodes to
represent the "DILocations" in common cases of -O0 -g, and it is
much more efficient to get things out of than the MDNode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100072 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LLVMContextImpl.h')
-rw-r--r-- | lib/VMCore/LLVMContextImpl.h | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h index 8666f45f4a..d4ebf8044d 100644 --- a/lib/VMCore/LLVMContextImpl.h +++ b/lib/VMCore/LLVMContextImpl.h @@ -90,6 +90,29 @@ struct DenseMapAPFloatKeyInfo { } }; +/// DebugRecVH - This is a CallbackVH used to keep the Scope -> index maps +/// up to date as MDNodes mutate. This class is implemented in DebugLoc.cpp. +class DebugRecVH : public CallbackVH { + /// Ctx - This is the LLVM Context being referenced. + LLVMContextImpl *Ctx; + + /// Idx - The index into either ScopeRecordIdx or ScopeInlinedAtRecords that + /// this reference lives in. If this is zero, then it represents a + /// non-canonical entry that has no DenseMap value. This can happen due to + /// RAUW. + int Idx; +public: + DebugRecVH(MDNode *n, LLVMContextImpl *ctx, int idx) + : CallbackVH(n), Ctx(ctx), Idx(idx) {} + + MDNode *get() const { + return cast_or_null<MDNode>(getValPtr()); + } + + virtual void deleted(); + virtual void allUsesReplacedWith(Value *VNew); +}; + class LLVMContextImpl { public: typedef DenseMap<DenseMapAPIntKeyInfo::KeyTy, ConstantInt*, @@ -128,7 +151,6 @@ public: VectorConstantsTy VectorConstants; ConstantUniqueMap<char, PointerType, ConstantPointerNull> NullPtrConstants; - ConstantUniqueMap<char, Type, UndefValue> UndefValueConstants; DenseMap<std::pair<Function*, BasicBlock*> , BlockAddress*> BlockAddresses; @@ -195,6 +217,27 @@ public: /// context. DenseMap<const Instruction *, MDMapTy> MetadataStore; + /// ScopeRecordIdx - This is the index in ScopeRecords for an MDNode scope + /// entry with no "inlined at" element. + DenseMap<MDNode*, int> ScopeRecordIdx; + + /// ScopeRecords - These are the actual mdnodes (in a value handle) for an + /// index. The ValueHandle ensures that ScopeRecordIdx stays up to date if + /// the MDNode is RAUW'd. + std::vector<DebugRecVH> ScopeRecords; + + /// ScopeInlinedAtIdx - This is the index in ScopeInlinedAtRecords for an + /// scope/inlined-at pair. + DenseMap<std::pair<MDNode*, MDNode*>, int> ScopeInlinedAtIdx; + + /// ScopeInlinedAtRecords - These are the actual mdnodes (in value handles) + /// for an index. The ValueHandle ensures that ScopeINlinedAtIdx stays up + /// to date. + std::vector<std::pair<DebugRecVH, DebugRecVH> > ScopeInlinedAtRecords; + + int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx); + int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx); + LLVMContextImpl(LLVMContext &C); ~LLVMContextImpl(); }; |