移动函数体,避免完全克隆

时间:2012-10-12 17:19:46

标签: c++ optimization llvm cloning

这是来自this one的后续问题。

我正在使用llvm::CloneFunctionInto中定义的llvm/Transforms/Utils/Cloning.h,以便在代码生成之后创建一个新函数,并根据返回值的类型推断出正确的签名。这很好用,但很慢

我试图通过某种方式优化这一点来将函数体从旧函数移动或转移到新函数,是否有实用程序?

我试图通过查看code in CloneFunctionInto来破解传输方式,但想查看是否存在现有函数

1 个答案:

答案 0 :(得分:5)

Arg Promotion pass(寻找拼接)无耻地偷走了:

// 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());

NF是您要克隆的新功能,而F是您刚刚克隆的旧功能。

相关问题