<div dir="ltr"><div><div><div><div><div><div>Dear all,<br><br></div>I am very new to LLVM. I run into a problem when changing the parameter type and return type of a function. I do it in the following way:<br><br> Step 1: create a new function type with new return type and new parameter type<br><div> <br></div><div> Step 2: map old parameters to new parameters with new type, and add the mapping to VMap<br></div><div> <br></div><div> Step3: for each old instruction in the function body which requires a new type, I create a new instruction with new type, and add the mapping to VMap<br><br></div>
Step4:using ClondFunctionInto(new_fun, old_fun, VMap, true, Returns) to copy the body of the old
function to the new function, with all values in the VMap replaced with
its new version.<br><br></div>Then I got the following error:<br><br>/llvm/lib/Transforms/Utils/ValueMapper.cpp:444: void llvm::RemapInstruction(llvm::Instruction*, llvm::ValueToValueMapTy&, llvm::RemapFlags, llvm::ValueMapTypeRemapper*, llvm::ValueMaterializer*): Assertion `(Flags & RF_IgnoreMissingEntries) && "Referenced value not in value map!"' failed.<br><br></div>Is Step3 correct? Since the document of CloneFunctionInto() said "<span class="gmail-comment">Clone OldFunc into NewFunc, transforming the old arguments into references to</span><span class="gmail-comment"> VMap values.</span>" Could I also transform the old instructions in the function body to new ones in the VMap?<br><br></div>Thank you very much :)<br><br></div>Sincerely,<br></div>Suhua<br><div><div><div><span class="gmail-comment"></span><div><div><div><br></div></div></div></div></div></div></div>