The parameters of the static function in rust have been optimized. Is there a way to disable this feature

I want to implement rust's hot patch mechanism, but I find that the parameters of static functions in rust will be optimized.
Take a look at the following example:

#[inline(never)]
fn rust_function_local(dat: &mut i32) -> i32 {
    println!("\t[bin] test_function_base032_local");
    *dat + 1
}

pub fn rust_function_base032() -> i32 {
    let mut dat = 9;
    rust_function_base032_local(&mut dat)
}

From the function prototype, wo can see the argument of a static function rust_function_local is a pointer .

I compile with cargo build --release and specify the --emit=llvm-ir compilation option in the config file to generate the llvm-ir file.

According to the llvm-ir file, the parameter of the static function rust_function_local is optimized to i32.

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

If I add pub before a static function, the parameters of the function will not be optimized.

#[inline(never)]
pub fn rust_function_local(dat: &mut i32) -> i32 { //add pub
    println!("\t[bin] test_function_base032_local");
    *dat + 1
}

pub fn rust_function_base032() -> i32 {
    let mut dat = 9;
    rust_function_base032_local(&mut dat)
}

After compiling in the same way, you can see from llvm-ir that the parameter is not optimized, but a pointer.

define noundef i32 @_RNvNtNtCsloQ4vc48znw_7binfunc10rust_basic15rust_basic_test19rust_function_local(ptr noalias nocapture noundef readonly align 4 dereferenceable(4) %dat)

The same phenomenon also occurs in the static member functions of the structure.

struct LocalCustomNamedStruct {
    width: u32,
    height: u32,
}
impl LocalCustomNamedStruct {
    #[inline(never)]
    fn get_area(&mut self) -> u32 {
        println!("\t[bin] LocalCustomNamedStruct get_area");
        self.width + self.height
    }
}
pub fn rust_customtype_base010() -> u32 {
    println!("\t[same] rust_customtype_base010");
    let mut p = LocalCustomNamedStruct {
        width: 1,
        height: 2
    };
    p.get_area()
}

The parameters of the static member function are optimized to be two i32, which should theoretically be a pointer.

define internal fastcc noundef i32 @_RNvMNtNtCsloQ4vc48znw_7binfunc10rust_basic15rust_basic_testNtB2_22LocalCustomNamedStruct8get_area(i32 %self.0.val, i32 %self.4.val)

If I write to a pointer variable in a static function, the parameter is a pointer, and no optimization occurs.

struct LocalCustomNamedStruct {
    width: u32,
    height: u32,
}
impl LocalCustomNamedStruct {
    #[inline(never)]
    fn get_area(&mut self) -> u32 {
        println!("\t[bin] LocalCustomNamedStruct get_area");
        self.width = 12; //add this line
        self.width + self.height
    }
}
pub fn rust_customtype_base010() -> u32 {
    println!("\t[same] rust_customtype_base010");
    let mut p = LocalCustomNamedStruct {
        width: 1,
        height: 2
    };
    p.get_area()
}

define internal fastcc noundef i32 @_RNvMNtNtCsloQ4vc48znw_7binfunc10rust_basic15rust_basic_testNtB2_22LocalCustomNamedStruct8get_area(ptr noalias nocapture noundef align 4 dereferenceable(8) %self)

I'd like to ask two questions,These optimizations cause some problems to hot patches. Patch installation requires that the parameters and return values of functions do not change.
1、Does this optimization of parameters or return values occur only in static functions?
2、Is there any compilation option to turn off the optimization of such parameters or return values?

Just to be sure, are you aware that there is no stable rust abi?

As far as I remember, using #[no_mangle] should fulfill your needs but in an undocumented non-guaranteed way.

Is there any compilation option to disable the optimization of these parameters and return values when opt-level=3 without modifying the source code? I find that most parameter optimizations are disabled after opt-level=2. Is there any compilation option with more granularity?

If there is no option to turn off, is there an option to print out the function whose parameters are optimized or whose return values are optimized?

Maybe this helps

https://doc.rust-lang.org/rustc/codegen-options/index.html#inline-threshold

Oh,Thanks. The LLVM pass that causes parameter optimization is found. The pass name is ArgumentPromotionPass . Is there any option in rust to disable this llvm pass separately?