mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
DeadObjectElimination: handle the builtin "prepareInitialization"
which allows e.g. eliminating dead `Atomic` values
This commit is contained in:
@@ -318,7 +318,8 @@ static bool canZapInstruction(SILInstruction *Inst, bool acceptRefCountInsts,
|
||||
// The value form of zero init is not a user of any operand. The address
|
||||
// form however is easily zappable because it's always a trivial store.
|
||||
if (auto bi = dyn_cast<BuiltinInst>(Inst)) {
|
||||
if (bi->getBuiltinKind() == BuiltinValueKind::ZeroInitializer) {
|
||||
if (bi->getBuiltinKind() == BuiltinValueKind::ZeroInitializer ||
|
||||
bi->getBuiltinKind() == BuiltinValueKind::PrepareInitialization) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,3 +721,15 @@ bb0:
|
||||
%1 = tuple ()
|
||||
return %1 : $()
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @dead_prepare_init
|
||||
// CHECK-NOT: alloc_stack
|
||||
// // CHECK: } // end sil function 'dead_prepare_init'
|
||||
sil @dead_prepare_init : $@convention(thin) () -> () {
|
||||
bb0:
|
||||
%0 = alloc_stack $Kl
|
||||
%empty = builtin "prepareInitialization"(%0 : $*Kl) : $()
|
||||
dealloc_stack %0 : $*Kl
|
||||
%1 = tuple ()
|
||||
return %1 : $()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user