Hi I want to replace all the return instructions in the program with pop <reg>; jmp <reg>. 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180809/d4693cb8/attachment.html>
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> 在 2018年8月9日,11:23,PenYiWang via llvm-dev <llvm-dev at lists.llvm.org> 写道: > > Hi > > I want to replace all the return instructions in the program with pop <reg>; jmp <reg>. > > 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 > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
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. ~Craig On Wed, Aug 8, 2018 at 8:31 PM mayuyu.io via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 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 > > > 在 2018年8月9日,11:23,PenYiWang via llvm-dev <llvm-dev at lists.llvm.org> 写道: > > > > Hi > > > > I want to replace all the return instructions in the program with pop > <reg>; jmp <reg>. > > > > 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 > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180808/cee9de01/attachment.html>
Liad Mordekoviz via llvm-dev
2018-Aug-09 07:58 UTC
[llvm-dev] Replace "ret" with "pop+jump"
Hey, Legalization steps in X86ISelLowering.cpp seems like your way to go, perhaps not even legalization and go straight away to LowerReturn. On Thu, Aug 9, 2018 at 6:23 AM, PenYiWang via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi > > I want to replace all the return instructions in the program with pop > <reg>; jmp <reg>. > > 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 > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180809/371027e0/attachment-0001.html>
Seemingly Similar Threads
- Tail call optimization is getting affected due to local function related optimization with IPRA
- Tail call optimization is getting affected due to local function related optimization with IPRA
- Bug 20871 -- is there a fix or work around?
- Tail call optimization is getting affected due to local function related optimization with IPRA
- Vectorizer has trouble with vpmovmskb and store