   }
 }
 
-/// Given a `%addr = pointer_to_address %ptr_operand` instruction tries to identify
-/// where the pointer operand `ptr_operand` originates from.
+/// Tries to identify from which address the pointer operand originates from.
 /// This is useful to identify patterns like
 /// ```
 /// %orig_addr = global_addr @...
 /// %ptr = address_to_pointer %orig_addr
 /// %addr = pointer_to_address %ptr
 /// ```
-struct PointerIdentification {
-  private var walker = PointerIdentificationUseDefWalker()
-
-  mutating func getOriginatingAddress(of pointerToAddr: PointerToAddressInst) -> Value? {
-    defer { walker.clear() }
-
-    walker.start(pointerToAddr.type)
-    if walker.walkUp(value: pointerToAddr.operand, path: SmallProjectionPath()) == .abortWalk {
-      return nil
-    }
-    return walker.result
-  }
-
-  private struct PointerIdentificationUseDefWalker : ValueUseDefWalker {
-    private var addrType: Type!
-    private(set) var result: Value?
-    var walkUpCache = WalkerCache<Path>()
-
-    mutating func start(_ addrType: Type) {
-      self.addrType = addrType
-      assert(result == nil)
-    }
-
-    mutating func clear() {
-      result = nil
-      walkUpCache.clear()
-    }
-
-    mutating func rootDef(value: Value, path: SmallProjectionPath) -> WalkResult {
-      if let atp = value as? AddressToPointerInst {
-        if let res = result, atp.operand != res {
+extension PointerToAddressInst {
+  var originatingAddress: Value? {
+
+    struct Walker : ValueUseDefWalker {
+      let addrType: Type
+      var result: Value?
+      var walkUpCache = WalkerCache<Path>()
+
+      mutating func rootDef(value: Value, path: SmallProjectionPath) -> WalkResult {
+        if let atp = value as? AddressToPointerInst {
+          if let res = result, atp.operand != res {
+            return .abortWalk
+          }
+
+          if addrType != atp.operand.type { return .abortWalk }
+          if !path.isEmpty { return .abortWalk }
+
+          self.result = atp.operand
+          return .continueWalk
+        }
+        return .abortWalk
+      }
+
+      mutating func walkUp(value: Value, path: SmallProjectionPath) -> WalkResult {
+        switch value {
+        case is BlockArgument, is MarkDependenceInst, is CopyValueInst,
+             is StructExtractInst, is TupleExtractInst, is StructInst, is TupleInst,
+             is FunctionArgument, is AddressToPointerInst:
+          return walkUpDefault(value: value, path: path)
+        default:
           return .abortWalk
         }
-
-        if addrType != atp.operand.type { return .abortWalk }
-        if !path.isEmpty { return .abortWalk }
-
-        self.result = atp.operand
-        return .continueWalk
-      }
-      return .abortWalk
-    }
-
-    mutating func walkUp(value: Value, path: SmallProjectionPath) -> WalkResult {
-      switch value {
-      case is BlockArgument, is MarkDependenceInst, is CopyValueInst,
-           is StructExtractInst, is TupleExtractInst, is StructInst, is TupleInst,
-           is FunctionArgument, is AddressToPointerInst:
-        return walkUpDefault(value: value, path: path)
-      default:
-        return .abortWalk
-      }
-    }
+      }
+    }
+
+    var walker = Walker(addrType: type)
+    if walker.walkUp(value: operand, path: SmallProjectionPath()) == .abortWalk {
+      return nil
+    }
+    return walker.result
   }
 }
 

      assert(result.base == .unidentified, "rootDef should only called once")
      // Try identifying the address a pointer originates from
      if let p2ai = address as? PointerToAddressInst {
        if let originatingAddr = pointerId.getOriginatingAddress(of: p2ai) {
          return walkUp(address: originatingAddr, path: path)
        } else {
          self.result = AccessPath(base: .pointer(p2ai), projectionPath: path.projectionPath)

  private struct Walker : AddressUseDefWalker {
    private(set) var result = AccessPath.unidentified()
    private(set) var foundBeginAccess: BeginAccessInst?

    mutating func start() {
      result = .unidentified()
