Files
swift-mirror/test/SILOptimizer/earlycodemotion_moveonly.sil
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

67 lines
1.8 KiB
Plaintext

// RUN: %target-sil-opt -sil-print-types -enable-sil-verify-all %s -early-codemotion -retain-sinking -enable-experimental-feature MoveOnlyEnumDeinits | %FileCheck %s
// REQUIRES: swift_feature_MoveOnlyEnumDeinits
sil_stage canonical
import Builtin
import Swift
struct FileDescriptor: ~Copyable {
var fd: Builtin.Int64
init(fd: Builtin.Int64)
deinit
}
enum MaybeFileDescriptor: ~Copyable {
case some(FileDescriptor)
case nothing
consuming func discard() { discard self }
deinit
}
struct CS {
let c: AnyObject
}
public struct S : ~Copyable {
var a: CS
}
// Test that a release_value is not replaced for a enum-with-deinit.
// Doing so would forget the deinit.
//
// CHECK-LABEL: sil hidden [noinline] @testEnumDeinit : $@convention(thin) () -> () {
// CHECK: release_value %{{.*}} : $MaybeFileDescriptor
// CHECK-LABEL: } // end sil function 'testEnumDeinit'
sil hidden [noinline] @testEnumDeinit : $@convention(thin) () -> () {
bb0:
%0 = integer_literal $Builtin.Int64, 0
%26 = struct $FileDescriptor (%0 : $Builtin.Int64)
%38 = enum $MaybeFileDescriptor, #MaybeFileDescriptor.some!enumelt, %26 : $FileDescriptor
release_value %38 : $MaybeFileDescriptor
%42 = tuple ()
return %42 : $()
}
sil @useCS : $@convention(thin) (@guaranteed CS) -> ()
// CHECK-LABEL: sil @testRCroot :
// CHECK-NOT: retain_value %{{[0-9]*}} : $S
// CHECK: } // end sil function 'testRCroot'
sil @testRCroot : $@convention(method) (@guaranteed S) -> () {
bb0(%0 : $S):
%2 = struct_extract %0 : $S, #S.a
%3 = struct_extract %2 : $CS, #CS.c
strong_retain %3 : $AnyObject
%5 = function_ref @useCS : $@convention(thin) (@guaranteed CS) -> ()
%6 = apply %5(%2) : $@convention(thin) (@guaranteed CS) -> ()
release_value %0 : $S
%9 = tuple ()
return %9 : $()
}