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.
Tim Northover via llvm-dev
2019-Sep-19 09:00 UTC
[llvm-dev] Type unmatched after replacing functions
On Thu, 19 Sep 2019 at 09:45, Will Lester <hslester96 at gmail.com> wrote:> > 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. :)OK, then it sounds like that might be exactly what you need: replaceAllUses of the function you're discarding with an appropriately casted version of the new function. It automatically rebuilds any Constant users it finds. Cheers. Tim.
Will Lester via llvm-dev
2019-Sep-19 12:55 UTC
[llvm-dev] Type unmatched after replacing functions
On Thu, Sep 19, 2019 at 5:01 PM Tim Northover <t.p.northover at gmail.com> wrote:> > On Thu, 19 Sep 2019 at 09:45, Will Lester <hslester96 at gmail.com> wrote: > > > 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. :) > > OK, then it sounds like that might be exactly what you need: > replaceAllUses of the function you're discarding with an appropriately > casted version of the new function. It automatically rebuilds any > Constant users it finds. >Thank you, this simple method solves the problem perfectly! Furthermore, I feel excited to receive your reply since last year your advice also helped me a lot. It is fortunate to be helped by you again :) Regards, Will> Cheers. > > Tim.