Index: test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov +++ test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-__gcov_flush-multiple.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-__gcov_flush-multiple.c // CHECK-NEXT: -: 0:Graph:instrprof-gcov-__gcov_flush-multiple.gcno // CHECK-NEXT: -: 0:Data:instrprof-gcov-__gcov_flush-multiple.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-__gcov_flush-terminate.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-__gcov_flush-terminate.c.gcov +++ test/profile/Inputs/instrprof-gcov-__gcov_flush-terminate.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-__gcov_flush-terminate.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-__gcov_flush-terminate.c // CHECK-NEXT: -: 0:Graph:instrprof-gcov-__gcov_flush-terminate.gcno // CHECK-NEXT: -: 0:Data:instrprof-gcov-__gcov_flush-terminate.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-exceptions.cpp.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-exceptions.cpp.gcov +++ test/profile/Inputs/instrprof-gcov-exceptions.cpp.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-exceptions.cpp +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-exceptions.cpp // CHECK-NEXT: -: 0:Graph:instrprof-gcov-exceptions.gcno // CHECK-NEXT: -: 0:Data:instrprof-gcov-exceptions.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-execlp.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-execlp.c.gcov +++ test/profile/Inputs/instrprof-gcov-execlp.c.gcov @@ -1,4 +1,4 @@ -//CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-execlp.c +//CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-execlp.c //CHECK-NEXT: -: 0:Graph:instrprof-gcov-execlp.gcno //CHECK-NEXT: -: 0:Data:instrprof-gcov-execlp.gcda //CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-execvp.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-execvp.c.gcov +++ test/profile/Inputs/instrprof-gcov-execvp.c.gcov @@ -1,4 +1,4 @@ -//CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-execvp.c +//CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-execvp.c //CHECK-NEXT: -: 0:Graph:instrprof-gcov-execvp.gcno //CHECK-NEXT: -: 0:Data:instrprof-gcov-execvp.gcda //CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-fork.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-fork.c.gcov +++ test/profile/Inputs/instrprof-gcov-fork.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-fork.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-fork.c // CHECK-NEXT: -: 0:Graph:instrprof-gcov-fork.gcno // CHECK-NEXT: -: 0:Data:instrprof-gcov-fork.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-multiple-bbs-single-line.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-multiple-bbs-single-line.c.gcov +++ test/profile/Inputs/instrprof-gcov-multiple-bbs-single-line.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-multiple-bbs-single-line.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-multiple-bbs-single-line.c // CHECK-NEXT: -: 0:Graph:instrprof-gcov-multiple-bbs-single-line.gcno // CHECK-NEXT: -: 0:Data:instrprof-gcov-multiple-bbs-single-line.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-one-line-function.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-one-line-function.c.gcov +++ test/profile/Inputs/instrprof-gcov-one-line-function.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-one-line-function.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-one-line-function.c // CHECK-NEXT: -: 0:Graph:instrprof-gcov-one-line-function.gcno // CHECK-NEXT: -: 0:Data:instrprof-gcov-one-line-function.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-switch1.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-switch1.c.gcov +++ test/profile/Inputs/instrprof-gcov-switch1.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-switch1.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-switch1.c // CHECK-NEXT: -: 0:Graph:instrprof-gcov-switch1.gcno // CHECK-NEXT: -: 0:Data:instrprof-gcov-switch1.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-gcov-switch2.c.gcov =================================================================== --- test/profile/Inputs/instrprof-gcov-switch2.c.gcov +++ test/profile/Inputs/instrprof-gcov-switch2.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-gcov-switch2.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-gcov-switch2.c // CHECK-NEXT: -: 0:Graph:instrprof-gcov-switch2.gcno // CHECK-NEXT: -: 0:Data:instrprof-gcov-switch2.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-shared-lib.c.gcov =================================================================== --- test/profile/Inputs/instrprof-shared-lib.c.gcov +++ test/profile/Inputs/instrprof-shared-lib.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-shared-lib.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-shared-lib.c // CHECK-NEXT: -: 0:Graph:instrprof-shared-lib.gcno // CHECK-NEXT: -: 0:Data:instrprof-shared-lib.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-shared-lib_called-twice.c.gcov =================================================================== --- test/profile/Inputs/instrprof-shared-lib_called-twice.c.gcov +++ test/profile/Inputs/instrprof-shared-lib_called-twice.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-shared-lib.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-shared-lib.c // CHECK-NEXT: -: 0:Graph:instrprof-shared-lib.gcno // CHECK-NEXT: -: 0:Data:instrprof-shared-lib.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-shared-lib_in-loop.c.gcov =================================================================== --- test/profile/Inputs/instrprof-shared-lib_in-loop.c.gcov +++ test/profile/Inputs/instrprof-shared-lib_in-loop.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-shared-lib.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-shared-lib.c // CHECK-NEXT: -: 0:Graph:instrprof-shared-lib.gcno // CHECK-NEXT: -: 0:Data:instrprof-shared-lib.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-shared-main-gcov-flush_no-writeout.c.gcov =================================================================== --- test/profile/Inputs/instrprof-shared-main-gcov-flush_no-writeout.c.gcov +++ test/profile/Inputs/instrprof-shared-main-gcov-flush_no-writeout.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-shared-main-gcov-flush.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-shared-main-gcov-flush.c // CHECK-NEXT: -: 0:Graph:instrprof-shared-main-gcov-flush.gcno // CHECK-NEXT: -: 0:Data:instrprof-shared-main-gcov-flush.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-after.c.gcov =================================================================== --- test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-after.c.gcov +++ test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-after.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-shared-main-gcov-flush.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-shared-main-gcov-flush.c // CHECK-NEXT: -: 0:Graph:instrprof-shared-main-gcov-flush.gcno // CHECK-NEXT: -: 0:Data:instrprof-shared-main-gcov-flush.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before-after.c.gcov =================================================================== --- test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before-after.c.gcov +++ test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before-after.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-shared-main-gcov-flush.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-shared-main-gcov-flush.c // CHECK-NEXT: -: 0:Graph:instrprof-shared-main-gcov-flush.gcno // CHECK-NEXT: -: 0:Data:instrprof-shared-main-gcov-flush.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before.c.gcov =================================================================== --- test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before.c.gcov +++ test/profile/Inputs/instrprof-shared-main-gcov-flush_shared-call-before.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-shared-main-gcov-flush.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-shared-main-gcov-flush.c // CHECK-NEXT: -: 0:Graph:instrprof-shared-main-gcov-flush.gcno // CHECK-NEXT: -: 0:Data:instrprof-shared-main-gcov-flush.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-shared-main.c.gcov =================================================================== --- test/profile/Inputs/instrprof-shared-main.c.gcov +++ test/profile/Inputs/instrprof-shared-main.c.gcov @@ -1,4 +1,4 @@ -// CHECK: -: 0:Source:{{.*}}Inputs/instrprof-shared-main.c +// CHECK: -: 0:Source:{{.*}}Inputs{{[/\\]}}instrprof-shared-main.c // CHECK-NEXT: -: 0:Graph:instrprof-shared-main.gcno // CHECK-NEXT: -: 0:Data:instrprof-shared-main.gcda // CHECK-NEXT: -: 0:Runs:1 Index: test/profile/Inputs/instrprof-visibility-helper.cpp =================================================================== --- test/profile/Inputs/instrprof-visibility-helper.cpp +++ test/profile/Inputs/instrprof-visibility-helper.cpp @@ -1,3 +0,0 @@ -namespace N1 { -void f4() {} -} Index: test/profile/Posix/Inputs/instrprof-visibility-helper.cpp =================================================================== --- test/profile/Posix/Inputs/instrprof-visibility-helper.cpp +++ test/profile/Posix/Inputs/instrprof-visibility-helper.cpp @@ -0,0 +1,3 @@ +namespace N1 { +void f4() {} +} Index: test/profile/Posix/instrprof-dlopen-dlclose-gcov.test =================================================================== --- test/profile/Posix/instrprof-dlopen-dlclose-gcov.test +++ test/profile/Posix/instrprof-dlopen-dlclose-gcov.test @@ -0,0 +1,33 @@ +# atexit(3) not supported in dlopen(3)ed+dlclose(3)d DSO +XFAIL: netbsd + +RUN: mkdir -p %t.d +RUN: cd %t.d + +RUN: %clang --coverage -o func.shared -fPIC -shared %S/../Inputs/instrprof-dlopen-func.c +RUN: %clang --coverage -o func2.shared -fPIC -shared %S/../Inputs/instrprof-dlopen-func2.c +RUN: %clang --coverage -o func3.shared -fPIC -shared %S/../Inputs/instrprof-dlopen-func3.c +RUN: %clang --coverage -o %t -fPIC -rpath %t.d %S/../Inputs/instrprof-dlopen-dlclose-main.c + +# Test with two dlopened libraries. +RUN: rm -f instrprof-dlopen-dlclose-main.gcda instrprof-dlopen-func.gcda instrprof-dlopen-func2.gcda +RUN: %run %t +RUN: llvm-cov gcov instrprof-dlopen-dlclose-main.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-dlclose-main.c.gcov %S/../Inputs/instrprof-dlopen-dlclose-main.c.gcov +RUN: llvm-cov gcov instrprof-dlopen-func.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func.c.gcov %S/../Inputs/instrprof-dlopen-func.c.gcov +RUN: llvm-cov gcov instrprof-dlopen-func2.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/../Inputs/instrprof-dlopen-func2.c.gcov + +# Test with three dlopened libraries. +RUN: %clang -DUSE_LIB3 --coverage -o %t -fPIC -rpath %t.d %S/../Inputs/instrprof-dlopen-dlclose-main.c +RUN: rm -f instrprof-dlopen-dlclose-main.gcda instrprof-dlopen-func.gcda instrprof-dlopen-func2.gcda instrprof-dlopen-func3.gcda +RUN: %run %t +RUN: llvm-cov gcov instrprof-dlopen-dlclose-main.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-dlclose-main.c.gcov %S/../Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov +RUN: llvm-cov gcov instrprof-dlopen-func.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func.c.gcov %S/../Inputs/instrprof-dlopen-func.c.gcov +RUN: llvm-cov gcov instrprof-dlopen-func2.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/../Inputs/instrprof-dlopen-func2.c.gcov +RUN: llvm-cov gcov instrprof-dlopen-func3.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/../Inputs/instrprof-dlopen-func3.c.gcov Index: test/profile/Posix/instrprof-dlopen.test =================================================================== --- test/profile/Posix/instrprof-dlopen.test +++ test/profile/Posix/instrprof-dlopen.test @@ -0,0 +1,34 @@ +RUN: mkdir -p %t.d +RUN: %clang_profgen -o %t.d/func.shared -fPIC -shared %S/../Inputs/instrprof-dlopen-func.c +RUN: %clang_profgen -o %t.d/func2.shared -fPIC -shared %S/../Inputs/instrprof-dlopen-func2.c +RUN: %clang -o %t-local -fPIC -DDLOPEN_FUNC_DIR=\"%t.d\" -DDLOPEN_FLAGS="RTLD_LAZY | RTLD_LOCAL" %S/../Inputs/instrprof-dlopen-main.c +RUN: %clang -o %t-global -fPIC -DDLOPEN_FUNC_DIR=\"%t.d\" -DDLOPEN_FLAGS="RTLD_LAZY | RTLD_GLOBAL" %S/../Inputs/instrprof-dlopen-main.c + +RUN: %clang -c -o %t.d/main.o %S/../Inputs/instrprof-dlopen-main.c +RUN: %clang_profgen -o %t-static %S/../Inputs/instrprof-dlopen-func.c %S/../Inputs/instrprof-dlopen-func2.c %t.d/main.o + +RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static +RUN: env LLVM_PROFILE_FILE=%t-local.profraw %run %t-local +RUN: env LLVM_PROFILE_FILE=%t-global.profraw %run %t-global + +RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw +RUN: llvm-profdata merge -o %t-local.profdata %t-local.profraw +RUN: llvm-profdata merge -o %t-global.profdata %t-global.profraw + +RUN: %clang_profuse=%t-static.profdata -o %t-func.static.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-func.c +RUN: %clang_profuse=%t-local.profdata -o %t-func.local.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-func.c +RUN: %clang_profuse=%t-global.profdata -o %t-func.global.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-func.c +RUN: diff %t-func.static.ll %t-func.local.ll +RUN: diff %t-func.static.ll %t-func.global.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-func2.static.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-func2.c +RUN: %clang_profuse=%t-local.profdata -o %t-func2.local.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-func2.c +RUN: %clang_profuse=%t-global.profdata -o %t-func2.global.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-func2.c +RUN: diff %t-func2.static.ll %t-func2.local.ll +RUN: diff %t-func2.static.ll %t-func2.global.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-main.static.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-main.c +RUN: %clang_profuse=%t-local.profdata -o %t-main.local.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-main.c +RUN: %clang_profuse=%t-local.profdata -o %t-main.global.ll -S -emit-llvm %S/../Inputs/instrprof-dlopen-main.c +RUN: diff %t-main.static.ll %t-main.local.ll +RUN: diff %t-main.static.ll %t-main.global.ll Index: test/profile/Posix/instrprof-dynamic-one-shared.test =================================================================== --- test/profile/Posix/instrprof-dynamic-one-shared.test +++ test/profile/Posix/instrprof-dynamic-one-shared.test @@ -0,0 +1,23 @@ +RUN: mkdir -p %t.d +RUN: %clang_profgen -o %t.d/a.shared -fPIC -shared %S/../Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profgen -o %t-shared -fPIC -rpath %t.d %t.d/a.shared %S/../Inputs/instrprof-dynamic-b.cpp %S/../Inputs/instrprof-dynamic-main.cpp + +RUN: %clang_profgen -o %t-static %S/../Inputs/instrprof-dynamic-a.cpp %S/../Inputs/instrprof-dynamic-b.cpp %S/../Inputs/instrprof-dynamic-main.cpp + +RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static +RUN: env LLVM_PROFILE_FILE=%t-shared.profraw %run %t-shared + +RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw +RUN: llvm-profdata merge -o %t-shared.profdata %t-shared.profraw + +RUN: %clang_profuse=%t-static.profdata -o %t-a.static.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-a.shared.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-a.cpp +RUN: diff %t-a.static.ll %t-a.shared.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-b.static.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-b.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-b.shared.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-b.cpp +RUN: diff %t-b.static.ll %t-b.shared.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-main.static.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-main.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-main.shared.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-main.cpp +RUN: diff %t-main.static.ll %t-main.shared.ll Index: test/profile/Posix/instrprof-dynamic-two-shared.test =================================================================== --- test/profile/Posix/instrprof-dynamic-two-shared.test +++ test/profile/Posix/instrprof-dynamic-two-shared.test @@ -0,0 +1,24 @@ +RUN: mkdir -p %t.d +RUN: %clang_profgen -o %t.d/a.shared -fPIC -shared %S/../Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profgen -o %t.d/b.shared -fPIC -shared %S/../Inputs/instrprof-dynamic-b.cpp +RUN: %clang_profgen -o %t-shared -fPIC -rpath %t.d %t.d/a.shared %t.d/b.shared %S/../Inputs/instrprof-dynamic-main.cpp + +RUN: %clang_profgen -o %t-static %S/../Inputs/instrprof-dynamic-a.cpp %S/../Inputs/instrprof-dynamic-b.cpp %S/../Inputs/instrprof-dynamic-main.cpp + +RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static +RUN: env LLVM_PROFILE_FILE=%t-shared.profraw %run %t-shared + +RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw +RUN: llvm-profdata merge -o %t-shared.profdata %t-shared.profraw + +RUN: %clang_profuse=%t-static.profdata -o %t-a.static.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-a.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-a.shared.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-a.cpp +RUN: diff %t-a.static.ll %t-a.shared.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-b.static.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-b.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-b.shared.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-b.cpp +RUN: diff %t-b.static.ll %t-b.shared.ll + +RUN: %clang_profuse=%t-static.profdata -o %t-main.static.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-main.cpp +RUN: %clang_profuse=%t-shared.profdata -o %t-main.shared.ll -S -emit-llvm %S/../Inputs/instrprof-dynamic-main.cpp +RUN: diff %t-main.static.ll %t-main.shared.ll Index: test/profile/Posix/instrprof-set-filename-shared.test =================================================================== --- test/profile/Posix/instrprof-set-filename-shared.test +++ test/profile/Posix/instrprof-set-filename-shared.test @@ -0,0 +1,8 @@ +# Test that __llvm_profile_set_filename is honored by shared libary too. +RUN: mkdir -p %t.d +RUN: %clang_profgen=%t.shared.profraw -fPIC -shared -o %t.d/t.shared %S/../Inputs/instrprof-dlopen-func.c +RUN: %clang_profgen -DCALL_SHARED -o %t.m -O3 -rpath %t.d %t.d/t.shared %S/../instrprof-set-filename.c +RUN: %run %t.m %t.main.profraw +RUN: llvm-profdata show %t.main.profraw | FileCheck --check-prefix=SHARED %s + +# SHARED: Total functions: 2 Index: test/profile/Posix/instrprof-shared-gcov-flush.test =================================================================== --- test/profile/Posix/instrprof-shared-gcov-flush.test +++ test/profile/Posix/instrprof-shared-gcov-flush.test @@ -0,0 +1,52 @@ +# This test fails on Mac (https://bugs.llvm.org/show_bug.cgi?id=38134) +XFAIL: darwin + +RUN: mkdir -p %t.d +RUN: cd %t.d + +RUN: %clang --coverage -o libfunc.so -fPIC -shared %S/../Inputs/instrprof-shared-lib.c +RUN: test -f instrprof-shared-lib.gcno + +# Test the case where we exit abruptly after calling __gcov_flush, which means we don't write out the counters at exit. +RUN: %clang -DEXIT_ABRUPTLY -DSHARED_CALL_BEFORE_GCOV_FLUSH -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/../Inputs/instrprof-shared-main-gcov-flush.c +RUN: test -f instrprof-shared-main-gcov-flush.gcno + +RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda +RUN: %run %t +RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/../Inputs/instrprof-shared-main-gcov-flush_no-writeout.c.gcov +RUN: llvm-cov gcov instrprof-shared-lib.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/../Inputs/instrprof-shared-lib.c.gcov + +# Test the case where we exit normally and we have a call to the shared library function before __gcov_flush. +RUN: %clang -DSHARED_CALL_BEFORE_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/../Inputs/instrprof-shared-main-gcov-flush.c +RUN: test -f instrprof-shared-main-gcov-flush.gcno + +RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda +RUN: %run %t +RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/../Inputs/instrprof-shared-main-gcov-flush_shared-call-before.c.gcov +RUN: llvm-cov gcov instrprof-shared-lib.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/../Inputs/instrprof-shared-lib.c.gcov + +# Test the case where we exit normally and we have a call to the shared library function after __gcov_flush. +RUN: %clang -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/../Inputs/instrprof-shared-main-gcov-flush.c +RUN: test -f instrprof-shared-main-gcov-flush.gcno + +RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda +RUN: %run %t +RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/../Inputs/instrprof-shared-main-gcov-flush_shared-call-after.c.gcov +RUN: llvm-cov gcov instrprof-shared-lib.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/../Inputs/instrprof-shared-lib.c.gcov + +# Test the case where we exit normally and we have calls to the shared library function before and after __gcov_flush. +RUN: %clang -DSHARED_CALL_BEFORE_GCOV_FLUSH -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/../Inputs/instrprof-shared-main-gcov-flush.c +RUN: test -f instrprof-shared-main-gcov-flush.gcno + +RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda +RUN: %run %t +RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/../Inputs/instrprof-shared-main-gcov-flush_shared-call-before-after.c.gcov +RUN: llvm-cov gcov instrprof-shared-lib.gcda +RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/../Inputs/instrprof-shared-lib_called-twice.c.gcov Index: test/profile/Posix/instrprof-shared.test =================================================================== --- test/profile/Posix/instrprof-shared.test +++ test/profile/Posix/instrprof-shared.test @@ -0,0 +1,75 @@ +""" +This test produces three shared libraries: + +1. libt-instr.so is instrumented +2. libt-no-instr1.so is not instrumented +3. libt-no-instr2.so is built with profile rt linked in (via -u), but the object file is built + with instrumentation turned off. + +After the libraries are built, the main program is then built with/without instrumentation and linked +against 3 libraries above. + +The test is to verify that programs linked against these shared objects with and without instrumentation +enabled behave as expected. +""" + +RUN: mkdir -p %t.d +RUN: %clang_profgen -o %t.d/libt-instr.so -fPIC -shared %S/../Inputs/instrprof-shared-lib.c +RUN: %clang -o %t.d/libt-no-instr1.so -fPIC -shared %S/../Inputs/instrprof-shared-lib.c +RUN: %clang -c -o %t.d/instrprof-shared-lib-no-instr2.o -fPIC %S/../Inputs/instrprof-shared-lib.c +RUN: %clang_profgen -o %t.d/libt-no-instr2.so -fPIC -shared %t.d/instrprof-shared-lib-no-instr2.o + +RUN: %clang_profgen -o %t-instr-instr -L%t.d -rpath %t.d -lt-instr %S/../Inputs/instrprof-shared-main.c +RUN: %clang_profgen -o %t-instr-no-instr1 -L%t.d -rpath %t.d -lt-no-instr1 %S/../Inputs/instrprof-shared-main.c +RUN: %clang_profgen -o %t-instr-no-instr2 -L%t.d -rpath %t.d -lt-no-instr2 %S/../Inputs/instrprof-shared-main.c +RUN: %clang -o %t-no-instr1-instr -L%t.d -rpath %t.d -lt-instr %S/../Inputs/instrprof-shared-main.c +RUN: %clang -o %t-no-instr1-no-instr1 -L%t.d -rpath %t.d -lt-no-instr1 %S/../Inputs/instrprof-shared-main.c +RUN: %clang -o %t-no-instr1-no-instr2 -L%t.d -rpath %t.d -lt-no-instr2 %S/../Inputs/instrprof-shared-main.c +RUN: %clang -c -o %t.d/instrprof-shared-main-no-instr2.o %S/../Inputs/instrprof-shared-main.c +RUN: %clang -o %t-no-instr2-instr -L%t.d -rpath %t.d -lt-instr %t.d/instrprof-shared-main-no-instr2.o +RUN: %clang -o %t-no-instr2-no-instr1 -L%t.d -rpath %t.d -lt-no-instr1 %t.d/instrprof-shared-main-no-instr2.o +RUN: %clang -o %t-no-instr2-no-instr2 -L%t.d -rpath %t.d -lt-no-instr2 %t.d/instrprof-shared-main-no-instr2.o + +RUN: env LLVM_PROFILE_FILE=%t-instr-instr.profraw %run %t-instr-instr +RUN: env LLVM_PROFILE_FILE=%t-instr-no-instr1.profraw %run %t-instr-no-instr1 +RUN: env LLVM_PROFILE_FILE=%t-instr-no-instr2.profraw %run %t-instr-no-instr2 +RUN: env LLVM_PROFILE_FILE=%t-no-instr1-instr.profraw %run %t-no-instr1-instr +RUN: env LLVM_PROFILE_FILE=%t-no-instr2-instr.profraw %run %t-no-instr2-instr +RUN: env LLVM_PROFILE_FILE=%t-no-instr1-no-instr1.profraw %run %t-no-instr1-no-instr1 +RUN: env LLVM_PROFILE_FILE=%t-no-instr1-no-instr2.profraw %run %t-no-instr1-no-instr2 +RUN: env LLVM_PROFILE_FILE=%t-no-instr2-no-instr1.profraw %run %t-no-instr2-no-instr1 +RUN: env LLVM_PROFILE_FILE=%t-no-instr2-no-instr2.profraw %run %t-no-instr2-no-instr2 + +RUN: llvm-profdata merge -o %t-instr-instr.profdata %t-instr-instr.profraw +RUN: llvm-profdata merge -o %t-instr-no-instr1.profdata %t-instr-no-instr1.profraw +RUN: llvm-profdata merge -o %t-instr-no-instr2.profdata %t-instr-no-instr2.profraw +RUN: llvm-profdata merge -o %t-no-instr1-instr.profdata %t-no-instr1-instr.profraw +RUN: llvm-profdata merge -o %t-no-instr2-instr.profdata %t-no-instr2-instr.profraw + +RUN: not llvm-profdata merge -o %t-no-instr1-no-instr1.profdata %t-no-instr1-no-instr1.profraw 2>&1 | FileCheck %s --check-prefix=MISSING-FILE +RUN: not llvm-profdata merge -o %t-no-instr2-no-instr1.profdata %t-no-instr2-no-instr1.profraw 2>&1 | FileCheck %s --check-prefix=MISSING-FILE +MISSING-FILE: profraw + +RUN: llvm-profdata show -counts --function main %t-instr-instr.profdata | grep -v 'Total\|Maximum' > %t-main-1 +RUN: llvm-profdata show -counts --function main %t-instr-no-instr1.profdata | grep -v 'Total\|Maximum' > %t-main-2 +RUN: llvm-profdata show -counts --function main %t-instr-no-instr2.profdata | grep -v 'Total\|Maximum' > %t-main-3 +RUN: llvm-profdata show -counts --function foo %t-instr-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-1 +RUN: llvm-profdata show -counts --function foo %t-no-instr1-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-2 +RUN: llvm-profdata show -counts --function foo %t-no-instr2-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-3 + +RUN: %clang_profuse=%t-instr-instr.profdata -o %t-main-instr-instr.ll -S -emit-llvm %S/../Inputs/instrprof-shared-main.c +RUN: %clang_profuse=%t-instr-no-instr1.profdata -o %t-main-instr-no-instr1.ll -S -emit-llvm %S/../Inputs/instrprof-shared-main.c +RUN: %clang_profuse=%t-instr-no-instr2.profdata -o %t-main-instr-no-instr2.ll -S -emit-llvm %S/../Inputs/instrprof-shared-main.c +RUN: %clang_profuse=%t-instr-instr.profdata -o %t-lib-instr-instr.ll -S -emit-llvm %S/../Inputs/instrprof-shared-lib.c +RUN: %clang_profuse=%t-no-instr1-instr.profdata -o %t-lib-no-instr1-instr.ll -S -emit-llvm %S/../Inputs/instrprof-shared-lib.c +RUN: %clang_profuse=%t-no-instr2-instr.profdata -o %t-lib-no-instr2-instr.ll -S -emit-llvm %S/../Inputs/instrprof-shared-lib.c +RUN: %clang_profuse=%t-instr-instr.profdata -o %t-lib-instr-instr.ll -S -emit-llvm %S/../Inputs/instrprof-shared-lib.c + +RUN: diff %t-main-instr-no-instr1.ll %t-main-instr-no-instr2.ll +RUN: diff %t-lib-no-instr1-instr.ll %t-lib-no-instr2-instr.ll + +RUN: diff %t-main-1 %t-main-2 +RUN: diff %t-main-1 %t-main-3 +RUN: diff %t-foo-1 %t-foo-2 +RUN: diff %t-foo-1 %t-foo-3 + Index: test/profile/Posix/instrprof-value-prof-shared.test =================================================================== --- test/profile/Posix/instrprof-value-prof-shared.test +++ test/profile/Posix/instrprof-value-prof-shared.test @@ -0,0 +1,52 @@ +// RUN: mkdir -p %t.d +// RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c +// RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -o %t -rpath %t.d %t.d/t.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c +// RUN: env LLVM_PROFILE_FILE=%t.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t +// RUN: llvm-profdata merge -o %t.profdata %t.profraw +// RUN: llvm-profdata show --all-functions -ic-targets %t.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c +// RUN: llvm-profdata show --all-functions -ic-targets %t.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED + +// IR level instrumentation +// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c +// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir %t.d/t.ir.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c +// Profile data from shared library will be concatenated to the same raw file. +// RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir +// RUN: llvm-profdata merge -o %t.ir.profdata %t.ir.profraw +// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c +// RUN: llvm-profdata merge -text %t.ir.profdata -o %t.ir.proftxt +// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED +// RUN: FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.proftxt + +// Same as above but with profile online merging enabled. +// RUN: rm -fr %t.prof/ +// RUN: mkdir -p %t.prof/ +// RUN: %clang_pgogen=%t.prof -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.m.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c +// RUN: %clang_pgogen=%t.prof -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.m %t.d/t.ir.m.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c +// RUN: env LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.m +// RUN: llvm-profdata merge -o %t.ir.m.profdata -dump-input-file-list %t.prof/ | count 2 +// RUN: llvm-profdata merge -o %t.ir.m.profdata %t.prof/ +// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.m.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c +// RUN: llvm-profdata merge -text %t.ir.m.profdata -o %t.ir.m.proftxt +// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.m.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED +// RUN: FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.m.proftxt + + +// IR level instrumentation: dynamic memory allocation +// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.dyn.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c +// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.dyn %t.d/t.ir.dyn.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c +// RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn +// RUN: llvm-profdata merge -o %t.ir.dyn.profdata %t.ir.dyn.profraw +// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.dyn.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c +// RUN: llvm-profdata merge -text %t.ir.dyn.profdata -o %t.ir.dyn.proftxt +// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.dyn.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED +// RUN: FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.dyn.proftxt + +// IR level instrumentation: main program uses static counter, shared library uses dynamic memory alloc. +// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.dyn.shared -DSHARED_LIB %S/../Inputs/instrprof-value-prof-real.c +// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.mixed %t.d/t.ir.dyn.shared -DCALL_SHARED %S/../Inputs/instrprof-value-prof-real.c +// RUN: env LLVM_PROFILE_FILE=%t.ir.mixed.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.mixed +// RUN: llvm-profdata merge -o %t.ir.mixed.profdata %t.ir.mixed.profraw +// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.mixed.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c +// RUN: llvm-profdata merge -text %t.ir.mixed.profdata -o %t.ir.mixed.proftxt +// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.mixed.profdata | FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=SHARED +// RUN: FileCheck %S/../Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.mixed.proftxt Index: test/profile/Posix/instrprof-visibility-kinds.inc =================================================================== --- test/profile/Posix/instrprof-visibility-kinds.inc +++ test/profile/Posix/instrprof-visibility-kinds.inc @@ -0,0 +1,36 @@ +void f1() {} + +#ifndef NO_WEAK +void f2() __attribute__((weak)); +void f2() {} +#endif + +void f3() __attribute__((always_inline)); +void f3() {} + +#ifndef NO_EXTERN +extern void f4(); +#endif + +void f5() __attribute__((visibility("default"))); +void f5() {} + +void f6() __attribute__((visibility("hidden"))); +void f6() {} + +void f7() __attribute__((visibility("internal"))); +void f7() {} + +void call() { + f1(); +#ifndef NO_WEAK + f2(); +#endif + f3(); +#ifndef NO_EXTERN + f4(); +#endif + f5(); + f6(); + f7(); +} Index: test/profile/Posix/instrprof-visibility.cpp =================================================================== --- test/profile/Posix/instrprof-visibility.cpp +++ test/profile/Posix/instrprof-visibility.cpp @@ -0,0 +1,89 @@ +// RUN: %clangxx_profgen -fcoverage-mapping %S/Inputs/instrprof-visibility-helper.cpp -o %t %s +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t +// RUN: llvm-profdata merge %t.profraw -o %t.profdata +// RUN: llvm-profdata show --all-functions %t.profraw | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROFILE +// RUN: llvm-cov show %t -instr-profile=%t.profdata | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=COV + +namespace { +#define NO_WEAK +#define NO_EXTERN +#include "instrprof-visibility-kinds.inc" +#undef NO_EXTERN +#undef NO_WEAK +} + +namespace N1 { +#include "instrprof-visibility-kinds.inc" +} + +int main() { + call(); + N1::call(); + return 0; +} + +// PROFILE-DAG: _ZN2N12f1Ev +// PROFILE-DAG: _ZN2N12f2Ev +// PROFILE-DAG: _ZN2N12f3Ev +// PROFILE-DAG: _ZN2N12f4Ev +// PROFILE-DAG: _ZN2N12f5Ev +// PROFILE-DAG: _ZN2N12f6Ev +// PROFILE-DAG: _ZN2N12f7Ev +// PROFILE-DAG: _ZN2N14callEv +// PROFILE-DAG: main +// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_14callEv +// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f1Ev +// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f3Ev +// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f5Ev +// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f6Ev +// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f7Ev +// PROFILE-DAG: Total functions: 15 + +// COV-DAG: instrprof-visibility-helper.cpp + +// COV-DAG: instrprof-visibility-kinds.inc + +// COV-DAG: _ZN2N12f1Ev +// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f1Ev +// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f3Ev +// COV-DAG: _ZN2N12f3Ev +// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f5Ev +// COV-DAG: _ZN2N12f5Ev +// COV-DAG: _ZN2N12f6Ev +// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f6Ev +// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f7Ev +// COV-DAG: _ZN2N12f7Ev + +// --- Check coverage for functions in the anonymous namespace. +// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_14callEv +// COV-DAG: [[CALL:[0-9]+]]|{{ *}}1|void call() { +// COV-DAG: {{.*}}|{{ *}}1| f1(); +// COV-DAG: {{.*}}|{{ *}}1|#ifndef NO_WEAK +// COV-DAG: {{.*}}|{{ *}} | f2(); +// COV-DAG: {{.*}}|{{ *}} |#endif +// COV-DAG: {{.*}}|{{ *}}1| f3(); +// COV-DAG: {{.*}}|{{ *}}1|#ifndef NO_EXTERN +// COV-DAG: {{.*}}|{{ *}} | f4(); +// COV-DAG: {{.*}}|{{ *}} |#endif +// COV-DAG: {{.*}}|{{ *}}1| f5(); +// COV-DAG: {{.*}}|{{ *}}1| f6(); +// COV-DAG: {{.*}}|{{ *}}1| f7(); +// COV-DAG: {{.*}}|{{ *}}1|} + +// --- Check coverage for functions in namespace N1. +// COV-DAG: _ZN2N14callEv +// COV-DAG: {{ *}}[[CALL]]|{{ *}}1|void call() { +// COV-DAG: {{.*}}|{{ *}}1| f1(); +// COV-DAG: {{.*}}|{{ *}}1|#ifndef NO_WEAK +// COV-DAG: {{.*}}|{{ *}}1| f2(); +// COV-DAG: {{.*}}|{{ *}}1|#endif +// COV-DAG: {{.*}}|{{ *}}1| f3(); +// COV-DAG: {{.*}}|{{ *}}1|#ifndef NO_EXTERN +// COV-DAG: {{.*}}|{{ *}}1| f4(); +// COV-DAG: {{.*}}|{{ *}}1|#endif +// COV-DAG: {{.*}}|{{ *}}1| f5(); +// COV-DAG: {{.*}}|{{ *}}1| f6(); +// COV-DAG: {{.*}}|{{ *}}1| f7(); +// COV-DAG: {{.*}}|{{ *}}1|} + +// COV-DAG: instrprof-visibility.cpp Index: test/profile/Posix/lit.local.cfg =================================================================== --- test/profile/Posix/lit.local.cfg +++ test/profile/Posix/lit.local.cfg @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: + return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os in ['Windows']: + config.unsupported = True Index: test/profile/instrprof-dlopen-dlclose-gcov.test =================================================================== --- test/profile/instrprof-dlopen-dlclose-gcov.test +++ test/profile/instrprof-dlopen-dlclose-gcov.test @@ -1,33 +0,0 @@ -# atexit(3) not supported in dlopen(3)ed+dlclose(3)d DSO -XFAIL: netbsd - -RUN: mkdir -p %t.d -RUN: cd %t.d - -RUN: %clang --coverage -o func.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func.c -RUN: %clang --coverage -o func2.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func2.c -RUN: %clang --coverage -o func3.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func3.c -RUN: %clang --coverage -o %t -fPIC -rpath %t.d %S/Inputs/instrprof-dlopen-dlclose-main.c - -# Test with two dlopened libraries. -RUN: rm -f instrprof-dlopen-dlclose-main.gcda instrprof-dlopen-func.gcda instrprof-dlopen-func2.gcda -RUN: %run %t -RUN: llvm-cov gcov instrprof-dlopen-dlclose-main.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-dlclose-main.c.gcov %S/Inputs/instrprof-dlopen-dlclose-main.c.gcov -RUN: llvm-cov gcov instrprof-dlopen-func.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func.c.gcov %S/Inputs/instrprof-dlopen-func.c.gcov -RUN: llvm-cov gcov instrprof-dlopen-func2.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/Inputs/instrprof-dlopen-func2.c.gcov - -# Test with three dlopened libraries. -RUN: %clang -DUSE_LIB3 --coverage -o %t -fPIC -rpath %t.d %S/Inputs/instrprof-dlopen-dlclose-main.c -RUN: rm -f instrprof-dlopen-dlclose-main.gcda instrprof-dlopen-func.gcda instrprof-dlopen-func2.gcda instrprof-dlopen-func3.gcda -RUN: %run %t -RUN: llvm-cov gcov instrprof-dlopen-dlclose-main.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-dlclose-main.c.gcov %S/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov -RUN: llvm-cov gcov instrprof-dlopen-func.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func.c.gcov %S/Inputs/instrprof-dlopen-func.c.gcov -RUN: llvm-cov gcov instrprof-dlopen-func2.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/Inputs/instrprof-dlopen-func2.c.gcov -RUN: llvm-cov gcov instrprof-dlopen-func3.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-dlopen-func2.c.gcov %S/Inputs/instrprof-dlopen-func3.c.gcov Index: test/profile/instrprof-dlopen.test =================================================================== --- test/profile/instrprof-dlopen.test +++ test/profile/instrprof-dlopen.test @@ -1,34 +0,0 @@ -RUN: mkdir -p %t.d -RUN: %clang_profgen -o %t.d/func.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func.c -RUN: %clang_profgen -o %t.d/func2.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func2.c -RUN: %clang -o %t-local -fPIC -DDLOPEN_FUNC_DIR=\"%t.d\" -DDLOPEN_FLAGS="RTLD_LAZY | RTLD_LOCAL" %S/Inputs/instrprof-dlopen-main.c -RUN: %clang -o %t-global -fPIC -DDLOPEN_FUNC_DIR=\"%t.d\" -DDLOPEN_FLAGS="RTLD_LAZY | RTLD_GLOBAL" %S/Inputs/instrprof-dlopen-main.c - -RUN: %clang -c -o %t.d/main.o %S/Inputs/instrprof-dlopen-main.c -RUN: %clang_profgen -o %t-static %S/Inputs/instrprof-dlopen-func.c %S/Inputs/instrprof-dlopen-func2.c %t.d/main.o - -RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static -RUN: env LLVM_PROFILE_FILE=%t-local.profraw %run %t-local -RUN: env LLVM_PROFILE_FILE=%t-global.profraw %run %t-global - -RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw -RUN: llvm-profdata merge -o %t-local.profdata %t-local.profraw -RUN: llvm-profdata merge -o %t-global.profdata %t-global.profraw - -RUN: %clang_profuse=%t-static.profdata -o %t-func.static.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-func.c -RUN: %clang_profuse=%t-local.profdata -o %t-func.local.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-func.c -RUN: %clang_profuse=%t-global.profdata -o %t-func.global.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-func.c -RUN: diff %t-func.static.ll %t-func.local.ll -RUN: diff %t-func.static.ll %t-func.global.ll - -RUN: %clang_profuse=%t-static.profdata -o %t-func2.static.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-func2.c -RUN: %clang_profuse=%t-local.profdata -o %t-func2.local.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-func2.c -RUN: %clang_profuse=%t-global.profdata -o %t-func2.global.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-func2.c -RUN: diff %t-func2.static.ll %t-func2.local.ll -RUN: diff %t-func2.static.ll %t-func2.global.ll - -RUN: %clang_profuse=%t-static.profdata -o %t-main.static.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-main.c -RUN: %clang_profuse=%t-local.profdata -o %t-main.local.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-main.c -RUN: %clang_profuse=%t-local.profdata -o %t-main.global.ll -S -emit-llvm %S/Inputs/instrprof-dlopen-main.c -RUN: diff %t-main.static.ll %t-main.local.ll -RUN: diff %t-main.static.ll %t-main.global.ll Index: test/profile/instrprof-dynamic-one-shared.test =================================================================== --- test/profile/instrprof-dynamic-one-shared.test +++ test/profile/instrprof-dynamic-one-shared.test @@ -1,23 +0,0 @@ -RUN: mkdir -p %t.d -RUN: %clang_profgen -o %t.d/a.shared -fPIC -shared %S/Inputs/instrprof-dynamic-a.cpp -RUN: %clang_profgen -o %t-shared -fPIC -rpath %t.d %t.d/a.shared %S/Inputs/instrprof-dynamic-b.cpp %S/Inputs/instrprof-dynamic-main.cpp - -RUN: %clang_profgen -o %t-static %S/Inputs/instrprof-dynamic-a.cpp %S/Inputs/instrprof-dynamic-b.cpp %S/Inputs/instrprof-dynamic-main.cpp - -RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static -RUN: env LLVM_PROFILE_FILE=%t-shared.profraw %run %t-shared - -RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw -RUN: llvm-profdata merge -o %t-shared.profdata %t-shared.profraw - -RUN: %clang_profuse=%t-static.profdata -o %t-a.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-a.cpp -RUN: %clang_profuse=%t-shared.profdata -o %t-a.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-a.cpp -RUN: diff %t-a.static.ll %t-a.shared.ll - -RUN: %clang_profuse=%t-static.profdata -o %t-b.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-b.cpp -RUN: %clang_profuse=%t-shared.profdata -o %t-b.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-b.cpp -RUN: diff %t-b.static.ll %t-b.shared.ll - -RUN: %clang_profuse=%t-static.profdata -o %t-main.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-main.cpp -RUN: %clang_profuse=%t-shared.profdata -o %t-main.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-main.cpp -RUN: diff %t-main.static.ll %t-main.shared.ll Index: test/profile/instrprof-dynamic-two-shared.test =================================================================== --- test/profile/instrprof-dynamic-two-shared.test +++ test/profile/instrprof-dynamic-two-shared.test @@ -1,24 +0,0 @@ -RUN: mkdir -p %t.d -RUN: %clang_profgen -o %t.d/a.shared -fPIC -shared %S/Inputs/instrprof-dynamic-a.cpp -RUN: %clang_profgen -o %t.d/b.shared -fPIC -shared %S/Inputs/instrprof-dynamic-b.cpp -RUN: %clang_profgen -o %t-shared -fPIC -rpath %t.d %t.d/a.shared %t.d/b.shared %S/Inputs/instrprof-dynamic-main.cpp - -RUN: %clang_profgen -o %t-static %S/Inputs/instrprof-dynamic-a.cpp %S/Inputs/instrprof-dynamic-b.cpp %S/Inputs/instrprof-dynamic-main.cpp - -RUN: env LLVM_PROFILE_FILE=%t-static.profraw %run %t-static -RUN: env LLVM_PROFILE_FILE=%t-shared.profraw %run %t-shared - -RUN: llvm-profdata merge -o %t-static.profdata %t-static.profraw -RUN: llvm-profdata merge -o %t-shared.profdata %t-shared.profraw - -RUN: %clang_profuse=%t-static.profdata -o %t-a.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-a.cpp -RUN: %clang_profuse=%t-shared.profdata -o %t-a.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-a.cpp -RUN: diff %t-a.static.ll %t-a.shared.ll - -RUN: %clang_profuse=%t-static.profdata -o %t-b.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-b.cpp -RUN: %clang_profuse=%t-shared.profdata -o %t-b.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-b.cpp -RUN: diff %t-b.static.ll %t-b.shared.ll - -RUN: %clang_profuse=%t-static.profdata -o %t-main.static.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-main.cpp -RUN: %clang_profuse=%t-shared.profdata -o %t-main.shared.ll -S -emit-llvm %S/Inputs/instrprof-dynamic-main.cpp -RUN: diff %t-main.static.ll %t-main.shared.ll Index: test/profile/instrprof-gcov-exceptions.test =================================================================== --- test/profile/instrprof-gcov-exceptions.test +++ test/profile/instrprof-gcov-exceptions.test @@ -17,5 +17,5 @@ RUN: rm -f instrprof-gcov-exceptions.gcda RUN: %run %t RUN: llvm-cov gcov instrprof-gcov-exceptions.gcda -# The result should be the same, not using XFAIL as only this part of the test is failing. -RUN: not FileCheck --match-full-lines --strict-whitespace --input-file instrprof-gcov-exceptions.cpp.gcov %S/Inputs/instrprof-gcov-exceptions.cpp.gcov +# FIXME: The result should be the same, but they are not on some platforms. +RUNX: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-gcov-exceptions.cpp.gcov %S/Inputs/instrprof-gcov-exceptions.cpp.gcov Index: test/profile/instrprof-icall-promo.test =================================================================== --- test/profile/instrprof-icall-promo.test +++ test/profile/instrprof-icall-promo.test @@ -12,6 +12,9 @@ RUN: llvm-profdata merge -o %t-icall2.profdata %t-icall2.profraw RUN: %clangxx_profuse=%t-icall2.profdata -O2 -Rpass=pgo-icall-prom -c -o %t.2.use.o %S/Inputs/instrprof-icall-promo_2.cc 2>&1 | FileCheck %s +FIXME: Relies on vtable layout +XFAIL: msvc + # CHECK: Promote indirect call to Index: test/profile/instrprof-merge-match.test =================================================================== --- test/profile/instrprof-merge-match.test +++ test/profile/instrprof-merge-match.test @@ -3,3 +3,5 @@ // RUN: %clang_profgen -o %t -L %t.d -rpath %t.d %S/Inputs/instrprof-merge-match.c -lt // RUN: %run %t +rpath isn't supported on Windows. +UNSUPPORTED: windows Index: test/profile/instrprof-merge.c =================================================================== --- test/profile/instrprof-merge.c +++ test/profile/instrprof-merge.c @@ -2,6 +2,9 @@ // RUN: %run %t %t.profraw 1 1 // RUN: llvm-profdata show --all-functions --counts %t.profraw | FileCheck %s +// FIXME: llvm-profdata exits with "Malformed instrumentation profile data" +// XFAIL: msvc + #include #include #include Index: test/profile/instrprof-merging.cpp =================================================================== --- test/profile/instrprof-merging.cpp +++ test/profile/instrprof-merging.cpp @@ -21,6 +21,9 @@ // and prefer it over others.) When only limited coverage information is // available (just from one binary), don't try to guess any region counts. +// FIXME: Fails with: "Failed to load coverage: No coverage data found" +// XFAIL: windows + struct A { A() {} // V1: [[@LINE]]{{ *}}|{{ *}}1 // V1-ONLY: [[@LINE+1]]{{ *}}|{{ *}}| Index: test/profile/instrprof-path.c =================================================================== --- test/profile/instrprof-path.c +++ test/profile/instrprof-path.c @@ -1,13 +1,13 @@ // RUN: %clang_pgogen -O2 -o %t.0 %s -// RUN: %clang_pgogen=%t.d1 -O2 -o %t.1 %s -// RUN: %clang_pgogen=%t.d1/%t.d2 -O2 -o %t.2 %s +// RUN: %clang_pgogen=%/t.d1 -O2 -o %t.1 %s +// RUN: %clang_pgogen=%/t.d1/%:t.d2 -O2 -o %t.2 %s // // RUN: %run %t.0 "" -// RUN: env LLVM_PROFILE_FILE=%t.d1/default.profraw %run %t.0 %t.d1/ -// RUN: env LLVM_PROFILE_FILE=%t.d1/%t.d2/default.profraw %run %t.0 %t.d1/%t.d2/ -// RUN: %run %t.1 %t.d1/ -// RUN: %run %t.2 %t.d1/%t.d2/ -// RUN: %run %t.2 %t.d1/%t.d2/ %t.d1/%t.d2/%t.d3/blah.profraw %t.d1/%t.d2/%t.d3/ +// RUN: env LLVM_PROFILE_FILE=%/t.d1/default.profraw %run %t.0 %/t.d1 +// RUN: env LLVM_PROFILE_FILE=%/t.d1/%:t.d2/default.profraw %run %t.0 %/t.d1/%:t.d2 +// RUN: %run %t.1 %/t.d1 +// RUN: %run %t.2 %/t.d1/%:t.d2 +// RUN: %run %t.2 %/t.d1/%:t.d2 %/t.d1/%:t.d2/%:t.d3/blah.profraw %/t.d1/%:t.d2/%:t.d3/ #include @@ -15,7 +15,6 @@ void __llvm_profile_set_filename(const char*); int main(int argc, const char *argv[]) { - int i; const char *expected; const char *prefix; if (argc < 2) @@ -24,7 +23,16 @@ expected = argv[1]; prefix = __llvm_profile_get_path_prefix(); - if (strcmp(prefix, expected)) + // The last character should be a trailing slash. Ignore it in the comparison + // since it could be '/' or '\\'. + int slashpos = strlen(prefix); + if (slashpos > 0) { + --slashpos; + if (prefix[slashpos] != '/' && prefix[slashpos] != '\\') + return 1; + } + + if (strncmp(prefix, expected, slashpos)) return 1; if (argc == 4) { Index: test/profile/instrprof-set-filename-shared.test =================================================================== --- test/profile/instrprof-set-filename-shared.test +++ test/profile/instrprof-set-filename-shared.test @@ -1,8 +0,0 @@ -# Test that __llvm_profile_set_filename is honored by shared libary too. -RUN: mkdir -p %t.d -RUN: %clang_profgen=%t.shared.profraw -fPIC -shared -o %t.d/t.shared %S/Inputs/instrprof-dlopen-func.c -RUN: %clang_profgen -DCALL_SHARED -o %t.m -O3 -rpath %t.d %t.d/t.shared %S/instrprof-set-filename.c -RUN: %run %t.m %t.main.profraw -RUN: llvm-profdata show %t.main.profraw | FileCheck --check-prefix=SHARED %s - -# SHARED: Total functions: 2 Index: test/profile/instrprof-shared-gcov-flush.test =================================================================== --- test/profile/instrprof-shared-gcov-flush.test +++ test/profile/instrprof-shared-gcov-flush.test @@ -1,52 +0,0 @@ -# This test fails on Mac (https://bugs.llvm.org/show_bug.cgi?id=38134) -XFAIL: darwin - -RUN: mkdir -p %t.d -RUN: cd %t.d - -RUN: %clang --coverage -o libfunc.so -fPIC -shared %S/Inputs/instrprof-shared-lib.c -RUN: test -f instrprof-shared-lib.gcno - -# Test the case where we exit abruptly after calling __gcov_flush, which means we don't write out the counters at exit. -RUN: %clang -DEXIT_ABRUPTLY -DSHARED_CALL_BEFORE_GCOV_FLUSH -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/Inputs/instrprof-shared-main-gcov-flush.c -RUN: test -f instrprof-shared-main-gcov-flush.gcno - -RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda -RUN: %run %t -RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/Inputs/instrprof-shared-main-gcov-flush_no-writeout.c.gcov -RUN: llvm-cov gcov instrprof-shared-lib.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/Inputs/instrprof-shared-lib.c.gcov - -# Test the case where we exit normally and we have a call to the shared library function before __gcov_flush. -RUN: %clang -DSHARED_CALL_BEFORE_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/Inputs/instrprof-shared-main-gcov-flush.c -RUN: test -f instrprof-shared-main-gcov-flush.gcno - -RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda -RUN: %run %t -RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/Inputs/instrprof-shared-main-gcov-flush_shared-call-before.c.gcov -RUN: llvm-cov gcov instrprof-shared-lib.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/Inputs/instrprof-shared-lib.c.gcov - -# Test the case where we exit normally and we have a call to the shared library function after __gcov_flush. -RUN: %clang -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/Inputs/instrprof-shared-main-gcov-flush.c -RUN: test -f instrprof-shared-main-gcov-flush.gcno - -RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda -RUN: %run %t -RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/Inputs/instrprof-shared-main-gcov-flush_shared-call-after.c.gcov -RUN: llvm-cov gcov instrprof-shared-lib.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/Inputs/instrprof-shared-lib.c.gcov - -# Test the case where we exit normally and we have calls to the shared library function before and after __gcov_flush. -RUN: %clang -DSHARED_CALL_BEFORE_GCOV_FLUSH -DSHARED_CALL_AFTER_GCOV_FLUSH --coverage -o %t -L%t.d -rpath %t.d -lfunc %S/Inputs/instrprof-shared-main-gcov-flush.c -RUN: test -f instrprof-shared-main-gcov-flush.gcno - -RUN: rm -f instrprof-shared-main-gcov-flush.gcda instrprof-shared-lib.gcda -RUN: %run %t -RUN: llvm-cov gcov instrprof-shared-main-gcov-flush.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-main-gcov-flush.c.gcov %S/Inputs/instrprof-shared-main-gcov-flush_shared-call-before-after.c.gcov -RUN: llvm-cov gcov instrprof-shared-lib.gcda -RUN: FileCheck --match-full-lines --strict-whitespace --input-file instrprof-shared-lib.c.gcov %S/Inputs/instrprof-shared-lib_called-twice.c.gcov Index: test/profile/instrprof-shared.test =================================================================== --- test/profile/instrprof-shared.test +++ test/profile/instrprof-shared.test @@ -1,75 +0,0 @@ -""" -This test produces three shared libraries: - -1. libt-instr.so is instrumented -2. libt-no-instr1.so is not instrumented -3. libt-no-instr2.so is built with profile rt linked in (via -u), but the object file is built - with instrumentation turned off. - -After the libraries are built, the main program is then built with/without instrumentation and linked -against 3 libraries above. - -The test is to verify that programs linked against these shared objects with and without instrumentation -enabled behave as expected. -""" - -RUN: mkdir -p %t.d -RUN: %clang_profgen -o %t.d/libt-instr.so -fPIC -shared %S/Inputs/instrprof-shared-lib.c -RUN: %clang -o %t.d/libt-no-instr1.so -fPIC -shared %S/Inputs/instrprof-shared-lib.c -RUN: %clang -c -o %t.d/instrprof-shared-lib-no-instr2.o -fPIC %S/Inputs/instrprof-shared-lib.c -RUN: %clang_profgen -o %t.d/libt-no-instr2.so -fPIC -shared %t.d/instrprof-shared-lib-no-instr2.o - -RUN: %clang_profgen -o %t-instr-instr -L%t.d -rpath %t.d -lt-instr %S/Inputs/instrprof-shared-main.c -RUN: %clang_profgen -o %t-instr-no-instr1 -L%t.d -rpath %t.d -lt-no-instr1 %S/Inputs/instrprof-shared-main.c -RUN: %clang_profgen -o %t-instr-no-instr2 -L%t.d -rpath %t.d -lt-no-instr2 %S/Inputs/instrprof-shared-main.c -RUN: %clang -o %t-no-instr1-instr -L%t.d -rpath %t.d -lt-instr %S/Inputs/instrprof-shared-main.c -RUN: %clang -o %t-no-instr1-no-instr1 -L%t.d -rpath %t.d -lt-no-instr1 %S/Inputs/instrprof-shared-main.c -RUN: %clang -o %t-no-instr1-no-instr2 -L%t.d -rpath %t.d -lt-no-instr2 %S/Inputs/instrprof-shared-main.c -RUN: %clang -c -o %t.d/instrprof-shared-main-no-instr2.o %S/Inputs/instrprof-shared-main.c -RUN: %clang -o %t-no-instr2-instr -L%t.d -rpath %t.d -lt-instr %t.d/instrprof-shared-main-no-instr2.o -RUN: %clang -o %t-no-instr2-no-instr1 -L%t.d -rpath %t.d -lt-no-instr1 %t.d/instrprof-shared-main-no-instr2.o -RUN: %clang -o %t-no-instr2-no-instr2 -L%t.d -rpath %t.d -lt-no-instr2 %t.d/instrprof-shared-main-no-instr2.o - -RUN: env LLVM_PROFILE_FILE=%t-instr-instr.profraw %run %t-instr-instr -RUN: env LLVM_PROFILE_FILE=%t-instr-no-instr1.profraw %run %t-instr-no-instr1 -RUN: env LLVM_PROFILE_FILE=%t-instr-no-instr2.profraw %run %t-instr-no-instr2 -RUN: env LLVM_PROFILE_FILE=%t-no-instr1-instr.profraw %run %t-no-instr1-instr -RUN: env LLVM_PROFILE_FILE=%t-no-instr2-instr.profraw %run %t-no-instr2-instr -RUN: env LLVM_PROFILE_FILE=%t-no-instr1-no-instr1.profraw %run %t-no-instr1-no-instr1 -RUN: env LLVM_PROFILE_FILE=%t-no-instr1-no-instr2.profraw %run %t-no-instr1-no-instr2 -RUN: env LLVM_PROFILE_FILE=%t-no-instr2-no-instr1.profraw %run %t-no-instr2-no-instr1 -RUN: env LLVM_PROFILE_FILE=%t-no-instr2-no-instr2.profraw %run %t-no-instr2-no-instr2 - -RUN: llvm-profdata merge -o %t-instr-instr.profdata %t-instr-instr.profraw -RUN: llvm-profdata merge -o %t-instr-no-instr1.profdata %t-instr-no-instr1.profraw -RUN: llvm-profdata merge -o %t-instr-no-instr2.profdata %t-instr-no-instr2.profraw -RUN: llvm-profdata merge -o %t-no-instr1-instr.profdata %t-no-instr1-instr.profraw -RUN: llvm-profdata merge -o %t-no-instr2-instr.profdata %t-no-instr2-instr.profraw - -RUN: not llvm-profdata merge -o %t-no-instr1-no-instr1.profdata %t-no-instr1-no-instr1.profraw 2>&1 | FileCheck %s --check-prefix=MISSING-FILE -RUN: not llvm-profdata merge -o %t-no-instr2-no-instr1.profdata %t-no-instr2-no-instr1.profraw 2>&1 | FileCheck %s --check-prefix=MISSING-FILE -MISSING-FILE: profraw - -RUN: llvm-profdata show -counts --function main %t-instr-instr.profdata | grep -v 'Total\|Maximum' > %t-main-1 -RUN: llvm-profdata show -counts --function main %t-instr-no-instr1.profdata | grep -v 'Total\|Maximum' > %t-main-2 -RUN: llvm-profdata show -counts --function main %t-instr-no-instr2.profdata | grep -v 'Total\|Maximum' > %t-main-3 -RUN: llvm-profdata show -counts --function foo %t-instr-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-1 -RUN: llvm-profdata show -counts --function foo %t-no-instr1-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-2 -RUN: llvm-profdata show -counts --function foo %t-no-instr2-instr.profdata | grep -v 'Total\|Maximum' > %t-foo-3 - -RUN: %clang_profuse=%t-instr-instr.profdata -o %t-main-instr-instr.ll -S -emit-llvm %S/Inputs/instrprof-shared-main.c -RUN: %clang_profuse=%t-instr-no-instr1.profdata -o %t-main-instr-no-instr1.ll -S -emit-llvm %S/Inputs/instrprof-shared-main.c -RUN: %clang_profuse=%t-instr-no-instr2.profdata -o %t-main-instr-no-instr2.ll -S -emit-llvm %S/Inputs/instrprof-shared-main.c -RUN: %clang_profuse=%t-instr-instr.profdata -o %t-lib-instr-instr.ll -S -emit-llvm %S/Inputs/instrprof-shared-lib.c -RUN: %clang_profuse=%t-no-instr1-instr.profdata -o %t-lib-no-instr1-instr.ll -S -emit-llvm %S/Inputs/instrprof-shared-lib.c -RUN: %clang_profuse=%t-no-instr2-instr.profdata -o %t-lib-no-instr2-instr.ll -S -emit-llvm %S/Inputs/instrprof-shared-lib.c -RUN: %clang_profuse=%t-instr-instr.profdata -o %t-lib-instr-instr.ll -S -emit-llvm %S/Inputs/instrprof-shared-lib.c - -RUN: diff %t-main-instr-no-instr1.ll %t-main-instr-no-instr2.ll -RUN: diff %t-lib-no-instr1-instr.ll %t-lib-no-instr2-instr.ll - -RUN: diff %t-main-1 %t-main-2 -RUN: diff %t-main-1 %t-main-3 -RUN: diff %t-foo-1 %t-foo-2 -RUN: diff %t-foo-1 %t-foo-3 - Index: test/profile/instrprof-value-prof-shared.test =================================================================== --- test/profile/instrprof-value-prof-shared.test +++ test/profile/instrprof-value-prof-shared.test @@ -1,52 +0,0 @@ -// RUN: mkdir -p %t.d -// RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.shared -DSHARED_LIB %S/Inputs/instrprof-value-prof-real.c -// RUN: %clang_profgen -O2 -mllvm -enable-value-profiling=true -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -o %t -rpath %t.d %t.d/t.shared -DCALL_SHARED %S/Inputs/instrprof-value-prof-real.c -// RUN: env LLVM_PROFILE_FILE=%t.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t -// RUN: llvm-profdata merge -o %t.profdata %t.profraw -// RUN: llvm-profdata show --all-functions -ic-targets %t.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c -// RUN: llvm-profdata show --all-functions -ic-targets %t.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=SHARED - -// IR level instrumentation -// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.shared -DSHARED_LIB %S/Inputs/instrprof-value-prof-real.c -// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir %t.d/t.ir.shared -DCALL_SHARED %S/Inputs/instrprof-value-prof-real.c -// Profile data from shared library will be concatenated to the same raw file. -// RUN: env LLVM_PROFILE_FILE=%t.ir.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir -// RUN: llvm-profdata merge -o %t.ir.profdata %t.ir.profraw -// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c -// RUN: llvm-profdata merge -text %t.ir.profdata -o %t.ir.proftxt -// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=SHARED -// RUN: FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.proftxt - -// Same as above but with profile online merging enabled. -// RUN: rm -fr %t.prof/ -// RUN: mkdir -p %t.prof/ -// RUN: %clang_pgogen=%t.prof -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.m.shared -DSHARED_LIB %S/Inputs/instrprof-value-prof-real.c -// RUN: %clang_pgogen=%t.prof -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.m %t.d/t.ir.m.shared -DCALL_SHARED %S/Inputs/instrprof-value-prof-real.c -// RUN: env LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.m -// RUN: llvm-profdata merge -o %t.ir.m.profdata -dump-input-file-list %t.prof/ | count 2 -// RUN: llvm-profdata merge -o %t.ir.m.profdata %t.prof/ -// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.m.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c -// RUN: llvm-profdata merge -text %t.ir.m.profdata -o %t.ir.m.proftxt -// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.m.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=SHARED -// RUN: FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.m.proftxt - - -// IR level instrumentation: dynamic memory allocation -// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.dyn.shared -DSHARED_LIB %S/Inputs/instrprof-value-prof-real.c -// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.dyn %t.d/t.ir.dyn.shared -DCALL_SHARED %S/Inputs/instrprof-value-prof-real.c -// RUN: env LLVM_PROFILE_FILE=%t.ir.dyn.profraw %run %t.ir.dyn -// RUN: llvm-profdata merge -o %t.ir.dyn.profdata %t.ir.dyn.profraw -// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.dyn.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c -// RUN: llvm-profdata merge -text %t.ir.dyn.profdata -o %t.ir.dyn.proftxt -// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.dyn.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=SHARED -// RUN: FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.dyn.proftxt - -// IR level instrumentation: main program uses static counter, shared library uses dynamic memory alloc. -// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=false -mllvm -vp-counters-per-site=256 -fPIC -shared -o %t.d/t.ir.dyn.shared -DSHARED_LIB %S/Inputs/instrprof-value-prof-real.c -// RUN: %clang_pgogen -O2 -mllvm -disable-vp=false -mllvm -vp-static-alloc=true -mllvm -vp-counters-per-site=256 -rpath %t.d -o %t.ir.mixed %t.d/t.ir.dyn.shared -DCALL_SHARED %S/Inputs/instrprof-value-prof-real.c -// RUN: env LLVM_PROFILE_FILE=%t.ir.mixed.profraw LLVM_VP_MAX_NUM_VALS_PER_SITE=255 %run %t.ir.mixed -// RUN: llvm-profdata merge -o %t.ir.mixed.profdata %t.ir.mixed.profraw -// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.mixed.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c -// RUN: llvm-profdata merge -text %t.ir.mixed.profdata -o %t.ir.mixed.proftxt -// RUN: llvm-profdata show --all-functions -ic-targets %t.ir.mixed.profdata | FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=SHARED -// RUN: FileCheck %S/Inputs/instrprof-value-prof-real.c --check-prefix=IR < %t.ir.mixed.proftxt Index: test/profile/instrprof-version-mismatch.c =================================================================== --- test/profile/instrprof-version-mismatch.c +++ test/profile/instrprof-version-mismatch.c @@ -1,6 +1,9 @@ // RUN: %clang_profgen -o %t -O3 %s // RUN: %run %t 1 2>&1 | FileCheck %s +// FIXME: Weak symbols are once again a portability problem for Windows. +// XFAIL: windows + // override the version variable with a bogus version: unsigned long long __llvm_profile_raw_version = 10000; int main(int argc, const char *argv[]) { Index: test/profile/instrprof-visibility-kinds.inc =================================================================== --- test/profile/instrprof-visibility-kinds.inc +++ test/profile/instrprof-visibility-kinds.inc @@ -1,36 +0,0 @@ -void f1() {} - -#ifndef NO_WEAK -void f2() __attribute__((weak)); -void f2() {} -#endif - -void f3() __attribute__((always_inline)); -void f3() {} - -#ifndef NO_EXTERN -extern void f4(); -#endif - -void f5() __attribute__((visibility("default"))); -void f5() {} - -void f6() __attribute__((visibility("hidden"))); -void f6() {} - -void f7() __attribute__((visibility("internal"))); -void f7() {} - -void call() { - f1(); -#ifndef NO_WEAK - f2(); -#endif - f3(); -#ifndef NO_EXTERN - f4(); -#endif - f5(); - f6(); - f7(); -} Index: test/profile/instrprof-visibility.cpp =================================================================== --- test/profile/instrprof-visibility.cpp +++ test/profile/instrprof-visibility.cpp @@ -1,89 +0,0 @@ -// RUN: %clangxx_profgen -fcoverage-mapping %S/Inputs/instrprof-visibility-helper.cpp -o %t %s -// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t -// RUN: llvm-profdata merge %t.profraw -o %t.profdata -// RUN: llvm-profdata show --all-functions %t.profraw | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=PROFILE -// RUN: llvm-cov show %t -instr-profile=%t.profdata | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=COV - -namespace { -#define NO_WEAK -#define NO_EXTERN -#include "instrprof-visibility-kinds.inc" -#undef NO_EXTERN -#undef NO_WEAK -} - -namespace N1 { -#include "instrprof-visibility-kinds.inc" -} - -int main() { - call(); - N1::call(); - return 0; -} - -// PROFILE-DAG: _ZN2N12f1Ev -// PROFILE-DAG: _ZN2N12f2Ev -// PROFILE-DAG: _ZN2N12f3Ev -// PROFILE-DAG: _ZN2N12f4Ev -// PROFILE-DAG: _ZN2N12f5Ev -// PROFILE-DAG: _ZN2N12f6Ev -// PROFILE-DAG: _ZN2N12f7Ev -// PROFILE-DAG: _ZN2N14callEv -// PROFILE-DAG: main -// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_14callEv -// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f1Ev -// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f3Ev -// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f5Ev -// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f6Ev -// PROFILE-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f7Ev -// PROFILE-DAG: Total functions: 15 - -// COV-DAG: instrprof-visibility-helper.cpp - -// COV-DAG: instrprof-visibility-kinds.inc - -// COV-DAG: _ZN2N12f1Ev -// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f1Ev -// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f3Ev -// COV-DAG: _ZN2N12f3Ev -// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f5Ev -// COV-DAG: _ZN2N12f5Ev -// COV-DAG: _ZN2N12f6Ev -// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f6Ev -// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_12f7Ev -// COV-DAG: _ZN2N12f7Ev - -// --- Check coverage for functions in the anonymous namespace. -// COV-DAG: instrprof-visibility.cpp:_ZN12_GLOBAL__N_14callEv -// COV-DAG: [[CALL:[0-9]+]]|{{ *}}1|void call() { -// COV-DAG: {{.*}}|{{ *}}1| f1(); -// COV-DAG: {{.*}}|{{ *}}1|#ifndef NO_WEAK -// COV-DAG: {{.*}}|{{ *}} | f2(); -// COV-DAG: {{.*}}|{{ *}} |#endif -// COV-DAG: {{.*}}|{{ *}}1| f3(); -// COV-DAG: {{.*}}|{{ *}}1|#ifndef NO_EXTERN -// COV-DAG: {{.*}}|{{ *}} | f4(); -// COV-DAG: {{.*}}|{{ *}} |#endif -// COV-DAG: {{.*}}|{{ *}}1| f5(); -// COV-DAG: {{.*}}|{{ *}}1| f6(); -// COV-DAG: {{.*}}|{{ *}}1| f7(); -// COV-DAG: {{.*}}|{{ *}}1|} - -// --- Check coverage for functions in namespace N1. -// COV-DAG: _ZN2N14callEv -// COV-DAG: {{ *}}[[CALL]]|{{ *}}1|void call() { -// COV-DAG: {{.*}}|{{ *}}1| f1(); -// COV-DAG: {{.*}}|{{ *}}1|#ifndef NO_WEAK -// COV-DAG: {{.*}}|{{ *}}1| f2(); -// COV-DAG: {{.*}}|{{ *}}1|#endif -// COV-DAG: {{.*}}|{{ *}}1| f3(); -// COV-DAG: {{.*}}|{{ *}}1|#ifndef NO_EXTERN -// COV-DAG: {{.*}}|{{ *}}1| f4(); -// COV-DAG: {{.*}}|{{ *}}1|#endif -// COV-DAG: {{.*}}|{{ *}}1| f5(); -// COV-DAG: {{.*}}|{{ *}}1| f6(); -// COV-DAG: {{.*}}|{{ *}}1| f7(); -// COV-DAG: {{.*}}|{{ *}}1|} - -// COV-DAG: instrprof-visibility.cpp Index: test/profile/instrprof-without-libc.c =================================================================== --- test/profile/instrprof-without-libc.c +++ test/profile/instrprof-without-libc.c @@ -5,6 +5,10 @@ // RUN: llvm-profdata merge -o %t.profdata %t.profraw // RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s +// This usage of llvm-nm assumes executables have symbol tables. They do not in +// an MSVC environment, so we can't make this test portable. +// UNSUPPORTED: msvc + #include #include Index: test/profile/lit.cfg =================================================================== --- test/profile/lit.cfg +++ test/profile/lit.cfg @@ -67,7 +67,7 @@ config.substitutions.append( ("%clang_lto_profgen=", build_invocation(clang_cflags, True) + " -fprofile-instr-generate=") ) -if config.host_os not in ['Darwin', 'FreeBSD', 'Linux', 'NetBSD', 'SunOS']: +if config.host_os not in ['Windows', 'Darwin', 'FreeBSD', 'Linux', 'NetBSD', 'SunOS']: config.unsupported = True if config.target_arch in ['armv7l']: