Files
swift-mirror/test/SILOptimizer/templvalueopt_crash.swift
Erik Eckstein f0b7bdb382 TempLValueOpt: avoid creating invalid apply argument aliasing.
An indirect argument (except `@inout_aliasable`) must not alias with another indirect argument.
Now, if we would replace tempAddr with destAddr in
```
  apply %f(%tempAddr, %destAddr) : (@in T) -> @out T
```
we would invalidate this rule.
This is even true if the called function does not read from destAddr.

Fixes a SIL verification error.
rdar://145090659
2025-02-19 10:33:18 +01:00

25 lines
418 B
Swift

// RUN: %target-swift-frontend %s -O -sil-verify-all -emit-sil -o /dev/null
// Check that TempLValueOpt does not create invalid SIL which causes a verification error.
public struct S<T> {
internal var a: T? = nil
public var b: T? {a}
public var c: T? = nil
public mutating func set() {
c = b
}
}
public class Klass{}
public func test() -> S<Klass> {
var s = S<Klass>()
s.set()
return s
}