Currently LICM expects SSAUpdater to call ValueIsRAUWd callback whenever SSAUpdater::RewriteUse replaces a use of value, in order to keep AliasSetTrackers that are cached by LICM up to date. Though it is incorrect to call that callback when only one use of the value is being replaced. In some cases this incorrect call of the callback can break SCEV.
This patch introduces a new CallbackVH callback oneUseReplacedWith with the sole purpose of serving this particular case. This callback is implemented only by ASTCallbackVH, it updates AST according to the change and it doesn't confuse/break any other CallbackVH provider.
This solution is far from perfect, but other options are even worse (including undesired compile time impact and/or way broader scope of changes).
This patch fixes bug https://bugs.llvm.org/show_bug.cgi?id=44320.