<div dir="ltr">Hi Daniel,<div><br></div><div>when and where are you getting that error? Can you paste the full code?</div><div><br></div><div>Cheers,</div><div>Philip</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 6, 2018 at 2:11 AM Daniel Moya <<a href="mailto:danielmscr1994@gmail.com">danielmscr1994@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Philip,<div><br></div><div>Thanks for the reference, I was able to follow it and copy the code that I saw necessary, but I still have some issues (references are still not updated). I created the function:</div><div><br></div><div><div>void populateVMap(llvm::ValueToValueMapTy &VMap, llvm::Function *fOld, llvm::Function *fNew) {</div><div>  llvm::Function::arg_iterator DestI = fOld->arg_begin();</div><div>  for (llvm::Function::const_arg_iterator J = fNew->arg_begin(); J != fNew->arg_end();</div><div>       ++J) {</div><div>    DestI->setName(J->getName());</div><div>    VMap[&*J] = &*DestI++;</div><div>  }</div></div><div>}</div><div><br></div><div>The same as in <b>CloneModule</b>, then I have this code:</div><div><br></div><div><div>llvm::Function *fNew = nMod->getFunction(nFName);</div><div>llvm::Function *fOld = oMod->getFunction(oFName);</div><div><br></div><div>fOld->dropAllReferences();</div><div>fOld->deleteBody();</div><div><br></div><div>llvm::ValueToValueMapTy VMap;</div><div>populateVMap(VMap, fOld, fNew);</div><div>bool ModuleArg = true;</div><div>llvm::SmallVector<llvm::ReturnInst*, 8> Returns;</div><div>llvm::CloneFunctionInto(fOld, fNew, VMap, ModuleArg, Returns);</div><div>if (fNew->hasPersonalityFn())</div><div>   fOld->setPersonalityFn(llvm::MapValue(fNew->getPersonalityFn(), VMap));</div></div><div><br></div><div>But after running the code, I still get the error: <b>Use still stuck around after Def is destroyed</b></div><div><br></div><div>Which means that the instructions moved from <b>fNew</b> still refer to the arguments of <b>fNew</b> instead of the "mapped" (supposedly) ones in <b>fOld</b>. I have some ideas of what could be going on:</div><div><ol><li>I'm not populating correctly the VMap argument, although I wouldn't know how to do it differently since I literally copied it from the <b>CloneModule</b>.</li><li>I have to still add more instruction either before or after <b>CloneFunctionInto</b>, for example in <b>CloneModule</b> they call the function [copyComdat](<font color="#1155cc"><u><a href="http://llvm.org/doxygen/CloneModule_8cpp.html#a04b8f04da3f1b0bf1c9a2802f73e2d05" target="_blank">http://llvm.org/doxygen/CloneModule_8cpp.html#a04b8f04da3f1b0bf1c9a2802f73e2d05</a></u></font>), but I don't know if it's necessary (I guess no because it's only defined in CloneModule.cpp), they also iterate over global alias and functions, but since I'm only concerned in the arguments of one function, I guess I don't have to worry about that.</li><li>Perhaps what you mentioned before "Only operations across LLVMContexts are tricky" has something to do, because the operation is between modules of different files, I'm guessing they have different Contexts too, what could be done in this case?</li></ol><div>Finally, I also tried moving the BasicBlocks manually and got the same error "Use still stuck..", and then tried calling llvm::RemapFunction afterwards with the populated VMap, but always got the error:</div></div><div><br></div><div>Assertion `(Flags & RF_IgnoreMissingLocals) && "Referenced value not in value map!"' failed<br></div><div><br></div><div>Which left me clueless since the mapping worked in the <b>CloneFunctionInto</b> (the program executed fine, the error "Use still stuck" happened at the program's end) but not in this <b>RemapFunction</b>. Anyways, I believe <b>CloneFunctionInto</b> should do this remap work so I shouldn't have to call <b class="m_1402287407233019456gmail-">RemapFunction</b>. Any guideline would be greatly appreciated, it has been a long suffering.</div><div><br></div><div>Regards,</div><div>Daniel Moya</div><div><br></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">El mié., 5 de sep. de 2018 a la(s) 11:15, Philip Pfaffe (<a href="mailto:philip.pfaffe@gmail.com" target="_blank">philip.pfaffe@gmail.com</a>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi Daniel,<div><br></div><div>the implementation of [CloneModule](<a href="http://llvm.org/doxygen/CloneModule_8cpp_source.html" target="_blank">http://llvm.org/doxygen/CloneModule_8cpp_source.html</a>) should be a good example. Generally all you need to do in your case is map old arguments to new arguments.</div><div><br></div><div>Cheers,</div><div>Philip</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 4, 2018 at 1:18 PM Daniel Moya <<a href="mailto:danielmscr1994@gmail.com" target="_blank">danielmscr1994@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Philip,<div><br></div><div>Thank you very much for your answer, the vector declaration example worked. I'm pretty sure the ValueToValueMapTy is the last thing I need because I even saw there is another function that could help me <a class="m_1402287407233019456m_328043379647728013m_-176443912390404052el" href="http://llvm.org/doxygen/namespacellvm.html#addf0183e92893bdbcde00fc9091dda93" style="color:rgb(70,101,162);font-weight:bold;text-decoration-line:underline;font-family:Roboto,sans-serif;font-size:14px" target="_blank">llvm<font color="#4665a2" face="Roboto, sans-serif"><span style="font-size:14px"><b><u>:</u></b></span></font>:RemapFunction</a>; but my problem is that I don't know how to populate the ValueToValueMapTy (VMap) and I couldn't find a single complete example on the internet. To begin with, as the name implies (and also from some errors that I got) the ValueToValueMapTy takes a std::pair<llvm::Value, llvm::Value>, but what I need is to map the arguments (llvm::Attribute) of both functions (the first argument of foo2 is equivalent to the first argument of foo3, and so on), however, apparently there's no transformation from a llvm::Attribute to a llvm::Value. I'm using the function <a class="m_1402287407233019456m_328043379647728013m_-176443912390404052el" href="http://llvm.org/doxygen/classllvm_1_1Function.html#ab2a5fc8baaee7e74dbe47d848508745a" style="color:rgb(70,101,162);font-weight:bold;font-family:Roboto,sans-serif;font-size:14px" target="_blank">getAttribute</a><span style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;background-color:rgb(249,250,252)"> (</span><a class="m_1402287407233019456m_328043379647728013m_-176443912390404052el" href="http://llvm.org/doxygen/classunsigned.html" style="color:rgb(70,101,162);font-weight:bold;font-family:Roboto,sans-serif;font-size:14px" target="_blank">unsigned</a><span style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;background-color:rgb(249,250,252)"> i, </span><a class="m_1402287407233019456m_328043379647728013m_-176443912390404052el" href="http://llvm.org/doxygen/classllvm_1_1StringRef.html" style="color:rgb(70,101,162);font-weight:bold;font-family:Roboto,sans-serif;font-size:14px" target="_blank">StringRef</a><span style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;background-color:rgb(249,250,252)"> </span><a class="m_1402287407233019456m_328043379647728013m_-176443912390404052el" href="http://llvm.org/doxygen/ARMAsmParser_8cpp.html#a5ec5335889cd241b0ccfd4e4e58cf52e" style="color:rgb(70,101,162);font-weight:bold;font-family:Roboto,sans-serif;font-size:14px" target="_blank">Kind</a><span style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;background-color:rgb(249,250,252)">) </span><a class="m_1402287407233019456m_328043379647728013m_-176443912390404052el" href="http://llvm.org/doxygen/AArch64PromoteConstant_8cpp.html#a90f8350fecae261c25be85d38b451bff" style="color:rgb(70,101,162);font-weight:bold;font-family:Roboto,sans-serif;font-size:14px" target="_blank">const</a> to get the attributes, but I don't even understand why is it required to give the <a class="m_1402287407233019456m_328043379647728013m_-176443912390404052el" href="http://llvm.org/doxygen/classllvm_1_1StringRef.html" style="color:rgb(70,101,162);font-weight:bold;font-family:Roboto,sans-serif;font-size:14px" target="_blank">StringRef</a><span style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;background-color:rgb(249,250,252)"> </span><a class="m_1402287407233019456m_328043379647728013m_-176443912390404052el" href="http://llvm.org/doxygen/ARMAsmParser_8cpp.html#a5ec5335889cd241b0ccfd4e4e58cf52e" style="color:rgb(70,101,162);font-weight:bold;font-family:Roboto,sans-serif;font-size:14px" target="_blank">Kind</a> if what I need is just the attribute of the function in the <b>i </b>position. I'm really thankful for the quick responses and for the attention received. </div><div><br></div><div>Regards,</div><div>Daniel Moya</div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">El lun., 3 de sep. de 2018 a la(s) 18:42, Philip Pfaffe (<a href="mailto:philip.pfaffe@gmail.com" target="_blank">philip.pfaffe@gmail.com</a>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi Daniel,<div><br></div><div>CloneFunctionInto wants to tell you about the new ReturnInstructions it produced, you're expected to pass a vector for this purpose. You're free to ignore these values, though, but you still have to pass that vector:  SmallVector<ReturnInst*, 8> Returns;</div><div><br></div><div>For the argument remapping, you're supposed to pre-populate the VMap you pass with the appropriate argument-to-argument mapping.</div><div><br></div><div>It's perfectly fine to use CloneFunctionInto across modules, btw. Only operations across LLVMContexts are tricky.</div><div><br></div><div>Cheers,</div><div>Philip</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Sep 3, 2018 at 6:31 PM Daniel Moya via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Thank you Ahmad,</div><div><br></div><div>I figured out that, although the type of both p(oInst) and p(nInst) were the same, I had to:</div><div><br></div>for (unsigned int i = 0; i < callOInst->getNumArgOperands(); i++) { callOInst->getArgOperand(i)->mutateType(callNInst->getArgOperand(i)->getType()); }</div><div dir="ltr"><br></div><div>that solves the issue at the calling instruction in the main function, but now I see that <b>linkModules</b> does not work for me (it's a mess to bring all the other unnecessary functions from the reference module) so what I need is to directly move one function from one module to another one. I'm still facing the issue with the <b>llvm::SmallVectorImpl< llvm::ReturnInst *> &Returns </b>argument for the <b>CloneFunctionInto, </b>can anyone please give an example of use of that function? I guess that's the only way because otherwise if I move the blocks from foo3 in the refModule to the oldModule, the references of the moved block still point to the arguments of foo3 defined in the refModule, and I don't know how to go instruction by instruction in all the moved blocks and correct the reference to point to the arguments in the oldModule's new function, this also sounds very messy and complicated. <br></div><div><br></div><div><br></div><div>Regards,</div><div>Daniel Moya<br></div><div><b></b></div><div dir="ltr"><div><br></div><div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">El dom., 2 de sep. de 2018 a la(s) 23:18, Ahmad Nouralizadeh Khorrami (<a href="mailto:ahmad.llvm@gmail.com" target="_blank">ahmad.llvm@gmail.com</a>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Daniel,<div>The answer was for your first thread. The benefits are outlined in the repository, but your problem is still there. I'm not sure. But this looks similar to my recent problem. I think that a bitcast will solve the problem. The types after the linking process may have different names but the same contents. The links to the answers are as follows:</div><div><a href="http://lists.llvm.org/pipermail/llvm-dev/2018-August/125413.html" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2018-August/125413.html</a><br></div><div><a href="https://stackoverflow.com/questions/51894129/convert-function-pointer-call-to-function-call-at-the-ir-level" target="_blank">https://stackoverflow.com/questions/51894129/convert-function-pointer-call-to-function-call-at-the-ir-level</a><br></div><div>Regards.</div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, 2 Sep 2018 at 23:30, Daniel Moya <<a href="mailto:danielmscr1994@gmail.com" target="_blank">danielmscr1994@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Ahmad,<div><br></div><div>What does that tool does besides what LLVM linker already does? I don't think my problem is in linking both modules, I think LLVM linker does the job for me, the issue is when changing the called function to call another function (in the example previously provided, to change it from foo2 to foo3, and adjusting the function parameter's references).</div><div><br></div><div>Regards,</div><div>Daniel Moya</div></div><br><div class="gmail_quote"><div dir="ltr">El dom., 2 de sep. de 2018 a la(s) 17:00, Ahmad Nouralizadeh Khorrami (<a href="mailto:ahmad.llvm@gmail.com" target="_blank">ahmad.llvm@gmail.com</a>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi.<div>Besides the LLVM linker, you can also use this tool:</div><div><a href="https://github.com/travitch/whole-program-llvm" target="_blank">https://github.com/travitch/whole-program-llvm</a><br></div><div>It links all the modules and produces a single module containing every function.</div><div>Regards.</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, 2 Sep 2018 at 16:57, Daniel Moya via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello and thanks for the answer,<div><br></div><div>I'm still facing issues, I'll do my best to explain my situation, as I explained, I have two modules, each one with its own main and functions, I would like to replace in the <b>oldModule</b> a function call that is calling <b>foo2</b> (defined in <b>oldModule</b>) to instead call <b>foo3</b>, which is defined in the <b>refModule.  </b>So in summary, I have:</div><div><ol><li>The original instruction call, defined in the main function of the oldModule, who is a calling function to foo2, I'll name it <b>oInst </b>(original Instruction)</li><li>The "new" instruction call, defined in the main function of the refModule, who is a calling function to foo3, I'll name it <b>nInst</b> (new Instruction)</li><li>The foo2 function definition, defined in the oldModule, I'll name it <b>oFunc </b>(original Function)</li><li>The foo3 function definition, defined in the refModule, I'll name it <b>nFunc</b> (new Function)</li><li>I have the parameters (or arguments?) of both functions, both in the calling instruction and in the function's definition, which I'll refer to as <b>p(oInst)</b>, <b>p(nInst)</b>, <b>p(oFunc)</b>, <b>p(nFunc) </b>(the parameters of)</li><li>For testing purposes, both foo2 and foo3 and defined identical, same returning type, parameter's type and even the same variable's name in the IR.</li></ol><div>So after calling the <b>llvm::LinkerlinkModules</b> function, I did:</div><div><br></div><div>1. First attempt: </div><div><ol><li>llvm::CallInst *callOInst = static_cast<llvm::CallInst*>(oInst);  // I cast the<b> oInst</b> to a llvm::CallInst<br></li><li>callOInst->setCalledFunction(nFunc); // now <b>oInst</b> should call nFunc<br></li></ol><div>Error: </div><div>Call parameter type does not match function signature!</div></div><div>%0 = load i32, i32* %a, align 4</div><div>i32 %call1 = call i32 @foo3(i32 %0, i32 %1)</div><div><br></div><div>So even though the parameters are the same type, and defined identically in both modules, the <b>p(oInst)</b> apparently does not match the <b>p(nFunc)</b>. </div><div><br></div><div>2. Second attempt:</div><div><div><ol><li>llvm::Instruction *nCloneInst = nInst->clone(); //Clone of the <b>nInst</b>, to avoid remove it from the refModule<br></li><li>nCloneInst->insertAfter(oInst); // I'll bring the nInst because I know <b>p(nInst)</b> and <b>p(nFunc)</b> match<br></li><li>nCloneInst->mutateType(oInst->getType()); //Idk why I have to this, but necessary for next line<br></li><li>oInst->replaceAllUsesWith(nCloneInst);<br></li><li>oInst->dropAllReferences();</li><li>oInst->eraseFromParent();</li></ol></div><div>Error:</div></div><div>Instruction does not dominate all uses!</div><div><div>%0 = load i32, i32* %a, align 4</div><div>%2 = call i32 @foo3(i32 %0, i32 %1)</div></div><div><br></div><div>Great, now the <b>p(nInst)</b> are still referring to their definition in the refModule, so either I bring those instructions too (which sounds really messy) or somehow I change the <b>p(nInst)</b> to refer to the instructions in oldModule, which in my case are actually defined the same (but apparently the references don't change based on the name being the same in both modules). </div><div><br></div><div>3. Third attempt:</div><div><ol><li>The same 1-4 steps as before, from cloning instruction to replaceAllUsesWith</li><li>llvm::CallInst *callNInst = static_cast<llvm::CallInst*>(nCloneInst);<br></li><li>llvm::CallInst *callOInst = static_cast<llvm::CallInst*>(oInst); // cast both <b>oInst</b> and <b>nInst</b><br></li><li>for (unsigned int i = 0; i < callOInst->getNumArgOperands(); i++) { callNInst->setArgOperand(i,callOInst->getArgOperand(i)); } //replace <b>p(nInst)</b> with <b>p(oInst)</b><br></li><li>The same 5-6 steps as before, drop and erase</li></ol><div><div>Error:</div><div>Call parameter type does not match function signature!</div><div>%0 = load i32, i32* %a, align 4</div><div>i32  %2 = call i32 @foo3(i32 %0, i32 %1) <br></div></div></div><div><br></div><div>So back to the first problem, the <b>p(nInst) </b>(now converted to <b>p(oInst)</b>) apparently does not match the <b>p(<span class="m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-gr_ m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-gr_4824 m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-gr-alert m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-gr_spell m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-gr_inline_cards m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-gr_disable_anim_appear m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-ContextualSpelling m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-ins-del m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-multiReplace" id="m_1402287407233019456m_328043379647728013m_-176443912390404052m_-2817668529343786898m_-5757159750255473956m_-3402637895520460606m_1958153990707407551m_4360065250572099151m_8328214421441790732gmail-4824" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat;color:inherit;font-size:inherit">nFunc</span>)</b>. </div><div><br></div><div>I also looked into the <b>CloneFunctionInto </b>function, but I didn't understand the arguments of it, and there's really no documentation or examples that I could find on the internet. Specifically, I have troubles with <b>llvm::SmallVectorImpl< llvm::ReturnInst *> &Returns </b>argument, I don't know how to initialize it, it doesn't have a 0 argument constructor and if I try:</div><div><br></div><div>llvm::SmallVectorImpl< llvm::ReturnInst *> ReturnsArg = llvm::SmallVectorImpl< llvm::ReturnInst *>(2); // Just as an example<br></div><div><br></div><div>It says that constructor is protected. I didn't want to go further since I'm clueless on how to properly use this function, and I'm even not completely sure if it would fix all the troubles that I've been having with the other three attempts.</div><div><br></div><div>Btw, all these errors happen when I try to run (through JIT) the module, a workaround that I know that I can do for all my attempts is just to dump the module to a file, and then reload it and execute it (I know it works since in both oldModule and refModule I use the same IR variable's names) but I would like to do the work the <b>right</b> way and not having to inefficiently dump a file just to reload it again and get all the references right. </div><div><br></div><div>Thanks for the help in advance, I'll be really grateful for any advice or light in my situation.</div><div><br></div><div>Regards,</div><div>Daniel Moya</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">El mar., 28 de ago. de 2018 a la(s) 20:26, Friedman, Eli (<a href="mailto:efriedma@codeaurora.org" target="_blank">efriedma@codeaurora.org</a>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 8/27/2018 10:37 AM, Daniel Moya via llvm-dev wrote:<br>
> Hello LLVM Developers,<br>
><br>
> I'm trying to replace a function defined in one module into another <br>
> module (different files). The first issue I ran into was that <br>
> llvm::Function does not have a method "moveBefore" or "moveAfter" as <br>
> the llvm::BasicBlock or llvm::Instruction do, so I figured I would <br>
> just move the BasicBlocks of the replacing function into the function <br>
> that was being replaced, and then eliminate the original BasicBlocks.<br>
<br>
Cross-module operations are tricky in general; I'd suggest using the <br>
Linker::linkModules API if possible.<br>
<br>
-Eli<br>
<br>
-- <br>
Employee of Qualcomm Innovation Center, Inc.<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<br>
<br>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>