[llvm-branch-commits] [llvm] CodeGen: Move SupportsDebugEntryValues from TargetOptions to TargetMachine (PR #227700)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Sep 30 06:12:17 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
This is a capability reported by the target rather than an option to the
target. It has no command line flag or frontend plumbing to write it.
I'm not sure if we really need this; Triple::supportsDebugEntryValues() exists
although these don't entirely agree today.
Co-authored-by: Claude Opus 5 <noreply@<!-- -->anthropic.com>
---
Full diff: https://github.com/llvm/llvm-project/pull/227700.diff
9 Files Affected:
- (modified) llvm/include/llvm/Target/TargetMachine.h (+8-1)
- (modified) llvm/include/llvm/Target/TargetOptions.h (+7-12)
- (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-1)
- (modified) llvm/lib/CodeGen/CMakeLists.txt (-1)
- (modified) llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp (+1-1)
- (removed) llvm/lib/CodeGen/TargetOptionsImpl.cpp (-28)
- (modified) llvm/lib/Passes/CodeGenPassBuilder.cpp (+2-2)
- (modified) llvm/lib/Target/TargetMachine.cpp (+12-1)
- (modified) llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn (-1)
``````````diff
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index 0ae2b945dde801..d535dbedd4681a 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -124,6 +124,9 @@ class LLVM_ABI TargetMachine {
/// Set if the target supports default outlining behaviour.
unsigned SupportsDefaultOutlining : 1;
+ /// Set if the target supports the debug entry values by default.
+ unsigned SupportsDebugEntryValues : 1;
+
// PGO related tunables.
std::optional<PGOOptions> PGOOption;
@@ -277,6 +280,10 @@ class LLVM_ABI TargetMachine {
SupportsDefaultOutlining = Enable;
}
+ /// NOTE: There are targets that still do not support the debug entry values
+ /// production.
+ bool shouldEmitDebugEntryValues() const;
+
/// Returns the code generation relocation model. The choices are static, PIC,
/// and dynamic-no-pic, and target default.
Reloc::Model getRelocationModel() const;
@@ -325,7 +332,7 @@ class LLVM_ABI TargetMachine {
Options.EnableMachineOutliner = Enable;
}
void setSupportsDebugEntryValues(bool Enable) {
- Options.SupportsDebugEntryValues = Enable;
+ SupportsDebugEntryValues = Enable;
}
void setEnableDefaultMachineVerifier(bool Enable) {
Options.EnableDefaultMachineVerifier = Enable;
diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
index 18c2e9c1746c87..6db8eca394a38c 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -116,12 +116,11 @@ class TargetOptions {
EnableMachineFunctionSplitter(false),
EnableStaticDataPartitioning(false), EnableDefaultMachineVerifier(true),
EmitAddrsig(false), BBAddrMap(false), EmitCallGraphSection(false),
- EmitCallSiteInfo(false), SupportsDebugEntryValues(false),
- EnableDebugEntryValues(false), ValueTrackingVariableLocations(false),
- ForceDwarfFrameSection(false), XRayFunctionIndex(true),
- DebugStrictDwarf(false), Hotpatch(false), JMCInstrument(false),
- EnableCFIFixup(false), MisExpect(false), XCOFFReadOnlyPointers(false),
- VerifyArgABICompliance(true) {}
+ EmitCallSiteInfo(false), EnableDebugEntryValues(false),
+ ValueTrackingVariableLocations(false), ForceDwarfFrameSection(false),
+ XRayFunctionIndex(true), DebugStrictDwarf(false), Hotpatch(false),
+ JMCInstrument(false), EnableCFIFixup(false), MisExpect(false),
+ XCOFFReadOnlyPointers(false), VerifyArgABICompliance(true) {}
/// NoZerosInBSS - By default some codegens place zero-initialized data to
/// .bss section. This flag disables such behaviour (necessary, e.g. for
@@ -240,16 +239,12 @@ class TargetOptions {
/// info, and it is restricted only to optimized code. This can be used for
/// something else, so that should be controlled in the frontend.
unsigned EmitCallSiteInfo : 1;
- /// Set if the target supports the debug entry values by default.
- unsigned SupportsDebugEntryValues : 1;
/// When set to true, the EnableDebugEntryValues option forces production
/// of debug entry values even if the target does not officially support
/// it. Useful for testing purposes only. This flag should never be checked
- /// directly, always use \ref ShouldEmitDebugEntryValues instead.
+ /// directly, always use \ref TargetMachine::shouldEmitDebugEntryValues
+ /// instead.
unsigned EnableDebugEntryValues : 1;
- /// NOTE: There are targets that still do not support the debug entry values
- /// production.
- LLVM_ABI bool ShouldEmitDebugEntryValues() const;
// When set to true, use experimental new debug variable location tracking,
// which seeks to follow the values of variables rather than their location,
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index b5828314590a57..ffa7f29c550f43 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -423,7 +423,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A)
// Emit call-site-param debug info for GDB and LLDB, if the target supports
// the debug entry values feature. It can also be enabled explicitly.
- EmitDebugEntryValues = Asm->TM.Options.ShouldEmitDebugEntryValues();
+ EmitDebugEntryValues = Asm->TM.shouldEmitDebugEntryValues();
// It is unclear if the GCC .debug_macro extension is well-specified
// for split DWARF. For now, do not allow LLVM to emit it.
diff --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt
index 99dfb4bb09df73..7db7c1ca932437 100644
--- a/llvm/lib/CodeGen/CMakeLists.txt
+++ b/llvm/lib/CodeGen/CMakeLists.txt
@@ -253,7 +253,6 @@ add_llvm_component_library(LLVMCodeGen
TargetInstrInfo.cpp
TargetLoweringBase.cpp
TargetLoweringObjectFileImpl.cpp
- TargetOptionsImpl.cpp
TargetPassConfig.cpp
TargetRegisterInfo.cpp
TargetSchedule.cpp
diff --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
index 8047e46e6456eb..7a9ca8a031fa8e 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
@@ -128,7 +128,7 @@ void LiveDebugValuesPass::printPipeline(
bool LiveDebugValuesLegacy::runOnMachineFunction(MachineFunction &MF) {
auto *TPC = &getAnalysis<TargetPassConfig>();
return LiveDebugValues().run(
- MF, TPC->getTM<TargetMachine>().Options.ShouldEmitDebugEntryValues());
+ MF, TPC->getTM<TargetMachine>().shouldEmitDebugEntryValues());
}
bool LiveDebugValues::run(MachineFunction &MF,
diff --git a/llvm/lib/CodeGen/TargetOptionsImpl.cpp b/llvm/lib/CodeGen/TargetOptionsImpl.cpp
deleted file mode 100644
index 2d06dd3b43c583..00000000000000
--- a/llvm/lib/CodeGen/TargetOptionsImpl.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-//===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the methods in the TargetOptions.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/CodeGen/MachineFrameInfo.h"
-#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/TargetFrameLowering.h"
-#include "llvm/CodeGen/TargetSubtargetInfo.h"
-#include "llvm/Target/TargetOptions.h"
-using namespace llvm;
-
-/// NOTE: There are targets that still do not support the debug entry values
-/// production and that is being controlled with the SupportsDebugEntryValues.
-/// In addition, SCE debugger does not have the feature implemented, so prefer
-/// not to emit the debug entry values in that case.
-/// The EnableDebugEntryValues can be used for the testing purposes.
-bool TargetOptions::ShouldEmitDebugEntryValues() const {
- return (SupportsDebugEntryValues && DebuggerTuning != DebuggerKind::SCE) ||
- EnableDebugEntryValues;
-}
diff --git a/llvm/lib/Passes/CodeGenPassBuilder.cpp b/llvm/lib/Passes/CodeGenPassBuilder.cpp
index 94540050402baf..d5418c54b6ac48 100644
--- a/llvm/lib/Passes/CodeGenPassBuilder.cpp
+++ b/llvm/lib/Passes/CodeGenPassBuilder.cpp
@@ -703,8 +703,8 @@ Error CodeGenPassBuilder::addMachinePasses(PassManagerWrapper &PMW) {
addMachineFunctionPass(RemoveLoadsIntoFakeUsesPass(), PMW);
addMachineFunctionPass(StackMapLivenessPass(), PMW);
- addMachineFunctionPass(
- LiveDebugValuesPass(TM.Options.ShouldEmitDebugEntryValues()), PMW);
+ addMachineFunctionPass(LiveDebugValuesPass(TM.shouldEmitDebugEntryValues()),
+ PMW);
addMachineFunctionPass(MachineSanitizerBinaryMetadataPass(), PMW);
if (TM.Options.EnableMachineOutliner &&
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 25ae039c48a4e7..009ae0bc11d89a 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -44,10 +44,21 @@ TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString,
TargetCPU(std::string(CPU)), TargetFS(std::string(FS)), AsmInfo(nullptr),
MRI(nullptr), MII(nullptr), STI(nullptr), RequireStructuredCFG(false),
O0WantsFastISel(false), SupportsDefaultOutlining(false),
- Options(Options) {}
+ SupportsDebugEntryValues(false), Options(Options) {}
TargetMachine::~TargetMachine() = default;
+/// NOTE: There are targets that still do not support the debug entry values
+/// production and that is being controlled with the SupportsDebugEntryValues.
+/// In addition, SCE debugger does not have the feature implemented, so prefer
+/// not to emit the debug entry values in that case.
+/// The EnableDebugEntryValues can be used for the testing purposes.
+bool TargetMachine::shouldEmitDebugEntryValues() const {
+ return (SupportsDebugEntryValues &&
+ Options.DebuggerTuning != DebuggerKind::SCE) ||
+ Options.EnableDebugEntryValues;
+}
+
Expected<std::unique_ptr<MCStreamer>>
TargetMachine::createMCStreamer(raw_pwrite_stream &Out,
raw_pwrite_stream *DwoOut,
diff --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
index 72c1c0ff844678..cc1463cbe9e3ae 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
@@ -244,7 +244,6 @@ static_library("CodeGen") {
"TargetInstrInfo.cpp",
"TargetLoweringBase.cpp",
"TargetLoweringObjectFileImpl.cpp",
- "TargetOptionsImpl.cpp",
"TargetPassConfig.cpp",
"TargetRegisterInfo.cpp",
"TargetSchedule.cpp",
``````````
</details>
https://github.com/llvm/llvm-project/pull/227700
More information about the llvm-branch-commits
mailing list