Using custom LLVM calling conventions with Rust FFI

I’m working on using rust for an instrumentation library. Currently I have functions like this:

#[no_mangle]
pub extern "C" fn __measure_instruction(
    arg: u32,
    arg2: u32,
    arg3: u32
){}

This works fine when I compile the program and instrumentation together. However, I want to call this instrumentation from binaries without making any register use assumptions. Ideally I want to use the PreserveAll LLVM calling convention so only a limited set of registers need to be saved. I noticed that no Rust call convention entry exists for PreserveAll, is this something I can override or does the Rust compiler need to be modified to add support for PreserveAll?

You’d need to modify the compiler.

You can post this on internals to get some feedback here

You can see how the AVR fork implements the "avr-interrupt" calling convention.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.