EscapeUtils: consider that a pointer argument can escape a function call

Unlike addresses of indirect arguments, a pointer argument (e.g. `UnsafePointer`) can escape a function call.
For example, it can be returned.

Fixes a miscompile
rdar://154124497
This commit is contained in:
Erik Eckstein
2025-07-03 12:47:34 +02:00
parent dd6813f1b8
commit fc7c9931b3
3 changed files with 41 additions and 1 deletions

View File

@@ -640,7 +640,7 @@ fileprivate struct EscapeWalker<V: EscapeVisitor> : ValueDefUseWalker,
}
// Indirect arguments cannot escape the function, but loaded values from such can.
if !followLoads(at: path) {
if argOp.value.type.isAddress && !followLoads(at: path) {
if let beginApply = apply as? BeginApplyInst {
// begin_apply can yield an address value.
if !indirectResultEscapes(of: beginApply, path: path) {