Commit Graph

3 Commits

Author SHA1 Message Date
Erik Eckstein
57e08affcb SIL: add ApplySite.calleeArgument(of operand: Operand, in callee: Function)
This is a safer API than using
```
  let argIdx = applySite.calleeArgumentIndex(of: op)
  let arg = callee.arguments[argIdx]
```
because there is no potential misuse of the index.
2025-06-20 08:14:59 +02:00
Erik Eckstein
1fee4fe953 Optimizer: support partial_apply of thunks in the copy_block simplification.
If the block is passed to another function - either as closure argument or as closure capture - it's "converted" to a swift closure with the help of a thunk. The thunk just calls the block.
If this is done with a non-escaping partial_apply, the block does not escape.

rdar://149095630
2025-05-02 18:10:08 +02:00
Erik Eckstein
199eb1d6e7 Optimizer: remove redundant copy_block instructions
Removes a `copy_block` if its only uses, beside ownership instructions, are callees of function calls
```
  %2 = copy_block %0
  %3 = begin_borrow [lexical] %2
  %4 = apply %3() : $@convention(block) @noescape () -> ()
  end_borrow %3
  destroy_value %2
```
->
```
  %4 = apply %0() : $@convention(block) @noescape () -> ()
```

rdar://118521396
2025-04-15 11:02:39 +02:00