Files
swift-mirror/test/SILOptimizer/mem2reg_resilient.sil
Michael Gottesman 333737bc7a [sil] Remove usage from TypeLowering of SILBuilder::create*AndFold().
These create*AndFold APIs are actively harmful when used in TypeLowering since:

1. In general they are a problem since it is weird for a builder API to remove
   an instruction.

2. These APIs do not take an erase callback that must be used in passes that
   need to update state before erasing the instruction.

3. The typelowering APIs that use this are emitDestroyValue/etc which are the
   main APIs that we are using to write code that works with OSSA/non-OSSA
   SIL. So we are going to use these APIs in many more places, introducing this
   bug in many places.

With that in mind, I have been committing small cheap ARC optimizations to
GuaranteedARCOpts (SemanticARCOpts with expensive optimizations turned off) so
that we can eliminate this without massively churning the code. We are at this
stage now, so it makes sense to turn this off.
2020-11-30 04:51:39 -08:00

33 lines
995 B
Plaintext

// RUN: %target-sil-opt -enable-sil-verify-all %s -mem2reg -enable-library-evolution | %FileCheck %s
import Builtin
import Swift
public struct ResilientStruct {
var x: AnyObject
}
// CHECK-LABEL: sil @mem2reg_debug_value_addr :
// CHECK: bb0(%0 : $*ResilientStruct):
// CHECK-NEXT: %1 = load %0
// CHECK-NEXT: retain_value %1
// CHECK-NEXT: debug_value %1
// CHECK-NEXT: release_value %1
// CHECK-NEXT: tuple ()
// CHECK-NEXT: return {{%.*}} : $()
// CHECK: } // end sil function 'mem2reg_debug_value_addr'
sil @mem2reg_debug_value_addr : $@convention(thin) (@in_guaranteed ResilientStruct) -> () {
bb0(%0 : $*ResilientStruct):
%1 = alloc_stack $ResilientStruct
%2 = load %0 : $*ResilientStruct
retain_value %2 : $ResilientStruct
store %2 to %1 : $*ResilientStruct
debug_value_addr %1 : $*ResilientStruct
%3 = load %1 : $*ResilientStruct
destroy_addr %1 : $*ResilientStruct
dealloc_stack %1 : $*ResilientStruct
%4 = tuple ()
return %4 : $()
}