Skip to content

[Clang][DLCov][NFCish] Fix debugloc coverage tracking macro in Clang #146521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SLTozer
Copy link
Contributor

@SLTozer SLTozer commented Jul 1, 2025

In a previous commit, the llvm-config-defined macro LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING was renamed to LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE. One instance of this in Clang remains unchanged; this patch renames it, and adds an explicit llvm-config inclusion to ensure the define doesn't silently get removed.

NFC outside of coverage tracking builds, which we do not currently test.

In a previous commit, the llvm-config-defined macro
LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING was renamed to
LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE. One instance of this in Clang
remains unchanged; this patch renames it, and adds an explicit llvm-config
inclusion to ensure it doesn't silently get removed.

NFC outside of coverage tracking builds, which we currently do not have
tests for.
@SLTozer SLTozer requested review from jryans, jmorse, OCHyams and vzakhari July 1, 2025 12:36
@SLTozer SLTozer self-assigned this Jul 1, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. labels Jul 1, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2025

@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Stephen Tozer (SLTozer)

Changes

In a previous commit, the llvm-config-defined macro LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING was renamed to LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE. One instance of this in Clang remains unchanged; this patch renames it, and adds an explicit llvm-config inclusion to ensure the define doesn't silently get removed.

NFC outside of coverage tracking builds, which we do not currently test.


Full diff: https://github.com/llvm/llvm-project/pull/146521.diff

1 Files Affected:

  • (modified) clang/lib/CodeGen/BackendUtil.cpp (+2-1)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 1c92ea45c7458..2f6d4c414e737 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -25,6 +25,7 @@
 #include "llvm/Bitcode/BitcodeWriter.h"
 #include "llvm/Bitcode/BitcodeWriterPass.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
+#include "llvm/Config/llvm-config.h"
 #include "llvm/Frontend/Driver/CodeGenOptions.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfo.h"
@@ -961,7 +962,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
           CodeGenOpts.DIBugsReportFilePath);
     Debugify.registerCallbacks(PIC, MAM);
 
-#if LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING
+#if LLVM_ENABLE_DEBUGLOC_TRACKING_COVERAGE
     // If we're using debug location coverage tracking, mark all the
     // instructions coming out of the frontend without a DebugLoc as being
     // compiler-generated, to prevent both those instructions and new

Copy link
Contributor

@OCHyams OCHyams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain how the include helps in a bit more detail? I don't see what it adds (I'm not very familiar with llvm-config!)

@SLTozer
Copy link
Contributor Author

SLTozer commented Jul 1, 2025

Can you explain how the include helps in a bit more detail? I don't see what it adds (I'm not very familiar with llvm-config!)

It changes nothing now, but llvm-config contains the macro definition used here - adding the include explicitly ensures that we don't silently lose the macro definition if all the headers that were including llvm-config are removed (or have their llvm-config inclusions removed).

Copy link
Contributor

@OCHyams OCHyams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I see, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants