[llvm] 6de8d7f - [BasicAA] Accept AATags by const reference (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 18 09:19:19 PDT 2020
Author: Nikita Popov
Date: 2020-10-18T18:19:01+02:00
New Revision: 6de8d7f1adc82504f2167131e40d3cceec6a6fac
URL: https://github.com/llvm/llvm-project/commit/6de8d7f1adc82504f2167131e40d3cceec6a6fac
DIFF: https://github.com/llvm/llvm-project/commit/6de8d7f1adc82504f2167131e40d3cceec6a6fac.diff
LOG: [BasicAA] Accept AATags by const reference (NFC)
Rather than swapping the value, the sizes, the AA tags and the
underlying objects multiple times, invoke the helper methods
with swapped arguments.
Added:
Modified:
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
index 9214bfcd7a24..60c6de7d2449 100644
--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
@@ -214,8 +214,8 @@ class BasicAAResult : public AAResultBase<BasicAAResult> {
const Value *UnderV2, AAQueryInfo &AAQI);
AliasResult aliasCheck(const Value *V1, LocationSize V1Size,
- AAMDNodes V1AATag, const Value *V2,
- LocationSize V2Size, AAMDNodes V2AATag,
+ const AAMDNodes &V1AATag, const Value *V2,
+ LocationSize V2Size, const AAMDNodes &V2AATag,
AAQueryInfo &AAQI, const Value *O1 = nullptr,
const Value *O2 = nullptr);
};
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 5baf31ed96e3..2c4a107603d8 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1685,8 +1685,9 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
/// Provides a bunch of ad-hoc rules to disambiguate in common cases, such as
/// array references.
AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
- AAMDNodes V1AAInfo, const Value *V2,
- LocationSize V2Size, AAMDNodes V2AAInfo,
+ const AAMDNodes &V1AAInfo,
+ const Value *V2, LocationSize V2Size,
+ const AAMDNodes &V2AAInfo,
AAQueryInfo &AAQI, const Value *O1,
const Value *O2) {
// If either of the memory references is empty, it doesn't matter what the
@@ -1788,43 +1789,40 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
// FIXME: This isn't aggressively handling alias(GEP, PHI) for example: if the
// GEP can't simplify, we don't even look at the PHI cases.
- if (!isa<GEPOperator>(V1) && isa<GEPOperator>(V2)) {
- std::swap(V1, V2);
- std::swap(V1Size, V2Size);
- std::swap(O1, O2);
- std::swap(V1AAInfo, V2AAInfo);
- }
if (const GEPOperator *GV1 = dyn_cast<GEPOperator>(V1)) {
AliasResult Result =
aliasGEP(GV1, V1Size, V1AAInfo, V2, V2Size, V2AAInfo, O1, O2, AAQI);
if (Result != MayAlias)
return AAQI.updateResult(Locs, Result);
+ } else if (const GEPOperator *GV2 = dyn_cast<GEPOperator>(V2)) {
+ AliasResult Result =
+ aliasGEP(GV2, V2Size, V2AAInfo, V1, V1Size, V1AAInfo, O2, O1, AAQI);
+ if (Result != MayAlias)
+ return AAQI.updateResult(Locs, Result);
}
- if (isa<PHINode>(V2) && !isa<PHINode>(V1)) {
- std::swap(V1, V2);
- std::swap(O1, O2);
- std::swap(V1Size, V2Size);
- std::swap(V1AAInfo, V2AAInfo);
- }
if (const PHINode *PN = dyn_cast<PHINode>(V1)) {
AliasResult Result =
aliasPHI(PN, V1Size, V1AAInfo, V2, V2Size, V2AAInfo, O2, AAQI);
if (Result != MayAlias)
return AAQI.updateResult(Locs, Result);
+ } else if (const PHINode *PN = dyn_cast<PHINode>(V2)) {
+ AliasResult Result =
+ aliasPHI(PN, V2Size, V2AAInfo, V1, V1Size, V1AAInfo, O1, AAQI);
+ if (Result != MayAlias)
+ return AAQI.updateResult(Locs, Result);
}
- if (isa<SelectInst>(V2) && !isa<SelectInst>(V1)) {
- std::swap(V1, V2);
- std::swap(O1, O2);
- std::swap(V1Size, V2Size);
- std::swap(V1AAInfo, V2AAInfo);
- }
if (const SelectInst *S1 = dyn_cast<SelectInst>(V1)) {
AliasResult Result =
aliasSelect(S1, V1Size, V1AAInfo, V2, V2Size, V2AAInfo, O2, AAQI);
if (Result != MayAlias)
return AAQI.updateResult(Locs, Result);
+ } else if (const SelectInst *S2 = dyn_cast<SelectInst>(V2)) {
+ AliasResult Result =
+ aliasSelect(S2, V2Size, V2AAInfo, V1, V1Size, V1AAInfo, O1, AAQI);
+ if (Result != MayAlias)
+ return AAQI.updateResult(Locs, Result);
}
// If both pointers are pointing into the same object and one of them
More information about the llvm-commits
mailing list