Skip to content

Commit

Permalink
[NFC][llvm-reduce] Use new pass manager for printing ThinLTO bitcode
Browse files Browse the repository at this point in the history
  • Loading branch information
aeubanks committed Aug 15, 2022
1 parent e994905 commit 853b57f
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions llvm/tools/llvm-reduce/llvm-reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,19 @@
#include "DeltaManager.h"
#include "ReducerWorkItem.h"
#include "TestRunner.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
#include <system_error>
#include <vector>

Expand Down Expand Up @@ -117,9 +109,19 @@ void writeOutput(ReducerWorkItem &M, StringRef Message) {

void writeBitcode(ReducerWorkItem &M, llvm::raw_ostream &OutStream) {
if (M.LTOInfo && M.LTOInfo->IsThinLTO && M.LTOInfo->EnableSplitLTOUnit) {
legacy::PassManager PM;
PM.add(llvm::createWriteThinLTOBitcodePass(OutStream));
PM.run(*(M.M));
PassBuilder PB;
LoopAnalysisManager LAM;
FunctionAnalysisManager FAM;
CGSCCAnalysisManager CGAM;
ModuleAnalysisManager MAM;
PB.registerModuleAnalyses(MAM);
PB.registerCGSCCAnalyses(CGAM);
PB.registerFunctionAnalyses(FAM);
PB.registerLoopAnalyses(LAM);
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
ModulePassManager MPM;
MPM.addPass(ThinLTOBitcodeWriterPass(OutStream, nullptr));
MPM.run(*M.M, MAM);
} else {
std::unique_ptr<ModuleSummaryIndex> Index;
if (M.LTOInfo && M.LTOInfo->HasSummary) {
Expand Down

0 comments on commit 853b57f

Please sign in to comment.