From 88cb08718ca2f4f8e07dfcb5c1d8fbb31f08d1ab Mon Sep 17 00:00:00 2001 From: Bob Haarman Date: Wed, 30 Nov 2016 03:25:36 +0000 Subject: [PATCH] make -fprofile-instr-generate and -fprofile-instr-use work with clang-cl Summary: Makes -fprofile-instr-generate and -fprofile-instr-use work with clang-cl so that profile-guided optimization can be used. Differential Revision: https://reviews.llvm.org/D27086 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@288230 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 8 ++++---- test/Driver/cl-options.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index fa2511de14..316eafd683 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -510,15 +510,15 @@ def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">, def fauto_profile_EQ : Joined<["-"], "fauto-profile=">, Alias; def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">, - Group, Flags<[DriverOption]>, + Group, Flags<[CoreOption]>, HelpText<"Generate instrumented code to collect execution counts into default.profraw file (overriden by '=' form of option or LLVM_PROFILE_FILE env var)">; def fprofile_instr_generate_EQ : Joined<["-"], "fprofile-instr-generate=">, - Group, Flags<[DriverOption]>, MetaVarName<"">, + Group, Flags<[CoreOption]>, MetaVarName<"">, HelpText<"Generate instrumented code to collect execution counts into (overridden by LLVM_PROFILE_FILE env var)">; def fprofile_instr_use : Flag<["-"], "fprofile-instr-use">, Group, - Flags<[DriverOption]>; + Flags<[CoreOption]>; def fprofile_instr_use_EQ : Joined<["-"], "fprofile-instr-use=">, - Group, Flags<[DriverOption]>, + Group, Flags<[CoreOption]>, HelpText<"Use instrumentation data for profile-guided optimization">; def fcoverage_mapping : Flag<["-"], "fcoverage-mapping">, Group, Flags<[CC1Option]>, diff --git a/test/Driver/cl-options.c b/test/Driver/cl-options.c index ec0bd572ba..5054d8ad1f 100644 --- a/test/Driver/cl-options.c +++ b/test/Driver/cl-options.c @@ -59,6 +59,19 @@ // RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=gdefcolumn %s // gdefcolumn-NOT: -dwarf-column-info +// RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s +// RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s +// RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s +// RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s +// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" +// CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw" +// CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}' + +// RUN: %clang_cl -### /FA -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s +// RUN: %clang_cl -### /FA -fprofile-instr-use=/tmp/somefile.prof -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s +// CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata" +// CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof" + // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s // GA: -ftls-model=local-exec -- 2.40.0