[PATCH] D129000: [PGO] Don't cross reference CSFDO profile and non-CSFDO profile

Rong Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 14:05:42 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a40fa82c072: [PGO] Don't cross reference CSFDO profile and non-CSFDO profile (authored by xur).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129000/new/

https://reviews.llvm.org/D129000

Files:
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/test/Transforms/PGOProfile/Inputs/cs_vs_nocs.proftext
  llvm/test/Transforms/PGOProfile/diag_no_funcprofdata_cs.ll


Index: llvm/test/Transforms/PGOProfile/diag_no_funcprofdata_cs.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/diag_no_funcprofdata_cs.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-profdata merge %S/Inputs/cs_vs_nocs.proftext -o %t.profdata
+; RUN: opt < %s -passes=pgo-instr-use -pgo-warn-missing-function=true -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s
+
+; CHECK: warning: {{.+}}: no profile data available for function bar
+; CHECK-NOT: warning: {{.+}}: function control flow change detected (hash mismatch)
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @bar() {
+entry:
+  ret i32 0
+}
Index: llvm/test/Transforms/PGOProfile/Inputs/cs_vs_nocs.proftext
===================================================================
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/Inputs/cs_vs_nocs.proftext
@@ -0,0 +1,10 @@
+# CSIR level Instrumentation Flag
+:csir
+bar
+# Func Hash:
+1895182923573755903
+# Num Counters:
+1
+# Counter Values:
+100000
+
Index: llvm/lib/ProfileData/InstrProfReader.cpp
===================================================================
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ llvm/lib/ProfileData/InstrProfReader.cpp
@@ -1034,12 +1034,24 @@
   if (Err)
     return std::move(Err);
   // Found it. Look for counters with the right hash.
+
+  // A flag to indicate if the records are from the same type
+  // of profile (i.e cs vs nocs).
+  bool CSBitMatch = false;
+
   for (const NamedInstrProfRecord &I : Data) {
     // Check for a match and fill the vector if there is one.
     if (I.Hash == FuncHash)
       return std::move(I);
+    if (NamedInstrProfRecord::hasCSFlagInHash(I.Hash) ==
+        NamedInstrProfRecord::hasCSFlagInHash(FuncHash)) {
+      CSBitMatch = true;
+    }
+  }
+  if (CSBitMatch) {
+    return error(instrprof_error::hash_mismatch);
   }
-  return error(instrprof_error::hash_mismatch);
+  return error(instrprof_error::unknown_function);
 }
 
 Expected<memprof::MemProfRecord>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129000.445128.patch
Type: text/x-patch
Size: 2129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220715/4a8e48d5/attachment.bin>


More information about the llvm-commits mailing list