Index: lib/Transforms/Utils/SSAUpdater.cpp =================================================================== --- lib/Transforms/Utils/SSAUpdater.cpp +++ lib/Transforms/Utils/SSAUpdater.cpp @@ -190,14 +190,17 @@ Instruction *User = cast(U.getUser()); Value *V; - if (PHINode *UserPN = dyn_cast(User)) + bool IsPhi = false; + if (PHINode *UserPN = dyn_cast(User)) { V = GetValueAtEndOfBlock(UserPN->getIncomingBlock(U)); + IsPhi = true; + } else V = GetValueInMiddleOfBlock(User->getParent()); // Notify that users of the existing value that it is being replaced. Value *OldVal = U.get(); - if (OldVal != V && OldVal->hasValueHandle()) + if (OldVal != V && OldVal->hasValueHandle() && !IsPhi) ValueHandleBase::ValueIsRAUWd(OldVal, V); U.set(V);