[PATCH] D126586: [InstrProf] Single byte counters in coverage

Zequan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 28 11:34:16 PDT 2023


zequanwu added inline comments.


================
Comment at: clang/lib/CodeGen/CGExprScalar.cpp:4812
+        } else
+          CGF.incrementProfileCounter(E);
+      }
----------------
This can be hoist outside `if (llvm::EnableSingleByteCoverage)`


================
Comment at: clang/lib/CodeGen/CodeGenPGO.cpp:1080-1081
+void CodeGenPGO::setProfileVersion(llvm::Module &M) {
+  if (CGM.getCodeGenOpts().hasProfileClangInstr() &&
+      llvm::EnableSingleByteCoverage) {
+    const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR));
----------------
I thinkit's better to emit the profile version global variable in `CoverageMappingModuleGen::emit` so this check `CGM.getCodeGenOpts().hasProfileClangInstr()` is not necessary. 

Also we should always emit the profile version global variable so that the runtime/backend knows if single byte coverage is enabled or not by looking at the version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126586



More information about the cfe-commits mailing list