mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This PR introduces three new instrumentation flags and plumbs them through to IRGen: 1. `-ir-profile-generate` - enable IR-level instrumentation. 2. `-cs-profile-generate` - enable context-sensitive IR-level instrumentation. 3. `-ir-profile-use` - IR-level PGO input profdata file to enable profile-guided optimization (both IRPGO and CSIRPGO) **Context:** https://forums.swift.org/t/ir-level-pgo-instrumentation-in-swift/82123 **Swift-driver PR:** https://github.com/swiftlang/swift-driver/pull/1992 **Tests and validation:** This PR includes ir level verification tests, also checks few edge-cases when `-ir-profile-use` supplied profile is either missing or is an invalid IR profile. However, for argument validation, linking, and generating IR profiles that can later be consumed by -cs-profile-generate, I’ll need corresponding swift-driver changes. Those changes are being tracked in https://github.com/swiftlang/swift-driver/pull/1992
24 lines
732 B
Plaintext
24 lines
732 B
Plaintext
// Missing file
|
|
// RUN: %target-swift-frontend -ir-profile-use=missing.profdata -emit-ir %s 2>&1 | %FileCheck --ignore-case --check-prefix=CHECK-NOFILE %s
|
|
// CHECK-NOFILE: error reading profile
|
|
// CHECK-NOFILE: .profdata
|
|
// CHECK-NOFILE: No such file or directory
|
|
|
|
|
|
// Invalid IR file
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: echo "" > %t.invalid.profdata
|
|
// RUN: %target-swift-frontend -ir-profile-use=%t.invalid.profdata -emit-ir %s 2>&1 | %FileCheck --ignore-case --check-prefix=CHECK-INVALIDFILE %s
|
|
// CHECK-INVALIDFILE: error reading profile
|
|
// CHECK-INVALIDFILE: invalid.profdata
|
|
// CHECK-INVALIDFILE: invalid instrumentation profile data
|
|
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
import Swift
|
|
import SwiftShims
|
|
|
|
public func foo() {}
|