Rollup merge of #96215 - nikic:legacy-pm-removal, r=nagisa
Drop support for legacy PM with LLVM 15 LLVM 15 already removes some of the legacy PM APIs we're using. This patch forces use of NewPM with LLVM 15 (with `-Z new-llvm-pass-manager=no` throwing a warning) and stubs out various FFI methods with a report_fatal_error on LLVM 15. For LLVMPassManagerBuilderPopulateLTOPassManager() I went with adding our own wrapper, as the alternative would be to muck about with weak symbols, which seems to be non-trivial as far as cross-platform support is concerned (std has `weak!` for this purpose, but only as an internal utility.) Fixes #96072. Fixes #96362.
This commit is contained in:
commit
433f1f425e
@ -625,7 +625,7 @@ pub(crate) fn run_pass_manager(
|
|||||||
if thin {
|
if thin {
|
||||||
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);
|
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);
|
||||||
} else {
|
} else {
|
||||||
llvm::LLVMPassManagerBuilderPopulateLTOPassManager(
|
llvm::LLVMRustPassManagerBuilderPopulateLTOPassManager(
|
||||||
b, pm, /* Internalize = */ False, /* RunInliner = */ True,
|
b, pm, /* Internalize = */ False, /* RunInliner = */ True,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -523,6 +523,12 @@ pub(crate) unsafe fn optimize(
|
|||||||
let module_name = module.name.clone();
|
let module_name = module.name.clone();
|
||||||
let module_name = Some(&module_name[..]);
|
let module_name = Some(&module_name[..]);
|
||||||
|
|
||||||
|
if let Some(false) = config.new_llvm_pass_manager && llvm_util::get_version() >= (15, 0, 0) {
|
||||||
|
diag_handler.warn(
|
||||||
|
"ignoring `-Z new-llvm-pass-manager=no`, which is no longer supported with LLVM 15",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if config.emit_no_opt_bc {
|
if config.emit_no_opt_bc {
|
||||||
let out = cgcx.output_filenames.temp_path_ext("no-opt.bc", module_name);
|
let out = cgcx.output_filenames.temp_path_ext("no-opt.bc", module_name);
|
||||||
let out = path_to_c_string(&out);
|
let out = path_to_c_string(&out);
|
||||||
@ -628,8 +634,8 @@ pub(crate) unsafe fn optimize(
|
|||||||
extra_passes.as_ptr(),
|
extra_passes.as_ptr(),
|
||||||
extra_passes.len() as size_t,
|
extra_passes.len() as size_t,
|
||||||
);
|
);
|
||||||
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(b, fpm);
|
llvm::LLVMRustPassManagerBuilderPopulateFunctionPassManager(b, fpm);
|
||||||
llvm::LLVMPassManagerBuilderPopulateModulePassManager(b, mpm);
|
llvm::LLVMRustPassManagerBuilderPopulateModulePassManager(b, mpm);
|
||||||
});
|
});
|
||||||
|
|
||||||
have_name_anon_globals_pass = have_name_anon_globals_pass || prepare_for_thin_lto;
|
have_name_anon_globals_pass = have_name_anon_globals_pass || prepare_for_thin_lto;
|
||||||
@ -1085,7 +1091,7 @@ pub unsafe fn with_llvm_pmb(
|
|||||||
// Create the PassManagerBuilder for LLVM. We configure it with
|
// Create the PassManagerBuilder for LLVM. We configure it with
|
||||||
// reasonable defaults and prepare it to actually populate the pass
|
// reasonable defaults and prepare it to actually populate the pass
|
||||||
// manager.
|
// manager.
|
||||||
let builder = llvm::LLVMPassManagerBuilderCreate();
|
let builder = llvm::LLVMRustPassManagerBuilderCreate();
|
||||||
let opt_size = config.opt_size.map_or(llvm::CodeGenOptSizeNone, |x| to_llvm_opt_settings(x).1);
|
let opt_size = config.opt_size.map_or(llvm::CodeGenOptSizeNone, |x| to_llvm_opt_settings(x).1);
|
||||||
let inline_threshold = config.inline_threshold;
|
let inline_threshold = config.inline_threshold;
|
||||||
let pgo_gen_path = get_pgo_gen_path(config);
|
let pgo_gen_path = get_pgo_gen_path(config);
|
||||||
@ -1102,14 +1108,9 @@ pub unsafe fn with_llvm_pmb(
|
|||||||
pgo_gen_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()),
|
pgo_gen_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()),
|
||||||
pgo_use_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()),
|
pgo_use_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()),
|
||||||
pgo_sample_use_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()),
|
pgo_sample_use_path.as_ref().map_or(ptr::null(), |s| s.as_ptr()),
|
||||||
|
opt_size as c_int,
|
||||||
);
|
);
|
||||||
|
|
||||||
llvm::LLVMPassManagerBuilderSetSizeLevel(builder, opt_size as u32);
|
|
||||||
|
|
||||||
if opt_size != llvm::CodeGenOptSizeNone {
|
|
||||||
llvm::LLVMPassManagerBuilderSetDisableUnrollLoops(builder, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, config.no_builtins);
|
llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, config.no_builtins);
|
||||||
|
|
||||||
// Here we match what clang does (kinda). For O0 we only inline
|
// Here we match what clang does (kinda). For O0 we only inline
|
||||||
@ -1118,16 +1119,16 @@ pub unsafe fn with_llvm_pmb(
|
|||||||
// thresholds copied from clang.
|
// thresholds copied from clang.
|
||||||
match (opt_level, opt_size, inline_threshold) {
|
match (opt_level, opt_size, inline_threshold) {
|
||||||
(.., Some(t)) => {
|
(.., Some(t)) => {
|
||||||
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, t);
|
llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, t);
|
||||||
}
|
}
|
||||||
(llvm::CodeGenOptLevel::Aggressive, ..) => {
|
(llvm::CodeGenOptLevel::Aggressive, ..) => {
|
||||||
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 275);
|
llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, 275);
|
||||||
}
|
}
|
||||||
(_, llvm::CodeGenOptSizeDefault, _) => {
|
(_, llvm::CodeGenOptSizeDefault, _) => {
|
||||||
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 75);
|
llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, 75);
|
||||||
}
|
}
|
||||||
(_, llvm::CodeGenOptSizeAggressive, _) => {
|
(_, llvm::CodeGenOptSizeAggressive, _) => {
|
||||||
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 25);
|
llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, 25);
|
||||||
}
|
}
|
||||||
(llvm::CodeGenOptLevel::None, ..) => {
|
(llvm::CodeGenOptLevel::None, ..) => {
|
||||||
llvm::LLVMRustAddAlwaysInlinePass(builder, config.emit_lifetime_markers);
|
llvm::LLVMRustAddAlwaysInlinePass(builder, config.emit_lifetime_markers);
|
||||||
@ -1136,12 +1137,12 @@ pub unsafe fn with_llvm_pmb(
|
|||||||
llvm::LLVMRustAddAlwaysInlinePass(builder, config.emit_lifetime_markers);
|
llvm::LLVMRustAddAlwaysInlinePass(builder, config.emit_lifetime_markers);
|
||||||
}
|
}
|
||||||
(llvm::CodeGenOptLevel::Default, ..) => {
|
(llvm::CodeGenOptLevel::Default, ..) => {
|
||||||
llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder, 225);
|
llvm::LLVMRustPassManagerBuilderUseInlinerWithThreshold(builder, 225);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f(builder);
|
f(builder);
|
||||||
llvm::LLVMPassManagerBuilderDispose(builder);
|
llvm::LLVMRustPassManagerBuilderDispose(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a `__imp_<symbol> = &symbol` global for every public static `symbol`.
|
// Create a `__imp_<symbol> = &symbol` global for every public static `symbol`.
|
||||||
|
@ -1825,24 +1825,22 @@ extern "C" {
|
|||||||
|
|
||||||
pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
|
pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
|
||||||
|
|
||||||
pub fn LLVMPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
|
pub fn LLVMRustPassManagerBuilderCreate() -> &'static mut PassManagerBuilder;
|
||||||
pub fn LLVMPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
|
pub fn LLVMRustPassManagerBuilderDispose(PMB: &'static mut PassManagerBuilder);
|
||||||
pub fn LLVMPassManagerBuilderSetSizeLevel(PMB: &PassManagerBuilder, Value: Bool);
|
pub fn LLVMRustPassManagerBuilderUseInlinerWithThreshold(
|
||||||
pub fn LLVMPassManagerBuilderSetDisableUnrollLoops(PMB: &PassManagerBuilder, Value: Bool);
|
|
||||||
pub fn LLVMPassManagerBuilderUseInlinerWithThreshold(
|
|
||||||
PMB: &PassManagerBuilder,
|
PMB: &PassManagerBuilder,
|
||||||
threshold: c_uint,
|
threshold: c_uint,
|
||||||
);
|
);
|
||||||
pub fn LLVMPassManagerBuilderPopulateModulePassManager(
|
pub fn LLVMRustPassManagerBuilderPopulateModulePassManager(
|
||||||
PMB: &PassManagerBuilder,
|
PMB: &PassManagerBuilder,
|
||||||
PM: &PassManager<'_>,
|
PM: &PassManager<'_>,
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn LLVMPassManagerBuilderPopulateFunctionPassManager(
|
pub fn LLVMRustPassManagerBuilderPopulateFunctionPassManager(
|
||||||
PMB: &PassManagerBuilder,
|
PMB: &PassManagerBuilder,
|
||||||
PM: &PassManager<'_>,
|
PM: &PassManager<'_>,
|
||||||
);
|
);
|
||||||
pub fn LLVMPassManagerBuilderPopulateLTOPassManager(
|
pub fn LLVMRustPassManagerBuilderPopulateLTOPassManager(
|
||||||
PMB: &PassManagerBuilder,
|
PMB: &PassManagerBuilder,
|
||||||
PM: &PassManager<'_>,
|
PM: &PassManager<'_>,
|
||||||
Internalize: Bool,
|
Internalize: Bool,
|
||||||
@ -2308,6 +2306,7 @@ extern "C" {
|
|||||||
PGOGenPath: *const c_char,
|
PGOGenPath: *const c_char,
|
||||||
PGOUsePath: *const c_char,
|
PGOUsePath: *const c_char,
|
||||||
PGOSampleUsePath: *const c_char,
|
PGOSampleUsePath: *const c_char,
|
||||||
|
SizeLevel: c_int,
|
||||||
);
|
);
|
||||||
pub fn LLVMRustAddLibraryInfo<'a>(
|
pub fn LLVMRustAddLibraryInfo<'a>(
|
||||||
PM: &PassManager<'a>,
|
PM: &PassManager<'a>,
|
||||||
|
@ -542,6 +542,11 @@ pub(crate) fn should_use_new_llvm_pass_manager(user_opt: &Option<bool>, target_a
|
|||||||
// The new pass manager is enabled by default for LLVM >= 13.
|
// The new pass manager is enabled by default for LLVM >= 13.
|
||||||
// This matches Clang, which also enables it since Clang 13.
|
// This matches Clang, which also enables it since Clang 13.
|
||||||
|
|
||||||
|
// Since LLVM 15, the legacy pass manager is no longer supported.
|
||||||
|
if llvm_util::get_version() >= (15, 0, 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// There are some perf issues with the new pass manager when targeting
|
// There are some perf issues with the new pass manager when targeting
|
||||||
// s390x with LLVM 13, so enable the new pass manager only with LLVM 14.
|
// s390x with LLVM 13, so enable the new pass manager only with LLVM 14.
|
||||||
// See https://github.com/rust-lang/rust/issues/89609.
|
// See https://github.com/rust-lang/rust/issues/89609.
|
||||||
|
@ -107,6 +107,7 @@ static LLVMRustPassKind toRust(PassKind Kind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
|
extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
StringRef SR(PassName);
|
StringRef SR(PassName);
|
||||||
PassRegistry *PR = PassRegistry::getPassRegistry();
|
PassRegistry *PR = PassRegistry::getPassRegistry();
|
||||||
|
|
||||||
@ -115,36 +116,59 @@ extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
|
|||||||
return wrap(PI->createPass());
|
return wrap(PI->createPass());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover) {
|
extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
const bool CompileKernel = false;
|
const bool CompileKernel = false;
|
||||||
const bool UseAfterScope = true;
|
const bool UseAfterScope = true;
|
||||||
|
|
||||||
return wrap(createAddressSanitizerFunctionPass(CompileKernel, Recover, UseAfterScope));
|
return wrap(createAddressSanitizerFunctionPass(CompileKernel, Recover, UseAfterScope));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
|
extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
const bool CompileKernel = false;
|
const bool CompileKernel = false;
|
||||||
|
|
||||||
return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
|
extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
const bool CompileKernel = false;
|
const bool CompileKernel = false;
|
||||||
|
|
||||||
return wrap(createMemorySanitizerLegacyPassPass(
|
return wrap(createMemorySanitizerLegacyPassPass(
|
||||||
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
|
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
|
extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
return wrap(createThreadSanitizerLegacyPassPass());
|
return wrap(createThreadSanitizerLegacyPassPass());
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMPassRef LLVMRustCreateHWAddressSanitizerPass(bool Recover) {
|
extern "C" LLVMPassRef LLVMRustCreateHWAddressSanitizerPass(bool Recover) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
const bool CompileKernel = false;
|
const bool CompileKernel = false;
|
||||||
|
|
||||||
return wrap(createHWAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
return wrap(createHWAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
|
extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
|
||||||
@ -154,10 +178,57 @@ extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
|
extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
assert(RustPass);
|
assert(RustPass);
|
||||||
Pass *Pass = unwrap(RustPass);
|
Pass *Pass = unwrap(RustPass);
|
||||||
PassManagerBase *PMB = unwrap(PMR);
|
PassManagerBase *PMB = unwrap(PMR);
|
||||||
PMB->add(Pass);
|
PMB->add(Pass);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" LLVMPassManagerBuilderRef LLVMRustPassManagerBuilderCreate() {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
|
return LLVMPassManagerBuilderCreate();
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void LLVMRustPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
|
LLVMPassManagerBuilderDispose(PMB);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void LLVMRustPassManagerBuilderPopulateFunctionPassManager(
|
||||||
|
LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
|
LLVMPassManagerBuilderPopulateFunctionPassManager(PMB, PM);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void LLVMRustPassManagerBuilderPopulateModulePassManager(
|
||||||
|
LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
|
LLVMPassManagerBuilderPopulateModulePassManager(PMB, PM);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void LLVMRustPassManagerBuilderPopulateLTOPassManager(
|
||||||
|
LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM, bool Internalize, bool RunInliner) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
|
LLVMPassManagerBuilderPopulateLTOPassManager(PMB, PM, Internalize, RunInliner);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -165,12 +236,26 @@ void LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
|
|||||||
LLVMPassManagerBuilderRef PMBR,
|
LLVMPassManagerBuilderRef PMBR,
|
||||||
LLVMPassManagerRef PMR
|
LLVMPassManagerRef PMR
|
||||||
) {
|
) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR));
|
unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR));
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void LLVMRustPassManagerBuilderUseInlinerWithThreshold(
|
||||||
|
LLVMPassManagerBuilderRef PMB, unsigned Threshold) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
|
LLVMPassManagerBuilderUseInlinerWithThreshold(PMB, Threshold);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
void LLVMRustAddLastExtensionPasses(
|
void LLVMRustAddLastExtensionPasses(
|
||||||
LLVMPassManagerBuilderRef PMBR, LLVMPassRef *Passes, size_t NumPasses) {
|
LLVMPassManagerBuilderRef PMBR, LLVMPassRef *Passes, size_t NumPasses) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
auto AddExtensionPasses = [Passes, NumPasses](
|
auto AddExtensionPasses = [Passes, NumPasses](
|
||||||
const PassManagerBuilder &Builder, PassManagerBase &PM) {
|
const PassManagerBuilder &Builder, PassManagerBase &PM) {
|
||||||
for (size_t I = 0; I < NumPasses; I++) {
|
for (size_t I = 0; I < NumPasses; I++) {
|
||||||
@ -183,6 +268,9 @@ void LLVMRustAddLastExtensionPasses(
|
|||||||
AddExtensionPasses);
|
AddExtensionPasses);
|
||||||
unwrap(PMBR)->addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
|
unwrap(PMBR)->addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
|
||||||
AddExtensionPasses);
|
AddExtensionPasses);
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LLVM_COMPONENT_X86
|
#ifdef LLVM_COMPONENT_X86
|
||||||
@ -533,12 +621,16 @@ extern "C" void LLVMRustDisposeTargetMachine(LLVMTargetMachineRef TM) {
|
|||||||
extern "C" void LLVMRustConfigurePassManagerBuilder(
|
extern "C" void LLVMRustConfigurePassManagerBuilder(
|
||||||
LLVMPassManagerBuilderRef PMBR, LLVMRustCodeGenOptLevel OptLevel,
|
LLVMPassManagerBuilderRef PMBR, LLVMRustCodeGenOptLevel OptLevel,
|
||||||
bool MergeFunctions, bool SLPVectorize, bool LoopVectorize, bool PrepareForThinLTO,
|
bool MergeFunctions, bool SLPVectorize, bool LoopVectorize, bool PrepareForThinLTO,
|
||||||
const char* PGOGenPath, const char* PGOUsePath, const char* PGOSampleUsePath) {
|
const char* PGOGenPath, const char* PGOUsePath, const char* PGOSampleUsePath,
|
||||||
|
int SizeLevel) {
|
||||||
|
#if LLVM_VERSION_LT(15, 0)
|
||||||
unwrap(PMBR)->MergeFunctions = MergeFunctions;
|
unwrap(PMBR)->MergeFunctions = MergeFunctions;
|
||||||
unwrap(PMBR)->SLPVectorize = SLPVectorize;
|
unwrap(PMBR)->SLPVectorize = SLPVectorize;
|
||||||
unwrap(PMBR)->OptLevel = fromRust(OptLevel);
|
unwrap(PMBR)->OptLevel = fromRust(OptLevel);
|
||||||
unwrap(PMBR)->LoopVectorize = LoopVectorize;
|
unwrap(PMBR)->LoopVectorize = LoopVectorize;
|
||||||
unwrap(PMBR)->PrepareForThinLTO = PrepareForThinLTO;
|
unwrap(PMBR)->PrepareForThinLTO = PrepareForThinLTO;
|
||||||
|
unwrap(PMBR)->SizeLevel = SizeLevel;
|
||||||
|
unwrap(PMBR)->DisableUnrollLoops = SizeLevel != 0;
|
||||||
|
|
||||||
if (PGOGenPath) {
|
if (PGOGenPath) {
|
||||||
assert(!PGOUsePath && !PGOSampleUsePath);
|
assert(!PGOUsePath && !PGOSampleUsePath);
|
||||||
@ -550,6 +642,9 @@ extern "C" void LLVMRustConfigurePassManagerBuilder(
|
|||||||
} else if (PGOSampleUsePath) {
|
} else if (PGOSampleUsePath) {
|
||||||
unwrap(PMBR)->PGOSampleUse = PGOSampleUsePath;
|
unwrap(PMBR)->PGOSampleUse = PGOSampleUsePath;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
report_fatal_error("Legacy PM not supported with LLVM 15");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unfortunately, the LLVM C API doesn't provide a way to set the `LibraryInfo`
|
// Unfortunately, the LLVM C API doesn't provide a way to set the `LibraryInfo`
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "llvm/IR/GlobalVariable.h"
|
#include "llvm/IR/GlobalVariable.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
#include "llvm/IR/Intrinsics.h"
|
#include "llvm/IR/Intrinsics.h"
|
||||||
|
#include "llvm/IR/Mangler.h"
|
||||||
#include "llvm/Object/Archive.h"
|
#include "llvm/Object/Archive.h"
|
||||||
#include "llvm/Object/COFFImportFile.h"
|
#include "llvm/Object/COFFImportFile.h"
|
||||||
#include "llvm/Object/ObjectFile.h"
|
#include "llvm/Object/ObjectFile.h"
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
// compile-flags: -Z panic-in-drop=abort -O -Z new-llvm-pass-manager=no
|
// compile-flags: -Z panic-in-drop=abort -O
|
||||||
|
// ignore-msvc
|
||||||
|
|
||||||
// Ensure that unwinding code paths are eliminated from the output after
|
// Ensure that unwinding code paths are eliminated from the output after
|
||||||
// optimization.
|
// optimization.
|
||||||
|
|
||||||
// This test uses -Z new-llvm-pass-manager=no, because the expected optimization does not happen
|
// This test uses ignore-msvc, because the expected optimization does not happen on targets using
|
||||||
// on targets using SEH exceptions (i.e. MSVC) anymore. The core issue is that Rust promises that
|
// SEH exceptions with the new LLVM pass manager anymore, see
|
||||||
// the drop_in_place() function can't unwind, but implements it in a way that *can*, because we
|
// https://github.com/llvm/llvm-project/issues/51311.
|
||||||
// currently go out of our way to allow longjmps, which also use the unwinding mechanism on MSVC
|
|
||||||
// targets. We should either forbid longjmps, or not assume nounwind, making this optimization
|
|
||||||
// incompatible with the current behavior of running cleanuppads on longjmp unwinding.
|
|
||||||
|
|
||||||
// CHECK-NOT: {{(call|invoke).*}}should_not_appear_in_output
|
// CHECK-NOT: {{(call|invoke).*}}should_not_appear_in_output
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user