Files
swift-mirror/test/SILOptimizer/inline_array_loop_mutation.swift
Kavon Farvardin fee696c49d Test: establish current OpaqueValues XFAILs
Please do not add any more XFAIL's of this kind!

If you break something under this configuration, you need to fix it
before merging your PR.
2026-07-26 22:25:20 -07:00

31 lines
930 B
Swift

// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking)
// RUN: %target-run-simple-swift(-O -Xfrontend -disable-availability-checking)
// REQUIRES: executable_test
// UNSUPPORTED: back_deployment_runtime || use_os_stdlib
// XFAIL: swift_test_mode_optimize_none_with_opaque_values
// Regression test for a miscompile where TBAA failed to recurse into
// `Builtin.FixedArray`'s element type, allowing LICM to hoist a load out
// of a loop past an aliasing store. The symptom was that a loop calling
// a `mutating` method which wrote to an `InlineArray` element via
// subscript left the effect of only one iteration in the final state.
struct Container {
var values: InlineArray<3, Int>
mutating func step() {
values[0] &+= 1
}
}
var c = Container(values: [0, 0, 0])
for _ in 0 ..< 10 {
c.step()
}
precondition(c.values[0] == 10)
precondition(c.values[1] == 0)
precondition(c.values[2] == 0)