Replace "ret" with "pop+jump"

Hi

I want to replace all the return instructions in the program with pop ; jmp .

Should I use IRBuilder in LLVM IR level?

I found that there is a IRBuilder::CreateIndirectBr

Or Should I modify the code in lib/Target/X86/X86ISelLowering.cpp in backend ?

I found that there is a X86TargetLowering::LowerCall

Which is better?

Thanks

IndirectBr only works for Branch instructions, not ret.
The latter one seems likely however I’m no where near a backend expert so I could be wrong : (

Zhang

You might be able to just check for the return instruction in X86AsmPrinter::EmitInstruction where we convert from MachineInstr to MCInst. You can change it to a POP and a JUMP MCInst.

Hey,
Legalization steps in X86ISelLowering.cpp seems like your way to go, perhaps not even legalization and go straight away to LowerReturn.