Casper Sun via llvm-dev
2019-Nov-28 05:16 UTC
[llvm-dev] How to write LLVM backend pass after every LLVM's internal pass?
Currently I’m writing a X86 backend pass for my research project. I inserted a few instructions in MachineBasicBlocks, but then llc optimized my code, and deleted some of it. So how to so backend pass after all machine level optimizations?
Nicholas Krause via llvm-dev
2019-Nov-28 06:02 UTC
[llvm-dev] How to write LLVM backend pass after every LLVM's internal pass?
On 11/28/19 12:16 AM, Casper Sun via llvm-dev wrote:> Currently I’m writing a X86 backend pass for my research project. I inserted a few instructions in MachineBasicBlocks, but then llc optimized my code, and deleted some of it. So how to so backend pass after all machine level optimizations? > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-devI don't have enough details to really help out here but my first assumption is that costs of selections are being merged in the llc. You should note that's normal and generally a good thing or other forms of combining or merging instructions in the llc. So based on that I'm curious as to why your concerned about the llc deleted parts of it, Nick
Nicholas Krause via llvm-dev
2019-Nov-28 16:17 UTC
[llvm-dev] How to write LLVM backend pass after every LLVM's internal pass?
On 11/28/19 2:06 AM, Casper Sun wrote:> Because I need to use reverse engineering to patched generated binary. But llc deleted some function call I injected, so I couldn’t find these instructions in radare2(reverse engine I used to patch binary). > > For example: > Mov edi, 0x1 mov edi, 0x2 > | | > | | > V V > Call func call func > > Will be opted into: > > Mov edi, 0x1. Mov edi, 0x2 > | | > | <—————— > V > Call func > > I write my MachineFunctionPass in lib/Targets/X86 directory. Will lib/CodeGen optimize my injected code? >If I understand your diagram yes as those are basically the same instructions excluding moving at 0x1 address versus 0x2 address. Combining would be normal here if and to my knowledge x86 can do mov with two addresses. What you want to figure out is how to inject earlier probably in the middle end and then trace it to see if the instructions are similar enough to be doing this. Nick> >> On Nov 28, 2019, at 2:02 PM, Nicholas Krause <xerofoify at gmail.com> wrote: >> >> >> >> On 11/28/19 12:16 AM, Casper Sun via llvm-dev wrote: >>> Currently I’m writing a X86 backend pass for my research project. I inserted a few instructions in MachineBasicBlocks, but then llc optimized my code, and deleted some of it. So how to so backend pass after all machine level optimizations? >>> _______________________________________________ >>> LLVM Developers mailing list >>> llvm-dev at lists.llvm.org >>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> I don't have enough details to really help out here but my first assumption is that costs of selections are being merged in the llc. >> You should note that's normal and generally a good thing or other forms of combining or merging instructions in the llc. >> >> So based on that I'm curious as to why your concerned about the llc deleted parts of it, >> >> Nick
Maybe Matching Threads
- [LLVMdev] Virtual register problem in X86 backend
- [LLVMdev] Virtual register problem in X86 backend
- [LLVMdev] [LLVMDev] [Modeling] About the structure of my allocator
- [LLVMdev] [LLVMDev] [Modeling] About the structure of my allocator
- [LLVMdev] [LLVMDev] [Modeling] About the structure of my allocator