Skip to content

Commit b633c81

Browse files
authored
Merge pull request swiftlang#78078 from kavon/samplepgo-driver-support
swift-frontend: Driver support for SamplePGO
2 parents f6304a0 + b1db012 commit b633c81

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

include/swift/Option/Options.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ def profile_generate : Flag<["-"], "profile-generate">,
14901490
HelpText<"Generate instrumented code to collect execution counts">;
14911491

14921492
def debug_info_for_profiling : Flag<["-"], "debug-info-for-profiling">,
1493-
Flags<[FrontendOption, NoInteractiveOption]>,
1493+
Flags<[FrontendOption, NoInteractiveOption, NewDriverOnlyOption]>,
14941494
HelpText<"Emit extra debug info (DWARF discriminators) to make sampling-based profiling more accurate">;
14951495

14961496
def profile_use : CommaJoined<["-"], "profile-use=">,
@@ -1502,8 +1502,8 @@ def profile_coverage_mapping : Flag<["-"], "profile-coverage-mapping">,
15021502
Flags<[FrontendOption, NoInteractiveOption]>,
15031503
HelpText<"Generate coverage data for use with profiled execution counts">;
15041504

1505-
def profile_sample_use : CommaJoined<["-"], "profile-sample-use=">,
1506-
Flags<[FrontendOption, NoInteractiveOption, ArgumentIsPath]>,
1505+
def profile_sample_use : Joined<["-"], "profile-sample-use=">,
1506+
Flags<[FrontendOption, NoInteractiveOption, ArgumentIsPath, NewDriverOnlyOption]>,
15071507
MetaVarName<"<profile data>">,
15081508
HelpText<"Supply sampling-based profiling data from llvm-profdata to enable profile-guided optimization">;
15091509

test/Profiler/samplepgo.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
// Test the -profile-sample-use= flag using bogus data, to ensure it's actually
66
// reaching LLVM in the expected way.
77

8-
// RUN: %target-swift-frontend %t/program.swift -module-name test -emit-ir \
9-
// RUN: -O -profile-sample-use=%t/profile.txt -o %t/has-data.ll
8+
// RUN: %target-swiftc_driver -v %t/program.swift -module-name test -emit-ir \
9+
// RUN: -O -profile-sample-use=%t/profile.txt -o %t/has-data.ll \
10+
// RUN: > %t/flags.txt
11+
12+
// RUN: %FileCheck %s --check-prefix CHECK-STDERR --input-file %t/flags.txt
13+
// CHECK-STDERR: -Xllvm -sample-profile-use-profi
1014

11-
// RUN: %FileCheck %s < %t/has-data.ll
15+
// RUN: %FileCheck %s --input-file %t/has-data.ll
1216

1317
// CHECK: define{{.*}} @"$s4test8anythingyyF"() #[[ATTRID:[0-9]+]]
1418
// CHECK: attributes #[[ATTRID]] = {{.*}} "use-sample-profile"
@@ -33,6 +37,11 @@
3337
// CHECK-NODATA-LABEL: !llvm.module.flags
3438
// CHECK-NODATA-NOT: Profile
3539

40+
// FIXME: It appears that Windows does not use the new swift-driver.
41+
// This test in particular includes end-to-end testing coverage via
42+
// that driver to ensure the flag works.
43+
// REQUIRES: OS=macosx || OS=linux-gnu
44+
3645

3746
//--- program.swift
3847
public func anything() {}

0 commit comments

Comments
 (0)