diff options
author | Adrian Prantl <aprantl@apple.com> | 2014-03-18 02:34:58 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2014-03-18 02:34:58 +0000 |
commit | 5e8144df32cad1bf29cf7cc27f53870302826256 (patch) | |
tree | 23574e1ab12406a5276e0481a16fed30b1ba0d0e /lib | |
parent | 4d82ca74626878ac2739a5532d101f27ef6eddfe (diff) | |
download | llvm-5e8144df32cad1bf29cf7cc27f53870302826256.tar.gz llvm-5e8144df32cad1bf29cf7cc27f53870302826256.tar.bz2 llvm-5e8144df32cad1bf29cf7cc27f53870302826256.tar.xz |
Switch the type field in DIVariable and DIGlobalVariable over to DITypeRefs.
This allows us to catch more opportunities for ODR-based type uniquing
during LTO.
Paired commit with CFE which updates some testcases to verify the new
DIBuilder behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204106 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 12 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.h | 10 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 2 | ||||
-rw-r--r-- | lib/IR/DIBuilder.cpp | 15 | ||||
-rw-r--r-- | lib/IR/DebugInfo.cpp | 16 |
5 files changed, 33 insertions, 22 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 03906f0110..ecd10460a5 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -115,11 +115,17 @@ template <typename T> T DbgVariable::resolve(DIRef<T> Ref) const { return DD->resolve(Ref); } +bool DbgVariable::isBlockByrefVariable() const { + assert(Var.isVariable() && "Invalid complex DbgVariable!"); + return Var.isBlockByrefVariable(DD->getTypeIdentifierMap()); +} + + DIType DbgVariable::getType() const { - DIType Ty = Var.getType(); + DIType Ty = Var.getType().resolve(DD->getTypeIdentifierMap()); // FIXME: isBlockByrefVariable should be reformulated in terms of complex // addresses instead. - if (Var.isBlockByrefVariable()) { + if (Var.isBlockByrefVariable(DD->getTypeIdentifierMap())) { /* Byref variables, in Blocks, are declared by the programmer as "SomeType VarName;", but the compiler creates a __Block_byref_x_VarName struct, and gives the variable VarName @@ -2301,7 +2307,7 @@ void DwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry) { DIVariable DV(Entry.getVariable()); if (Entry.isInt()) { - DIBasicType BTy(DV.getType()); + DIBasicType BTy(resolve(DV.getType())); if (BTy.Verify() && (BTy.getEncoding() == dwarf::DW_ATE_signed || BTy.getEncoding() == dwarf::DW_ATE_signed_char)) { Streamer.EmitInt8(dwarf::DW_OP_consts, "DW_OP_consts"); diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 44eed9406f..2f6c2546ed 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -199,10 +199,7 @@ public: assert(Var.isVariable() && "Invalid complex DbgVariable!"); return Var.hasComplexAddress(); } - bool isBlockByrefVariable() const { - assert(Var.isVariable() && "Invalid complex DbgVariable!"); - return Var.isBlockByrefVariable(); - } + bool isBlockByrefVariable() const; unsigned getNumAddrElements() const { assert(Var.isVariable() && "Invalid complex DbgVariable!"); return Var.getNumAddrElements(); @@ -777,6 +774,11 @@ public: return Ref.resolve(TypeIdentifierMap); } + /// \brief Return the TypeIdentifierMap. + const DITypeIdentifierMap& getTypeIdentifierMap() const { + return TypeIdentifierMap; + } + /// Find the DwarfCompileUnit for the given CU Die. DwarfCompileUnit *lookupUnit(const DIE *CU) const { return CUDieMap.lookup(CU); diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 2eda435f86..a7b43d8032 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1604,7 +1604,7 @@ void DwarfCompileUnit::createGlobalVariableDIE(DIGlobalVariable GV) { assert(GV.isGlobalVariable()); DIScope GVContext = GV.getContext(); - DIType GTy = GV.getType(); + DIType GTy = DD->resolve(GV.getType()); // If this is a static data member definition, some attributes belong // to the declaration DIE. diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index 634240c945..8f3d979712 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -927,7 +927,7 @@ DISubrange DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) { DIGlobalVariable DIBuilder::createGlobalVariable(StringRef Name, StringRef LinkageName, DIFile F, unsigned LineNumber, - DIType Ty, bool isLocalToUnit, + DITypeRef Ty, bool isLocalToUnit, Value *Val) { Value *Elts[] = { GetTagConstant(VMContext, dwarf::DW_TAG_variable), @@ -951,7 +951,8 @@ DIGlobalVariable DIBuilder::createGlobalVariable(StringRef Name, /// \brief Create a new descriptor for the specified global. DIGlobalVariable DIBuilder::createGlobalVariable(StringRef Name, DIFile F, - unsigned LineNumber, DIType Ty, + unsigned LineNumber, + DITypeRef Ty, bool isLocalToUnit, Value *Val) { return createGlobalVariable(Name, Name, F, LineNumber, Ty, isLocalToUnit, @@ -964,7 +965,8 @@ DIGlobalVariable DIBuilder::createStaticVariable(DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F, unsigned LineNumber, - DIType Ty, bool isLocalToUnit, + DITypeRef Ty, + bool isLocalToUnit, Value *Val, MDNode *Decl) { Value *Elts[] = { GetTagConstant(VMContext, dwarf::DW_TAG_variable), @@ -989,14 +991,12 @@ DIGlobalVariable DIBuilder::createStaticVariable(DIDescriptor Context, /// createVariable - Create a new descriptor for the specified variable. DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, DIFile File, - unsigned LineNo, DIType Ty, + unsigned LineNo, DITypeRef Ty, bool AlwaysPreserve, unsigned Flags, unsigned ArgNo) { DIDescriptor Context(getNonCompileUnitScope(Scope)); assert((!Context || Context.isScope()) && "createLocalVariable should be called with a valid Context"); - assert(Ty.isType() && - "createLocalVariable should be called with a valid type"); Value *Elts[] = { GetTagConstant(VMContext, Tag), getNonCompileUnitScope(Scope), @@ -1027,7 +1027,8 @@ DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope, DIVariable DIBuilder::createComplexVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, DIFile F, unsigned LineNo, - DIType Ty, ArrayRef<Value *> Addr, + DITypeRef Ty, + ArrayRef<Value *> Addr, unsigned ArgNo) { SmallVector<Value *, 15> Elts; Elts.push_back(GetTagConstant(VMContext, Tag)); diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index d69138e057..afeeb7b685 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -541,10 +541,11 @@ bool DIGlobalVariable::Verify() const { if (getDisplayName().empty()) return false; - // Make sure context @ field 2 and type @ field 8 are MDNodes. + // Make sure context @ field 2 is an MDNode. if (!fieldIsMDNode(DbgNode, 2)) return false; - if (!fieldIsMDNode(DbgNode, 8)) + // Make sure that type @ field 8 is a DITypeRef. + if (!fieldIsTypeRef(DbgNode, 8)) return false; // Make sure StaticDataMemberDeclaration @ field 12 is MDNode. if (!fieldIsMDNode(DbgNode, 12)) @@ -558,10 +559,11 @@ bool DIVariable::Verify() const { if (!isVariable()) return false; - // Make sure context @ field 1 and type @ field 5 are MDNodes. + // Make sure context @ field 1 is an MDNode. if (!fieldIsMDNode(DbgNode, 1)) return false; - if (!fieldIsMDNode(DbgNode, 5)) + // Make sure that type @ field 5 is a DITypeRef. + if (!fieldIsTypeRef(DbgNode, 5)) return false; return DbgNode->getNumOperands() >= 8; } @@ -999,7 +1001,7 @@ void DebugInfoFinder::processModule(const Module &M) { DIGlobalVariable DIG(GVs.getElement(i)); if (addGlobalVariable(DIG)) { processScope(DIG.getContext()); - processType(DIG.getType()); + processType(DIG.getType().resolve(TypeIdentifierMap)); } } DIArray SPs = CU.getSubprograms(); @@ -1133,7 +1135,7 @@ void DebugInfoFinder::processDeclare(const Module &M, if (!NodesSeen.insert(DV)) return; processScope(DIVariable(N).getContext()); - processType(DIVariable(N).getType()); + processType(DIVariable(N).getType().resolve(TypeIdentifierMap)); } void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) { @@ -1149,7 +1151,7 @@ void DebugInfoFinder::processValue(const Module &M, const DbgValueInst *DVI) { if (!NodesSeen.insert(DV)) return; processScope(DIVariable(N).getContext()); - processType(DIVariable(N).getType()); + processType(DIVariable(N).getType().resolve(TypeIdentifierMap)); } /// addType - Add type into Tys. |