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.
Dale Johannesen
2010-Jun-24 18:00 UTC
[LLVMdev] How to prevent an instruction to be executed more than once?
On Jun 24, 2010, at 7:00 AMPDT, Xinfinity wrote:> > 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 %BB5You can't prevent various optimizations from making multiple copies of asm's. Also, branches from one asm to another, or into or out of an asm, do not work, in general. All of this is the same as gcc. I'm not sure if a branch within the same asm is powerful enough to do what you want, but the way to avoid the duplicate-label problem in that case is to use local labels, "jmp 0f" etc. See gcc description of asm for examples.> 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. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Xinfinity
2011-Feb-07 11:17 UTC
[LLVMdev] How to prevent an instruction to be executed more than once?
As I have seen in the CodeGen phase there is the tail duplication step which duplicates all my inlined asm. However, tail duplication checks for each machine instruction if the description allows duplication or not. /// isNotDuplicable - Return true if this instruction cannot be safely 00363 /// duplicated. For example, if the instruction has a unique labels attached 00364 /// to it, duplicating it would cause multiple definition errors. 00365 bool isNotDuplicable() const { 00366 return Flags & (1 << TID::NotDuplicable); 00367 } Is there a way to mark my instructions as not duplicable and to propagate this description till the machine instruction level? What is the "unique label" attached to an instruction? Thanks. Alexandra. -- View this message in context: http://old.nabble.com/How-to-prevent-an-instruction-to-be-executed-more-than-once--tp28981639p30862596.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Reasonably Related 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] How to prevent an instruction to be executed more than once?
- [RFC] Potential extension to asm statement functionality
- [RFC] Potential extension to asm statement functionality