[llvm] r260462 - Use a StringSet in Internalize, and allow to create the pass from an existing one (NFC)

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 15:24:31 PST 2016


Author: mehdi_amini
Date: Wed Feb 10 17:24:31 2016
New Revision: 260462

URL: http://llvm.org/viewvc/llvm-project?rev=260462&view=rev
Log:
Use a StringSet in Internalize, and allow to create the pass from an existing one (NFC)

There is not reason to pass an array of "char *" to rebuild a set if
the client already has one.

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/include/llvm/Transforms/IPO.h
    llvm/trunk/lib/Transforms/IPO/Internalize.cpp

Modified: llvm/trunk/include/llvm/Transforms/IPO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO.h?rev=260462&r1=260461&r2=260462&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO.h Wed Feb 10 17:24:31 2016
@@ -17,6 +17,7 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 
 namespace llvm {
 
@@ -126,7 +127,11 @@ Pass *createPruneEHPass();
 ///
 /// Note that commandline options that are used with the above function are not
 /// used now!
+ModulePass *createInternalizePass(StringSet<> ExportList);
+
+/// Same as above, but with an exportList created for an array.
 ModulePass *createInternalizePass(ArrayRef<const char *> ExportList);
+
 /// createInternalizePass - Same as above, but with an empty exportList.
 ModulePass *createInternalizePass();
 

Modified: llvm/trunk/lib/Transforms/IPO/Internalize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Internalize.cpp?rev=260462&r1=260461&r2=260462&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Internalize.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Internalize.cpp Wed Feb 10 17:24:31 2016
@@ -22,6 +22,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
@@ -54,11 +55,13 @@ APIList("internalize-public-api-list", c
 
 namespace {
   class InternalizePass : public ModulePass {
-    std::set<std::string> ExternalNames;
+    StringSet<> ExternalNames;
+
   public:
     static char ID; // Pass identification, replacement for typeid
     explicit InternalizePass();
     explicit InternalizePass(ArrayRef<const char *> ExportList);
+    explicit InternalizePass(StringSet<> ExportList);
     void LoadFile(const char *Filename);
     bool maybeInternalize(GlobalValue &GV,
                           const std::set<const Comdat *> &ExternalComdats);
@@ -93,6 +96,9 @@ InternalizePass::InternalizePass(ArrayRe
   }
 }
 
+InternalizePass::InternalizePass(StringSet<> ExportList)
+    : ModulePass(ID), ExternalNames(std::move(ExportList)) {}
+
 void InternalizePass::LoadFile(const char *Filename) {
   // Load the APIFile...
   std::ifstream In(Filename);
@@ -110,7 +116,7 @@ void InternalizePass::LoadFile(const cha
 }
 
 static bool isExternallyVisible(const GlobalValue &GV,
-                                const std::set<std::string> &ExternalNames) {
+                                const StringSet<> &ExternalNames) {
   // Function must be defined here
   if (GV.isDeclaration())
     return true;
@@ -267,3 +273,7 @@ ModulePass *llvm::createInternalizePass(
 ModulePass *llvm::createInternalizePass(ArrayRef<const char *> ExportList) {
   return new InternalizePass(ExportList);
 }
+
+ModulePass *llvm::createInternalizePass(StringSet<> ExportList) {
+  return new InternalizePass(std::move(ExportList));
+}




More information about the llvm-commits mailing list