How to disable the specified llvm pass(ArgumentPromotionPass) in rust

For some reason, I want to disable rust static function parameter optimization. Here's an example:

fn rust_function_base032_local(dat: &mut i32) -> i32 {
    println!("\t[bin] test_function_base032_local");
    *dat + 1
pub fn rust_function_base032() -> i32 {
    println!("\t[same] test_function_base032");
    let mut dat = 9;
    rust_function_base032_local(&mut dat)

We can see the argument of a static function rust_function_local is a pointer. But The parameter in the final ir generated by rust is optimized to i32.

define internal fastcc noundef i32 @_RNvCsbR6APES6H5u_13paramopt_test27rust_function_base032_local(i32 %dat.0.val)

I use -C no-prepopulate-passes view the LLVM IR that rustc generates, not the LLVM IR after optimizations´╝îThe parameter in the original ir generated by rustc is not optimized and is a pointer.

define internal noundef i32 @_RNvCsbR6APES6H5u_13paramopt_test27rust_function_base032_local(ptr noalias noundef align 4 dereferenceable(4) %dat)

Then I use "-Cllvm-args=-print-after-all","-Cllvm-args=-filter-print-funcs=_RNvCsbR6APES6H5u_13paramopt_test27rust_function_base032_local" view the llvm optimization process, The pass that causes parameter optimization is found. The pass name is ArgumentPromotionPass.

define internal fastcc noundef i32 @_RNvCsbR6APES6H5u_13paramopt_test27rust_function_base032_local(ptr noalias noundef align 4 dereferenceable(4) %dat) unnamed_addr #0 {
*** IR Dump After ArgumentPromotionPass on (_RNvCsbR6APES6H5u_13paramopt_test27rust_function_base032_local) ***
; Function Attrs: noinline uwtable
define internal fastcc noundef i32 @_RNvCsbR6APES6H5u_13paramopt_test27rust_function_base032_local(i32 %dat.0.val) unnamed_addr #0 {

Is there any option in rust to disable this llvm pass separately?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.