[PATCH] D16730: [PGO] cc1 option names change for profile instrumentation (NFC)

Bob Wilson via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 13:13:52 PST 2016


Ah, right. I missed that this is only changing the cc1 option. Unless Justin sees a problem, that part seems OK with me.

> On Feb 3, 2016, at 1:11 PM, Xinliang David Li <davidxl at google.com> wrote:
> 
> There is no change in driver option at all with this patch. So
> basically -fprofile-instr-generate and -fprofile-instr-generate=<...>
> option's behavior does not change.
> 
> What is changed is purely internal --  -fprofile-instr-generate  used
> to be an cc1/FE option to inform the FE to do instrumentation. With
> this patch, this cc1 option is enhanced to allow passing a flavor
> argument.
> 
> In short, from a compiler user's point of view, this change is NFC.
> 
> thanks,
> 
> David
> 
> On Wed, Feb 3, 2016 at 1:03 PM, Bob Wilson <bob.wilson at apple.com> wrote:
>> 
>>> On Feb 3, 2016, at 12:54 PM, Justin Bogner <mail at justinbogner.com> wrote:
>>> 
>>> Rong Xu <xur at google.com> writes:
>>>> This patch is split from http://reviews.llvm.org/D15829.
>>>> 
>>>> It changes cc1 option -fprofile-generate to an enum option
>>>> -fprofile-instrument=,
>>>> and it takes Clang as the default (and only, or now) value.
>>>> 
>>>> It also changes cc1 options -fprofile-generate= to -fprofile-instrument-path=.
>>>> 
>>>> The driver level option -fprofile-generate and -fprofile-generate= are intact.
>>>> 
>>>> This change will pave the way to integrate new PGO instrumentation in IR level.
>>> 
>>> The implementation here looks fine, but a change like this will force
>>> anyone who's already using clang's instrumentation based profiling
>>> features to update how they do this, and possibly have to determine
>>> which flag to use based on the current host compiler.
>>> 
>>> Some people might have a problem with that. CCing Bob and Vedant for
>>> comment.
>> 
>> Yes, I might have a problem with that. Does the new -fprofile-generate=clang option exactly match the behavior of -fprofile-instr-generate? Does the patch keep the existing -fprofile-instr-generate option as a synonym for the new option? We have existing clients that we cannot break without providing a transition over 1-2 LLVM releases to give time to migrate to new options.
>> 
>>> 
>>> Rong Xu <xur at google.com> writes:
>>>> xur updated this revision to Diff 46477.
>>>> xur added a comment.
>>>> 
>>>> change test case test/Profile/c-generate.c:
>>>> (1) use clang_cc1
>>>> (2) use 2>&1
>>>> 
>>>> Thanks,
>>>> 
>>>> -Rong
>>>> 
>>>> 
>>>> http://reviews.llvm.org/D16730
>>>> 
>>>> Files:
>>>> include/clang/Basic/DiagnosticDriverKinds.td
>>>> include/clang/Driver/CC1Options.td
>>>> include/clang/Driver/Options.td
>>>> include/clang/Frontend/CodeGenOptions.def
>>>> include/clang/Frontend/CodeGenOptions.h
>>>> lib/CodeGen/BackendUtil.cpp
>>>> lib/CodeGen/CGStmt.cpp
>>>> lib/CodeGen/CodeGenFunction.cpp
>>>> lib/CodeGen/CodeGenFunction.h
>>>> lib/CodeGen/CodeGenPGO.cpp
>>>> lib/Driver/Tools.cpp
>>>> lib/Frontend/CompilerInvocation.cpp
>>>> test/CoverageMapping/block-storage-starts-region.m
>>>> test/CoverageMapping/break.c
>>>> test/CoverageMapping/builtinmacro.c
>>>> test/CoverageMapping/casts.c
>>>> test/CoverageMapping/classtemplate.cpp
>>>> test/CoverageMapping/comment-in-macro.c
>>>> test/CoverageMapping/continue.c
>>>> test/CoverageMapping/control-flow-macro.c
>>>> test/CoverageMapping/decl.c
>>>> test/CoverageMapping/header.cpp
>>>> test/CoverageMapping/if.c
>>>> test/CoverageMapping/implicit-def-in-macro.m
>>>> test/CoverageMapping/includehell.cpp
>>>> test/CoverageMapping/ir.c
>>>> test/CoverageMapping/label.cpp
>>>> test/CoverageMapping/lambda.cpp
>>>> test/CoverageMapping/logical.cpp
>>>> test/CoverageMapping/loopmacro.c
>>>> test/CoverageMapping/loops.cpp
>>>> test/CoverageMapping/macro-expansion.c
>>>> test/CoverageMapping/macro-expressions.cpp
>>>> test/CoverageMapping/macroception.c
>>>> test/CoverageMapping/macroparams.c
>>>> test/CoverageMapping/macroparams2.c
>>>> test/CoverageMapping/macros.c
>>>> test/CoverageMapping/macroscopes.cpp
>>>> test/CoverageMapping/md.cpp
>>>> test/CoverageMapping/moremacros.c
>>>> test/CoverageMapping/nestedclass.cpp
>>>> test/CoverageMapping/objc.m
>>>> test/CoverageMapping/preprocessor.c
>>>> test/CoverageMapping/return.c
>>>> test/CoverageMapping/switch.c
>>>> test/CoverageMapping/switchmacro.c
>>>> test/CoverageMapping/system_macro.c
>>>> test/CoverageMapping/templates.cpp
>>>> test/CoverageMapping/test.c
>>>> test/CoverageMapping/trycatch.cpp
>>>> test/CoverageMapping/trymacro.cpp
>>>> test/CoverageMapping/unreachable-macro.c
>>>> test/CoverageMapping/unused_names.c
>>>> test/CoverageMapping/while.c
>>>> test/Driver/clang_f_opts.c
>>>> test/Profile/c-captured.c
>>>> test/Profile/c-general.c
>>>> test/Profile/c-generate.c
>>>> test/Profile/c-indirect-call.c
>>>> test/Profile/c-linkage-available_externally.c
>>>> test/Profile/c-linkage.c
>>>> test/Profile/c-unreachable-after-switch.c
>>>> test/Profile/cxx-implicit.cpp
>>>> test/Profile/cxx-lambda.cpp
>>>> test/Profile/cxx-linkage.cpp
>>>> test/Profile/cxx-rangefor.cpp
>>>> test/Profile/cxx-structors.cpp
>>>> test/Profile/cxx-templates.cpp
>>>> test/Profile/cxx-virtual-destructor-calls.cpp
>>>> test/Profile/objc-general.m
>>>> 
>>>> Index: test/Profile/objc-general.m
>>>> ===================================================================
>>>> --- test/Profile/objc-general.m
>>>> +++ test/Profile/objc-general.m
>>>> @@ -1,6 +1,6 @@
>>>> // Test instrumentation of general constructs in objective C.
>>>> 
>>>> -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN %s
>>>> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN %s
>>>> 
>>>> // RUN: llvm-profdata merge %S/Inputs/objc-general.proftext -o %t.profdata
>>>> // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
>>>> Index: test/Profile/cxx-virtual-destructor-calls.cpp
>>>> ===================================================================
>>>> --- test/Profile/cxx-virtual-destructor-calls.cpp
>>>> +++ test/Profile/cxx-virtual-destructor-calls.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instr-generate | FileCheck %s
>>>> +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instrument=clang | FileCheck %s
>>>> 
>>>> struct Member {
>>>>  ~Member();
>>>> Index: test/Profile/cxx-templates.cpp
>>>> ===================================================================
>>>> --- test/Profile/cxx-templates.cpp
>>>> +++ test/Profile/cxx-templates.cpp
>>>> @@ -1,7 +1,7 @@
>>>> // Tests for instrumentation of templated code. Each instantiation of a template
>>>> // should be instrumented separately.
>>>> 
>>>> -// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen
>>>> +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument=clang > %tgen
>>>> // RUN: FileCheck --input-file=%tgen -check-prefix=T0GEN -check-prefix=ALL %s
>>>> // RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s
>>>> 
>>>> Index: test/Profile/cxx-structors.cpp
>>>> ===================================================================
>>>> --- test/Profile/cxx-structors.cpp
>>>> +++ test/Profile/cxx-structors.cpp
>>>> @@ -1,6 +1,6 @@
>>>> // Tests for instrumentation of C++ constructors and destructors.
>>>> //
>>>> -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
>>>> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s
>>>> 
>>>> struct Foo {
>>>>  Foo() {}
>>>> Index: test/Profile/cxx-rangefor.cpp
>>>> ===================================================================
>>>> --- test/Profile/cxx-rangefor.cpp
>>>> +++ test/Profile/cxx-rangefor.cpp
>>>> @@ -1,6 +1,6 @@
>>>> // Tests for instrumentation of C++11 range-for
>>>> 
>>>> -// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen
>>>> +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument=clang > %tgen
>>>> // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s
>>>> 
>>>> // RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata
>>>> Index: test/Profile/cxx-linkage.cpp
>>>> ===================================================================
>>>> --- test/Profile/cxx-linkage.cpp
>>>> +++ test/Profile/cxx-linkage.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -emit-llvm -main-file-name cxx-linkage.cpp %s -o - -fprofile-instr-generate | FileCheck %s
>>>> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -emit-llvm -main-file-name cxx-linkage.cpp %s -o - -fprofile-instrument=clang | FileCheck %s
>>>> 
>>>> // CHECK: @__profc__Z3foov = private global
>>>> // CHECK: @__profd__Z3foov = private global
>>>> Index: test/Profile/cxx-lambda.cpp
>>>> ===================================================================
>>>> --- test/Profile/cxx-lambda.cpp
>>>> +++ test/Profile/cxx-lambda.cpp
>>>> @@ -1,6 +1,6 @@
>>>> // Tests for instrumentation of C++11 lambdas
>>>> 
>>>> -// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-generate > %tgen
>>>> +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-lambda.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument=clang > %tgen
>>>> // RUN: FileCheck --input-file=%tgen -check-prefix=PGOGEN %s
>>>> // RUN: FileCheck --input-file=%tgen -check-prefix=LMBGEN %s
>>>> 
>>>> Index: test/Profile/cxx-implicit.cpp
>>>> ===================================================================
>>>> --- test/Profile/cxx-implicit.cpp
>>>> +++ test/Profile/cxx-implicit.cpp
>>>> @@ -1,6 +1,6 @@
>>>> // Ensure that implicit methods aren't instrumented.
>>>> 
>>>> -// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-implicit.cpp -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
>>>> +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-implicit.cpp -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s
>>>> 
>>>> // An implicit constructor is generated for Base. We should not emit counters
>>>> // for it.
>>>> Index: test/Profile/c-unreachable-after-switch.c
>>>> ===================================================================
>>>> --- test/Profile/c-unreachable-after-switch.c
>>>> +++ test/Profile/c-unreachable-after-switch.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -O3 -triple x86_64-apple-macosx10.10 -main-file-name c-unreachable-after-switch.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
>>>> +// RUN: %clang_cc1 -O3 -triple x86_64-apple-macosx10.10 -main-file-name c-unreachable-after-switch.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s
>>>> 
>>>> // CHECK: @[[C:__profc_foo]] = private global [3 x i64] zeroinitializer
>>>> 
>>>> Index: test/Profile/c-linkage.c
>>>> ===================================================================
>>>> --- test/Profile/c-linkage.c
>>>> +++ test/Profile/c-linkage.c
>>>> @@ -1,5 +1,5 @@
>>>> // Check that the profiling counters and data we create have the linkage we expect
>>>> -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
>>>> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s
>>>> 
>>>> // CHECK: @__profc_foo = private global
>>>> // CHECK: @__profd_foo = private global
>>>> Index: test/Profile/c-linkage-available_externally.c
>>>> ===================================================================
>>>> --- test/Profile/c-linkage-available_externally.c
>>>> +++ test/Profile/c-linkage-available_externally.c
>>>> @@ -1,6 +1,6 @@
>>>> // Make sure instrumentation data from available_externally functions doesn't
>>>> // get thrown out and are emitted with the expected linkage.
>>>> -// RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck %s
>>>> +// RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s
>>>> 
>>>> // CHECK: @__profc_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
>>>> // CHECK: @__profd_foo = linkonce_odr hidden global {{.*}} i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0){{.*}}, section "__DATA,__llvm_prf_data", align 8
>>>> Index: test/Profile/c-indirect-call.c
>>>> ===================================================================
>>>> --- test/Profile/c-indirect-call.c
>>>> +++ test/Profile/c-indirect-call.c
>>>> @@ -1,5 +1,5 @@
>>>> // Check the data structures emitted by instrumentation.
>>>> -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-indirect-call.c %s -o - -emit-llvm -fprofile-instr-generate -mllvm -enable-value-profiling | FileCheck %s
>>>> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-indirect-call.c %s -o - -emit-llvm -fprofile-instrument=clang -mllvm -enable-value-profiling | FileCheck %s
>>>> 
>>>> void (*foo)(void);
>>>> 
>>>> Index: test/Profile/c-generate.c
>>>> ===================================================================
>>>> --- test/Profile/c-generate.c
>>>> +++ test/Profile/c-generate.c
>>>> @@ -1,9 +1,14 @@
>>>> -// Check that the -fprofile-instr-generate= form works.
>>>> -// RUN: %clang_cc1 -main-file-name c-generate.c %s -o - -emit-llvm -fprofile-instr-generate=c-generate-test.profraw | FileCheck %s
>>>> -
>>>> -// CHECK: private constant [24 x i8] c"c-generate-test.profraw\00"
>>>> -// CHECK: call void @__llvm_profile_override_default_filename(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @0, i32 0, i32 0))
>>>> -// CHECK: declare void @__llvm_profile_override_default_filename(i8*)
>>>> +// Check that the -fprofile-instrument-path= form works.
>>>> +// RUN: %clang_cc1 -main-file-name c-generate.c %s -o - -emit-llvm -fprofile-instrument=clang -fprofile-instrument-path=c-generate-test.profraw | FileCheck %s --check-prefix=PROF-INSTR-PATH
>>>> +// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=none | FileCheck %s --check-prefix=PROF-INSTR-NONE
>>>> +// RUN: not %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=garbage 2>&1 | FileCheck %s --check-prefix=PROF-INSTR-GARBAGE
>>>> +//
>>>> +// PROF-INSTR-PATH: private constant [24 x i8] c"c-generate-test.profraw\00"
>>>> +// PROF-INSTR-PATH: call void @__llvm_profile_override_default_filename(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @0, i32 0, i32 0))
>>>> +// PROF-INSTR-PATH: declare void @__llvm_profile_override_default_filename(i8*)
>>>> +//
>>>> +// PROF-INSTR-NONE-NOT: @__profn_main
>>>> +// PROF-INSTR-GARBAGE: invalid PGO instrumentor in argument '-fprofile-instrument=garbage'
>>>> 
>>>> int main(void) {
>>>>  return 0;
>>>> Index: test/Profile/c-general.c
>>>> ===================================================================
>>>> --- test/Profile/c-general.c
>>>> +++ test/Profile/c-general.c
>>>> @@ -1,6 +1,6 @@
>>>> // Test instrumentation of general constructs in C.
>>>> 
>>>> -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN %s
>>>> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN %s
>>>> 
>>>> // RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata
>>>> // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s
>>>> Index: test/Profile/c-captured.c
>>>> ===================================================================
>>>> --- test/Profile/c-captured.c
>>>> +++ test/Profile/c-captured.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN -check-prefix=PGOALL %s
>>>> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN -check-prefix=PGOALL %s
>>>> 
>>>> // RUN: llvm-profdata merge %S/Inputs/c-captured.proftext -o %t.profdata
>>>> // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-captured.c %s -o - -emit-llvm -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE -check-prefix=PGOALL %s
>>>> Index: test/Driver/clang_f_opts.c
>>>> ===================================================================
>>>> --- test/Driver/clang_f_opts.c
>>>> +++ test/Driver/clang_f_opts.c
>>>> @@ -97,11 +97,11 @@
>>>> // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
>>>> // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
>>>> // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
>>>> -// CHECK-PROFILE-GENERATE: "-fprofile-instr-generate"
>>>> -// CHECK-PROFILE-GENERATE-DIR: "-fprofile-instr-generate=/some/dir{{/|\\\\}}default.profraw"
>>>> -// CHECK-PROFILE-GENERATE-FILE: "-fprofile-instr-generate=/tmp/somefile.profraw"
>>>> +// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
>>>> +// CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|\\\\}}default.profraw"
>>>> +// CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
>>>> // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
>>>> -// CHECK-DISABLE-GEN-NOT: "-fprofile-instr-generate"
>>>> +// CHECK-DISABLE-GEN-NOT: "-fprofile-instrument=clang"
>>>> // CHECK-DISABLE-USE-NOT: "-fprofile-instr-use"
>>>> // CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with '-fprofile-instr-generate'
>>>> // CHECK-DISABLE-COVERAGE-NOT: "-fcoverage-mapping"
>>>> Index: test/CoverageMapping/while.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/while.c
>>>> +++ test/CoverageMapping/while.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
>>>> 
>>>>                                    // CHECK: main
>>>> int main() {                        // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+8]]:2 = #0
>>>> Index: test/CoverageMapping/unused_names.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/unused_names.c
>>>> +++ test/CoverageMapping/unused_names.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -emit-llvm -main-file-name unused_names.c -o - %s > %t
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -main-file-name unused_names.c -o - %s > %t
>>>> // RUN: FileCheck -input-file %t %s
>>>> // RUN: FileCheck -check-prefix=SYSHEADER -input-file %t %s
>>>> 
>>>> Index: test/CoverageMapping/unreachable-macro.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/unreachable-macro.c
>>>> +++ test/CoverageMapping/unreachable-macro.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
>>>> 
>>>> #define WHILE while (0) {}
>>>> 
>>>> Index: test/CoverageMapping/trymacro.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/trymacro.cpp
>>>> +++ test/CoverageMapping/trymacro.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trymacro.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trymacro.cpp %s | FileCheck %s
>>>> 
>>>> // CHECK: Z3fn1v:
>>>> void fn1() try { return; } // CHECK: [[@LINE]]:12 -> [[@LINE+1]]:14 = #1
>>>> Index: test/CoverageMapping/trycatch.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/trycatch.cpp
>>>> +++ test/CoverageMapping/trycatch.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trycatch.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trycatch.cpp %s | FileCheck %s
>>>> 
>>>> class Error {
>>>> };
>>>> Index: test/CoverageMapping/test.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/test.c
>>>> +++ test/CoverageMapping/test.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name test.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name test.c %s | FileCheck %s
>>>> 
>>>> void bar();
>>>> static void static_func();
>>>> Index: test/CoverageMapping/templates.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/templates.cpp
>>>> +++ test/CoverageMapping/templates.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name templates.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name templates.cpp %s | FileCheck %s
>>>> 
>>>> template<typename T>
>>>> void unused(T x) {
>>>> Index: test/CoverageMapping/system_macro.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/system_macro.c
>>>> +++ test/CoverageMapping/system_macro.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name system_macro.c -o - %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name system_macro.c -o - %s | FileCheck %s
>>>> 
>>>> #ifdef IS_SYSHEADER
>>>> 
>>>> Index: test/CoverageMapping/switchmacro.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/switchmacro.c
>>>> +++ test/CoverageMapping/switchmacro.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switchmacro.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switchmacro.c %s | FileCheck %s
>>>> 
>>>> #define FOO(x) (void)x
>>>> 
>>>> Index: test/CoverageMapping/switch.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/switch.c
>>>> +++ test/CoverageMapping/switch.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name switch.c %s | FileCheck %s
>>>>                    // CHECK: foo
>>>> void foo(int i) {   // CHECK-NEXT: File 0, [[@LINE]]:17 -> [[@LINE+8]]:2 = #0
>>>>  switch(i) {
>>>> Index: test/CoverageMapping/return.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/return.c
>>>> +++ test/CoverageMapping/return.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name return.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name return.c %s | FileCheck %s
>>>> 
>>>>                                // CHECK: func
>>>> void func() {                   // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+3]]:2 = #0
>>>> Index: test/CoverageMapping/preprocessor.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/preprocessor.c
>>>> +++ test/CoverageMapping/preprocessor.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name preprocessor.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name preprocessor.c %s | FileCheck %s
>>>> 
>>>>                 // CHECK: func
>>>> void func() {    // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
>>>> Index: test/CoverageMapping/objc.m
>>>> ===================================================================
>>>> --- test/CoverageMapping/objc.m
>>>> +++ test/CoverageMapping/objc.m
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name objc.m -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name objc.m -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s
>>>> 
>>>> @interface A
>>>> - (void)bork:(int)msg;
>>>> Index: test/CoverageMapping/nestedclass.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/nestedclass.cpp
>>>> +++ test/CoverageMapping/nestedclass.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name nestedclass.cpp %s > %tmapping
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name nestedclass.cpp %s > %tmapping
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-OUTER
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-INNER
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-INNERMOST
>>>> Index: test/CoverageMapping/moremacros.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/moremacros.c
>>>> +++ test/CoverageMapping/moremacros.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s
>>>> 
>>>> #define LBRAC {
>>>> #define RBRAC }
>>>> Index: test/CoverageMapping/md.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/md.cpp
>>>> +++ test/CoverageMapping/md.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++11 %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -std=c++11 %s | FileCheck %s
>>>> 
>>>> #define BREAK break
>>>> 
>>>> Index: test/CoverageMapping/macroscopes.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/macroscopes.cpp
>>>> +++ test/CoverageMapping/macroscopes.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroscopes.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroscopes.cpp %s | FileCheck %s
>>>> 
>>>> #define starts_a_scope for (int i = 0; i < 2; ++i) {
>>>> 
>>>> Index: test/CoverageMapping/macros.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/macros.c
>>>> +++ test/CoverageMapping/macros.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macros.c %s | FileCheck %s
>>>> 
>>>> #define MACRO return; bar()
>>>> #define MACRO_2 bar()
>>>> Index: test/CoverageMapping/macroparams2.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/macroparams2.c
>>>> +++ test/CoverageMapping/macroparams2.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams2.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams2.c %s | FileCheck %s
>>>> 
>>>> #define MACRO(REFS, CALLS)  (4 * (CALLS) < (REFS))
>>>> 
>>>> Index: test/CoverageMapping/macroparams.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/macroparams.c
>>>> +++ test/CoverageMapping/macroparams.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroparams.c %s | FileCheck %s
>>>> 
>>>> // CHECK: main
>>>> // CHECK-NEXT: File 0, {{[0-9]+}}:12 -> {{[0-9]+}}:2 = #0
>>>> Index: test/CoverageMapping/macroception.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/macroception.c
>>>> +++ test/CoverageMapping/macroception.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroception.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macroception.c %s | FileCheck %s
>>>> 
>>>> #define M2 {
>>>> #define M1 M2
>>>> Index: test/CoverageMapping/macro-expressions.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/macro-expressions.cpp
>>>> +++ test/CoverageMapping/macro-expressions.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -std=c++11 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expressions.cpp %s | FileCheck %s
>>>> 
>>>> #define EXPR(x) (x)
>>>> #define NEXPR(x) (!x)
>>>> Index: test/CoverageMapping/macro-expansion.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/macro-expansion.c
>>>> +++ test/CoverageMapping/macro-expansion.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name macro-expansion.c %s | FileCheck %s
>>>> 
>>>> // CHECK: func
>>>> // CHECK:      File 1, [[@LINE+5]]:12 -> [[@LINE+5]]:38 = #0
>>>> Index: test/CoverageMapping/loops.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/loops.cpp
>>>> +++ test/CoverageMapping/loops.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -std=c++11 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
>>>> 
>>>>                                    // CHECK: rangedFor
>>>> void rangedFor() {                  // CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[0-9]+}}:2 = #0
>>>> Index: test/CoverageMapping/loopmacro.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/loopmacro.c
>>>> +++ test/CoverageMapping/loopmacro.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loopmacro.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loopmacro.c %s | FileCheck %s
>>>> 
>>>> // CHECK: main
>>>> // CHECK-NEXT: File 0, {{[0-9]+}}:12 -> {{[0-9]+}}:2 = #0
>>>> Index: test/CoverageMapping/logical.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/logical.cpp
>>>> +++ test/CoverageMapping/logical.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name logical.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name logical.cpp %s | FileCheck %s
>>>> 
>>>> int main() {                        // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+10]]:2 = #0
>>>>  bool bt = true;
>>>> Index: test/CoverageMapping/lambda.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/lambda.cpp
>>>> +++ test/CoverageMapping/lambda.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -x c++ -std=c++11 -triple %itanium_abi_triple -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s -main-file-name lambda.cpp | FileCheck %s
>>>> +// RUN: %clang_cc1 -x c++ -std=c++11 -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s -main-file-name lambda.cpp | FileCheck %s
>>>> 
>>>> // CHECK-LABEL: _Z3fooi:
>>>> void foo(int i) { // CHECK: File 0, [[@LINE]]:17 -> {{[0-9]+}}:2 = #0
>>>> Index: test/CoverageMapping/label.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/label.cpp
>>>> +++ test/CoverageMapping/label.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name label.cpp %s | FileCheck %s
>>>> 
>>>>                             // CHECK: func
>>>> void func() {                // CHECK-NEXT: File 0, [[@LINE]]:13 -> {{[0-9]+}}:2 = #0
>>>> Index: test/CoverageMapping/ir.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/ir.c
>>>> +++ test/CoverageMapping/ir.c
>>>> @@ -1,5 +1,5 @@
>>>> // Check the data structures emitted by coverage mapping
>>>> -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name ir.c %s -o - -emit-llvm -fprofile-instr-generate -fcoverage-mapping | FileCheck %s
>>>> +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name ir.c %s -o - -emit-llvm -fprofile-instrument=clang -fcoverage-mapping | FileCheck %s
>>>> 
>>>> 
>>>> void foo(void) { }
>>>> Index: test/CoverageMapping/includehell.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/includehell.cpp
>>>> +++ test/CoverageMapping/includehell.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %s > %tmapping
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name includehell.cpp %s > %tmapping
>>>> 
>>>> int main() {
>>>>  int x = 0;
>>>> Index: test/CoverageMapping/implicit-def-in-macro.m
>>>> ===================================================================
>>>> --- test/CoverageMapping/implicit-def-in-macro.m
>>>> +++ test/CoverageMapping/implicit-def-in-macro.m
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc %s | FileCheck %s
>>>> 
>>>> @interface Foo
>>>> @end
>>>> Index: test/CoverageMapping/if.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/if.c
>>>> +++ test/CoverageMapping/if.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name if.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name if.c %s | FileCheck %s
>>>> 
>>>> int main() {                    // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
>>>>  int i = 0;
>>>> Index: test/CoverageMapping/header.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/header.cpp
>>>> +++ test/CoverageMapping/header.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name header.cpp %s > %tmapping
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name header.cpp %s > %tmapping
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-FUNC
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-STATIC-FUNC
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-STATIC-FUNC2
>>>> Index: test/CoverageMapping/decl.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/decl.c
>>>> +++ test/CoverageMapping/decl.c
>>>> @@ -1,6 +1,6 @@
>>>> // Ensure that declarations without definitions don't have maps emitted for them
>>>> 
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s > %t
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s > %t
>>>> // FileCheck -input-file %t %s
>>>> // RUN: FileCheck -check-prefix BAR -input-file %t %s
>>>> 
>>>> Index: test/CoverageMapping/control-flow-macro.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/control-flow-macro.c
>>>> +++ test/CoverageMapping/control-flow-macro.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
>>>> 
>>>> #define ifc if
>>>> 
>>>> Index: test/CoverageMapping/continue.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/continue.c
>>>> +++ test/CoverageMapping/continue.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name continue.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name continue.c %s | FileCheck %s
>>>> 
>>>> int main() {                    // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+21]]:2 = #0
>>>>  int j = 0;                    // CHECK-NEXT: File 0, [[@LINE+2]]:18 -> [[@LINE+2]]:24 = (#0 + #1)
>>>> Index: test/CoverageMapping/comment-in-macro.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/comment-in-macro.c
>>>> +++ test/CoverageMapping/comment-in-macro.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only %s | FileCheck %s
>>>> 
>>>> #define x1 "" // ...
>>>> #define x2 return 0
>>>> Index: test/CoverageMapping/classtemplate.cpp
>>>> ===================================================================
>>>> --- test/CoverageMapping/classtemplate.cpp
>>>> +++ test/CoverageMapping/classtemplate.cpp
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -triple %itanium_abi_triple -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name classtemplate.cpp %s > %tmapping
>>>> +// RUN: %clang_cc1 -triple %itanium_abi_triple -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name classtemplate.cpp %s > %tmapping
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-CONSTRUCTOR
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-GETTER
>>>> // RUN: FileCheck -input-file %tmapping %s --check-prefix=CHECK-SETTER
>>>> Index: test/CoverageMapping/casts.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/casts.c
>>>> +++ test/CoverageMapping/casts.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name casts.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name casts.c %s | FileCheck %s
>>>> 
>>>> int main() {                                                   // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+4]]:2 = #0
>>>>                                                               // CHECK-NEXT: File 0, [[@LINE+1]]:41 -> [[@LINE+1]]:54 = #1
>>>> Index: test/CoverageMapping/builtinmacro.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/builtinmacro.c
>>>> +++ test/CoverageMapping/builtinmacro.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name builtinmacro.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name builtinmacro.c %s | FileCheck %s
>>>> 
>>>> // Test the coverage mapping generation for built-in macroes.
>>>> 
>>>> Index: test/CoverageMapping/break.c
>>>> ===================================================================
>>>> --- test/CoverageMapping/break.c
>>>> +++ test/CoverageMapping/break.c
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name break.c %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name break.c %s | FileCheck %s
>>>> 
>>>> int main() {         // CHECK: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
>>>>  int cnt = 0;       // CHECK-NEXT: File 0, [[@LINE+1]]:9 -> [[@LINE+1]]:18 = #0
>>>> Index: test/CoverageMapping/block-storage-starts-region.m
>>>> ===================================================================
>>>> --- test/CoverageMapping/block-storage-starts-region.m
>>>> +++ test/CoverageMapping/block-storage-starts-region.m
>>>> @@ -1,4 +1,4 @@
>>>> -// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc %s | FileCheck %s
>>>> +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -triple x86_64-apple-darwin -fobjc-runtime=macosx-10.10.0 -fblocks -fobjc-arc %s | FileCheck %s
>>>> 
>>>> @interface Foo
>>>> @end
>>>> Index: lib/Frontend/CompilerInvocation.cpp
>>>> ===================================================================
>>>> --- lib/Frontend/CompilerInvocation.cpp
>>>> +++ lib/Frontend/CompilerInvocation.cpp
>>>> @@ -477,9 +477,29 @@
>>>>  Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
>>>>  Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
>>>>  Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
>>>> -  Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
>>>> -      Args.hasArg(OPT_fprofile_instr_generate_EQ);
>>>> -  Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instr_generate_EQ);
>>>> +
>>>> +  enum PGOInstrumentor { Unknown, None, Clang };
>>>> +  if (Arg *A = Args.getLastArg(OPT_fprofile_instrument_EQ)) {
>>>> +    StringRef Value = A->getValue();
>>>> +    PGOInstrumentor Method = llvm::StringSwitch<PGOInstrumentor>(Value)
>>>> +                                 .Case("clang", Clang)
>>>> +                                 .Case("none", None)
>>>> +                                 .Default(Unknown);
>>>> +    switch (Method) {
>>>> +    case Clang:
>>>> +      Opts.setProfileInstr(CodeGenOptions::ProfileClangInstr);
>>>> +      break;
>>>> +    case None:
>>>> +      break;
>>>> +    case Unknown:
>>>> +    default:
>>>> +      Diags.Report(diag::err_drv_invalid_pgo_instrumentor)
>>>> +          << A->getAsString(Args) << Value;
>>>> +      break;
>>>> +    }
>>>> +  }
>>>> +
>>>> +  Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instrument_path_EQ);
>>>>  Opts.InstrProfileInput = Args.getLastArgValue(OPT_fprofile_instr_use_EQ);
>>>>  Opts.CoverageMapping =
>>>>      Args.hasFlag(OPT_fcoverage_mapping, OPT_fno_coverage_mapping, false);
>>>> Index: lib/Driver/Tools.cpp
>>>> ===================================================================
>>>> --- lib/Driver/Tools.cpp
>>>> +++ lib/Driver/Tools.cpp
>>>> @@ -3224,15 +3224,17 @@
>>>>  if (ProfileGenerateArg) {
>>>>    if (ProfileGenerateArg->getOption().matches(
>>>>            options::OPT_fprofile_instr_generate_EQ))
>>>> -      ProfileGenerateArg->render(Args, CmdArgs);
>>>> +      CmdArgs.push_back(Args.MakeArgString(Twine("-fprofile-instrument-path=") +
>>>> +                                           ProfileGenerateArg->getValue()));
>>>>    else if (ProfileGenerateArg->getOption().matches(
>>>>                 options::OPT_fprofile_generate_EQ)) {
>>>>      SmallString<128> Path(ProfileGenerateArg->getValue());
>>>>      llvm::sys::path::append(Path, "default.profraw");
>>>>      CmdArgs.push_back(
>>>> -          Args.MakeArgString(Twine("-fprofile-instr-generate=") + Path));
>>>> -    } else
>>>> -      Args.AddAllArgs(CmdArgs, options::OPT_fprofile_instr_generate);
>>>> +          Args.MakeArgString(Twine("-fprofile-instrument-path=") + Path));
>>>> +    }
>>>> +    // The default is to use Clang Instrumentation.
>>>> +    CmdArgs.push_back("-fprofile-instrument=clang");
>>>>  }
>>>> 
>>>>  if (ProfileUseArg) {
>>>> Index: lib/CodeGen/CodeGenPGO.cpp
>>>> ===================================================================
>>>> --- lib/CodeGen/CodeGenPGO.cpp
>>>> +++ lib/CodeGen/CodeGenPGO.cpp
>>>> @@ -37,7 +37,7 @@
>>>>      PGOReader ? PGOReader->getVersion() : llvm::IndexedInstrProf::Version);
>>>> 
>>>>  // If we're generating a profile, create a variable for the name.
>>>> -  if (CGM.getCodeGenOpts().ProfileInstrGenerate)
>>>> +  if (CGM.getCodeGenOpts().hasProfileClangInstr())
>>>>    FuncNameVar = llvm::createPGOFuncNameVar(CGM.getModule(), Linkage, FuncName);
>>>> }
>>>> 
>>>> @@ -610,7 +610,7 @@
>>>> 
>>>> void CodeGenPGO::assignRegionCounters(GlobalDecl GD, llvm::Function *Fn) {
>>>>  const Decl *D = GD.getDecl();
>>>> -  bool InstrumentRegions = CGM.getCodeGenOpts().ProfileInstrGenerate;
>>>> +  bool InstrumentRegions = CGM.getCodeGenOpts().hasProfileClangInstr();
>>>>  llvm::IndexedInstrProfReader *PGOReader = CGM.getPGOReader();
>>>>  if (!InstrumentRegions && !PGOReader)
>>>>    return;
>>>> @@ -729,7 +729,7 @@
>>>> }
>>>> 
>>>> void CodeGenPGO::emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S) {
>>>> -  if (!CGM.getCodeGenOpts().ProfileInstrGenerate || !RegionCounterMap)
>>>> +  if (!CGM.getCodeGenOpts().hasProfileClangInstr() || !RegionCounterMap)
>>>>    return;
>>>>  if (!Builder.GetInsertBlock())
>>>>    return;
>>>> @@ -754,7 +754,7 @@
>>>>  if (!ValuePtr || !ValueSite || !Builder.GetInsertBlock())
>>>>    return;
>>>> 
>>>> -  bool InstrumentValueSites = CGM.getCodeGenOpts().ProfileInstrGenerate;
>>>> +  bool InstrumentValueSites = CGM.getCodeGenOpts().hasProfileClangInstr();
>>>>  if (InstrumentValueSites && RegionCounterMap) {
>>>>    llvm::LLVMContext &Ctx = CGM.getLLVMContext();
>>>>    auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx);
>>>> Index: lib/CodeGen/CodeGenFunction.h
>>>> ===================================================================
>>>> --- lib/CodeGen/CodeGenFunction.h
>>>> +++ lib/CodeGen/CodeGenFunction.h
>>>> @@ -952,7 +952,7 @@
>>>> public:
>>>>  /// Increment the profiler's counter for the given statement.
>>>>  void incrementProfileCounter(const Stmt *S) {
>>>> -    if (CGM.getCodeGenOpts().ProfileInstrGenerate)
>>>> +    if (CGM.getCodeGenOpts().hasProfileClangInstr())
>>>>      PGO.emitCounterIncrement(Builder, S);
>>>>    PGO.setCurrentStmt(S);
>>>>  }
>>>> Index: lib/CodeGen/CodeGenFunction.cpp
>>>> ===================================================================
>>>> --- lib/CodeGen/CodeGenFunction.cpp
>>>> +++ lib/CodeGen/CodeGenFunction.cpp
>>>> @@ -883,7 +883,7 @@
>>>> void CodeGenFunction::EmitBlockWithFallThrough(llvm::BasicBlock *BB,
>>>>                                               const Stmt *S) {
>>>>  llvm::BasicBlock *SkipCountBB = nullptr;
>>>> -  if (HaveInsertPoint() && CGM.getCodeGenOpts().ProfileInstrGenerate) {
>>>> +  if (HaveInsertPoint() && CGM.getCodeGenOpts().hasProfileClangInstr()) {
>>>>    // When instrumenting for profiling, the fallthrough to certain
>>>>    // statements needs to skip over the instrumentation code so that we
>>>>    // get an accurate count.
>>>> Index: lib/CodeGen/CGStmt.cpp
>>>> ===================================================================
>>>> --- lib/CodeGen/CGStmt.cpp
>>>> +++ lib/CodeGen/CGStmt.cpp
>>>> @@ -1156,7 +1156,7 @@
>>>>  // If the body of the case is just a 'break', try to not emit an empty block.
>>>>  // If we're profiling or we're not optimizing, leave the block in for better
>>>>  // debug and coverage analysis.
>>>> -  if (!CGM.getCodeGenOpts().ProfileInstrGenerate &&
>>>> +  if (!CGM.getCodeGenOpts().hasProfileClangInstr() &&
>>>>      CGM.getCodeGenOpts().OptimizationLevel > 0 &&
>>>>      isa<BreakStmt>(S.getSubStmt())) {
>>>>    JumpDest Block = BreakContinueStack.back().BreakBlock;
>>>> @@ -1203,7 +1203,7 @@
>>>> 
>>>>    if (SwitchWeights)
>>>>      SwitchWeights->push_back(getProfileCount(NextCase));
>>>> -    if (CGM.getCodeGenOpts().ProfileInstrGenerate) {
>>>> +    if (CGM.getCodeGenOpts().hasProfileClangInstr()) {
>>>>      CaseDest = createBasicBlock("sw.bb");
>>>>      EmitBlockWithFallThrough(CaseDest, &S);
>>>>    }
>>>> Index: lib/CodeGen/BackendUtil.cpp
>>>> ===================================================================
>>>> --- lib/CodeGen/BackendUtil.cpp
>>>> +++ lib/CodeGen/BackendUtil.cpp
>>>> @@ -429,7 +429,7 @@
>>>>      MPM->add(createStripSymbolsPass(true));
>>>>  }
>>>> 
>>>> -  if (CodeGenOpts.ProfileInstrGenerate) {
>>>> +  if (CodeGenOpts.hasProfileClangInstr()) {
>>>>    InstrProfOptions Options;
>>>>    Options.NoRedZone = CodeGenOpts.DisableRedZone;
>>>>    Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
>>>> Index: include/clang/Frontend/CodeGenOptions.h
>>>> ===================================================================
>>>> --- include/clang/Frontend/CodeGenOptions.h
>>>> +++ include/clang/Frontend/CodeGenOptions.h
>>>> @@ -108,6 +108,12 @@
>>>>    SRCK_InRegs    // Small structs in registers (-freg-struct-return).
>>>>  };
>>>> 
>>>> +  enum ProfileInstrKind {
>>>> +    ProfileNoInstr,    // No instrumentation.
>>>> +    ProfileClangInstr  // Clang instrumentation to generate execution counts
>>>> +                       // to use with PGO.
>>>> +  };
>>>> +
>>>>  /// The code model to use (-mcmodel).
>>>>  std::string CodeModel;
>>>> 
>>>> @@ -241,6 +247,11 @@
>>>>  const std::vector<std::string> &getNoBuiltinFuncs() const {
>>>>    return NoBuiltinFuncs;
>>>>  }
>>>> +
>>>> +  /// \brief Check if Clang profile instrumenation is on.
>>>> +  bool hasProfileClangInstr() const {
>>>> +    return getProfileInstr() == ProfileClangInstr;
>>>> +  }
>>>> };
>>>> 
>>>> }  // end namespace clang
>>>> Index: include/clang/Frontend/CodeGenOptions.def
>>>> ===================================================================
>>>> --- include/clang/Frontend/CodeGenOptions.def
>>>> +++ include/clang/Frontend/CodeGenOptions.def
>>>> @@ -103,8 +103,8 @@
>>>> VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
>>>> VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.
>>>> 
>>>> -CODEGENOPT(ProfileInstrGenerate , 1, 0) ///< Instrument code to generate
>>>> -                                        ///< execution counts to use with PGO.
>>>> +/// \brief Choose profile instrumenation kind or no instrumentation.
>>>> +ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNoInstr)
>>>> CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
>>>>                                   ///< enable code coverage analysis.
>>>> CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping
>>>> Index: include/clang/Driver/Options.td
>>>> ===================================================================
>>>> --- include/clang/Driver/Options.td
>>>> +++ include/clang/Driver/Options.td
>>>> @@ -446,10 +446,10 @@
>>>> def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
>>>>    Alias<fprofile_sample_use_EQ>;
>>>> def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
>>>> -    Group<f_Group>, Flags<[CC1Option]>,
>>>> +    Group<f_Group>, Flags<[DriverOption]>,
>>>>    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<f_Group>, Flags<[CC1Option]>, MetaVarName<"<file>">,
>>>> +    Group<f_Group>, Flags<[DriverOption]>, MetaVarName<"<file>">,
>>>>    HelpText<"Generate instrumented code to collect execution counts into <file> (overridden by LLVM_PROFILE_FILE env var)">;
>>>> def fprofile_instr_use : Flag<["-"], "fprofile-instr-use">, Group<f_Group>,
>>>>    Flags<[DriverOption]>;
>>>> Index: include/clang/Driver/CC1Options.td
>>>> ===================================================================
>>>> --- include/clang/Driver/CC1Options.td
>>>> +++ include/clang/Driver/CC1Options.td
>>>> @@ -268,6 +268,12 @@
>>>> def fsanitize_coverage_8bit_counters
>>>>    : Flag<["-"], "fsanitize-coverage-8bit-counters">,
>>>>      HelpText<"Enable frequency counters in sanitizer coverage">;
>>>> +def fprofile_instrument_EQ: Joined<["-"], "fprofile-instrument=">,
>>>> +    HelpText<"Enable PGO instrumentation. The accepted values is clang or "
>>>> +             "none">;
>>>> +def fprofile_instrument_path_EQ: Joined<["-"], "fprofile-instrument-path=">,
>>>> +    HelpText<"Generate instrumented code to collect execution counts into "
>>>> +             "<file> (overridden by LLVM_PROFILE_FILE env var)">;
>>>> 
>>>> //===----------------------------------------------------------------------===//
>>>> // Dependency Output Options
>>>> Index: include/clang/Basic/DiagnosticDriverKinds.td
>>>> ===================================================================
>>>> --- include/clang/Basic/DiagnosticDriverKinds.td
>>>> +++ include/clang/Basic/DiagnosticDriverKinds.td
>>>> @@ -27,6 +27,8 @@
>>>>  "invalid thread model '%0' in '%1' for this target">;
>>>> def err_drv_invalid_linker_name : Error<
>>>>  "invalid linker name in argument '%0'">;
>>>> +def err_drv_invalid_pgo_instrumentor: Error<
>>>> +  "invalid PGO instrumentor in argument '%0'">;
>>>> def err_drv_invalid_rtlib_name : Error<
>>>>  "invalid runtime library name in argument '%0'">;
>>>> def err_drv_unsupported_rtlib_for_platform : Error<
>> 



More information about the llvm-commits mailing list