Re moving the instrumented instructions at runtime

Hello,

I have some questions about removing the instrumented instructions at
runtime.

Assume I instrument some instructions by using some transformation passes.
At runtime, I just need those instrumented instructions at the beginning,
and I would like to remove instrumented instructions at runtime to reduce
overhead.

Does anyone know how to do this by using LLVM?

Thanks,

Bo

Assume I instrument some instructions by using some transformation passes.
At runtime, I just need those instrumented instructions at the beginning,
and I would like to remove instrumented instructions at runtime to reduce
overhead.

  At the beginning of what? You mean at the time of program starup? Then
after detecting/collecting whatever you want, you would like to remove
those instrumented instructions?

  I think you insert those instrumented instructions in LLVM IR, then
leave LLVM to generate the host binary, right? If so, I think it's hard
to remove those instrumented instructions.

  However, you can switch on/off instrument by, say, skipping those
instrumented instructions at runtime. I mean you can patch a "jump addr"
to by pass those instrumented instructions at runtime.

HTH,
chenwj

Hello Wei-Ren,

Thank you for your reply and suggestion. I mean that I use these
instrumented instructions at the beginning of the program executions to
collect some information. And after that, to reduce the overhead, we hope to
remove these instrumented instructions at runtime. I want to know whether
LLVM can modify the binary codes at runtime.

Bo

Chen Wei-Ren (陳韋任) wrote:

Thank you for your reply and suggestion. I mean that I use these
instrumented instructions at the beginning of the program executions to
collect some information. And after that, to reduce the overhead, we hope to
remove these instrumented instructions at runtime. I want to know whether
LLVM can modify the binary codes at runtime.

  As I replied before, I think LLVM cannot modify the binary at runtime.
But I leave others for comments. :slight_smile:

Regards,
chenwj