Will Lester via llvm-dev
2019-Sep-19 08:20 UTC
[llvm-dev] Type unmatched after replacing functions
Hi all, I am trying to merge functions with the same debug location by using replaceAllUsesWith(). However, this leads to type unmatched problems because the functions with the same debug location can have different parameters. An example is foo(struct A) can be compiled to foo.1(struct A.1) and foo.2(struct A.2). I have inserted CastInst to solve the problems of arguments and return values type unmatched. But I find the problem of unmatched type of uses of function pointers is harder to solve. The function pointers are often put in the initializers of global variables, and they can not be simply replaced by a bitcast ConstantExpr since setOperand() cannot be used for Constant. So, is there any solution to this problem? Thanks!
Tim Northover via llvm-dev
2019-Sep-19 08:34 UTC
[llvm-dev] Type unmatched after replacing functions
Hi Will, On Thu, 19 Sep 2019 at 09:21, Will Lester via llvm-dev <llvm-dev at lists.llvm.org> wrote:> The function pointers are often put in the initializers of global variables, and > they can not be simply replaced by a bitcast ConstantExpr since setOperand() > cannot be used for Constant.Are you trying to be more selective than Value::replaceAllUsesWith would allow for some reason? Cheers. Tim.
Will Lester via llvm-dev
2019-Sep-19 08:44 UTC
[llvm-dev] Type unmatched after replacing functions
On Thu, Sep 19, 2019 at 4:34 PM Tim Northover <t.p.northover at gmail.com> wrote:> > Hi Will, > > On Thu, 19 Sep 2019 at 09:21, Will Lester via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > The function pointers are often put in the initializers of global variables, and > > they can not be simply replaced by a bitcast ConstantExpr since setOperand() > > cannot be used for Constant. > > Are you trying to be more selective than Value::replaceAllUsesWith > would allow for some reason?I'm very glad to select another way if there is a better one. :)> > Cheers. > > Tim.