[llvm-dev] Function - replaceAllUsesWith

Mehdi AMINI via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 14 16:15:42 PST 2019


On Mon, Jan 14, 2019 at 3:21 AM Gaier, Bjoern via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello LLVM-World,
>
>
>
> currently I play around with a „llvm::Module” and an external function
> defined there “puts”. Normally this function gets resolved in the
> JIT-Process but I wonder about two things:
>
>
>
>    1. Can I resolve the function already in this step? I used
>    “replaceAllUsesWith” and passed a “llvm::ConstantInt” to the function. But
>    this didn’t worked.
>
>
I'm not sure if I followed correctly, but you can't replace a function
declaration with a constant int. The value for the function will be used
(mostly) as an argument to the call instruction, which won't really be able
to operate on an int. It isn't clear to me what you're trying to do
exactly, replace the call to puts with an indirect call to the pointer
value that correspond to puts in your current process? You would need to at
least cast this pointer value to the right type, and use an indirect call.

Best,

-- 
Mehdi




>
>    1.
>    2. What might happen if I have two modules and use
>    “replaceAllUsesWith” on a function of Module A, passing a function of
>    Module B.
>
>
>
> Thank you for the help in advance!
>
>
>
> Kind greetings
>
> Björn
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert
> Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima.
> Junichi Tajika
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190114/0be79af6/attachment.html>


More information about the llvm-dev mailing list