mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add IRPGO and CSIRPGO options to Swift (#84335)
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
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
using namespace swift;
|
||||
using namespace swift::driver;
|
||||
using namespace llvm::opt;
|
||||
using namespace swift::driver::toolchains;
|
||||
|
||||
std::string
|
||||
toolchains::GenericUnix::sanitizerRuntimeLibName(StringRef Sanitizer,
|
||||
@@ -330,7 +331,7 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
|
||||
}
|
||||
}
|
||||
|
||||
if (context.Args.hasArg(options::OPT_profile_generate)) {
|
||||
if (needsInstrProfileRuntime(context.Args)) {
|
||||
SmallString<128> LibProfile(SharedResourceDirPath);
|
||||
llvm::sys::path::remove_filename(LibProfile); // remove platform name
|
||||
llvm::sys::path::append(LibProfile, "clang", "lib");
|
||||
|
||||
Reference in New Issue
Block a user