[llvm] r266169 - Really return whether Internalize did change the Module or not.

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 12 22:25:16 PDT 2016


Author: mehdi_amini
Date: Wed Apr 13 00:25:16 2016
New Revision: 266169

URL: http://llvm.org/viewvc/llvm-project?rev=266169&view=rev
Log:
Really return whether Internalize did change the Module or not.

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

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

Modified: llvm/trunk/lib/Transforms/IPO/Internalize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Internalize.cpp?rev=266169&r1=266168&r2=266169&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Internalize.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Internalize.cpp Wed Apr 13 00:25:16 2016
@@ -213,6 +213,7 @@ void Internalizer::checkComdatVisibility
 }
 
 bool Internalizer::internalizeModule(Module &M, CallGraph *CG) {
+  bool Changed = false;
   CallGraphNode *ExternalNode = CG ? CG->getExternalCallingNode() : nullptr;
 
   SmallPtrSet<GlobalValue *, 8> Used;
@@ -246,6 +247,7 @@ bool Internalizer::internalizeModule(Mod
   for (Function &I : M) {
     if (!maybeInternalize(I, ExternalComdats))
       continue;
+    Changed = true;
 
     if (ExternalNode)
       // Remove a callgraph edge from the external node to this function.
@@ -278,6 +280,7 @@ bool Internalizer::internalizeModule(Mod
   for (auto &GV : M.globals()) {
     if (!maybeInternalize(GV, ExternalComdats))
       continue;
+    Changed = true;
 
     ++NumGlobals;
     DEBUG(dbgs() << "Internalized gvar " << GV.getName() << "\n");
@@ -287,18 +290,13 @@ bool Internalizer::internalizeModule(Mod
   for (auto &GA : M.aliases()) {
     if (!maybeInternalize(GA, ExternalComdats))
       continue;
+    Changed = true;
 
     ++NumAliases;
     DEBUG(dbgs() << "Internalized alias " << GA.getName() << "\n");
   }
 
-  // We do not keep track of whether this pass changed the module because
-  // it adds unnecessary complexity:
-  // 1) This pass will generally be near the start of the pass pipeline, so
-  //    there will be no analyses to invalidate.
-  // 2) This pass will most likely end up changing the module and it isn't worth
-  //    worrying about optimizing the case where the module is unchanged.
-  return true;
+  return Changed;
 }
 
 /// Public API below




More information about the llvm-commits mailing list