[llvm-dev] Function - replaceAllUsesWith
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Mon Jan 14 04:48:17 PST 2019
On Mon, 14 Jan 2019 at 11:21, Gaier, Bjoern via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> 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.
In general it's good to tell us why something didn't work (error
messages, assertions etc). In this case I'd guess it's because the
types don't match up: you probably have to wrap your int in a
ConstantExpr::getPointerCast to the same type you're replacing.
> What might happen if I have two modules and use “replaceAllUsesWith” on a function of Module A, passing a function of Module B.
Nothing good. You have to copy the function (and its dependencies)
into the new module yourself. CloneFunction will probably be helpful
there, or maybe just linking the modules together.
More information about the llvm-dev