Xinfinity
2010-Jun-24 11:54 UTC
[LLVMdev] How to prevent an instruction to be executed more than once?
Hi LLVM-devs, I am looking for a way to prevent an instruction to be executed more than once, or duplicated .. I know that by default everything can be duplicated, but is there a work-around? The structure of the code is BB1 BB2 | | | | | | |----------| | v BB3 where the first instruction in BB3 is inserting an inline assembly which contains a newly defined label: call void asm "BB4_label:\0A", ""() I want to find a way to have this instruction executed only once. The problem is that in the optimisation steps, LLVM duplicates BB3 and concatenates it with BB1 and with BB2, therefore the label is defined twice, which gives an error. Is it possible to do this, without having to modify the back-end of LLVM ? Thanks, Alexandra -- View this message in context: http://old.nabble.com/How-to-prevent-an-instruction-to-be-executed-more-than-once--tp28981639p28981639.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Alistair Lynn
2010-Jun-24 12:09 UTC
[LLVMdev] How to prevent an instruction to be executed more than once?
Hello- Doing control-flow (jumps and/or labels) in inline asm is a really bad idea. What are you trying to achieve? Alistair On 24 Jun 2010, at 12:54, Xinfinity wrote:> > Hi LLVM-devs, > > I am looking for a way to prevent an instruction to be executed more than > once, or duplicated .. I know that by default everything can be duplicated, > but is there a work-around? > > The structure of the code is > BB1 BB2 > | | > | | > | | > |----------| > | > v > BB3 > > where the first instruction in BB3 is inserting an inline assembly which > contains a newly defined label: > > call void asm "BB4_label:\0A", ""() > > I want to find a way to have this instruction executed only once. The > problem is that in the optimisation steps, LLVM duplicates BB3 and > concatenates it with BB1 and with BB2, therefore the label is defined twice, > which gives an error. > > Is it possible to do this, without having to modify the back-end of LLVM ? > > Thanks, > Alexandra > > -- > View this message in context: http://old.nabble.com/How-to-prevent-an-instruction-to-be-executed-more-than-once--tp28981639p28981639.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Xinfinity
2010-Jun-24 14:00 UTC
[LLVMdev] How to prevent an instruction to be executed more than once?
I need to mark the beginning of some regions of code, that I want to patch at runtime. In this case, I want to mark the beginning of BB4 and then to patch the jumps, because I want to temporarily change the flow at runtime and then to restore the previous version. In order to patch, I need to know the exact structure of the generated code. So, I might have a BasicBlock like: BB4: call void asm "label_BB4:\0A", ""() call void asm "jmp label_BB5\0A", ""() br label %BB5 and in the generated code the br label %BB5 will actually never be reached. But I introduce the jmp in inline asm in hexa code with .byte in order to control if it is a long or a short jump and to know how many bytes to patch. I tried to keep it short, please let me know if it is not clear enough. Mainly, what I need to know statically is the beginning of the code contained in the BasicBlock BB4 and the size of jump, in the generated code. Alexandra -- View this message in context: http://old.nabble.com/How-to-prevent-an-instruction-to-be-executed-more-than-once--tp28981639p28982790.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Maybe Matching Threads
- [LLVMdev] How to prevent an instruction to be executed more than once?
- [LLVMdev] How to prevent an instruction to be executed more than once?
- [LLVMdev] Copy Instruction from one Basic block to another
- [LLVMdev] How to prevent an instruction to be executed more than once?
- [LLVMdev] Fwd: Order of Basic Blocks