move function body, avoiding full cloning

懵懂的女人 提交于 2019-12-07 20:03:02

问题


This is a follow up question from this one.

I am using llvm::CloneFunctionInto defined in llvm/Transforms/Utils/Cloning.h in order to create a new function after code generation with the right signature inferred from the type of the return values. This works nicely but it is slow

I am trying to optimize this a little bit by some way to move or transfer the function body from the old function to the new one, is there a utility for that?

I am trying to hack a way to do the transfer by looking at the code in CloneFunctionInto, but wanted to see if an existing function exists


回答1:


Shamelessly stolen from the Arg Promotion pass (search for splice):

// Since we have now created the new function, splice the body of the old
// function right into the new function, leaving the old rotting hulk of the
// function empty.
NF->getBasicBlockList().splice(NF->begin(), F->getBasicBlockList());

Where NF is the new function you're cloning into and F is the old function that you have just cloned.



来源:https://stackoverflow.com/questions/12864106/move-function-body-avoiding-full-cloning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!