File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
rustc_codegen_llvm/src/back Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -370,8 +370,9 @@ fn get_pgo_use_path(config: &ModuleConfig) -> Option<CString> {
370370}
371371
372372pub ( crate ) fn should_use_new_llvm_pass_manager ( config : & ModuleConfig ) -> bool {
373- // The new pass manager is disabled by default.
374- config. new_llvm_pass_manager . unwrap_or ( false )
373+ // The new pass manager is enabled by default for LLVM >= 13.
374+ // This matches Clang, which also enables it since Clang 13.
375+ config. new_llvm_pass_manager . unwrap_or_else ( || llvm_util:: get_version ( ) >= ( 13 , 0 , 0 ) )
375376}
376377
377378pub ( crate ) unsafe fn optimize_with_new_llvm_pass_manager (
Original file line number Diff line number Diff line change @@ -1004,7 +1004,10 @@ LLVMRustOptimizeWithNewPassManager(
10041004#endif
10051005 bool NeedThinLTOBufferPasses = UseThinLTOBuffers;
10061006 if (!NoPrepopulatePasses) {
1007- if (OptLevel == OptimizationLevel::O0) {
1007+ // The pre-link pipelines don't support O0 and require using budilO0DefaultPipeline() instead.
1008+ // At the same time, the LTO pipelines do support O0 and using them is required.
1009+ bool IsLTO = OptStage == LLVMRustOptStage::ThinLTO || OptStage == LLVMRustOptStage::FatLTO;
1010+ if (OptLevel == OptimizationLevel::O0 && !IsLTO) {
10081011#if LLVM_VERSION_GE(12, 0)
10091012 for (const auto &C : PipelineStartEPCallbacks)
10101013 PB.registerPipelineStartEPCallback (C);
Original file line number Diff line number Diff line change 1- // compile-flags: -Z panic-in-drop=abort -O
1+ // compile-flags: -Z panic-in-drop=abort -O -Z new-llvm-pass-manager=no
22
33// Ensure that unwinding code paths are eliminated from the output after
44// optimization.
55
6+ // This test uses -Z new-llvm-pass-manager=no, because the expected optimization does not happen
7+ // on targets using SEH exceptions (i.e. MSVC) anymore. The core issue is that Rust promises that
8+ // the drop_in_place() function can't unwind, but implements it in a way that *can*, because we
9+ // currently go out of our way to allow longjmps, which also use the unwinding mechanism on MSVC
10+ // targets. We should either forbid longjmps, or not assume nounwind, making this optimization
11+ // incompatible with the current behavior of running cleanuppads on longjmp unwinding.
12+
13+ // CHECK-NOT: {{(call|invoke).*}}should_not_appear_in_output
14+
615#![ crate_type = "lib" ]
716use std:: any:: Any ;
817use std:: mem:: forget;
@@ -35,17 +44,13 @@ impl Drop for AssertNeverDrop {
3544 }
3645}
3746
38- // CHECK-LABEL: normal_drop
39- // CHECK-NOT: should_not_appear_in_output
4047#[ no_mangle]
4148pub fn normal_drop ( x : ExternDrop ) {
4249 let guard = AssertNeverDrop ;
4350 drop ( x) ;
4451 forget ( guard) ;
4552}
4653
47- // CHECK-LABEL: indirect_drop
48- // CHECK-NOT: should_not_appear_in_output
4954#[ no_mangle]
5055pub fn indirect_drop ( x : Box < dyn Any > ) {
5156 let guard = AssertNeverDrop ;
You can’t perform that action at this time.
0 commit comments