@@ -85,17 +85,14 @@ static llvm::cl::opt<bool>
85
85
// Utilities
86
86
// ===----------------------------------------------------------------------===//
87
87
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) {
90
91
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" ;
99
96
}
100
97
}
101
98
@@ -265,9 +262,8 @@ static bool aliasUnequalObjects(SILValue O1, SILValue O2) {
265
262
// / Uses a bunch of ad-hoc rules to disambiguate a GEP instruction against
266
263
// / another pointer. We know that V1 is a GEP, but we don't know anything about
267
264
// / 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) {
271
267
272
268
// If V2 is also a gep instruction with a must-alias or not-aliasing base
273
269
// pointer, figure out if the indices of the GEPs tell us anything about the
@@ -278,9 +274,9 @@ AliasAnalysis::aliasAddressProjection(SILValue V1, SILValue V2,
278
274
// must alias relation on O1. This ensures that given an alloc_stack and a
279
275
// gep from that alloc_stack, we say that they partially alias.
280
276
if (isSameValueOrGlobal (O1, V2.stripCasts ()))
281
- return AliasAnalysis:: AliasResult::PartialAlias;
277
+ return AliasResult::PartialAlias;
282
278
283
- return AliasAnalysis:: AliasResult::MayAlias;
279
+ return AliasResult::MayAlias;
284
280
}
285
281
286
282
assert (!Projection::isAddrProjection (O1) &&
@@ -289,12 +285,12 @@ AliasAnalysis::aliasAddressProjection(SILValue V1, SILValue V2,
289
285
" underlying object may not be a projection" );
290
286
291
287
// Do the base pointers alias?
292
- AliasAnalysis:: AliasResult BaseAlias = aliasInner (O1, O2);
288
+ AliasResult BaseAlias = aliasInner (O1, O2);
293
289
294
290
// If the underlying objects are not aliased, the projected values are also
295
291
// not aliased.
296
- if (BaseAlias == AliasAnalysis:: AliasResult::NoAlias)
297
- return AliasAnalysis:: AliasResult::NoAlias;
292
+ if (BaseAlias == AliasResult::NoAlias)
293
+ return AliasResult::NoAlias;
298
294
299
295
// Let's do alias checking based on projections.
300
296
auto V1Path = ProjectionPath::getAddrProjectionPath (O1, V1, true );
@@ -311,32 +307,32 @@ AliasAnalysis::aliasAddressProjection(SILValue V1, SILValue V2,
311
307
// horizon) or enable Projection to represent a cast as a special sort of
312
308
// projection.
313
309
if (!V1Path || !V2Path)
314
- return AliasAnalysis:: AliasResult::MayAlias;
310
+ return AliasResult::MayAlias;
315
311
316
312
auto R = V1Path->computeSubSeqRelation (*V2Path);
317
313
318
314
// If all of the projections are equal (and they have the same base pointer),
319
315
// the two GEPs must be the same.
320
- if (BaseAlias == AliasAnalysis:: AliasResult::MustAlias &&
316
+ if (BaseAlias == AliasResult::MustAlias &&
321
317
R == SubSeqRelation_t::Equal)
322
- return AliasAnalysis:: AliasResult::MustAlias;
318
+ return AliasResult::MustAlias;
323
319
324
320
// The two GEPs do not alias if they are accessing different fields, even if
325
321
// we don't know the base pointers. Different fields should not overlap.
326
322
//
327
323
// TODO: Replace this with a check on the computed subseq relation. See the
328
324
// TODO in computeSubSeqRelation.
329
325
if (V1Path->hasNonEmptySymmetricDifference (V2Path.getValue ()))
330
- return AliasAnalysis:: AliasResult::NoAlias;
326
+ return AliasResult::NoAlias;
331
327
332
328
// If one of the GEPs is a super path of the other then they partially
333
329
// alias. W
334
- if (BaseAlias == AliasAnalysis:: AliasResult::MustAlias &&
330
+ if (BaseAlias == AliasResult::MustAlias &&
335
331
isStrictSubSeqRelation (R))
336
- return AliasAnalysis:: AliasResult::PartialAlias;
332
+ return AliasResult::PartialAlias;
337
333
338
334
// We failed to prove anything. Be conservative and return MayAlias.
339
- return AliasAnalysis:: AliasResult::MayAlias;
335
+ return AliasResult::MayAlias;
340
336
}
341
337
342
338
@@ -606,19 +602,19 @@ static bool typesMayAlias(SILType T1, SILType T2, SILType TBAA1Ty,
606
602
607
603
// / The main AA entry point. Performs various analyses on V1, V2 in an attempt
608
604
// / 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) {
612
608
auto Result = aliasInner (V1, V2, TBAAType1, TBAAType2);
613
609
AliasCache.clear ();
614
610
return Result;
615
611
}
616
612
617
613
// / The main AA entry point. Performs various analyses on V1, V2 in an attempt
618
614
// / 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) {
622
618
#ifndef NDEBUG
623
619
// If alias analysis is disabled, always return may alias.
624
620
if (!shouldRunAA ())
@@ -733,8 +729,7 @@ bool swift::isLetPointer(SILValue V) {
733
729
return false ;
734
730
}
735
731
736
- AliasAnalysis::AliasResult AliasAnalysis::cacheValue (AliasCacheKey Key,
737
- AliasResult Result) {
732
+ AliasResult AliasAnalysis::cacheValue (AliasCacheKey Key, AliasResult Result) {
738
733
if (!CacheAAResults)
739
734
return Result;
740
735
DEBUG (llvm::dbgs () << " Caching Alias Result: " << Result << " \n " << Key.first
0 commit comments