================
@@ -21,46 +24,64 @@ using namespace llvm;
 PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) 
{
   M.removeDebugIntrinsicDeclarations();
 
-  const ModuleSummaryIndex *Index =
-      EmitSummaryIndex ? &(AM.getResult<ModuleSummaryIndexAnalysis>(M))
-                       : nullptr;
-  WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, Index, EmitModuleHash);
+  ProfileSummaryInfo &PSI = AM.getResult<ProfileSummaryAnalysis>(M);
+  auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
+  bool NeedSSI = needsParamAccessSummary(M);
+  std::unique_ptr<ModuleSummaryIndex> NewIndex = nullptr;
+  if (EmitSummaryIndex) {
+    NewIndex = std::make_unique<ModuleSummaryIndex>(buildModuleSummaryIndex(
+        M,
+        [&FAM](const Function &F) {
+          return &FAM.getResult<BlockFrequencyAnalysis>(
+              *const_cast<Function *>(&F));
+        },
+        &PSI, TM,
+        [&FAM, NeedSSI](const Function &F) -> const StackSafetyInfo * {
+          return NeedSSI ? &FAM.getResult<StackSafetyAnalysis>(
+                               const_cast<Function &>(F))
+                         : nullptr;
+        }));
+  }
+  WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, NewIndex.get(),
+                     EmitModuleHash, /*ModHash=*/nullptr, TM);
 
   return PreservedAnalyses::all();
 }
 
 namespace {
-  class WriteBitcodePass : public ModulePass {
-    raw_ostream &OS; // raw_ostream to print on
-    bool ShouldPreserveUseListOrder;
+class WriteBitcodePass : public ModulePass {
----------------
teresajohnson wrote:

Please don't do unnecessary reformatting. Are you doing clang format on the 
entire file or just on the changed lines?

https://github.com/llvm/llvm-project/pull/143692
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to