# Does FullApplySite::getCalleeOrigin() work correctly?

**URL:** <https://forums.swift.org/t/does-fullapplysite-getcalleeorigin-work-correctly/88314>\
**Category:** Compiler\
**Created:** [July 15, 2026, 7:06pm UTC](https://forums.swift.org/t/does-fullapplysite-getcalleeorigin-work-correctly/88314 "2026-07-15T19:06:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamieQ](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jamieq/32/5117_2.png) [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Post date:** [July 15, 2026, 7:06pm UTC](https://forums.swift.org/t/does-fullapplysite-getcalleeorigin-work-correctly/88314/1 "2026-07-15T19:06:45Z")

</div>

I was debugging some code that produced SIL like this:

```swift
  %7 = partial_apply [callee_guaranteed] %5(%6) : $@convention(thin) (@guaranteed NS) -> @owned NS // user: %8
  %8 = move_value [lexical] [var_decl] %7 // users: %23, %10, %9
  debug_value %8, let, name "c" // id: %9
  %10 = begin_borrow %8 // users: %18, %11
  %11 = copy_value %10 // users: %17, %12
  %12 = begin_borrow %11 // users: %14, %13
  %13 = apply %12() : $@callee_guaranteed () -> @owned NS // user: %16

```

I was using a `FullApplySite` of the apply at `%13 = apply %12()`, and when I [called](https://github.com/swiftlang/swift/blob/e9e1fa9e028bb8dcff68550afb939ac3103a8702/include/swift/SIL/SILInstruction.h#L12171) `getCalleeOrigin()` on it, I expected to get back to the the partial\_apply. However, it seems that utility does not look through `MoveValueInst` and I ended up with the `move_value` being returned instead.

Is that the expected behavior, or should `getCalleeOrigin()` look through the move\_value? Relatedly, are there any other instructions it should also look through (e.g. mark\_dependence or any newer ownership/lifetime things?)?

---

<div class="post-metadata">

**Author:** ![Andrew\_Trick](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/andrew_trick/32/323_2.png) [@Andrew\_Trick](https://forums.swift.org/u/Andrew_Trick)\
**Post date:** [July 16, 2026, 6:18am UTC](https://forums.swift.org/t/does-fullapplysite-getcalleeorigin-work-correctly/88314/2 "2026-07-16T06:18:53Z")

</div>

`getCalleeOrigin` already looks through copies, so looking through moves shouldn't confuse anything. `getCalleeOrigin` should just loop over `getSingleValueCopyOrCast` without checking anything else.

The additional instructions handled by `getSingleValueCopyOrCast` are:

- From its own switch `CopyBlockInst, CopyBlockWithoutEscapingInst, BeginAccessInst, MarkDependenceInst, MoveValueInst`
- From `ConversionOperation::isa`
- 

```swift
  - MarkUnresolvedNonCopyableValueInst
  - MarkUninitializedInst
  - ConvertFunctionInst
  - UpcastInst
  - AddressToPointerInst
  - UncheckedTrivialBitCastInst
  - UncheckedAddrCastInst
  - UncheckedBitwiseCastInst
  - RefToRawPointerInst
  - RawPointerToRefInst
  - ConvertEscapeToNoEscapeInst
  - RefToBridgeObjectInst
  - BridgeObjectToRefInst
  - BridgeObjectToWordInst
  - ThinToThickFunctionInst
  - ThickToObjCMetatypeInst
  - ObjCToThickMetatypeInst
  - ObjCMetatypeToObjectInst
  - ObjCExistentialMetatypeToObjectInst
  - UnconditionalCheckedCastInst
  - UncheckedRefCastInst
  - UncheckedValueCastInst
  - RefToUnmanagedInst
  - RefToUnownedInst
  - UnmanagedToRefInst
  - UnownedToRefInst
  - CopyableToMoveOnlyWrapperValueInst
  - MoveOnlyWrapperToCopyableValueInst
  - MoveOnlyWrapperToCopyableBoxInst
  - DropDeinitInst

```

---

<div class="post-metadata">

**Author:** ![jamieQ](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jamieq/32/5117_2.png) [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Post date:** [July 17, 2026, 1:57pm UTC](https://forums.swift.org/t/does-fullapplysite-getcalleeorigin-work-correctly/88314/3 "2026-07-17T13:57:10Z")

</div>

Thank you!

> [@Andrew\_Trick](#):
>
> `getCalleeOrigin` should just loop over `getSingleValueCopyOrCast` without checking anything else.

Here is a proposed refactor based on this suggestion, for which I would appreciate any/all feedback: [[SIL]: Refactor getCalleeOrigin to look through more instructions by jamieQ · Pull Request #90765 · swiftlang/swift · GitHub](https://github.com/swiftlang/swift/pull/90765).

---

<div class="post-metadata">

**Author:** ![Andrew\_Trick](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/andrew_trick/32/323_2.png) [@Andrew\_Trick](https://forums.swift.org/u/Andrew_Trick)\
**Post date:** [July 17, 2026, 10:07pm UTC](https://forums.swift.org/t/does-fullapplysite-getcalleeorigin-work-correctly/88314/4 "2026-07-17T22:07:11Z")

</div>

I should have pointed out that `ConversionOperation` can change the function type. It's possible we have code that expects the original callee to have the same type as the applied callee.
