mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This fixes a miscompile in case the source of the optimized copy_addr is modified in a called function with to a not visible alias. This can happen with class properties or global variables. This fix removes the special handling of function parameters, which was just wrong. Instead it simply uses the alias analysis API to check for modifications of the source object. The fix makes TempRValueElimination more conservative and this can cause some performance regressions, but this is unavoidable. rdar://problem/69605657
25 lines
467 B
Swift
25 lines
467 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift -O %s -o %t/a.out
|
|
// RUN: %target-codesign %t/a.out
|
|
// RUN: %target-run %t/a.out | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
var global: Any = 1
|
|
func withValue(action: (Any) -> Void) {
|
|
action(global)
|
|
}
|
|
|
|
@inline(never)
|
|
public func test_global_side_effect() {
|
|
withValue { value in
|
|
print(value)
|
|
global = 24
|
|
print(value)
|
|
}
|
|
}
|
|
|
|
// CHECK: 1
|
|
// CHECK-NEXT: 1
|
|
test_global_side_effect()
|