【问题标题】:move function body, avoiding full cloning移动函数体,避免完全克隆
【发布时间】:2012-10-03 13:35:48
【问题描述】:

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

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

我正在尝试通过某种方式对其进行一些优化,以将函数体从旧函数移动或转移到新函数,是否有一个实用程序?

我正在尝试通过查看code in CloneFunctionInto 来破解一种进行传输的方法,但想看看是否存在现有函数

【问题讨论】:

    标签: c++ optimization llvm cloning


    【解决方案1】:

    无耻从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 是您刚刚克隆的旧函数。

    【讨论】:

    • 这不包括参数。我们需要该通道中剩余的部分代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-03
    相关资源
    最近更新 更多