LTO type uniquing: store the Decl field of a DIImportedEntity as a DIRef.
authorAdrian Prantl <aprantl@apple.com>
Tue, 1 Apr 2014 03:41:04 +0000 (03:41 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 1 Apr 2014 03:41:04 +0000 (03:41 +0000)
No other functionality changes, DIBuilder testcase is included in a paired
CFE commit.

This relaxes the assertion in isScopeRef to also accept subclasses of
DIScope.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205279 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DIBuilder.h
include/llvm/IR/DebugInfo.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/IR/DIBuilder.cpp
lib/IR/DebugInfo.cpp

index 40fa0950cd72bda9e84534ed1dd32e3e85b13953..7d87a69de0e8361768823bbf0df63b3d37c351a3 100644 (file)
@@ -663,7 +663,7 @@ namespace llvm {
     ///             variable
     /// @param Line Line number
     DIImportedEntity createImportedDeclaration(DIScope Context,
-                                               DIDescriptor Decl,
+                                               DIScope Decl,
                                                unsigned Line);
 
     /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
index f2f935ae0975f5bf207ac69006d2d2c68f53b54e..228df49793d1879acbfde8ae42be13da3b991ea1 100644 (file)
@@ -783,7 +783,7 @@ class DIImportedEntity : public DIDescriptor {
 public:
   explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) {}
   DIScope getContext() const { return getFieldAs<DIScope>(1); }
-  DIDescriptor getEntity() const { return getFieldAs<DIDescriptor>(2); }
+  DIScopeRef getEntity() const { return getFieldAs<DIScopeRef>(2); }
   unsigned getLineNumber() const { return getUnsignedField(3); }
   StringRef getName() const { return getStringField(4); }
   bool Verify() const;
index f4182d0b79b20975a55422556c6fc626bda8b89e..a21fa673118386582b17a4e5545fc6cfa69d9d98 100644 (file)
@@ -794,7 +794,7 @@ void DwarfDebug::constructImportedEntityDIE(DwarfCompileUnit *TheCU,
   DIE *IMDie = new DIE(Module.getTag());
   TheCU->insertDIE(Module, IMDie);
   DIE *EntityDie;
-  DIDescriptor Entity = Module.getEntity();
+  DIDescriptor Entity = resolve(Module.getEntity());
   if (Entity.isNameSpace())
     EntityDie = TheCU->getOrCreateNameSpace(DINameSpace(Entity));
   else if (Entity.isSubprogram())
index 8f3d979712a7a133c75d8cba524239696f45a80a..1ea381a454cf7c3b2402523ab855ccc3bc9fd344 100644 (file)
@@ -190,12 +190,12 @@ DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
 }
 
 DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
-                                                      DIDescriptor Decl,
+                                                      DIScope Decl,
                                                       unsigned Line) {
   Value *Elts[] = {
     GetTagConstant(VMContext, dwarf::DW_TAG_imported_declaration),
     Context,
-    Decl,
+    Decl.getRef(),
     ConstantInt::get(Type::getInt32Ty(VMContext), Line),
   };
   DIImportedEntity M(MDNode::get(VMContext, Elts));
index 9d708c6fce00b05ec92660881c9765cb508705fc..f9bc63b389e2b0074ba6364ace757fd91945c0aa 100644 (file)
@@ -430,7 +430,7 @@ static bool fieldIsTypeRef(const MDNode *DbgNode, unsigned Elt) {
 static bool isScopeRef(const Value *Val) {
   return !Val ||
          (isa<MDString>(Val) && !cast<MDString>(Val)->getString().empty()) ||
-         (isa<MDNode>(Val) && DIScope(cast<MDNode>(Val)).isScope());
+         isa<MDNode>(Val);
 }
 
 /// Check if a field at position Elt of a MDNode can be a ScopeRef.
@@ -1016,7 +1016,7 @@ void DebugInfoFinder::processModule(const Module &M) {
       DIArray Imports = CU.getImportedEntities();
       for (unsigned i = 0, e = Imports.getNumElements(); i != e; ++i) {
         DIImportedEntity Import = DIImportedEntity(Imports.getElement(i));
-        DIDescriptor Entity = Import.getEntity();
+        DIDescriptor Entity = Import.getEntity().resolve(TypeIdentifierMap);
         if (Entity.isType())
           processType(DIType(Entity));
         else if (Entity.isSubprogram())