Skip to content

Commit 08d75ca

Browse files
committed
Abbreviate AliasResult.
1 parent 4b2da0a commit 08d75ca

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

lib/SILAnalysis/AliasAnalysis.cpp

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,14 @@ static llvm::cl::opt<bool>
8585
// Utilities
8686
//===----------------------------------------------------------------------===//
8787

88-
llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &OS,
89-
AliasAnalysis::AliasResult R) {
88+
using AliasResult = AliasAnalysis::AliasResult;
89+
90+
llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &OS, AliasResult R) {
9091
switch (R) {
91-
case AliasAnalysis::AliasResult::NoAlias:
92-
return OS << "NoAlias";
93-
case AliasAnalysis::AliasResult::MayAlias:
94-
return OS << "MayAlias";
95-
case AliasAnalysis::AliasResult::PartialAlias:
96-
return OS << "PartialAlias";
97-
case AliasAnalysis::AliasResult::MustAlias:
98-
return OS << "MustAlias";
92+
case AliasResult::NoAlias: return OS << "NoAlias";
93+
case AliasResult::MayAlias: return OS << "MayAlias";
94+
case AliasResult::PartialAlias: return OS << "PartialAlias";
95+
case AliasResult::MustAlias: return OS << "MustAlias";
9996
}
10097
}
10198

@@ -265,9 +262,8 @@ static bool aliasUnequalObjects(SILValue O1, SILValue O2) {
265262
/// Uses a bunch of ad-hoc rules to disambiguate a GEP instruction against
266263
/// another pointer. We know that V1 is a GEP, but we don't know anything about
267264
/// V2. O1, O2 are getUnderlyingObject of V1, V2 respectively.
268-
AliasAnalysis::AliasResult
269-
AliasAnalysis::aliasAddressProjection(SILValue V1, SILValue V2,
270-
SILValue O1, SILValue O2) {
265+
AliasResult AliasAnalysis::aliasAddressProjection(SILValue V1, SILValue V2,
266+
SILValue O1, SILValue O2) {
271267

272268
// If V2 is also a gep instruction with a must-alias or not-aliasing base
273269
// pointer, figure out if the indices of the GEPs tell us anything about the
@@ -278,9 +274,9 @@ AliasAnalysis::aliasAddressProjection(SILValue V1, SILValue V2,
278274
// must alias relation on O1. This ensures that given an alloc_stack and a
279275
// gep from that alloc_stack, we say that they partially alias.
280276
if (isSameValueOrGlobal(O1, V2.stripCasts()))
281-
return AliasAnalysis::AliasResult::PartialAlias;
277+
return AliasResult::PartialAlias;
282278

283-
return AliasAnalysis::AliasResult::MayAlias;
279+
return AliasResult::MayAlias;
284280
}
285281

286282
assert(!Projection::isAddrProjection(O1) &&
@@ -289,12 +285,12 @@ AliasAnalysis::aliasAddressProjection(SILValue V1, SILValue V2,
289285
"underlying object may not be a projection");
290286

291287
// Do the base pointers alias?
292-
AliasAnalysis::AliasResult BaseAlias = aliasInner(O1, O2);
288+
AliasResult BaseAlias = aliasInner(O1, O2);
293289

294290
// If the underlying objects are not aliased, the projected values are also
295291
// not aliased.
296-
if (BaseAlias == AliasAnalysis::AliasResult::NoAlias)
297-
return AliasAnalysis::AliasResult::NoAlias;
292+
if (BaseAlias == AliasResult::NoAlias)
293+
return AliasResult::NoAlias;
298294

299295
// Let's do alias checking based on projections.
300296
auto V1Path = ProjectionPath::getAddrProjectionPath(O1, V1, true);
@@ -311,32 +307,32 @@ AliasAnalysis::aliasAddressProjection(SILValue V1, SILValue V2,
311307
// horizon) or enable Projection to represent a cast as a special sort of
312308
// projection.
313309
if (!V1Path || !V2Path)
314-
return AliasAnalysis::AliasResult::MayAlias;
310+
return AliasResult::MayAlias;
315311

316312
auto R = V1Path->computeSubSeqRelation(*V2Path);
317313

318314
// If all of the projections are equal (and they have the same base pointer),
319315
// the two GEPs must be the same.
320-
if (BaseAlias == AliasAnalysis::AliasResult::MustAlias &&
316+
if (BaseAlias == AliasResult::MustAlias &&
321317
R == SubSeqRelation_t::Equal)
322-
return AliasAnalysis::AliasResult::MustAlias;
318+
return AliasResult::MustAlias;
323319

324320
// The two GEPs do not alias if they are accessing different fields, even if
325321
// we don't know the base pointers. Different fields should not overlap.
326322
//
327323
// TODO: Replace this with a check on the computed subseq relation. See the
328324
// TODO in computeSubSeqRelation.
329325
if (V1Path->hasNonEmptySymmetricDifference(V2Path.getValue()))
330-
return AliasAnalysis::AliasResult::NoAlias;
326+
return AliasResult::NoAlias;
331327

332328
// If one of the GEPs is a super path of the other then they partially
333329
// alias. W
334-
if (BaseAlias == AliasAnalysis::AliasResult::MustAlias &&
330+
if (BaseAlias == AliasResult::MustAlias &&
335331
isStrictSubSeqRelation(R))
336-
return AliasAnalysis::AliasResult::PartialAlias;
332+
return AliasResult::PartialAlias;
337333

338334
// We failed to prove anything. Be conservative and return MayAlias.
339-
return AliasAnalysis::AliasResult::MayAlias;
335+
return AliasResult::MayAlias;
340336
}
341337

342338

@@ -606,19 +602,19 @@ static bool typesMayAlias(SILType T1, SILType T2, SILType TBAA1Ty,
606602

607603
/// The main AA entry point. Performs various analyses on V1, V2 in an attempt
608604
/// to disambiguate the two values.
609-
AliasAnalysis::AliasResult AliasAnalysis::alias(SILValue V1, SILValue V2,
610-
SILType TBAAType1,
611-
SILType TBAAType2) {
605+
AliasResult AliasAnalysis::alias(SILValue V1, SILValue V2,
606+
SILType TBAAType1,
607+
SILType TBAAType2) {
612608
auto Result = aliasInner(V1, V2, TBAAType1, TBAAType2);
613609
AliasCache.clear();
614610
return Result;
615611
}
616612

617613
/// The main AA entry point. Performs various analyses on V1, V2 in an attempt
618614
/// to disambiguate the two values.
619-
AliasAnalysis::AliasResult AliasAnalysis::aliasInner(SILValue V1, SILValue V2,
620-
SILType TBAAType1,
621-
SILType TBAAType2) {
615+
AliasResult AliasAnalysis::aliasInner(SILValue V1, SILValue V2,
616+
SILType TBAAType1,
617+
SILType TBAAType2) {
622618
#ifndef NDEBUG
623619
// If alias analysis is disabled, always return may alias.
624620
if (!shouldRunAA())
@@ -733,8 +729,7 @@ bool swift::isLetPointer(SILValue V) {
733729
return false;
734730
}
735731

736-
AliasAnalysis::AliasResult AliasAnalysis::cacheValue(AliasCacheKey Key,
737-
AliasResult Result) {
732+
AliasResult AliasAnalysis::cacheValue(AliasCacheKey Key, AliasResult Result) {
738733
if (!CacheAAResults)
739734
return Result;
740735
DEBUG(llvm::dbgs() << "Caching Alias Result: " << Result << "\n" << Key.first

0 commit comments

Comments
 (0)