Is there a way to prevent the LLVM IR from being thrown out by removing unused features?

I am trying to analyze the LLVM-IR emitted by an interface rustc. The plan is to emit IR for certain language elements. Is there such a list of elements and pattern matching for IR codes or a list?

The compiler is smart enough to remove unused functions in the emitted infrared mode: unless something has been printed on the console with println!, the compiler deletes each used function.

This also does not work, saying that xit is not used anywhere, and also when overwriting x.

let x = function();

Is there any determinant in Rust so that the emitted IR retains all the functions?

+4
source share
1 answer

Is there such a list of elements and a display or a list of IR code templates?

Code rustc.

It may seem like a tongue in the cheek, but in fact it is the only answer available.

Rust ABI is unstable because Rust developers want to keep the ability to change these things when a more efficient way to do them appears.

This applies to representing structures in memory, to calling conventions, etc.

Is there any determinant in Rust so that the emitted IR retains all the functions?

The easiest way to save a function:

  • compilation as a library and function marking pub

#[inline(never)], , , . .

+4

Source: https://habr.com/ru/post/1669259/


All Articles