llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Fangrui Song (MaskRay)

<details>
<summary>Changes</summary>

Renames, with the old spellings kept as aliases:

```
-enable-single-byte-coverage  -&gt; -single-byte-coverage
-enable-value-profiling       -&gt; -value-profiling
```

LLM-aided

---

Patch is 34.47 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/246727.diff


15 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (+21-40) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+2-10) 
- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+2-5) 
- (modified) clang/lib/CodeGen/CMakeLists.txt (+7) 
- (modified) clang/lib/CodeGen/CodeGenAction.cpp (+2-1) 
- (added) clang/lib/CodeGen/CodeGenCLOptions.cpp (+21) 
- (added) clang/lib/CodeGen/CodeGenCLOptions.h (+25) 
- (added) clang/lib/CodeGen/CodeGenCLOptions.td (+51) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+6-8) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+3) 
- (modified) clang/lib/CodeGen/CodeGenPGO.cpp (+7-16) 
- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+19-35) 
- (modified) clang/lib/CodeGen/CoverageMappingGen.h (+8-7) 
- (modified) llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn (+10) 
- (modified) utils/bazel/llvm-project-overlay/clang/BUILD.bazel (+11) 


``````````diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 0ef49e16ca6072..d86c52432b42eb 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/CodeGen/BackendUtil.h"
 #include "BackendConsumer.h"
+#include "CodeGenCLOptions.h"
 #include "LinkInModulesPass.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/Diagnostic.h"
@@ -119,31 +120,6 @@ using namespace llvm;
   llvm::PassPluginLibraryInfo get##Ext##PluginInfo();
 #include "llvm/Support/Extension.def"
 
-namespace llvm {
-// Experiment to move sanitizers earlier.
-static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
-    "sanitizer-early-opt-ep",
-    cl::desc("Insert sanitizers on OptimizerEarlyEP."));
-
-// Experiment to mark cold functions as optsize/minsize/optnone.
-// TODO: remove once this is exposed as a proper driver flag.
-static cl::opt<PGOOptions::ColdFuncOpt> ClPGOColdFuncAttr(
-    "pgo-cold-func-opt", cl::init(PGOOptions::ColdFuncOpt::Default), 
cl::Hidden,
-    cl::desc(
-        "Function attribute to apply to cold functions as determined by PGO"),
-    cl::values(clEnumValN(PGOOptions::ColdFuncOpt::Default, "default",
-                          "Default (no attribute)"),
-               clEnumValN(PGOOptions::ColdFuncOpt::OptSize, "optsize",
-                          "Mark cold functions with optsize."),
-               clEnumValN(PGOOptions::ColdFuncOpt::MinSize, "minsize",
-                          "Mark cold functions with minsize."),
-               clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
-                          "Mark cold functions with optnone.")));
-} // namespace llvm
-namespace clang {
-extern llvm::cl::opt<bool> ClSanitizeGuardChecks;
-}
-
 // Path and name of file used for profile generation
 static std::string
 getProfileGenName(const cl::LibraryOptionsContext &LibraryOptions,
@@ -655,7 +631,8 @@ static void addKCFIPass(const Triple &TargetTriple, const 
LangOptions &LangOpts,
       });
 }
 
-static void addSanitizers(const Triple &TargetTriple,
+static void addSanitizers(const CodeGen::CodeGenCLOptions &CLOpts,
+                          const Triple &TargetTriple,
                           const CodeGenOptions &CodeGenOpts,
                           const LangOptions &LangOpts, PassBuilder &PB) {
   auto SanitizersCallback = [&](ModulePassManager &MPM, OptimizationLevel 
Level,
@@ -756,7 +733,7 @@ static void addSanitizers(const Triple &TargetTriple,
                                         PB.getVirtualFileSystemPtr()));
     }
   };
-  if (ClSanitizeOnOptimizerEarlyEP) {
+  if (CLOpts.sanitizer_early_opt_ep) {
     PB.registerOptimizerEarlyEPCallback(
         [SanitizersCallback](ModulePassManager &MPM, OptimizationLevel Level,
                              ThinOrFullLTOPhase Phase) {
@@ -848,13 +825,15 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
     std::unique_ptr<llvm::ToolOutputFile> &ThinLinkOS, BackendConsumer *BC) {
   const cl::LibraryOptionsContext &LibraryOptions =
       TheModule->getContext().getLibraryOptions();
+  const CodeGen::CodeGenCLOptions &CLOpts =
+      CodeGen::getCodeGenCLOptions(TheModule->getContext());
   std::optional<PGOOptions> PGOOpt;
 
   if (CodeGenOpts.hasProfileIRInstr())
     // -fprofile-generate.
     PGOOpt = PGOOptions(getProfileGenName(LibraryOptions, CodeGenOpts), "", "",
                         CodeGenOpts.MemoryProfileUsePath, PGOOptions::IRInstr,
-                        PGOOptions::NoCSAction, ClPGOColdFuncAttr,
+                        PGOOptions::NoCSAction, CLOpts.pgo_cold_func_opt,
                         CodeGenOpts.DebugInfoForProfiling,
                         /*PseudoProbeForProfiling=*/false,
                         CodeGenOpts.AtomicProfileUpdate);
@@ -865,29 +844,30 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
     PGOOpt = PGOOptions(CodeGenOpts.ProfileInstrumentUsePath, "",
                         CodeGenOpts.ProfileRemappingFile,
                         CodeGenOpts.MemoryProfileUsePath, PGOOptions::IRUse,
-                        CSAction, ClPGOColdFuncAttr,
+                        CSAction, CLOpts.pgo_cold_func_opt,
                         CodeGenOpts.DebugInfoForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
     // -fprofile-sample-use
     PGOOpt = PGOOptions(
         CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
         CodeGenOpts.MemoryProfileUsePath, PGOOptions::SampleUse,
-        PGOOptions::NoCSAction, ClPGOColdFuncAttr,
+        PGOOptions::NoCSAction, CLOpts.pgo_cold_func_opt,
         CodeGenOpts.DebugInfoForProfiling, 
CodeGenOpts.PseudoProbeForProfiling);
   else if (!CodeGenOpts.MemoryProfileUsePath.empty())
     // -fmemory-profile-use (without any of the above options)
-    PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath,
-                        PGOOptions::NoAction, PGOOptions::NoCSAction,
-                        ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
+    PGOOpt =
+        PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath,
+                   PGOOptions::NoAction, PGOOptions::NoCSAction,
+                   CLOpts.pgo_cold_func_opt, 
CodeGenOpts.DebugInfoForProfiling);
   else if (CodeGenOpts.PseudoProbeForProfiling)
     // -fpseudo-probe-for-profiling
     PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", PGOOptions::NoAction,
-                        PGOOptions::NoCSAction, ClPGOColdFuncAttr,
+                        PGOOptions::NoCSAction, CLOpts.pgo_cold_func_opt,
                         CodeGenOpts.DebugInfoForProfiling, true);
   else if (CodeGenOpts.DebugInfoForProfiling)
     // -fdebug-info-for-profiling
     PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", PGOOptions::NoAction,
-                        PGOOptions::NoCSAction, ClPGOColdFuncAttr, true);
+                        PGOOptions::NoCSAction, CLOpts.pgo_cold_func_opt, 
true);
 
   // Check to see if we want to generate a CS profile.
   if (CodeGenOpts.hasProfileCSIRInstr()) {
@@ -905,7 +885,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
       PGOOpt = PGOOptions(
           "", getProfileGenName(LibraryOptions, CodeGenOpts), "",
           /*MemoryProfile=*/"", PGOOptions::NoAction, PGOOptions::CSIRInstr,
-          ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
+          CLOpts.pgo_cold_func_opt, CodeGenOpts.DebugInfoForProfiling);
   }
   if (TM)
     TM->setPGOOption(PGOOpt);
@@ -1061,11 +1041,12 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
     // Register callbacks to schedule sanitizer passes at the appropriate part
     // of the pipeline.
     if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
-      PB.registerScalarOptimizerLateEPCallback([this](FunctionPassManager &FPM,
-                                                      OptimizationLevel Level) 
{
+      PB.registerScalarOptimizerLateEPCallback([this, &CLOpts](
+                                                   FunctionPassManager &FPM,
+                                                   OptimizationLevel Level) {
         BoundsCheckingPass::Options Options;
         if (CodeGenOpts.SanitizeSkipHotCutoffs[SanitizerKind::SO_LocalBounds] 
||
-            ClSanitizeGuardChecks) {
+            CLOpts.ubsan_guard_checks) {
           static_assert(SanitizerKind::SO_LocalBounds <=
                             std::numeric_limits<
                                 
decltype(Options.GuardKind)::value_type>::max(),
@@ -1090,7 +1071,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 
     if (!IsThinLTOPostLink) {
       // Most sanitizers only run during PreLink stage.
-      addSanitizers(TargetTriple, CodeGenOpts, LangOpts, PB);
+      addSanitizers(CLOpts, TargetTriple, CodeGenOpts, LangOpts, PB);
       addKCFIPass(TargetTriple, LangOpts, PB);
       addLowerAllowCheckPass(LibraryOptions, CodeGenOpts, LangOpts, PB);
 
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 4a0a043a00b266..64419f5d62519f 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -20,6 +20,7 @@
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
 #include "CGRecordLayout.h"
+#include "CodeGenCLOptions.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "CodeGenPGO.h"
@@ -67,15 +68,6 @@
 using namespace clang;
 using namespace CodeGen;
 
-namespace clang {
-// TODO: consider deprecating ClSanitizeGuardChecks; functionality is subsumed
-//       by -fsanitize-skip-hot-cutoff
-llvm::cl::opt<bool> ClSanitizeGuardChecks(
-    "ubsan-guard-checks",
-    llvm::cl::desc("Guard UBSAN checks with `llvm.allow.ubsan.check()`."));
-
-} // namespace clang
-
 //===--------------------------------------------------------------------===//
 //                        Defines for metadata
 //===--------------------------------------------------------------------===//
@@ -4352,7 +4344,7 @@ void CodeGenFunction::EmitCheck(
   // LowerAllowCheckPass.
   for (auto &[Check, Ord] : Checked) {
     llvm::Value *GuardedCheck = Check;
-    if (ClSanitizeGuardChecks ||
+    if (CGM.getCLOpts().ubsan_guard_checks ||
         (CGM.getCodeGenOpts().SanitizeSkipHotCutoffs[Ord] > 0)) {
       llvm::Value *Allow = Builder.CreateCall(
           CGM.getIntrinsic(llvm::Intrinsic::allow_ubsan_check),
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 768e01deb9ceb3..4ced42154b6a28 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -17,6 +17,7 @@
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
 #include "CGRecordLayout.h"
+#include "CodeGenCLOptions.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
@@ -64,10 +65,6 @@ using llvm::Value;
 //                         Scalar Expression Emitter
 
//===----------------------------------------------------------------------===//
 
-namespace llvm {
-extern cl::opt<bool> EnableSingleByteCoverage;
-} // namespace llvm
-
 namespace {
 
 /// Determine whether the given binary operation may overflow.
@@ -6015,7 +6012,7 @@ VisitAbstractConditionalOperator(const 
AbstractConditionalOperator *E) {
   // If this is a really simple expression (like x ? 4 : 5), emit this as a
   // select instead of as control flow.  We can only do this if it is cheap and
   // safe to evaluate the LHS and RHS unconditionally.
-  if (!llvm::EnableSingleByteCoverage &&
+  if (!CGF.CGM.getCLOpts().single_byte_coverage &&
       CodeGenUtils::isCheapEnoughToEvaluateUnconditionally(lhsExpr,
                                                            CGF.getContext()) &&
       CodeGenUtils::isCheapEnoughToEvaluateUnconditionally(rhsExpr,
diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt
index 93790567dcf8bb..1ac56d0ad1b83d 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -26,6 +26,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   ObjCARCOpts
   Object
+  Option
   Passes
   Plugins
   ProfileData
@@ -57,6 +58,10 @@ if(MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES Clang
   endif()
 endif()
 
+set(LLVM_TARGET_DEFINITIONS CodeGenCLOptions.td)
+llvm_tablegen(CodeGenCLOptions.inc -gen-opt-parser-defs)
+add_public_tablegen_target(CodeGenCLOptionsTableGen)
+
 add_clang_library(clangCodeGen
   ABIInfo.cpp
   ABIInfoImpl.cpp
@@ -102,6 +107,7 @@ add_clang_library(clangCodeGen
   CGVTables.cpp
   CodeGenABITypes.cpp
   CodeGenAction.cpp
+  CodeGenCLOptions.cpp
   CodeGenFunction.cpp
   CodeGenModule.cpp
   CodeGenPGO.cpp
@@ -169,6 +175,7 @@ add_clang_library(clangCodeGen
   [["pch.h"]]
 
   DEPENDS
+  CodeGenCLOptionsTableGen
   vt_gen
   intrinsics_gen
   ClangDriverOptions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index dd7ba0b741c857..91f8b666fb83d7 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -10,6 +10,7 @@
 #include "BackendConsumer.h"
 #include "CGCall.h"
 #include "CGDebugInfo.h"
+#include "CodeGenCLOptions.h"
 #include "CodeGenModule.h"
 #include "CoverageMappingGen.h"
 #include "MacroPPCallbacks.h"
@@ -391,7 +392,7 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, 
StringRef InFile) {
   // Add the preprocessor callback only when the coverage mapping is generated.
   if (CI.getCodeGenOpts().CoverageMapping)
     CoverageInfo = CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks(
-        CI.getPreprocessor());
+        CodeGen::getCodeGenCLOptions(*VMContext), CI.getPreprocessor());
 
   std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
       CI, BA, CI.getVirtualFileSystemPtr(), *VMContext, std::move(LinkModules),
diff --git a/clang/lib/CodeGen/CodeGenCLOptions.cpp 
b/clang/lib/CodeGen/CodeGenCLOptions.cpp
new file mode 100644
index 00000000000000..a41f7a4364baa4
--- /dev/null
+++ b/clang/lib/CodeGen/CodeGenCLOptions.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "CodeGenCLOptions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/Option/LibraryOptions.h"
+
+#define OPTIONS_STRUCT_DEFS
+#include "CodeGenCLOptions.inc"
+
+LLVM_REGISTER_LIBRARY_OPTIONS(clang::CodeGen::CodeGenCLOptions)
+
+const clang::CodeGen::CodeGenCLOptions &
+clang::CodeGen::getCodeGenCLOptions(const llvm::LLVMContext &Ctx) {
+  return Ctx.getLibraryOptions().get<CodeGenCLOptions>();
+}
diff --git a/clang/lib/CodeGen/CodeGenCLOptions.h 
b/clang/lib/CodeGen/CodeGenCLOptions.h
new file mode 100644
index 00000000000000..afb64ed9a92d3d
--- /dev/null
+++ b/clang/lib/CodeGen/CodeGenCLOptions.h
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENCLOPTIONS_H
+#define LLVM_CLANG_LIB_CODEGEN_CODEGENCLOPTIONS_H
+
+#include "llvm/Support/PGOOptions.h"
+
+#define OPTIONS_STRUCT_DECL
+#include "CodeGenCLOptions.inc"
+
+namespace llvm {
+class LLVMContext;
+} // namespace llvm
+
+namespace clang::CodeGen {
+const CodeGenCLOptions &getCodeGenCLOptions(const llvm::LLVMContext &Ctx);
+} // namespace clang::CodeGen
+
+#endif // LLVM_CLANG_LIB_CODEGEN_CODEGENCLOPTIONS_H
diff --git a/clang/lib/CodeGen/CodeGenCLOptions.td 
b/clang/lib/CodeGen/CodeGenCLOptions.td
new file mode 100644
index 00000000000000..775a7799c32ba3
--- /dev/null
+++ b/clang/lib/CodeGen/CodeGenCLOptions.td
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+include "llvm/Option/LibraryOptions.td"
+
+def CodeGenCLOptions : OptionsStruct<"clang::CodeGen">;
+
+// BackendUtil.cpp
+// Experiment to mark cold functions as optsize/minsize/optnone.
+// TODO: remove once this is exposed as a proper driver flag.
+defm : EnumField<"pgo-cold-func-opt", "llvm::PGOOptions::ColdFuncOpt",
+  "llvm::PGOOptions::ColdFuncOpt::Default", "default,optsize,minsize,optnone",
+  ["llvm::PGOOptions::ColdFuncOpt::Default",
+   "llvm::PGOOptions::ColdFuncOpt::OptSize",
+   "llvm::PGOOptions::ColdFuncOpt::MinSize",
+   "llvm::PGOOptions::ColdFuncOpt::OptNone"],
+  "Function attribute to apply to cold functions as determined by PGO">;
+// Experiment to move sanitizers earlier.
+defm : BoolField<"sanitizer-early-opt-ep", "false",
+  "Insert sanitizers on OptimizerEarlyEP">;
+
+// CGExpr.cpp
+// TODO: consider deprecating ubsan-guard-checks; functionality is subsumed by
+// -fsanitize-skip-hot-cutoff
+defm : BoolField<"ubsan-guard-checks", "false",
+  "Guard UBSAN checks with `llvm.allow.ubsan.check()`">;
+
+// CodeGenModule.cpp
+defm : BoolField<"limited-coverage-experimental", "false",
+  "Emit limited coverage mapping information (experimental)">;
+
+// CodeGenPGO.cpp
+defm : BoolField<"value-profiling", "false",
+  "Enable value profiling">;
+// TODO: Remove the old spelling after 2027-05.
+def : AliasOf<"enable-value-profiling", "value-profiling">;
+
+// CoverageMappingGen.cpp
+defm : BoolField<"emptyline-comment-coverage", "true",
+  "Emit emptylines and comment lines as skipped regions (only disable it on 
test)">;
+defm : BoolField<"single-byte-coverage", "false",
+  "Enable single byte coverage">;
+defm : BoolField<"system-headers-coverage", "false",
+  "Enable collecting coverage from system headers">;
+// TODO: Remove the old spelling after 2027-05.
+def : AliasOf<"enable-single-byte-coverage", "single-byte-coverage">;
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 390ca6dbba4616..d4363862722adc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -22,6 +22,7 @@
 #include "CGOpenCLRuntime.h"
 #include "CGOpenMPRuntime.h"
 #include "CGOpenMPRuntimeGPU.h"
+#include "CodeGenCLOptions.h"
 #include "CodeGenFunction.h"
 #include "CodeGenPGO.h"
 #include "ConstantEmitter.h"
@@ -72,7 +73,6 @@
 #include "llvm/Support/ARMBuildAttributes.h"
 #include "llvm/Support/CRC.h"
 #include "llvm/Support/CodeGen.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/TimeProfiler.h"
@@ -91,10 +91,6 @@
 using namespace clang;
 using namespace CodeGen;
 
-static llvm::cl::opt<bool> LimitedCoverage(
-    "limited-coverage-experimental", llvm::cl::Hidden,
-    llvm::cl::desc("Emit limited coverage mapping information 
(experimental)"));
-
 static const char AnnotationSection[] = "llvm.metadata";
 static constexpr auto ErrnoTBAAMDName = "llvm.errno.tbaa";
 
@@ -603,7 +599,8 @@ CodeGenModule::CodeGenModule(ASTContext &C,
                              const CodeGenOptions &CGO, llvm::Module &M,
                              DiagnosticsEngine &diags,
                              CoverageSourceInfo *CoverageInfo)
-    : Context(C), LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
+    : CLOpts(getCodeGenCLOptions(M.getContext())), Context(C),
+      LangOpts(C.getLangOpts()), FS(FS), HeaderSearchOpts(HSO),
       PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
       Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
       VMContext(M.getContext()), VTables(*this), StackHandler(diags),
@@ -8441,9 +8438,10 @@ void 
CodeGenModule::AddDeferredUnusedCoverageMapping(Decl *D) {
     if (!cast<FunctionDecl>(D)->doesThisDeclarationHaveABody())
       break;
     SourceManager &SM = getContext().getSourceManager();
-    if (LimitedCoverage && SM.getMainFileID() != 
SM.getFileID(D->getBeginLoc()))
+    if (CLOpts.limited_coverage_experimental &&
+        SM.getMainFileID() != SM.getFileID(D->getBeginLoc()))
       break;
-    if (!llvm::coverage::SystemHeadersCoverage &&
+    if (!CLOpts.system_headers_coverage &&
         SM.isInSystemHeader(D->getBeginLoc()))
       break;
     DeferredEmptyCoverageMappingDecls.try_emplace(D, true);
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index c6b13f58817843..d110c454af87ad 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -101,6 +101,7 @@ class CGOpenMPRuntime;
 class CGCUDARuntime;
 class CGHLSLRuntime;
 class CGFunctionInfo;
+struct CodeGenCLOptions;
 class CoverageMappingModuleGen;
 class QualTypeMapper;
 class TargetCodeGenInfo;
@@ -352,6 +353,7 @@ class CodeGenModule : public CodeGenTypeCache {
   typedef std::vector<Structor> CtorList;
 
 private:
+  const CodeGenCLOptions &CLOpts;
   ASTContext &Context;
   const LangOptions &LangOpts;
   IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS; // Only used for debug info.
@@ -908,6 +910,7 @@ class Cod...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/246727
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to