mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #40741 from eeckstein/fix-alloc-stack-hoisting
AllocStackHoisting: fix the check for availability-checks
This commit is contained in:
@@ -348,14 +348,12 @@ private:
|
||||
} // end anonymous namespace
|
||||
|
||||
bool indicatesDynamicAvailabilityCheckUse(SILInstruction *I) {
|
||||
auto *Apply = dyn_cast<ApplyInst>(I);
|
||||
if (!Apply)
|
||||
return false;
|
||||
if (Apply->hasSemantics(semantics::AVAILABILITY_OSVERSION))
|
||||
return true;
|
||||
auto *FunRef = Apply->getReferencedFunctionOrNull();
|
||||
if (!FunRef)
|
||||
return false;
|
||||
if (auto *Apply = dyn_cast<ApplyInst>(I)) {
|
||||
return Apply->hasSemantics(semantics::AVAILABILITY_OSVERSION);
|
||||
}
|
||||
if (auto *bi = dyn_cast<BuiltinInst>(I)) {
|
||||
return bi->getBuiltinInfo().ID == BuiltinValueKind::TargetOSVersionAtLeast;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,3 +230,30 @@ bb3:
|
||||
%3 = builtin "int_trap"() : $()
|
||||
unreachable
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil @dont_hoist_with_availability_checks
|
||||
// CHECK-NOT: alloc_stack
|
||||
// CHECK: cond_br
|
||||
// CHECK: bb1:
|
||||
// CHECK: alloc_stack
|
||||
// CHECK: } // end sil function 'dont_hoist_with_availability_checks'
|
||||
sil @dont_hoist_with_availability_checks : $@convention(thin) <T> (@in T, Builtin.Int1) -> () {
|
||||
bb0(%0 : $*T, %1: $Builtin.Int1):
|
||||
%5 = integer_literal $Builtin.Int32, 15
|
||||
%7 = builtin "targetOSVersionAtLeast"(%5 : $Builtin.Int32, %5 : $Builtin.Int32, %5 : $Builtin.Int32) : $Builtin.Int32
|
||||
%8 = builtin "cmp_eq_Int32"(%7 : $Builtin.Int32, %5 : $Builtin.Int32) : $Builtin.Int1
|
||||
cond_br %8, bb1, bb2
|
||||
bb1:
|
||||
%2 = alloc_stack $T
|
||||
copy_addr [take] %0 to [initialization] %2 : $*T
|
||||
destroy_addr %2 : $*T
|
||||
dealloc_stack %2 : $*T
|
||||
br bb3
|
||||
bb2:
|
||||
destroy_addr %0 : $*T
|
||||
br bb3
|
||||
bb3:
|
||||
%3 = tuple ()
|
||||
return %3 : $()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user