[clang] [llvm] Pass TargetMachine from from Clang to `BitcodeWriter`and `ThinLTOBitcodeWriter` pass for thin and fat LTO respectively. (PR #143692)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 16 09:41:17 PDT 2025
================
@@ -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
More information about the llvm-commits
mailing list