machine pass


LLVM documentation is not clear. Is it possible to write a machine pass?
I am trying to insert some machine code before the return instruction.
ideally, I’d like a pass that runs the last one before generating assembly.
How can this be done?

Thank you,


Please look at llvm\lib\Target\X86\X86FloatingPointRegKill.cpp as an example on how to write a Machine pass.

In the backend that you want to add the pass to, modify the TargetMachine.cpp file and add the pass to addPreEmitPass()