[llvm-dev] clone function
Pierre Gagelin via llvm-dev
llvm-dev at lists.llvm.org
Thu Jul 14 07:58:35 PDT 2016
Hi,
I am trying to use the CloneFunction from llvm/Transforms/Utils/Cloning.h
and I don't understand how the ValueToValueMapTy argument should be
initialized. For instance, let say I want to clone this function (to add an
argument):
define void @function(i32 %i) #0 {
entry:
%i.addr = alloca i32, align 4
store i32 %i, i32* %i.addr, align 4
ret void
}
to another function which should, after the CloneFunction, be like:
define void @cloned_function(i32 %i, i8* %ptr) #0 {
entry:
%i.addr = alloca i32, align 4
store i32 %i, i32* %i.addr, align 4
ret void
}
To do so, I first declared the clone_function with its arguments into the
module then I should call CloneFunction like:
Function *function = M.getFunction("function");
Function *cloned_function = M.getFunction("cloned_function");
cloned_function = CloneFunction(
function,
VM,
false /* or true? didn't get the difference */
);
The question is how should I setup VM so that the job is correctly done? I
assumed I had to link arguments from function to their equivalent in
cloned_function but I don't see why VM should contain pair<Value*, WeakVH>
instead of pair<Value*, Value*>...
Thank you for the help,
Pierre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160714/6bb51498/attachment.html>
More information about the llvm-dev
mailing list