[llvm-dev] Added AllocaInsts are relocated in stack

sam djafari via llvm-dev
Thu, 20 Sep 2018 20:37:34 -0000

Hi there,

I am wondering how I can prevent the LLVM from re-ordering the added local
variables during instrumentation?
Because, during the instrumentation, I add some metadata to some local
variables, exactly next to it, and the generated bitcode looks good.
However, when it is executed, basically the stack is formed as all original
local variables are located next to each other, and then all the metadata
is inserted. In other words, I was expecting to have "data, metadata, data,
metadata", however, I was seeing "data, data, metadata, metadata"
in the
actual stack.

Investigating into this problem, I realized that when printing the
instruction instance (errs() << AI << "\n"), there is a
numbering for each
AllocaInst. However, the newly-added AllocaInsts, during instrumentation,
are having a way higher number than the original AllocaInsts', and I guess
that is why all the original local variables are first located in the
stack, and then the metadata that I added are inserted into the stack.

I am wondering how I can prevent LLVM from doing re-ordering them, or even
reset the AllocaInst numbers, so the newly added AllocaInst can be inserted
between the existing and original local variables?

Look forward to hearing from you.
Best regards,
Saman
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20180920/46d50b52/attachment.html>