From 1d5da8cd30fce1c0a2c2fa6ba656dbfaa36192c8 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Sat, 15 Feb 2020 20:38:49 -0600 Subject: [PATCH] [Attributor][FIX] Use pointer not reference as it can be null --- llvm/include/llvm/Transforms/IPO/Attributor.h | 2 +- llvm/lib/Transforms/IPO/Attributor.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index 625c756d16cf..4da26e2e4973 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -2699,7 +2699,7 @@ struct AAMemoryLocation /// underlying accessed memory pointer) and it will return true if \p Pred /// holds every time. virtual bool checkForAllAccessesToMemoryKind( - const function_ref &Pred, MemoryLocationsKind MLK) const = 0; diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 5ebe00767a02..e84f84bb6dd3 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -6203,7 +6203,7 @@ struct AAMemoryLocationImpl : public AAMemoryLocation { /// See AAMemoryLocation::checkForAllAccessesToMemoryKind(...). bool checkForAllAccessesToMemoryKind( - const function_ref &Pred, MemoryLocationsKind RequestedMLK) const override { if (!isValidState()) @@ -6218,9 +6218,10 @@ struct AAMemoryLocationImpl : public AAMemoryLocation { continue; const auto &Accesses = AccessKindAccessesMap.lookup(CurMLK); - for (const AccessInfo &AI : Accesses) - if (!Pred(*AI.I, AI.Ptr, AI.Kind, CurMLK)) + for (const AccessInfo &AI : Accesses) { + if (!Pred(AI.I, AI.Ptr, AI.Kind, CurMLK)) return false; + } } return true; @@ -6432,7 +6433,7 @@ AAMemoryLocationImpl::categorizeAccessedLocations(Attributor &A, Instruction &I, // Now handle global memory if it might be accessed. bool HasGlobalAccesses = !(ICSAssumedNotAccessedLocs & NO_GLOBAL_MEM); if (HasGlobalAccesses) { - auto AccessPred = [&](const Instruction &, const Value *Ptr, + auto AccessPred = [&](const Instruction *, const Value *Ptr, AccessKind Kind, MemoryLocationsKind MLK) { updateStateAndAccessesMap(AccessedLocs, AccessKindAccessesMap, MLK, &I, Ptr, Changed); @@ -6566,9 +6567,9 @@ struct AAMemoryLocationCallSite final : AAMemoryLocationImpl { const IRPosition &FnPos = IRPosition::function(*F); auto &FnAA = A.getAAFor(*this, FnPos); bool Changed = false; - auto AccessPred = [&](const Instruction &I, const Value *Ptr, + auto AccessPred = [&](const Instruction *I, const Value *Ptr, AccessKind Kind, MemoryLocationsKind MLK) { - updateStateAndAccessesMap(getState(), AccessKindAccessesMap, MLK, &I, Ptr, + updateStateAndAccessesMap(getState(), AccessKindAccessesMap, MLK, I, Ptr, Changed); return true; };