[llvm-commits] [llvm] r155300 - in /llvm/trunk: ./ include/llvm/Module.h lib/Linker/LinkModules.cpp lib/VMCore/Module.cpp

Bill Wendling isanbard at gmail.com
Sat Apr 21 16:59:16 PDT 2012


Author: void
Date: Sat Apr 21 18:59:16 2012
New Revision: 155300

URL: http://llvm.org/viewvc/llvm-project?rev=155300&view=rev
Log:
Add a flag to the struct type finder to collect only those types which have
names. This saves collecting types we normally don't care about.

Modified:
    llvm/trunk/   (props changed)
    llvm/trunk/include/llvm/Module.h
    llvm/trunk/lib/Linker/LinkModules.cpp
    llvm/trunk/lib/VMCore/Module.cpp

Propchange: llvm/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Apr 21 18:59:16 2012
@@ -1,2 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
+/llvm/trunk:155241

Modified: llvm/trunk/include/llvm/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=155300&r1=155299&r2=155300&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Module.h (original)
+++ llvm/trunk/include/llvm/Module.h Sat Apr 21 18:59:16 2012
@@ -303,7 +303,8 @@
 
   /// findUsedStructTypes - Walk the entire module and find all of the
   /// struct types that are in use, returning them in a vector.
-  void findUsedStructTypes(std::vector<StructType*> &StructTypes) const;
+  void findUsedStructTypes(std::vector<StructType*> &StructTypes,
+                           bool OnlyNamed = false) const;
   
   /// getTypeByName - Return the type with the specified name, or null if there
   /// is none by that name.

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=155300&r1=155299&r2=155300&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Sat Apr 21 18:59:16 2012
@@ -595,12 +595,12 @@
   // example.  When the source module got loaded into the same LLVMContext, if
   // it had the same type, it would have been renamed to "%foo.42 = { i32 }".
   std::vector<StructType*> SrcStructTypes;
-  SrcM->findUsedStructTypes(SrcStructTypes);
+  SrcM->findUsedStructTypes(SrcStructTypes, true);
   SmallPtrSet<StructType*, 32> SrcStructTypesSet(SrcStructTypes.begin(),
                                                  SrcStructTypes.end());
 
   std::vector<StructType*> DstStructTypes;
-  DstM->findUsedStructTypes(DstStructTypes);
+  DstM->findUsedStructTypes(DstStructTypes, true);
   SmallPtrSet<StructType*, 32> DstStructTypesSet(DstStructTypes.begin(),
                                                  DstStructTypes.end());
 

Modified: llvm/trunk/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=155300&r1=155299&r2=155300&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Module.cpp (original)
+++ llvm/trunk/lib/VMCore/Module.cpp Sat Apr 21 18:59:16 2012
@@ -483,9 +483,10 @@
     DenseSet<Type*> VisitedTypes;
     
     std::vector<StructType*> &StructTypes;
+    bool OnlyNamed;
   public:
-    TypeFinder(std::vector<StructType*> &structTypes)
-      : StructTypes(structTypes) {}
+    TypeFinder(std::vector<StructType*> &structTypes, bool onlyNamed)
+      : StructTypes(structTypes), OnlyNamed(onlyNamed) {}
     
     void run(const Module &M) {
       // Get types from global variables.
@@ -545,7 +546,8 @@
       
       // If this is a structure or opaque type, add a name for the type.
       if (StructType *STy = dyn_cast<StructType>(Ty))
-        StructTypes.push_back(STy);
+        if (!OnlyNamed || STy->hasName())
+          StructTypes.push_back(STy);
       
       // Recursively walk all contained types.
       for (Type::subtype_iterator I = Ty->subtype_begin(),
@@ -590,6 +592,7 @@
   };
 } // end anonymous namespace
 
-void Module::findUsedStructTypes(std::vector<StructType*> &StructTypes) const {
-  TypeFinder(StructTypes).run(*this);
+void Module::findUsedStructTypes(std::vector<StructType*> &StructTypes,
+                                 bool OnlyNamed) const {
+  TypeFinder(StructTypes, OnlyNamed).run(*this);
 }





More information about the llvm-commits mailing list