[llvm] 3ddc88c - Revert "[AST] Use ModRefInfo to represent access kind (NFC)"
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 17 09:24:44 PDT 2023
Author: Nikita Popov
Date: 2023-03-17T17:24:35+01:00
New Revision: 3ddc88c38068449842b5ae31285d2a194f0dc4f9
URL: https://github.com/llvm/llvm-project/commit/3ddc88c38068449842b5ae31285d2a194f0dc4f9
DIFF: https://github.com/llvm/llvm-project/commit/3ddc88c38068449842b5ae31285d2a194f0dc4f9.diff
LOG: Revert "[AST] Use ModRefInfo to represent access kind (NFC)"
This reverts commit 2c78a9e65ccfe36d213a409592bebdd3ed8ba771.
Fails to compile on mlir-s390x-linux buildbot using GCC 9.4 with:
llvm/lib/Analysis/AliasSetTracker.cpp: In member function 'void llvm::AliasSet::mergeSetIn(llvm::AliasSet&, llvm::AliasSetTracker&, llvm::BatchAAResults&)':
llvm/lib/Analysis/AliasSetTracker.cpp:50:19: error: invalid operands of types 'unsigned char:2' and 'unsigned char:2' to binary 'operator|'
Added:
Modified:
llvm/include/llvm/Analysis/AliasSetTracker.h
llvm/lib/Analysis/AliasSetTracker.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h
index 6fdca459e9c96..e485e1ff2f4c9 100644
--- a/llvm/include/llvm/Analysis/AliasSetTracker.h
+++ b/llvm/include/llvm/Analysis/AliasSetTracker.h
@@ -26,7 +26,6 @@
#include "llvm/IR/Instruction.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ValueHandle.h"
-#include "llvm/Support/ModRef.h"
#include <cassert>
#include <cstddef>
#include <iterator>
@@ -158,9 +157,15 @@ class AliasSet : public ilist_node<AliasSet> {
///
/// We keep track of whether this alias set merely refers to the locations of
/// memory (and not any particular access), whether it modifies or references
- /// the memory, or whether it does both. The lattice goes from NoModRef to
- /// either Ref or Mod, then to ModRef as necessary.
- ModRefInfo Access : 2;
+ /// the memory, or whether it does both. The lattice goes from "NoAccess" to
+ /// either RefAccess or ModAccess, then to ModRefAccess as necessary.
+ enum AccessLattice {
+ NoAccess = 0,
+ RefAccess = 1,
+ ModAccess = 2,
+ ModRefAccess = RefAccess | ModAccess
+ };
+ unsigned Access : 2;
/// The kind of alias relationship between pointers of the set.
///
@@ -188,8 +193,8 @@ class AliasSet : public ilist_node<AliasSet> {
AliasSet &operator=(const AliasSet &) = delete;
/// Accessors...
- bool isRef() const { return isRefSet(Access); }
- bool isMod() const { return isModSet(Access); }
+ bool isRef() const { return Access & RefAccess; }
+ bool isMod() const { return Access & ModAccess; }
bool isMustAlias() const { return Alias == SetMustAlias; }
bool isMayAlias() const { return Alias == SetMayAlias; }
@@ -255,8 +260,8 @@ class AliasSet : public ilist_node<AliasSet> {
private:
// Can only be created by AliasSetTracker.
AliasSet()
- : PtrListEnd(&PtrList), RefCount(0), AliasAny(false),
- Access(ModRefInfo::NoModRef), Alias(SetMustAlias) {}
+ : PtrListEnd(&PtrList), RefCount(0), AliasAny(false), Access(NoAccess),
+ Alias(SetMustAlias) {}
PointerRec *getSomePointer() const {
return PtrList;
@@ -383,7 +388,7 @@ class AliasSetTracker {
return *Entry;
}
- AliasSet &addPointer(MemoryLocation Loc, ModRefInfo E);
+ AliasSet &addPointer(MemoryLocation Loc, AliasSet::AccessLattice E);
AliasSet *mergeAliasSetsForPointer(const Value *Ptr, LocationSize Size,
const AAMDNodes &AAInfo,
bool &MustAliasAll);
diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp
index 93e222f3d1aaf..1c9ebadf36493 100644
--- a/llvm/lib/Analysis/AliasSetTracker.cpp
+++ b/llvm/lib/Analysis/AliasSetTracker.cpp
@@ -47,7 +47,7 @@ void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST,
bool WasMustAlias = (Alias == SetMustAlias);
// Update the alias and access types of this set...
- Access = Access | AS.Access;
+ Access |= AS.Access;
Alias |= AS.Alias;
if (Alias == SetMustAlias) {
@@ -173,13 +173,13 @@ void AliasSet::addUnknownInst(Instruction *I, BatchAAResults &AA) {
!(I->use_empty() && match(I, m_Intrinsic<Intrinsic::invariant_start>()));
if (!MayWriteMemory) {
Alias = SetMayAlias;
- Access = Access | ModRefInfo::Ref;
+ Access |= RefAccess;
return;
}
// FIXME: This should use mod/ref information to make this not suck so bad
Alias = SetMayAlias;
- Access = ModRefInfo::ModRef;
+ Access = ModRefAccess;
}
/// aliasesPointer - If the specified pointer "may" (or must) alias one of the
@@ -368,32 +368,32 @@ AliasSet &AliasSetTracker::getAliasSetFor(const MemoryLocation &MemLoc) {
void AliasSetTracker::add(Value *Ptr, LocationSize Size,
const AAMDNodes &AAInfo) {
- addPointer(MemoryLocation(Ptr, Size, AAInfo), ModRefInfo::NoModRef);
+ addPointer(MemoryLocation(Ptr, Size, AAInfo), AliasSet::NoAccess);
}
void AliasSetTracker::add(LoadInst *LI) {
if (isStrongerThanMonotonic(LI->getOrdering()))
return addUnknown(LI);
- addPointer(MemoryLocation::get(LI), ModRefInfo::Ref);
+ addPointer(MemoryLocation::get(LI), AliasSet::RefAccess);
}
void AliasSetTracker::add(StoreInst *SI) {
if (isStrongerThanMonotonic(SI->getOrdering()))
return addUnknown(SI);
- addPointer(MemoryLocation::get(SI), ModRefInfo::Mod);
+ addPointer(MemoryLocation::get(SI), AliasSet::ModAccess);
}
void AliasSetTracker::add(VAArgInst *VAAI) {
- addPointer(MemoryLocation::get(VAAI), ModRefInfo::ModRef);
+ addPointer(MemoryLocation::get(VAAI), AliasSet::ModRefAccess);
}
void AliasSetTracker::add(AnyMemSetInst *MSI) {
- addPointer(MemoryLocation::getForDest(MSI), ModRefInfo::Mod);
+ addPointer(MemoryLocation::getForDest(MSI), AliasSet::ModAccess);
}
void AliasSetTracker::add(AnyMemTransferInst *MTI) {
- addPointer(MemoryLocation::getForDest(MTI), ModRefInfo::Mod);
- addPointer(MemoryLocation::getForSource(MTI), ModRefInfo::Ref);
+ addPointer(MemoryLocation::getForDest(MTI), AliasSet::ModAccess);
+ addPointer(MemoryLocation::getForSource(MTI), AliasSet::RefAccess);
}
void AliasSetTracker::addUnknown(Instruction *Inst) {
@@ -441,6 +441,17 @@ void AliasSetTracker::add(Instruction *I) {
// Handle all calls with known mod/ref sets genericall
if (auto *Call = dyn_cast<CallBase>(I))
if (Call->onlyAccessesArgMemory()) {
+ auto getAccessFromModRef = [](ModRefInfo MRI) {
+ if (isRefSet(MRI) && isModSet(MRI))
+ return AliasSet::ModRefAccess;
+ else if (isModSet(MRI))
+ return AliasSet::ModAccess;
+ else if (isRefSet(MRI))
+ return AliasSet::RefAccess;
+ else
+ return AliasSet::NoAccess;
+ };
+
ModRefInfo CallMask = AA.getMemoryEffects(Call).getModRef();
// Some intrinsics are marked as modifying memory for control flow
@@ -461,7 +472,7 @@ void AliasSetTracker::add(Instruction *I) {
ModRefInfo ArgMask = AA.getArgModRefInfo(Call, ArgIdx);
ArgMask &= CallMask;
if (!isNoModRef(ArgMask))
- addPointer(ArgLoc, ArgMask);
+ addPointer(ArgLoc, getAccessFromModRef(ArgMask));
}
return;
}
@@ -493,7 +504,7 @@ void AliasSetTracker::add(const AliasSetTracker &AST) {
for (AliasSet::iterator ASI = AS.begin(), E = AS.end(); ASI != E; ++ASI)
addPointer(
MemoryLocation(ASI.getPointer(), ASI.getSize(), ASI.getAAInfo()),
- AS.Access);
+ (AliasSet::AccessLattice)AS.Access);
}
}
@@ -514,7 +525,7 @@ AliasSet &AliasSetTracker::mergeAllAliasSets() {
AliasSets.push_back(new AliasSet());
AliasAnyAS = &AliasSets.back();
AliasAnyAS->Alias = AliasSet::SetMayAlias;
- AliasAnyAS->Access = ModRefInfo::ModRef;
+ AliasAnyAS->Access = AliasSet::ModRefAccess;
AliasAnyAS->AliasAny = true;
for (auto *Cur : ASVector) {
@@ -535,9 +546,9 @@ AliasSet &AliasSetTracker::mergeAllAliasSets() {
}
AliasSet &AliasSetTracker::addPointer(MemoryLocation Loc,
- ModRefInfo MRI) {
+ AliasSet::AccessLattice E) {
AliasSet &AS = getAliasSetFor(Loc);
- AS.Access = AS.Access | MRI;
+ AS.Access |= E;
if (!AliasAnyAS && (TotalMayAliasSetSize > SaturationThreshold)) {
// The AST is now saturated. From here on, we conservatively consider all
@@ -556,10 +567,10 @@ void AliasSet::print(raw_ostream &OS) const {
OS << " AliasSet[" << (const void*)this << ", " << RefCount << "] ";
OS << (Alias == SetMustAlias ? "must" : "may") << " alias, ";
switch (Access) {
- case ModRefInfo::NoModRef: OS << "No access "; break;
- case ModRefInfo::Ref: OS << "Ref "; break;
- case ModRefInfo::Mod: OS << "Mod "; break;
- case ModRefInfo::ModRef: OS << "Mod/Ref "; break;
+ case NoAccess: OS << "No access "; break;
+ case RefAccess: OS << "Ref "; break;
+ case ModAccess: OS << "Mod "; break;
+ case ModRefAccess: OS << "Mod/Ref "; break;
default: llvm_unreachable("Bad value for Access!");
}
if (Forward)
More information about the llvm-commits
mailing list