[llvm] 1d5da8c - [Attributor][FIX] Use pointer not reference as it can be null
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 15 19:54:47 PST 2020
Author: Johannes Doerfert
Date: 2020-02-15T20:38:49-06:00
New Revision: 1d5da8cd30fce1c0a2c2fa6ba656dbfaa36192c8
URL: https://github.com/llvm/llvm-project/commit/1d5da8cd30fce1c0a2c2fa6ba656dbfaa36192c8
DIFF: https://github.com/llvm/llvm-project/commit/1d5da8cd30fce1c0a2c2fa6ba656dbfaa36192c8.diff
LOG: [Attributor][FIX] Use pointer not reference as it can be null
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
Removed:
################################################################################
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<bool(const Instruction &, const Value *, AccessKind,
+ const function_ref<bool(const Instruction *, const Value *, AccessKind,
MemoryLocationsKind)> &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<bool(const Instruction &, const Value *, AccessKind,
+ const function_ref<bool(const Instruction *, const Value *, AccessKind,
MemoryLocationsKind)> &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<AAMemoryLocation>(*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;
};
More information about the llvm-commits
mailing list