Files
swift-mirror/test/SILOptimizer/semanticarc_and_inlining.sil
Erik Eckstein cd275f3ceb SIL: Fix a wrong assert in ValueOwnershipKind::forwardToInit
The assert implies that non-copyable struct instructions must not have "guaranteed" ownership. However, this is not enforced in the SIL verifier are anywhere else.
SemanticARCOpt converts this owned struct into a guaranteed struct, which is a legal transformation.
The fix is to remove the assert.

Fixes a compiler crash
rdar://172675080
2026-03-17 15:06:00 +01:00

37 lines
878 B
Plaintext

// RUN: %target-sil-opt -semantic-arc-opts -inline %s | %FileCheck %s
sil_stage canonical
import Builtin
import Swift
import SwiftShims
struct NC : ~Copyable {
var o: AnyObject
}
sil [ossa] @testit : $@convention(thin) (@guaranteed AnyObject) -> () {
bb0(%0: @guaranteed $AnyObject):
%1 = copy_value %0
%2 = struct $NC (%1)
%3 = destructure_struct %2
destroy_value %3
%r = tuple ()
return %r
}
// Check that the compiler doesn't crash
// CHECK-LABEL: sil [ossa] @caller :
// CHECK-NOT: copy_value
// CHECK-NOT: apply
// CHECK: } // end sil function 'caller'
sil [ossa] @caller : $@convention(thin) (@guaranteed AnyObject) -> () {
bb0(%0: @guaranteed $AnyObject):
%1 = function_ref @testit : $@convention(thin) (@guaranteed AnyObject) -> ()
%2 = apply %1(%0) : $@convention(thin) (@guaranteed AnyObject) -> ()
%r = tuple ()
return %r
}