Files
swift-mirror/test/SILOptimizer/callee_analysis_crash.swift
Erik Eckstein d88edadb60 BasicCalleeAnalysis: fix computation of class method callees if an overridden function has a different ABI
In such a case the overridden function gets a new separate vtable entry.
With this change, the computation of class method callees only uses the information in sil_vtables (instead of ClassDecl members).

Fixes a compiler crash in various optimization passes.
rdar://problem/56146633
2019-10-22 11:27:21 +02:00

42 lines
721 B
Swift

// RUN: %target-swift-frontend -O %s -emit-ir -o /dev/null
// Check that we don't crash here.
enum E<T> {
case A
case B(T)
}
public protocol P {
associatedtype A
}
internal class Base<T: P> {
func foo() -> E<T.A> {
return .A
}
}
struct Outer<T: P> where T.A == Int {
private class Inner : Base<T> {
// This overridden function has a different ABI than the base implementation.
// The BasicCalleeAnalysis put both methods in the callee list, which let
// some optimizations crash.
override func foo() -> E<T.A> {
return .A
}
}
}
@inline(never)
func getit<T: P>(_ t: T) -> Base<T> {
return Base<T>()
}
public func testit<T: P>(_ t: T) {
let b = getit(t)
b.foo()
}