<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>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):<br><br>define void @function(i32 %i) #0 {<br>entry:<br>  %i.addr = alloca i32, align 4<br>  store i32 %i, i32* %i.addr, align 4<br>  ret void<br>}<br><br></div>to another function which should, after the CloneFunction, be like:<br><br>define void @cloned_function(i32 %i, i8* %ptr) #0 {<br>entry:<br>  %i.addr = alloca i32, align 4<br>  store i32 %i, i32* %i.addr, align 4<br>  ret void<br>}<br><br></div>To do so, I first declared the clone_function with its arguments into the module then I should call CloneFunction like:<br><br></div>Function *function = M.getFunction("function");<br></div>Function *cloned_function = M.getFunction("cloned_function");<br>cloned_function = CloneFunction(<br>    function,<br>    VM,<br>    false /* or true? didn't get the difference */<br>  );<br><div><div><br></div><div>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*>...<br><br></div><div>Thank you for the help,<br></div><div>Pierre<br></div></div></div>