Create Pack Specialisation pass

This commit is contained in:
Aidan Hall
2025-09-03 11:25:22 +01:00
parent c7af4c584e
commit 8632e58825
11 changed files with 1927 additions and 0 deletions

View File

@@ -139,6 +139,7 @@ set(SWIFT_BENCH_MODULES
single-source/ObserverUnappliedMethod
single-source/OpaqueConsumingUsers
single-source/OpenClose
single-source/ParameterPacks
single-source/Phonebook
single-source/PointerArithmetics
single-source/PolymorphicCalls

View File

@@ -0,0 +1,53 @@
//===--- ParameterPacks.swift ---------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// This benchmark serves to test the overhead of
import TestsUtils
public let benchmarks = [
BenchmarkInfo(
name: "ParameterPacks.VariadicFibonacci",
runFunction: run_ParameterPacksVariadicFibonacci,
tags: [.validation])
]
@inline(never)
func numericLoop<each T: BinaryInteger>(xs: repeat each T) -> (repeat each T) {
return
(repeat { x in
// Recursive "Fibonacci" function prevents inlining
if x <= 1 {
return x
} else {
let (a, b) = numericLoop(xs: x - 1, x - 2)
return a + b
}
}(each xs)
)
}
let expectedResult = (610, 987, 1597)
@inline(never)
public func run_ParameterPacksVariadicFibonacci(_ n: Int) {
var result = (0, 0, 0)
for _ in 1...n {
result = numericLoop(xs: 15, 16, 17)
if result != expectedResult {
break
}
}
check(result == expectedResult)
}

View File

@@ -143,6 +143,7 @@ import ObserverPartiallyAppliedMethod
import ObserverUnappliedMethod
import OpaqueConsumingUsers
import OpenClose
import ParameterPacks
import Phonebook
import PointerArithmetics
import PolymorphicCalls
@@ -343,6 +344,7 @@ register(ObserverPartiallyAppliedMethod.benchmarks)
register(ObserverUnappliedMethod.benchmarks)
register(OpaqueConsumingUsers.benchmarks)
register(OpenClose.benchmarks)
register(ParameterPacks.benchmarks)
register(Phonebook.benchmarks)
register(PointerArithmetics.benchmarks)
register(PolymorphicCalls.benchmarks)