[InstrProf] Allow CSIRPGO function entry coverage
The flag `-fcs-profile-generate` for enabling CSIRPGO moves the pass `pgo-instrumentation` after inlining. Function entry coverage works fine with this change, so remove the assert. I had originally left this assert in because I had not tested this at the time. Reviewed By: davidxl, MaskRay Differential Revision: https://reviews.llvm.org/D129407
This commit is contained in:
parent
e83d47f6b7
commit
3580daacf3
@ -1,6 +1,6 @@
|
||||
RUN: rm -rf %t.d
|
||||
RUN: mkdir -p %t.d
|
||||
RUN: %clang_profgen_gcc=%t.d/d1/d2 -o %t.d/code %S/Inputs/gcc-flag-compatibility.c
|
||||
RUN: %clang_pgogen=%t.d/d1/d2 -o %t.d/code %S/Inputs/gcc-flag-compatibility.c
|
||||
|
||||
# Test that the instrumented code writes to %t.d/d1/d2/
|
||||
RUN: %run %t.d/code
|
||||
@ -12,7 +12,7 @@ RUN: llvm-profdata merge -o %t.profdata %t.d/x1/
|
||||
|
||||
# Test that we can specify a directory with -fprofile-use.
|
||||
RUN: llvm-profdata merge -o %t.d/default.profdata %t.d/x1/
|
||||
RUN: %clang_profuse_gcc=%t.d -o %t.d/code %S/Inputs/gcc-flag-compatibility.c
|
||||
RUN: %clang_pgouse=%t.d -o %t.d/code %S/Inputs/gcc-flag-compatibility.c
|
||||
|
||||
# Test that we can specify a file with -fprofile-use.
|
||||
RUN: %clang_profuse_gcc=%t.profdata -o %t.d/code %S/Inputs/gcc-flag-compatibility.c
|
||||
RUN: %clang_pgouse=%t.profdata -o %t.d/code %S/Inputs/gcc-flag-compatibility.c
|
||||
|
||||
@ -2,15 +2,25 @@
|
||||
// RUN: %clang_pgogen -mllvm -pgo-function-entry-coverage %s -o %t.out
|
||||
// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.out
|
||||
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
|
||||
// RUN: llvm-profdata show --covered %t.profdata | FileCheck %s --check-prefix CHECK --implicit-check-not goo
|
||||
// RUN: llvm-profdata show --covered %t.profdata | FileCheck %s --implicit-check-not goo
|
||||
|
||||
int foo(int i) { return 4 * i + 1; }
|
||||
int bar(int i) { return 4 * i + 2; }
|
||||
int goo(int i) { return 4 * i + 3; }
|
||||
// RUN: %clang_cspgogen -O1 -mllvm -pgo-function-entry-coverage %s -o %t.cs.out
|
||||
// RUN: env LLVM_PROFILE_FILE=%t.csprofraw %run %t.cs.out
|
||||
// RUN: llvm-profdata merge -o %t.csprofdata %t.csprofraw
|
||||
// RUN: llvm-profdata show --covered %t.csprofdata --showcs | FileCheck %s --implicit-check-not goo
|
||||
|
||||
void markUsed(int a) {
|
||||
volatile int g;
|
||||
g = a;
|
||||
}
|
||||
|
||||
__attribute__((noinline)) int foo(int i) { return 4 * i + 1; }
|
||||
__attribute__((noinline)) int bar(int i) { return 4 * i + 2; }
|
||||
__attribute__((noinline)) int goo(int i) { return 4 * i + 3; }
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
foo(5);
|
||||
argc ? bar(6) : goo(7);
|
||||
markUsed(foo(5));
|
||||
markUsed(argc ? bar(6) : goo(7));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -65,22 +65,28 @@ def exclude_unsupported_files_for_aix(dirname):
|
||||
# Add clang substitutions.
|
||||
config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
|
||||
config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
|
||||
|
||||
config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") )
|
||||
config.substitutions.append( ("%clang_profgen=", build_invocation(clang_cflags) + " -fprofile-instr-generate=") )
|
||||
config.substitutions.append( ("%clang_pgogen ", build_invocation(clang_cflags) + " -fprofile-generate ") )
|
||||
config.substitutions.append( ("%clang_pgogen=", build_invocation(clang_cflags) + " -fprofile-generate=") )
|
||||
|
||||
config.substitutions.append( ("%clangxx_profgen ", build_invocation(clang_cxxflags) + " -fprofile-instr-generate ") )
|
||||
config.substitutions.append( ("%clangxx_profgen=", build_invocation(clang_cxxflags) + " -fprofile-instr-generate=") )
|
||||
|
||||
config.substitutions.append( ("%clang_pgogen ", build_invocation(clang_cflags) + " -fprofile-generate ") )
|
||||
config.substitutions.append( ("%clang_pgogen=", build_invocation(clang_cflags) + " -fprofile-generate=") )
|
||||
config.substitutions.append( ("%clangxx_pgogen ", build_invocation(clang_cxxflags) + " -fprofile-generate ") )
|
||||
config.substitutions.append( ("%clangxx_pgogen=", build_invocation(clang_cxxflags) + " -fprofile-generate=") )
|
||||
|
||||
config.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") )
|
||||
config.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") )
|
||||
config.substitutions.append( ("%clang_cspgogen ", build_invocation(clang_cflags) + " -fcs-profile-generate ") )
|
||||
config.substitutions.append( ("%clang_cspgogen=", build_invocation(clang_cflags) + " -fcs-profile-generate=") )
|
||||
config.substitutions.append( ("%clangxx_cspgogen ", build_invocation(clang_cxxflags) + " -fcs-profile-generate ") )
|
||||
config.substitutions.append( ("%clangxx_cspgogen=", build_invocation(clang_cxxflags) + " -fcs-profile-generate=") )
|
||||
|
||||
config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
|
||||
config.substitutions.append( ("%clangxx_profuse=", build_invocation(clang_cxxflags) + " -fprofile-instr-use=") )
|
||||
|
||||
config.substitutions.append( ("%clang_pgouse=", build_invocation(clang_cflags) + " -fprofile-use=") )
|
||||
config.substitutions.append( ("%clangxx_profuse=", build_invocation(clang_cxxflags) + " -fprofile-instr-use=") )
|
||||
|
||||
config.substitutions.append( ("%clang_lto_profgen=", build_invocation(clang_cflags, True) + " -fprofile-instr-generate=") )
|
||||
|
||||
if config.host_os not in ['Windows', 'Darwin', 'FreeBSD', 'Linux', 'NetBSD', 'SunOS', 'AIX']:
|
||||
|
||||
@ -840,8 +840,6 @@ static void instrumentOneFunc(
|
||||
auto CFGHash = ConstantInt::get(Type::getInt64Ty(M->getContext()),
|
||||
FuncInfo.FunctionHash);
|
||||
if (PGOFunctionEntryCoverage) {
|
||||
assert(!IsCS &&
|
||||
"entry coverge does not support context-sensitive instrumentation");
|
||||
auto &EntryBB = F.getEntryBlock();
|
||||
IRBuilder<> Builder(&EntryBB, EntryBB.getFirstInsertionPt());
|
||||
// llvm.instrprof.cover(i8* <name>, i64 <hash>, i32 <num-counters>,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user