File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,27 @@ struct AccessPathWalker {
476
476
}
477
477
}
478
478
479
+ extension Value {
480
+ // Convenient properties to avoid instantiating an explicit AccessPathWalker.
481
+ //
482
+ // Although an AccessPathWalker is created for each call of these properties,
483
+ // it's very unlikely that this will end up in memory allocations.
484
+ // Only in the rare case of `pointer_to_address` -> `address_to_pointer` pairs, which
485
+ // go through phi-arguments, the AccessPathWalker will allocate memnory in its cache.
486
+
487
+ /// Computes the access base of this address value.
488
+ var accessBase : AccessBase {
489
+ var apWalker = AccessPathWalker ( )
490
+ return apWalker. getAccessBase ( of: self )
491
+ }
492
+
493
+ /// Computes the enclosing access scope of this address value.
494
+ var accessScope : EnclosingScope {
495
+ var apWalker = AccessPathWalker ( )
496
+ return apWalker. getAccessScope ( of: self )
497
+ }
498
+ }
499
+
479
500
/// A ValueUseDef walker that identifies which values a reference of an access path might
480
501
/// originate from.
481
502
protocol AccessStoragePathWalker : ValueUseDefWalker where Path == SmallProjectionPath {
You can’t perform that action at this time.
0 commit comments