From c022413023855334a9f7cb6718bc20d00b0c6759 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 2 Oct 2025 17:22:15 +0200 Subject: [PATCH] Enable -disable-i2p-p2i-opt flag --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 2 ++ tests/codegen-llvm/iter-repeat-n-trivial-drop.rs | 3 ++- tests/codegen-llvm/try_question_mark_nop.rs | 4 ++++ tests/codegen-llvm/vec-iter-collect-len.rs | 3 ++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 3b920168e06dc..6d8c52438f77e 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -118,6 +118,8 @@ unsafe fn configure_llvm(sess: &Session) { // Use non-zero `import-instr-limit` multiplier for cold callsites. add("-import-cold-multiplier=0.1", false); + add("-disable-i2p-p2i-opt", false); + if sess.print_llvm_stats() { add("-stats", false); } diff --git a/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs b/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs index 6f34097842800..8e6d757756b92 100644 --- a/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs @@ -47,8 +47,9 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN) -> Option Vec { + // FIXME: Has extra inttoptr + ptrtoint pair // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @{{.*}}__rust_alloc(i64 noundef {{(range\(i64 1, 0\) )?}}1234, i64 noundef {{(range\(i64 1, -9223372036854775807\) )?}}1) - // CHECK: tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1234) %[[ADDR]], i8 42, i64 1234, + // CHECK: tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1234) %[[ADDR2:.+]], i8 42, i64 1234, let n = 1234_usize; let mut v = Vec::with_capacity(n); diff --git a/tests/codegen-llvm/try_question_mark_nop.rs b/tests/codegen-llvm/try_question_mark_nop.rs index a09fa0a49019d..4dfa20c852f84 100644 --- a/tests/codegen-llvm/try_question_mark_nop.rs +++ b/tests/codegen-llvm/try_question_mark_nop.rs @@ -212,6 +212,8 @@ pub fn control_flow_nop_traits_128(x: ControlFlow) -> ControlFlow>) -> Result> { // CHECK: start: + // CHECK-NEXT: ptrtoint + // CHECK-NEXT: inttoptr // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } // CHECK-NEXT: ret @@ -225,6 +227,8 @@ pub fn result_nop_match_ptr(x: Result>) -> Result> #[no_mangle] pub fn result_nop_traits_ptr(x: Result>) -> Result> { // CHECK: start: + // CHECK-NEXT: ptrtoint + // CHECK-NEXT: inttoptr // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } // CHECK-NEXT: insertvalue { i{{[0-9]+}}, ptr } // CHECK-NEXT: ret diff --git a/tests/codegen-llvm/vec-iter-collect-len.rs b/tests/codegen-llvm/vec-iter-collect-len.rs index 807548ef883f5..0666ba8f5fb07 100644 --- a/tests/codegen-llvm/vec-iter-collect-len.rs +++ b/tests/codegen-llvm/vec-iter-collect-len.rs @@ -3,10 +3,11 @@ #[no_mangle] pub fn get_len() -> usize { + // FIXME: Allocation no longer optimized away. // CHECK-LABEL: @get_len // CHECK-NEXT: start: // CHECK-NEXT: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 // CHECK-NEXT: tail call void @_R{{.+}}__rust_no_alloc_shim_is_unstable_v2() - // CHECK-NEXT: ret i{{[0-9]+}} 3 + // CHECK: ret i{{[0-9]+}} 3 [1, 2, 3].iter().collect::>().len() }