Files
swift-mirror/test/embedded/devirt_generic_class_methods.swift
Erik Eckstein 606f7693d4 MandatoryPerformanceOptimizations: don't de-virtualize a generic class method call to specialized method
This results in wrong argument/return calling conventions.
First, the method call must be specialized. Only then the call can be de-virtualized.
Usually, it's done in this order anyway, because the `class_method` instruction is located before the `apply`.
But when inlining functions, the order (in the worklist) can be the other way round.

Fixes a compiler crash.
rdar://154631438
2025-07-01 09:44:47 +02:00

23 lines
462 B
Swift

// RUN: %target-swift-frontend %s -parse-as-library -enable-experimental-feature Embedded -Xllvm -sil-disable-pass=mandatory-inlining -emit-ir -o /dev/null
// REQUIRES: swift_feature_Embedded
// Check that the compiler doesn't crash
public class Base<T> {
func foo(_ t: T) -> T {
return t
}
}
@_transparent
func callee(_ i: Int, _ c: Base<Int>) -> Int {
return c.foo(i)
}
public func testit(_ i : Int) -> Int {
return callee(i, Base<Int>())
}