[llvm] 7f608a2 - Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm"
Mikhail Goncharov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 18 00:26:22 PST 2022
Author: Mikhail Goncharov
Date: 2022-11-18T09:25:45+01:00
New Revision: 7f608a2497c7578b9f3ca98014176ab95cffe3c0
URL: https://github.com/llvm/llvm-project/commit/7f608a2497c7578b9f3ca98014176ab95cffe3c0
DIFF: https://github.com/llvm/llvm-project/commit/7f608a2497c7578b9f3ca98014176ab95cffe3c0.diff
LOG: Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm"
This reverts commit 34ab474348e2623cc67abddb7bb662385297ac65.
as it has introduced circular dependency lib - analysis
Added:
Modified:
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGen/split-lto-unit.c
llvm/include/llvm/IRPrinter/IRPrintingPasses.h
llvm/lib/IRPrinter/CMakeLists.txt
llvm/lib/IRPrinter/IRPrintingPasses.cpp
llvm/test/Bitcode/thinlto-function-summary.ll
llvm/tools/opt/NewPMDriver.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index d6a7a9800ec58..9c677140b4a5d 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -983,24 +983,19 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
MPM.addPass(VerifierPass());
- if (Action == Backend_EmitBC || Action == Backend_EmitLL) {
+ switch (Action) {
+ case Backend_EmitBC:
if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
+ if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
+ ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
+ if (!ThinLinkOS)
+ return;
+ }
if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
CodeGenOpts.EnableSplitLTOUnit);
- if (Action == Backend_EmitBC) {
- if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
- ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
- if (!ThinLinkOS)
- return;
- }
- MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
- : nullptr));
- } else {
- MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
- /*EmitLTOSummary=*/true));
- }
-
+ MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
+ : nullptr));
} else {
// Emit a module summary by default for Regular LTO except for ld64
// targets
@@ -1012,13 +1007,17 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
uint32_t(1));
}
- if (Action == Backend_EmitBC)
- MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
- EmitLTOSummary));
- else
- MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
- EmitLTOSummary));
+ MPM.addPass(
+ BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, EmitLTOSummary));
}
+ break;
+
+ case Backend_EmitLL:
+ MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists));
+ break;
+
+ default:
+ break;
}
// Now that we have all of the passes ready, run them.
diff --git a/clang/test/CodeGen/split-lto-unit.c b/clang/test/CodeGen/split-lto-unit.c
index b1560b61f3e30..941aebafd01b3 100644
--- a/clang/test/CodeGen/split-lto-unit.c
+++ b/clang/test/CodeGen/split-lto-unit.c
@@ -1,15 +1,12 @@
// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
-// RUN: %clang_cc1 -flto=thin -emit-llvm < %s | FileCheck %s
// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
//
// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --check-prefix=SPLIT
-// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm < %s | FileCheck %s --check-prefix=SPLIT
// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
//
// ; Check that regular LTO has EnableSplitLTOUnit = 1
// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
-// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm < %s | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
int main(void) {}
diff --git a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
index 8eb7973365172..6cfa7a87af933 100644
--- a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
+++ b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
@@ -34,13 +34,11 @@ class PrintModulePass : public PassInfoMixin<PrintModulePass> {
raw_ostream &OS;
std::string Banner;
bool ShouldPreserveUseListOrder;
- bool EmitSummaryIndex;
public:
PrintModulePass();
PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
- bool ShouldPreserveUseListOrder = false,
- bool EmitSummaryIndex = false);
+ bool ShouldPreserveUseListOrder = false);
PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
static bool isRequired() { return true; }
diff --git a/llvm/lib/IRPrinter/CMakeLists.txt b/llvm/lib/IRPrinter/CMakeLists.txt
index 0c8c4a0122c15..926835ab965bc 100644
--- a/llvm/lib/IRPrinter/CMakeLists.txt
+++ b/llvm/lib/IRPrinter/CMakeLists.txt
@@ -8,7 +8,6 @@ add_llvm_component_library(LLVMIRPrinter
intrinsics_gen
LINK_COMPONENTS
- Analysis
Core
Support
)
diff --git a/llvm/lib/IRPrinter/IRPrintingPasses.cpp b/llvm/lib/IRPrinter/IRPrintingPasses.cpp
index 9552ce3862c57..4b31c68bfc2b6 100644
--- a/llvm/lib/IRPrinter/IRPrintingPasses.cpp
+++ b/llvm/lib/IRPrinter/IRPrintingPasses.cpp
@@ -12,7 +12,6 @@
#include "llvm/IRPrinter/IRPrintingPasses.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Analysis/ModuleSummaryAnalysis.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PrintPasses.h"
@@ -24,13 +23,11 @@ using namespace llvm;
PrintModulePass::PrintModulePass() : OS(dbgs()) {}
PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
- bool ShouldPreserveUseListOrder,
- bool EmitSummaryIndex)
+ bool ShouldPreserveUseListOrder)
: OS(OS), Banner(Banner),
- ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
- EmitSummaryIndex(EmitSummaryIndex) {}
+ ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
-PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &AM) {
+PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &) {
if (llvm::isFunctionInPrintList("*")) {
if (!Banner.empty())
OS << Banner << "\n";
@@ -47,16 +44,6 @@ PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &AM) {
}
}
}
-
- ModuleSummaryIndex *Index =
- EmitSummaryIndex ? &(AM.getResult<ModuleSummaryIndexAnalysis>(M))
- : nullptr;
- if (Index) {
- if (Index->modulePaths().empty())
- Index->addModule("", 0);
- Index->print(OS);
- }
-
return PreservedAnalyses::all();
}
diff --git a/llvm/test/Bitcode/thinlto-function-summary.ll b/llvm/test/Bitcode/thinlto-function-summary.ll
index 68636ed192a19..ad745dd826acd 100644
--- a/llvm/test/Bitcode/thinlto-function-summary.ll
+++ b/llvm/test/Bitcode/thinlto-function-summary.ll
@@ -31,8 +31,6 @@
; RUN: opt -passes=name-anon-globals -module-summary < %s | llvm-dis | FileCheck %s
-; RUN: opt -passes=name-anon-globals -module-summary -S < %s | FileCheck %s
-; RUN: opt -passes=name-anon-globals -module-summary -S < %s | llvm-as | llvm-dis | FileCheck %s
; Check that this round-trips correctly.
; ModuleID = '<stdin>'
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 4e6a501a4f0a8..8c4233f8f5560 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -443,16 +443,16 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
MPM.addPass(NewPMCheckDebugifyPass(false, "", &DIStatsMap));
if (VerifyDIPreserve)
MPM.addPass(NewPMCheckDebugifyPass(
- false, "", nullptr, DebugifyMode::OriginalDebugInfo,
- &DebugInfoBeforePass, VerifyDIPreserveExport));
+ false, "", nullptr, DebugifyMode::OriginalDebugInfo, &DebugInfoBeforePass,
+ VerifyDIPreserveExport));
// Add any relevant output pass at the end of the pipeline.
switch (OK) {
case OK_NoOutput:
break; // No output pass needed.
case OK_OutputAssembly:
- MPM.addPass(PrintModulePass(
- Out->os(), "", ShouldPreserveAssemblyUseListOrder, EmitSummaryIndex));
+ MPM.addPass(
+ PrintModulePass(Out->os(), "", ShouldPreserveAssemblyUseListOrder));
break;
case OK_OutputBitcode:
MPM.addPass(BitcodeWriterPass(Out->os(), ShouldPreserveBitcodeUseListOrder,
More information about the llvm-commits
mailing list