Move ModuleSummaryAnalysis from libAnalysis to libObject to break the dependency...
authorMehdi Amini <joker.eph@gmail.com>
Mon, 13 Apr 2020 04:21:40 +0000 (04:21 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 13 Apr 2020 23:12:11 +0000 (23:12 +0000)
ModuleSummaryAnalysis is the only file in libAnalysis that brings a
dependency on the CodeGen layer from libAnalysis, moving it breaks this
dependency.

Differential Revision: https://reviews.llvm.org/D77994

llvm/include/llvm/Object/ModuleSummaryAnalysis.h [moved from llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h with 100% similarity]
llvm/lib/Analysis/CMakeLists.txt
llvm/lib/Analysis/LLVMBuild.txt
llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Object/CMakeLists.txt
llvm/lib/Object/ModuleSummaryAnalysis.cpp [moved from llvm/lib/Analysis/ModuleSummaryAnalysis.cpp with 97% similarity]
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp

index dccd3d7..5a20b83 100644 (file)
@@ -67,7 +67,6 @@ add_llvm_component_library(LLVMAnalysis
   MemorySSA.cpp
   MemorySSAUpdater.cpp
   ModuleDebugInfoPrinter.cpp
-  ModuleSummaryAnalysis.cpp
   MustExecute.cpp
   ObjCARCAliasAnalysis.cpp
   ObjCARCAnalysisUtils.cpp
index d73b55f..b67dc4d 100644 (file)
@@ -18,4 +18,4 @@
 type = Library
 name = Analysis
 parent = Libraries
-required_libraries = BinaryFormat Core Object ProfileData Support
+required_libraries = BinaryFormat Core ProfileData Support
index d884415..1e9b349 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Bitcode/BitcodeWriterPass.h"
-#include "llvm/Analysis/ModuleSummaryAnalysis.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/Object/ModuleSummaryAnalysis.h"
 #include "llvm/Pass.h"
 using namespace llvm;
 
index 3d8d48d..d23ebe6 100644 (file)
@@ -16,7 +16,6 @@
 
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/Analysis/ModuleSummaryAnalysis.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -37,6 +36,7 @@
 #include "llvm/LTO/SummaryBasedOptimizations.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ModuleSummaryAnalysis.h"
 #include "llvm/Support/CachePruning.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
index 61888cb..1eeac73 100644 (file)
@@ -14,6 +14,7 @@ add_llvm_component_library(LLVMObject
   MachOObjectFile.cpp
   MachOUniversal.cpp
   Minidump.cpp
+  ModuleSummaryAnalysis.cpp
   ModuleSymbolTable.cpp
   Object.cpp
   ObjectFile.cpp
similarity index 97%
rename from llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
rename to llvm/lib/Object/ModuleSummaryAnalysis.cpp
index 1ff47e1..1c586a3 100644 (file)
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Analysis/ModuleSummaryAnalysis.h"
+#include "llvm/Object/ModuleSummaryAnalysis.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
@@ -327,7 +327,8 @@ static void computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M,
       // Check if this is an alias to a function. If so, get the
       // called aliasee for the checks below.
       if (auto *GA = dyn_cast<GlobalAlias>(CalledValue)) {
-        assert(!CalledFunction && "Expected null called function in callsite for alias");
+        assert(!CalledFunction &&
+               "Expected null called function in callsite for alias");
         CalledFunction = dyn_cast<Function>(GA->getBaseObject());
       }
       // Check if this is a direct call to a known function or a known
@@ -460,7 +461,8 @@ static void computeFunctionSummary(ModuleSummaryIndex &Index, const Module &M,
       NonRenamableLocal || HasInlineAsmMaybeReferencingInternal;
   GlobalValueSummary::GVFlags Flags(F.getLinkage(), NotEligibleForImport,
                                     /* Live = */ false, F.isDSOLocal(),
-                                    F.hasLinkOnceODRLinkage() && F.hasGlobalUnnamedAddr());
+                                    F.hasLinkOnceODRLinkage() &&
+                                        F.hasGlobalUnnamedAddr());
   FunctionSummary::FFlags FunFlags{
       F.hasFnAttribute(Attribute::ReadNone),
       F.hasFnAttribute(Attribute::ReadOnly),
@@ -578,7 +580,8 @@ static void computeVariableSummary(ModuleSummaryIndex &Index,
   bool NonRenamableLocal = isNonRenamableLocal(V);
   GlobalValueSummary::GVFlags Flags(V.getLinkage(), NonRenamableLocal,
                                     /* Live = */ false, V.isDSOLocal(),
-                                    V.hasLinkOnceODRLinkage() && V.hasGlobalUnnamedAddr());
+                                    V.hasLinkOnceODRLinkage() &&
+                                        V.hasGlobalUnnamedAddr());
 
   VTableFuncList VTableFuncs;
   // If splitting is not enabled, then we compute the summary information
@@ -604,7 +607,7 @@ static void computeVariableSummary(ModuleSummaryIndex &Index,
                                        Constant ? false : CanBeInternalized,
                                        Constant, V.getVCallVisibility());
   auto GVarSummary = std::make_unique<GlobalVarSummary>(Flags, VarFlags,
-                                                         RefEdges.takeVector());
+                                                        RefEdges.takeVector());
   if (NonRenamableLocal)
     CantBePromoted.insert(V.getGUID());
   if (HasBlockAddress)
@@ -614,13 +617,13 @@ static void computeVariableSummary(ModuleSummaryIndex &Index,
   Index.addGlobalValueSummary(V, std::move(GVarSummary));
 }
 
-static void
-computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
-                    DenseSet<GlobalValue::GUID> &CantBePromoted) {
+static void computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
+                                DenseSet<GlobalValue::GUID> &CantBePromoted) {
   bool NonRenamableLocal = isNonRenamableLocal(A);
   GlobalValueSummary::GVFlags Flags(A.getLinkage(), NonRenamableLocal,
                                     /* Live = */ false, A.isDSOLocal(),
-                                    A.hasLinkOnceODRLinkage() && A.hasGlobalUnnamedAddr());
+                                    A.hasLinkOnceODRLinkage() &&
+                                        A.hasGlobalUnnamedAddr());
   auto AS = std::make_unique<AliasSummary>(Flags);
   auto *Aliasee = A.getBaseObject();
   auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID());
@@ -691,12 +694,14 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex(
           GlobalValue *GV = M.getNamedValue(Name);
           if (!GV)
             return;
-          assert(GV->isDeclaration() && "Def in module asm already has definition");
+          assert(GV->isDeclaration() &&
+                 "Def in module asm already has definition");
           GlobalValueSummary::GVFlags GVFlags(GlobalValue::InternalLinkage,
                                               /* NotEligibleToImport = */ true,
                                               /* Live = */ true,
                                               /* Local */ GV->isDSOLocal(),
-                                              GV->hasLinkOnceODRLinkage() && GV->hasGlobalUnnamedAddr());
+                                              GV->hasLinkOnceODRLinkage() &&
+                                                  GV->hasGlobalUnnamedAddr());
           CantBePromoted.insert(GV->getGUID());
           // Create the appropriate summary type.
           if (Function *F = dyn_cast<Function>(GV)) {
@@ -834,8 +839,8 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex(
 
 AnalysisKey ModuleSummaryIndexAnalysis::Key;
 
-ModuleSummaryIndex
-ModuleSummaryIndexAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
+ModuleSummaryIndex ModuleSummaryIndexAnalysis::run(Module &M,
+                                                   ModuleAnalysisManager &AM) {
   ProfileSummaryInfo &PSI = AM.getResult<ProfileSummaryAnalysis>(M);
   auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
   return buildModuleSummaryIndex(
index 9f60324..f0dd79a 100644 (file)
@@ -41,7 +41,6 @@
 #include "llvm/Analysis/LoopNestAnalysis.h"
 #include "llvm/Analysis/MemoryDependenceAnalysis.h"
 #include "llvm/Analysis/MemorySSA.h"
-#include "llvm/Analysis/ModuleSummaryAnalysis.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/Analysis/PhiValues.h"
 #include "llvm/Analysis/PostDominators.h"
@@ -62,6 +61,7 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/SafepointIRVerifier.h"
 #include "llvm/IR/Verifier.h"
+#include "llvm/Object/ModuleSummaryAnalysis.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FormatVariadic.h"
index 87a1817..6e1417a 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
-#include "llvm/Analysis/ModuleSummaryAnalysis.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
 #include "llvm/Analysis/TypeMetadataUtils.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
@@ -18,6 +17,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/InitializePasses.h"
+#include "llvm/Object/ModuleSummaryAnalysis.h"
 #include "llvm/Object/ModuleSymbolTable.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/ScopedPrinter.h"