Files
swift-mirror/test/SILGen/objc_final.swift
Erik Eckstein 7cceaff5f3 SIL: don't print operand types in textual SIL
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
2024-11-21 18:49:52 +01:00

33 lines
1.2 KiB
Swift

// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-verbose-sil | %FileCheck %s
// REQUIRES: objc_interop
import Foundation
final class Foo {
@objc func foo() {}
// CHECK-LABEL: sil private [thunk] [ossa] @$s10objc_final3FooC3foo{{[_0-9a-zA-Z]*}}FTo
@objc var prop: Int = 0
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s10objc_final3FooC4propSivgTo
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s10objc_final3FooC4propSivsTo
}
// CHECK-LABEL: sil hidden [ossa] @$s10objc_final7callFooyyAA0D0CF
func callFoo(_ x: Foo) {
// Calls to the final @objc method statically reference the native entry
// point.
// CHECK: function_ref @$s10objc_final3FooC3foo{{[_0-9a-zA-Z]*}}F
x.foo()
// Final @objc properties are still accessed directly.
// CHECK: [[PROP:%.*]] = ref_element_addr {{%.*}} : $Foo, #Foo.prop
// CHECK: [[READ:%.*]] = begin_access [read] [dynamic] [[PROP]] : $*Int
// CHECK: load [trivial] [[READ]] : $*Int
let prop = x.prop
// CHECK: [[PROP:%.*]] = ref_element_addr {{%.*}} : $Foo, #Foo.prop
// CHECK: [[WRITE:%.*]] = begin_access [modify] [dynamic] [[PROP]] : $*Int
// CHECK: assign {{%.*}} to [[WRITE]] : $*Int
x.prop = prop
}