1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[AST] Remove notion of volatile from alias sets [NFCI]

Volatility is not an aliasing property. We used to model volatile as if it had extremely conservative aliasing implications, but that hasn't been true for several years now. So, it doesn't make sense to be in AliasSet.

It also turns out the code is entirely a noop. Outside of the AST code to update it, there was only one user: load store promotion in LICM. L/S promotion doesn't need the check since it walks all the users of the address anyway. It already checks each load or store via !isUnordered which causes us to bail for volatile accesses. (Look at the lines immediately following the two remove asserts.)

There is the possibility of some small compile time impact here, but the only case which will get noticeably slower is a loop with a large number of loads and stores to the same address where only the last one we inspect is volatile. This is sufficiently rare it's not worth optimizing for..

llvm-svn: 340312
This commit is contained in:
Philip Reames 2018-08-21 17:59:11 +00:00
parent bf75cf8d32
commit 8217861627
4 changed files with 12 additions and 38 deletions

View File

@ -175,9 +175,6 @@ class AliasSet : public ilist_node<AliasSet> {
};
unsigned Alias : 1;
/// True if this alias set contains volatile loads or stores.
unsigned Volatile : 1;
unsigned SetSize = 0;
void addRef() { ++RefCount; }
@ -203,9 +200,6 @@ public:
bool isMustAlias() const { return Alias == SetMustAlias; }
bool isMayAlias() const { return Alias == SetMayAlias; }
/// Return true if this alias set contains volatile loads or stores.
bool isVolatile() const { return Volatile; }
/// Return true if this alias set should be ignored as part of the
/// AliasSetTracker object.
bool isForwardingAliasSet() const { return Forward; }
@ -278,7 +272,7 @@ private:
// Can only be created by AliasSetTracker.
AliasSet()
: PtrListEnd(&PtrList), RefCount(0), AliasAny(false), Access(NoAccess),
Alias(SetMustAlias), Volatile(false) {}
Alias(SetMustAlias) {}
PointerRec *getSomePointer() const {
return PtrList;
@ -317,8 +311,6 @@ private:
dropRef(AST);
}
void setVolatile() { Volatile = true; }
public:
/// Return true if the specified pointer "may" (or must) alias one of the
/// members in the set.

View File

@ -56,7 +56,6 @@ void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST) {
// Update the alias and access types of this set...
Access |= AS.Access;
Alias |= AS.Alias;
Volatile |= AS.Volatile;
if (Alias == SetMustAlias) {
// Check that these two merged sets really are must aliases. Since both
@ -365,15 +364,13 @@ void AliasSetTracker::add(Value *Ptr, LocationSize Size,
void AliasSetTracker::add(LoadInst *LI) {
if (isStrongerThanMonotonic(LI->getOrdering())) return addUnknown(LI);
AliasSet &AS = addPointer(MemoryLocation::get(LI), AliasSet::RefAccess);
if (LI->isVolatile()) AS.setVolatile();
addPointer(MemoryLocation::get(LI), AliasSet::RefAccess);
}
void AliasSetTracker::add(StoreInst *SI) {
if (isStrongerThanMonotonic(SI->getOrdering())) return addUnknown(SI);
AliasSet &AS = addPointer(MemoryLocation::get(SI), AliasSet::ModAccess);
if (SI->isVolatile()) AS.setVolatile();
addPointer(MemoryLocation::get(SI), AliasSet::ModAccess);
}
void AliasSetTracker::add(VAArgInst *VAAI) {
@ -382,24 +379,15 @@ void AliasSetTracker::add(VAArgInst *VAAI) {
void AliasSetTracker::add(AnyMemSetInst *MSI) {
auto MemLoc = MemoryLocation::getForDest(MSI);
AliasSet &AS = addPointer(MemLoc, AliasSet::ModAccess);
auto *MS = dyn_cast<MemSetInst>(MSI);
if (MS && MS->isVolatile())
AS.setVolatile();
addPointer(MemLoc, AliasSet::ModAccess);
}
void AliasSetTracker::add(AnyMemTransferInst *MTI) {
auto SrcLoc = MemoryLocation::getForSource(MTI);
AliasSet &ASSrc = addPointer(SrcLoc, AliasSet::RefAccess);
addPointer(SrcLoc, AliasSet::RefAccess);
auto DestLoc = MemoryLocation::getForDest(MTI);
AliasSet &ASDst = addPointer(DestLoc, AliasSet::ModAccess);
auto* MT = dyn_cast<MemTransferInst>(MTI);
if (MT && MT->isVolatile()) {
ASSrc.setVolatile();
ASDst.setVolatile();
}
addPointer(DestLoc, AliasSet::ModAccess);
}
void AliasSetTracker::addUnknown(Instruction *Inst) {
@ -468,12 +456,9 @@ void AliasSetTracker::add(const AliasSetTracker &AST) {
add(Inst);
// Loop over all of the pointers in this alias set.
for (AliasSet::iterator ASI = AS.begin(), E = AS.end(); ASI != E; ++ASI) {
AliasSet &NewAS =
addPointer(ASI.getPointer(), ASI.getSize(), ASI.getAAInfo(),
(AliasSet::AccessLattice)AS.Access);
if (AS.isVolatile()) NewAS.setVolatile();
}
for (AliasSet::iterator ASI = AS.begin(), E = AS.end(); ASI != E; ++ASI)
addPointer(ASI.getPointer(), ASI.getSize(), ASI.getAAInfo(),
(AliasSet::AccessLattice)AS.Access);
}
}
@ -595,7 +580,6 @@ void AliasSet::print(raw_ostream &OS) const {
case ModRefAccess: OS << "Mod/Ref "; break;
default: llvm_unreachable("Bad value for Access!");
}
if (isVolatile()) OS << "[volatile] ";
if (Forward)
OS << " forwarding to " << (void*)Forward;

View File

@ -322,7 +322,7 @@ bool LoopInvariantCodeMotion::runOnLoop(
// alias set, if the pointer is loop invariant, and if we are not
// eliminating any volatile loads or stores.
if (AS.isForwardingAliasSet() || !AS.isMod() || !AS.isMustAlias() ||
AS.isVolatile() || !L->isLoopInvariant(AS.begin()->getValue()))
!L->isLoopInvariant(AS.begin()->getValue()))
continue;
assert(
@ -1368,7 +1368,6 @@ bool llvm::promoteLoopAccessesToScalars(
// If there is an non-load/store instruction in the loop, we can't promote
// it.
if (LoadInst *Load = dyn_cast<LoadInst>(UI)) {
assert(!Load->isVolatile() && "AST broken");
if (!Load->isUnordered())
return false;
@ -1383,7 +1382,6 @@ bool llvm::promoteLoopAccessesToScalars(
// pointer.
if (UI->getOperand(1) != ASIV)
continue;
assert(!Store->isVolatile() && "AST broken");
if (!Store->isUnordered())
return false;

View File

@ -61,7 +61,7 @@ entry:
; CHECK: Alias Set Tracker: 3 alias sets for 4 pointer values.
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, 1)
; CHECK-NOT: 1 Unknown instructions
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref [volatile] Pointers: (i8* %s, 1), (i8* %d, 1)
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref Pointers: (i8* %s, 1), (i8* %d, 1)
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %b, 1)
define void @test2(i8* %s, i8* %d) {
entry:
@ -109,7 +109,7 @@ entry:
; CHECK: Alias Set Tracker: 3 alias sets for 4 pointer values.
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %a, 1)
; CHECK-NOT: 1 Unknown instructions
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref [volatile] Pointers: (i8* %s, 1), (i8* %d, 1)
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 2] may alias, Mod/Ref Pointers: (i8* %s, 1), (i8* %d, 1)
; CHECK: AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod Pointers: (i8* %b, 1)
define void @test4(i8* %s, i8* %d) {
entry: