diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index ac1890a771409..81ee6d5b762f0 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -1589,11 +1589,17 @@ struct Attributor { return true; } - /// Helper function to replace all uses of \p V with \p NV. Return true if - /// there is any change. The flag \p ChangeDroppable indicates if dropppable - /// uses should be changed too. - bool changeValueAfterManifest(Value &V, Value &NV, - bool ChangeDroppable = true) { + /// Helper function to replace all uses associated with \p IRP with \p NV. + /// Return true if there is any change. The flag \p ChangeDroppable indicates + /// if dropppable uses should be changed too. + bool changeAfterManifest(const IRPosition IRP, Value &NV, + bool ChangeDroppable = true) { + if (IRP.getPositionKind() == IRPosition::IRP_CALL_SITE_ARGUMENT) { + auto *CB = cast(IRP.getCtxI()); + return changeUseAfterManifest( + CB->getArgOperandUse(IRP.getCallSiteArgNo()), NV); + } + Value &V = IRP.getAssociatedValue(); auto &Entry = ToBeChangedValues[&V]; Value *&CurNV = Entry.first; if (CurNV && (CurNV->stripPointerCasts() == NV.stripPointerCasts() || diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index ed87ecdde44d5..58f407db5d014 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -6259,7 +6259,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack { assert(InitVal && "Must be able to materialize initial memory state of allocation"); - A.changeValueAfterManifest(*AI.CB, *Alloca); + A.changeAfterManifest(IRPosition::inst(*AI.CB), *Alloca); if (auto *II = dyn_cast(AI.CB)) { auto *NBB = II->getNormalDest(); diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index 5c457ba83f898..99b996ad57ed1 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -2657,7 +2657,7 @@ struct AAICVTrackerCallSite : AAICVTracker { if (!ReplVal.hasValue() || !ReplVal.getValue()) return ChangeStatus::UNCHANGED; - A.changeValueAfterManifest(*getCtxI(), **ReplVal); + A.changeAfterManifest(IRPosition::inst(*getCtxI()), **ReplVal); A.deleteAfterManifest(*getCtxI()); return ChangeStatus::CHANGED; @@ -3054,7 +3054,7 @@ struct AAHeapToSharedFunction : public AAHeapToShared { "HeapToShared on allocation without alignment attribute"); SharedMem->setAlignment(MaybeAlign(Alignment)); - A.changeValueAfterManifest(*CB, *NewBuffer); + A.changeAfterManifest(IRPosition::callsite_returned(*CB), *NewBuffer); A.deleteAfterManifest(*CB); A.deleteAfterManifest(*FreeCalls.front()); @@ -4496,7 +4496,7 @@ struct AAFoldRuntimeCallCallSiteReturned : AAFoldRuntimeCall { if (SimplifiedValue.hasValue() && SimplifiedValue.getValue()) { Instruction &I = *getCtxI(); - A.changeValueAfterManifest(I, **SimplifiedValue); + A.changeAfterManifest(IRPosition::inst(I), **SimplifiedValue); A.deleteAfterManifest(I); CallBase *CB = dyn_cast(&I);