[PGO] Don't cross reference CSFDO profile and non-CSFDO profile · llvm/llvm-project@4a40fa8 (original) (raw)
File tree
3 files changed
lines changed
- test/Transforms/PGOProfile
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1034,12 +1034,24 @@ IndexedInstrProfReader::getInstrProfRecord(StringRef FuncName, | ||
1034 | 1034 | if (Err) |
1035 | 1035 | return std::move(Err); |
1036 | 1036 | // Found it. Look for counters with the right hash. |
1037 | + | |
1038 | +// A flag to indicate if the records are from the same type | |
1039 | +// of profile (i.e cs vs nocs). | |
1040 | +bool CSBitMatch = false; | |
1041 | + | |
1037 | 1042 | for (const NamedInstrProfRecord &I : Data) { |
1038 | 1043 | // Check for a match and fill the vector if there is one. |
1039 | 1044 | if (I.Hash == FuncHash) |
1040 | 1045 | return std::move(I); |
1046 | +if (NamedInstrProfRecord::hasCSFlagInHash(I.Hash) == | |
1047 | +NamedInstrProfRecord::hasCSFlagInHash(FuncHash)) { | |
1048 | + CSBitMatch = true; | |
1049 | + } | |
1050 | + } | |
1051 | +if (CSBitMatch) { | |
1052 | +return error(instrprof_error::hash_mismatch); | |
1041 | 1053 | } |
1042 | -return error(instrprof_error::hash_mismatch); | |
1054 | +return error(instrprof_error::unknown_function); | |
1043 | 1055 | } |
1044 | 1056 | |
1045 | 1057 | Expectedmemprof::MemProfRecord |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
1 | +# CSIR level Instrumentation Flag | |
2 | +:csir | |
3 | +bar | |
4 | +# Func Hash: | |
5 | +1895182923573755903 | |
6 | +# Num Counters: | |
7 | +1 | |
8 | +# Counter Values: | |
9 | +100000 | |
10 | + |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
1 | +; RUN: llvm-profdata merge %S/Inputs/cs_vs_nocs.proftext -o %t.profdata | |
2 | +; RUN: opt < %s -passes=pgo-instr-use -pgo-warn-missing-function=true -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s | |
3 | + | |
4 | +; CHECK: warning: {{.+}}: no profile data available for function bar | |
5 | +; CHECK-NOT: warning: {{.+}}: function control flow change detected (hash mismatch) | |
6 | + | |
7 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" | |
8 | +target triple = "x86_64-unknown-linux-gnu" | |
9 | + | |
10 | +define i32 @bar() { | |
11 | +entry: | |
12 | +ret i32 0 | |
13 | +} |