[Internalize] Remove interaction with CallGraph
authorArthur Eubanks <aeubanks@google.com>
Mon, 20 Mar 2023 16:24:11 +0000 (09:24 -0700)
committerArthur Eubanks <aeubanks@google.com>
Mon, 20 Mar 2023 16:24:11 +0000 (09:24 -0700)
Internalize was trying to update CallGraph if the analysis was available, but the new PM doesn't really use it so there's little reason to update it.

llvm/include/llvm/Transforms/IPO/Internalize.h
llvm/lib/Transforms/IPO/Internalize.cpp

index adcf5a9..5beb925 100644 (file)
@@ -66,10 +66,7 @@ public:
 
   /// Run the internalizer on \p TheModule, returns true if any changes was
   /// made.
-  ///
-  /// If the CallGraph \p CG is supplied, it will be updated when
-  /// internalizing a function (by removing any edge from the "external node")
-  bool internalizeModule(Module &TheModule, CallGraph *CG = nullptr);
+  bool internalizeModule(Module &TheModule);
 
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
 };
@@ -77,10 +74,9 @@ public:
 /// Helper function to internalize functions and variables in a Module.
 inline bool
 internalizeModule(Module &TheModule,
-                  std::function<bool(const GlobalValue &)> MustPreserveGV,
-                  CallGraph *CG = nullptr) {
+                  std::function<bool(const GlobalValue &)> MustPreserveGV) {
   return InternalizePass(std::move(MustPreserveGV))
-      .internalizeModule(TheModule, CG);
+      .internalizeModule(TheModule);
 }
 } // end namespace llvm
 
index 5982b8e..21d6492 100644 (file)
@@ -183,9 +183,8 @@ void InternalizePass::checkComdat(
     Info.External = true;
 }
 
-bool InternalizePass::internalizeModule(Module &M, CallGraph *CG) {
+bool InternalizePass::internalizeModule(Module &M) {
   bool Changed = false;
-  CallGraphNode *ExternalNode = CG ? CG->getExternalCallingNode() : nullptr;
 
   SmallVector<GlobalValue *, 4> Used;
   collectUsedGlobalVariables(M, Used, false);
@@ -242,10 +241,6 @@ bool InternalizePass::internalizeModule(Module &M, CallGraph *CG) {
       continue;
     Changed = true;
 
-    if (ExternalNode)
-      // Remove a callgraph edge from the external node to this function.
-      ExternalNode->removeOneAbstractEdgeTo((*CG)[&I]);
-
     ++NumFunctions;
     LLVM_DEBUG(dbgs() << "Internalizing func " << I.getName() << "\n");
   }
@@ -277,7 +272,7 @@ bool InternalizePass::internalizeModule(Module &M, CallGraph *CG) {
 InternalizePass::InternalizePass() : MustPreserveGV(PreserveAPIList()) {}
 
 PreservedAnalyses InternalizePass::run(Module &M, ModuleAnalysisManager &AM) {
-  if (!internalizeModule(M, AM.getCachedResult<CallGraphAnalysis>(M)))
+  if (!internalizeModule(M))
     return PreservedAnalyses::all();
 
   PreservedAnalyses PA;