diff options
| author | Justin Bogner <mail@justinbogner.com> | 2014-08-01 22:50:16 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2014-08-01 22:50:16 +0000 |
| commit | 9c6818ef00da5c59c0762fea85bd936e0fc31327 (patch) | |
| tree | c988497e08b952a52a934ab5c1892ba9f4ed2d27 | |
| parent | 821d7471f91858ce91de86df940cedfab4166543 (diff) | |
| download | bcm5719-llvm-9c6818ef00da5c59c0762fea85bd936e0fc31327.tar.gz bcm5719-llvm-9c6818ef00da5c59c0762fea85bd936e0fc31327.zip | |
InstrProf: Update for LLVM API change
We've added support for a multiple functions with the same name in
LLVM's profile data, so the lookup returning the function hash it
found doesn't make sense anymore. Update to pass in the hash we
expect.
This also adds a test that the version 1 format is still readable,
since the new API is expected to handle that.
llvm-svn: 214586
| -rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.cpp | 16 | ||||
| -rw-r--r-- | clang/test/Profile/Inputs/c-general.profdata.v1 | bin | 0 -> 2000 bytes | |||
| -rw-r--r-- | clang/test/Profile/c-general.c | 3 |
3 files changed, 12 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index b233e3c7d75..4def789132a 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -917,13 +917,15 @@ void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader, bool IsInMainFile) { CGM.getPGOStats().addVisited(IsInMainFile); RegionCounts.reset(new std::vector<uint64_t>); - uint64_t Hash; - if (PGOReader->getFunctionCounts(getFuncName(), Hash, *RegionCounts)) { - CGM.getPGOStats().addMissing(IsInMainFile); - RegionCounts.reset(); - } else if (Hash != FunctionHash || - RegionCounts->size() != NumRegionCounters) { - CGM.getPGOStats().addMismatched(IsInMainFile); + if (std::error_code EC = PGOReader->getFunctionCounts( + getFuncName(), FunctionHash, *RegionCounts)) { + if (EC == llvm::instrprof_error::unknown_function) + CGM.getPGOStats().addMissing(IsInMainFile); + else if (EC == llvm::instrprof_error::hash_mismatch) + CGM.getPGOStats().addMismatched(IsInMainFile); + else if (EC == llvm::instrprof_error::malformed) + // TODO: Consider a more specific warning for this case. + CGM.getPGOStats().addMismatched(IsInMainFile); RegionCounts.reset(); } } diff --git a/clang/test/Profile/Inputs/c-general.profdata.v1 b/clang/test/Profile/Inputs/c-general.profdata.v1 Binary files differnew file mode 100644 index 00000000000..e7dedcbf97f --- /dev/null +++ b/clang/test/Profile/Inputs/c-general.profdata.v1 diff --git a/clang/test/Profile/c-general.c b/clang/test/Profile/c-general.c index 442fdd336c7..79707ad2f5b 100644 --- a/clang/test/Profile/c-general.c +++ b/clang/test/Profile/c-general.c @@ -5,6 +5,9 @@ // 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 +// Also check compatibility with older profiles. +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instr-use=%S/Inputs/c-general.profdata.v1 | FileCheck -check-prefix=PGOUSE %s + // PGOGEN: @[[SLC:__llvm_profile_counters_simple_loops]] = hidden global [4 x i64] zeroinitializer // PGOGEN: @[[IFC:__llvm_profile_counters_conditionals]] = hidden global [11 x i64] zeroinitializer // PGOGEN: @[[EEC:__llvm_profile_counters_early_exits]] = hidden global [9 x i64] zeroinitializer |

