[llvm] CodeGen: Move SupportsDefaultOutlining from TargetOptions to TargetMachine (PR #227691)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 05:55:38 PDT 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/227691

This flag is not an option passed down to a target, it is a capability reported
by one. It is only written by backend TargetMachine constructors. Move it into
TargetMachine, along with the vaguely similar O0WantsFastISel.

Co-authored-by: Claude Opus 5 <noreply at anthropic.com>

>From 32f2fd24d9bc1c822cb5120d562807ce8c0ae611 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 30 Sep 2026 14:51:30 +0200
Subject: [PATCH] CodeGen: Move SupportsDefaultOutlining from TargetOptions to
 TargetMachine

This flag is not an option passed down to a target, it is a capability reported
by one. It is only written by backend TargetMachine constructors. Move it into
TargetMachine, along with the vaguely similar O0WantsFastISel.

Co-authored-by: Claude Opus 5 <noreply at anthropic.com>
---
 llvm/include/llvm/Target/TargetMachine.h | 11 ++++++++---
 llvm/include/llvm/Target/TargetOptions.h | 19 ++++++++-----------
 llvm/lib/CodeGen/TargetPassConfig.cpp    |  2 +-
 llvm/lib/Passes/CodeGenPassBuilder.cpp   |  2 +-
 llvm/lib/Target/TargetMachine.cpp        |  3 ++-
 5 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index 7c52c72cc400e..0ae2b945dde80 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -121,6 +121,9 @@ class LLVM_ABI TargetMachine {
   unsigned RequireStructuredCFG : 1;
   unsigned O0WantsFastISel : 1;
 
+  /// Set if the target supports default outlining behaviour.
+  unsigned SupportsDefaultOutlining : 1;
+
   // PGO related tunables.
   std::optional<PGOOptions> PGOOption;
 
@@ -269,6 +272,11 @@ class LLVM_ABI TargetMachine {
   bool requiresStructuredCFG() const { return RequireStructuredCFG; }
   void setRequiresStructuredCFG(bool Value) { RequireStructuredCFG = Value; }
 
+  bool supportsDefaultOutlining() const { return SupportsDefaultOutlining; }
+  void setSupportsDefaultOutlining(bool Enable) {
+    SupportsDefaultOutlining = Enable;
+  }
+
   /// Returns the code generation relocation model. The choices are static, PIC,
   /// and dynamic-no-pic, and target default.
   Reloc::Model getRelocationModel() const;
@@ -316,9 +324,6 @@ class LLVM_ABI TargetMachine {
   void setMachineOutliner(bool Enable) {
     Options.EnableMachineOutliner = Enable;
   }
-  void setSupportsDefaultOutlining(bool Enable) {
-    Options.SupportsDefaultOutlining = Enable;
-  }
   void setSupportsDebugEntryValues(bool Enable) {
     Options.SupportsDebugEntryValues = Enable;
   }
diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
index 7ebc0e0e9ed1e..18c2e9c1746c8 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -114,14 +114,14 @@ class TargetOptions {
         EmulatedTLS(false), EnableTLSDESC(false), EnableIPRA(false),
         EmitStackSizeSection(false), EnableMachineOutliner(false),
         EnableMachineFunctionSplitter(false),
-        EnableStaticDataPartitioning(false), SupportsDefaultOutlining(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) {}
+        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) {}
 
   /// NoZerosInBSS - By default some codegens place zero-initialized data to
   /// .bss section. This flag disables such behaviour (necessary, e.g. for
@@ -215,9 +215,6 @@ class TargetOptions {
   /// Enables the StaticDataSplitter pass.
   unsigned EnableStaticDataPartitioning : 1;
 
-  /// Set if the target supports default outlining behaviour.
-  unsigned SupportsDefaultOutlining : 1;
-
   /// Enable Machine verifier at the end of default codegen pipelines. (Only
   /// used with NPM)
   unsigned EnableDefaultMachineVerifier : 1;
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 07f2450690a8d..d7bb131c97256 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -1254,7 +1254,7 @@ void TargetPassConfig::addMachinePasses() {
       getOptLevel() != CodeGenOptLevel::None &&
       EnableMachineOutliner != RunOutliner::NeverOutline) {
     if (EnableMachineOutliner != RunOutliner::TargetDefault ||
-        TM->Options.SupportsDefaultOutlining)
+        TM->supportsDefaultOutlining())
       addPass(createMachineOutlinerPass(EnableMachineOutliner));
   }
 
diff --git a/llvm/lib/Passes/CodeGenPassBuilder.cpp b/llvm/lib/Passes/CodeGenPassBuilder.cpp
index 58162012daa13..94540050402ba 100644
--- a/llvm/lib/Passes/CodeGenPassBuilder.cpp
+++ b/llvm/lib/Passes/CodeGenPassBuilder.cpp
@@ -711,7 +711,7 @@ Error CodeGenPassBuilder::addMachinePasses(PassManagerWrapper &PMW) {
       getOptLevel() != CodeGenOptLevel::None &&
       Opt.EnableMachineOutliner != RunOutliner::NeverOutline) {
     if (Opt.EnableMachineOutliner != RunOutliner::TargetDefault ||
-        TM.Options.SupportsDefaultOutlining) {
+        TM.supportsDefaultOutlining()) {
       flushFPMsToMPM(PMW);
       addModulePass(MachineOutlinerPass(Opt.EnableMachineOutliner), PMW);
     }
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index abf3afcc6969b..25ae039c48a4e 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -43,7 +43,8 @@ TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString,
     : TheTarget(T), DL(DataLayoutString), TargetTriple(TT),
       TargetCPU(std::string(CPU)), TargetFS(std::string(FS)), AsmInfo(nullptr),
       MRI(nullptr), MII(nullptr), STI(nullptr), RequireStructuredCFG(false),
-      O0WantsFastISel(false), Options(Options) {}
+      O0WantsFastISel(false), SupportsDefaultOutlining(false),
+      Options(Options) {}
 
 TargetMachine::~TargetMachine() = default;
 



More information about the llvm-commits mailing list