mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This pass generated incorrect borrow scopes: %stack = alloc_stack %borrow = begin_borrow %element store_borrow %borrow to %stack end_borrow %borrow try_apply %f(%stack) normal bb1, error bb2 ... destroy_value %element This was not showing up as a miscompile before because: - an array holds an extra copy of the unrolled elements, that array is now being optimized away completely. - CopyPropagation now canonicalizes OSSA lifetimes independent of unrelated program side effects. So, since there is no explicit relationship between %borrow and the OSSA value in %stack, we end up with: %stack = alloc_stack %borrow = begin_borrow %element store_borrow %borrow to %stack end_borrow %borrow destroy_value %element try_apply %f(%stack) normal bb1, error bb2 Fixes rdar://72904101 ([CanonicalOSSA] Fix ForEachLoopUnroll use-after-free miscompile.)
27 KiB
27 KiB