Tim Northover
2014-Aug-09 15:43 UTC
[LLVMdev] difference between replaceAllUsesWith and replaceUsesOfWith?
> I think this is incorrect since the use_iterator is defined as: > > `typedef value_use_iterator<User> use_iterator;` > > and indeed `ui->getUser();` is not a callable function on a User. What am I > missing?Ah, looks like this has changed this year. What I said applies to trunk; you may be right there about 3.4 or earlier (looks plausible from the key commit). Another problem might be that User::replaceUsesOfWith only works in limited situations if the User is a Constant. But I'd expect that to fail with an assertion (assuming your LLVM has been built with assertions enabled, of course). Do you have (preferably as simple as possible) IR module that shows the replacement failure? Cheers. Tim.
Tim Northover
2014-Aug-09 16:50 UTC
[LLVMdev] difference between replaceAllUsesWith and replaceUsesOfWith?
On 9 August 2014 17:42, Rob Jansen <jansen at cs.umn.edu> wrote:> Ahh ha! I believe that `User::replaceUsesOfWith` modifies the use list, > which probably invalidated the use_iterator and caused my code to miss some > of the uses.Ah yes, that would explain it. Sorry I wasn't much help. You could also safely increment the iterator before removing the use, I think (which has the benefit of not being a quadratic algorithm). Cheers. Tim.