Files
swift-mirror/test/SILOptimizer/temp_rvalue_opt.swift
Erik Eckstein 9f85cb8576 TempRValueElimination: handle potential modifications of the copy-source in a called functions correctly.
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
2020-10-09 20:54:59 +02:00

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()