[LLVMdev] How to prevent an instruction to be executed more than once?
dalej at apple.com
Thu Jun 24 11:00:12 PDT 2010
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
> In this case, I want to mark the beginning of BB4 and then to patch
> 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:
> call void asm "label_BB4:\0A", ""()
> call void asm "jmp label_BB5\0A", ""()
> br label %BB5
You 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
> 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
> 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.
> 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
More information about the llvm-dev