[llvm-commits] [dragonegg] r101888 - in /dragonegg/branches/release_27: llvm-debug.cpp llvm-debug.h

Duncan Sands baldrick at free.fr
Tue Apr 20 00:45:59 PDT 2010


Author: baldrick
Date: Tue Apr 20 02:45:59 2010
New Revision: 101888

URL: http://llvm.org/viewvc/llvm-project?rev=101888&view=rev
Log:
Undo commit 98147, which is incompatible with llvm-2.7:
Port commit 98022 (dpatel) from llvm-gcc:
Start using DIFile. Corresponding llvm patch is r98020.

Modified:
    dragonegg/branches/release_27/llvm-debug.cpp
    dragonegg/branches/release_27/llvm-debug.h

Modified: dragonegg/branches/release_27/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_27/llvm-debug.cpp?rev=101888&r1=101887&r2=101888&view=diff
==============================================================================
--- dragonegg/branches/release_27/llvm-debug.cpp (original)
+++ dragonegg/branches/release_27/llvm-debug.cpp Tue Apr 20 02:45:59 2010
@@ -275,7 +275,7 @@
     ArtificialFnWithAbstractOrigin = true;
 
   DIDescriptor SPContext = ArtificialFnWithAbstractOrigin ?
-    getOrCreateFile(main_input_filename) :
+    getOrCreateCompileUnit(main_input_filename) :
     findRegion (DECL_CONTEXT(FnDecl));
 
   // Creating context may have triggered creation of this SP descriptor. So
@@ -316,7 +316,7 @@
     DebugFactory.CreateSubprogram(SPContext,
                                   FnName, FnName,
                                   LinkageName,
-                                  getOrCreateFile(Loc.file), lineno,
+                                  getOrCreateCompileUnit(Loc.file), lineno,
                                   FNType,
                                   Fn->hasInternalLinkage(),
                                   true /*definition*/,
@@ -340,7 +340,7 @@
   expanded_location Loc = GetNodeLocation(Node, false);
   DINameSpace DNS =
     DebugFactory.CreateNameSpace(Context, GetNodeName(Node),
-                                 getOrCreateFile(Loc.file), Loc.line);
+                                 getOrCreateCompileUnit(Loc.file), Loc.line);
 
   NameSpaceCache[Node] = WeakVH(DNS.getNode());
   return DNS;
@@ -349,7 +349,7 @@
 /// findRegion - Find tree_node N's region.
 DIDescriptor DebugInfo::findRegion(tree Node) {
   if (Node == NULL_TREE)
-    return getOrCreateFile(main_input_filename);
+    return getOrCreateCompileUnit(main_input_filename);
 
   std::map<tree_node *, WeakVH>::iterator I = RegionMap.find(Node);
   if (I != RegionMap.end())
@@ -369,7 +369,7 @@
   }
 
   // Otherwise main compile unit covers everything.
-  return getOrCreateFile(main_input_filename);
+  return getOrCreateCompileUnit(main_input_filename);
 }
 
 /// EmitFunctionEnd - Constructs the debug code for exiting a declarative
@@ -410,7 +410,7 @@
       Ty = DebugFactory.CreateArtificialType(Ty);
   llvm::DIVariable D =
     DebugFactory.CreateVariable(Tag, VarScope,
-                                Name, getOrCreateFile(Loc.file),
+                                Name, getOrCreateCompileUnit(Loc.file),
                                 Loc.line, Ty);
 
   // Insert an llvm.dbg.declare into the current block.
@@ -470,7 +470,7 @@
       LinkageName = GV->getName();
   DebugFactory.CreateGlobalVariable(findRegion(DECL_CONTEXT(decl)),
                                     DispName, DispName, LinkageName,
-                                    getOrCreateFile(Loc.file), Loc.line,
+                                    getOrCreateCompileUnit(Loc.file), Loc.line,
                                     TyD, GV->hasInternalLinkage(),
                                     true/*definition*/, GV);
 }
@@ -517,9 +517,9 @@
   }
 
   return 
-    DebugFactory.CreateBasicType(getOrCreateFile(main_input_filename),
+    DebugFactory.CreateBasicType(getOrCreateCompileUnit(main_input_filename),
                                  TypeName, 
-                                 getOrCreateFile(main_input_filename),
+                                 getOrCreateCompileUnit(main_input_filename),
                                  0, Size, Align,
                                  0, 0, Encoding);
 }
@@ -548,9 +548,9 @@
   sprintf(FwdTypeName, "fwd.type.%d", FwdTypeCount++);
   llvm::DIType FwdType = 
     DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
-                                     getOrCreateFile(main_input_filename),
+                                     getOrCreateCompileUnit(NULL), 
                                      FwdTypeName,
-                                     getOrCreateFile(main_input_filename),
+                                     getOrCreateCompileUnit(NULL), 
                                      0, 0, 0, 0, 0,
                                      llvm::DIType(), llvm::DIArray());
   llvm::TrackingVH<llvm::MDNode> FwdTypeNode = FwdType.getNode();
@@ -591,7 +591,7 @@
     DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
                                      findRegion(TYPE_CONTEXT(type)), 
                                      StringRef(),
-                                     getOrCreateFile(main_input_filename),
+                                     getOrCreateCompileUnit(NULL), 
                                      0, 0, 0, 0, 0,
                                      llvm::DIType(), EltTypeArray);
 
@@ -620,7 +620,7 @@
       DIType Ty = 
         DebugFactory.CreateDerivedType(Tag, findRegion(DECL_CONTEXT(TyName)),
                                        GetNodeName(TyName), 
-                                       getOrCreateFile(TypeNameLoc.file),
+                                       getOrCreateCompileUnit(TypeNameLoc.file),
                                        TypeNameLoc.line,
                                        0 /*size*/,
                                        0 /*align*/,
@@ -636,7 +636,7 @@
     DebugFactory.CreateDerivedType(Tag, findRegion(TYPE_CONTEXT(type)), 
                                    Tag == DW_TAG_pointer_type ? 
                                    StringRef() : PName,
-                                   getOrCreateFile(main_input_filename),
+                                   getOrCreateCompileUnit(NULL), 
                                    0 /*line no*/, 
                                    NodeSizeInBits(type),
                                    NodeAlignInBits(type),
@@ -698,7 +698,7 @@
   return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_array_type,
                                           findRegion(TYPE_CONTEXT(type)), 
                                           StringRef(),
-                                          getOrCreateFile(Loc.file), 0, 
+                                          getOrCreateCompileUnit(Loc.file), 0, 
                                           NodeSizeInBits(type), 
                                           NodeAlignInBits(type), 0, 0,
                                           getOrCreateType(EltTy),
@@ -732,7 +732,7 @@
   return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
                                           findRegion(TYPE_CONTEXT(type)), 
                                           GetNodeName(type), 
-                                          getOrCreateFile(Loc.file), 
+                                          getOrCreateCompileUnit(Loc.file), 
                                           Loc.line,
                                           NodeSizeInBits(type), 
                                           NodeAlignInBits(type), 0, 0,
@@ -750,7 +750,8 @@
 //TODO  if (TYPE_LANG_SPECIFIC (type)
 //TODO      && lang_hooks.types.is_runtime_specific_type (type))
 //TODO    {
-//TODO      unsigned CULang = TheCU.getLanguage();
+//TODO      DICompileUnit CU = getOrCreateCompileUnit(main_input_filename);
+//TODO      unsigned CULang = CU.getLanguage();
 //TODO      switch (CULang) {
 //TODO      case DW_LANG_ObjC_plus_plus :
 //TODO        RunTimeLang = DW_LANG_ObjC_plus_plus;
@@ -801,7 +802,7 @@
     DebugFactory.CreateCompositeType(Tag, 
                                      TyContext,
                                      FwdName.c_str(),
-                                     getOrCreateFile(Loc.file), 
+                                     getOrCreateCompileUnit(Loc.file), 
                                      Loc.line, 
                                      0, 0, 0, SFlags | llvm::DIType::FlagFwdDecl,
                                      llvm::DIType(), llvm::DIArray(),
@@ -851,7 +852,7 @@
       DIType DTy = 
         DebugFactory.CreateDerivedType(DW_TAG_inheritance, 
                                        findRegion(TYPE_CONTEXT(type)), StringRef(),
-                                       llvm::DIFile(), 0,0,0, 
+                                       llvm::DICompileUnit(), 0,0,0, 
                                        Offset,
                                        BFlags, BaseClass);
       EltTys.push_back(DTy);
@@ -897,7 +898,7 @@
       DebugFactory.CreateDerivedType(DW_TAG_member, 
                                      findRegion(DECL_CONTEXT(Member)),
                                      MemberName, 
-                                     getOrCreateFile(MemLoc.file),
+                                     getOrCreateCompileUnit(MemLoc.file),
                                      MemLoc.line, NodeSizeInBits(Member),
                                      NodeAlignInBits(FieldNodeType),
                                      int_bit_position(Member), 
@@ -936,7 +937,7 @@
         DebugFactory.CreateSubprogram(findRegion(DECL_CONTEXT(Member)), 
                                       MemberName, MemberName,
                                       LinkageName, 
-                                      getOrCreateFile(MemLoc.file),
+                                      getOrCreateCompileUnit(MemLoc.file),
                                       MemLoc.line, SPTy, false, false,
                                       Virtuality, VIndex, ContainingType,
                                       DECL_ARTIFICIAL (Member));
@@ -961,7 +962,7 @@
   llvm::DICompositeType RealDecl =
     DebugFactory.CreateCompositeType(Tag, findRegion(TYPE_CONTEXT(type)),
                                      GetNodeName(type),
-                                     getOrCreateFile(Loc.file),
+                                     getOrCreateCompileUnit(Loc.file),
                                      Loc.line, 
                                      NodeSizeInBits(type), NodeAlignInBits(type),
                                      0, SFlags, llvm::DIType(), Elements,
@@ -989,7 +990,7 @@
       Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef, 
                                           findRegion(DECL_CONTEXT(TyDef)),
                                           GetNodeName(TyDef), 
-                                          getOrCreateFile(TypeDefLoc.file),
+                                          getOrCreateCompileUnit(TypeDefLoc.file),
                                           TypeDefLoc.line,
                                           0 /*size*/,
                                           0 /*align*/,
@@ -1005,7 +1006,7 @@
     Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type, 
                                         findRegion(TYPE_CONTEXT(type)), 
                                         StringRef(),
-                                        getOrCreateFile(main_input_filename),
+                                        getOrCreateCompileUnit(NULL), 
                                         0 /*line no*/, 
                                         NodeSizeInBits(type),
                                         NodeAlignInBits(type),
@@ -1019,7 +1020,7 @@
     Ty =  DebugFactory.CreateDerivedType(DW_TAG_const_type, 
                                          findRegion(TYPE_CONTEXT(type)), 
                                          StringRef(),
-                                         getOrCreateFile(main_input_filename),
+                                         getOrCreateCompileUnit(NULL), 
                                          0 /*line no*/, 
                                          NodeSizeInBits(type),
                                          NodeAlignInBits(type),
@@ -1130,9 +1131,9 @@
   // module does not contain any main compile unit then the code generator 
   // will emit multiple compile units in the output object file.
   if (!strcmp (main_input_filename, ""))
-    TheCU = getOrCreateCompileUnit("<stdin>", true);
+    getOrCreateCompileUnit("<stdin>", true);
   else
-    TheCU = getOrCreateCompileUnit(main_input_filename, true);
+    getOrCreateCompileUnit(main_input_filename, true);
 }
 
 /// getOrCreateCompileUnit - Get the compile unit from the cache or 
@@ -1145,6 +1146,10 @@
     else
       FullPath = main_input_filename;
   }
+  std::map<std::string, WeakVH >::iterator I = CUCache.find(FullPath);
+  if (I != CUCache.end())
+    if (Value *M = I->second)
+      return DICompileUnit(cast<MDNode>(M));
 
   // Get source file information.
   std::string Directory;
@@ -1180,25 +1185,11 @@
   unsigned ObjcRunTimeVer = 0;
 //  if (flag_objc_abi != 0 && flag_objc_abi != -1)
 //    ObjcRunTimeVer = flag_objc_abi;
-  return DebugFactory.CreateCompileUnit(LangTag, FileName.c_str(),
-                                        Directory.c_str(),
-                                        version_string, isMain,
-                                        optimize, Flags,
-                                        ObjcRunTimeVer);
-}
-
-/// getOrCreateFile - Get DIFile descriptor.
-DIFile DebugInfo::getOrCreateFile(const char *FullPath) {
-  if (!FullPath) {
-    if (!strcmp (main_input_filename, ""))
-      FullPath = "<stdin>";
-    else
-      FullPath = main_input_filename;
-  }
-
-  // Get source file information.
-  std::string Directory;
-  std::string FileName;
-  DirectoryAndFile(FullPath, Directory, FileName);
-  return DebugFactory.CreateFile(FileName, Directory, TheCU);
+  DICompileUnit NewCU = DebugFactory.CreateCompileUnit(LangTag, FileName.c_str(), 
+                                                       Directory.c_str(),
+                                                       version_string, isMain,
+                                                       optimize, Flags,
+                                                       ObjcRunTimeVer);
+  CUCache[FullPath] = WeakVH(NewCU.getNode());
+  return NewCU;
 }

Modified: dragonegg/branches/release_27/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_27/llvm-debug.h?rev=101888&r1=101887&r2=101888&view=diff
==============================================================================
--- dragonegg/branches/release_27/llvm-debug.h (original)
+++ dragonegg/branches/release_27/llvm-debug.h Tue Apr 20 02:45:59 2010
@@ -57,14 +57,13 @@
   const char *PrevFullPath;             // Previous location file encountered.
   int PrevLineNo;                       // Previous location line# encountered.
   BasicBlock *PrevBB;                   // Last basic block encountered.
-
-  DICompileUnit TheCU;                  // The compile unit.
-
+  
   // This counter counts debug info for forward referenced subroutine types.
   // This counter is used to create unique name for such types so that their 
   // debug info (through MDNodes) is not shared accidently.
   unsigned FwdTypeCount;
 
+  std::map<std::string, WeakVH > CUCache;
   std::map<tree_node *, WeakVH > TypeCache;
                                         // Cache of previously constructed 
                                         // Types.
@@ -146,9 +145,6 @@
   DICompileUnit getOrCreateCompileUnit(const char *FullPath,
                                        bool isMain = false);
 
-  /// getOrCreateFile - Get DIFile descriptor.
-  DIFile getOrCreateFile(const char *FullPath);
-
   /// findRegion - Find tree_node N's region.
   DIDescriptor findRegion(tree_node *n);
   





More information about the llvm-commits mailing list