[clang] [llvm] [Support] Move OptimizationLevel to the Support directory (PR #157057)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 5 02:13:52 PDT 2025
https://github.com/david-arm created https://github.com/llvm/llvm-project/pull/157057
Sometimes code depends upon the constant variables declared in OptimizationLevel (e.g. see #156802), which then requires them to add a dependency on the Passes directory. Given that code is much more likely to depend upon Support than Passes I believe it makes sense to move OptimizationLevel to Support. The Passes component already depends upon Support.
>From a28f0fc701704f7e5e3e5194e256d455316d8304 Mon Sep 17 00:00:00 2001
From: David Sherwood <david.sherwood at arm.com>
Date: Fri, 5 Sep 2025 09:10:47 +0000
Subject: [PATCH] [Support] Move OptimizationLevel to the Support directory
Sometimes code depends upon the constant variables declared
in OptimizationLevel (e.g. see #156802), which then requires
them to add a dependency on the Passes directory. Given that
code is much more likely to depend upon Support than Passes
I believe it makes sense to move OptimizationLevel to
Support. The Passes component already depends upon Support.
---
clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp | 2 +-
llvm/include/llvm/Passes/PassBuilder.h | 2 +-
llvm/include/llvm/{Passes => Support}/OptimizationLevel.h | 0
llvm/lib/Passes/CMakeLists.txt | 1 -
llvm/lib/Passes/PassBuilder.cpp | 2 +-
llvm/lib/Passes/PassBuilderPipelines.cpp | 4 ++--
llvm/lib/Support/CMakeLists.txt | 1 +
llvm/lib/{Passes => Support}/OptimizationLevel.cpp | 2 +-
8 files changed, 7 insertions(+), 7 deletions(-)
rename llvm/include/llvm/{Passes => Support}/OptimizationLevel.h (100%)
rename llvm/lib/{Passes => Support}/OptimizationLevel.cpp (95%)
diff --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
index 798b34b3ef0af..edaf0fa887720 100644
--- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -34,9 +34,9 @@
#include "llvm/IRPrinter/IRPrintingPasses.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/MC/TargetRegistry.h"
-#include "llvm/Passes/OptimizationLevel.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/OptimizationLevel.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetMachine.h"
diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h
index 9cdb7ca7dbc9b..64bdb84a68d78 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -19,9 +19,9 @@
#include "llvm/CodeGen/MachinePassManager.h"
#include "llvm/CodeGen/RegAllocCommon.h"
#include "llvm/IR/PassManager.h"
-#include "llvm/Passes/OptimizationLevel.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/OptimizationLevel.h"
#include "llvm/Support/PGOOptions.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO/Inliner.h"
diff --git a/llvm/include/llvm/Passes/OptimizationLevel.h b/llvm/include/llvm/Support/OptimizationLevel.h
similarity index 100%
rename from llvm/include/llvm/Passes/OptimizationLevel.h
rename to llvm/include/llvm/Support/OptimizationLevel.h
diff --git a/llvm/lib/Passes/CMakeLists.txt b/llvm/lib/Passes/CMakeLists.txt
index 91c8c4f67074d..6f1ade87bc431 100644
--- a/llvm/lib/Passes/CMakeLists.txt
+++ b/llvm/lib/Passes/CMakeLists.txt
@@ -1,6 +1,5 @@
add_llvm_component_library(LLVMPasses
CodeGenPassBuilder.cpp
- OptimizationLevel.cpp
PassBuilder.cpp
PassBuilderBindings.cpp
PassBuilderPipelines.cpp
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 587f0ece0859b..ef18bd132499f 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -184,12 +184,12 @@
#include "llvm/IR/SafepointIRVerifier.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRPrinter/IRPrintingPasses.h"
-#include "llvm/Passes/OptimizationLevel.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/OptimizationLevel.h"
#include "llvm/Support/Regex.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h"
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 98821bb1408a7..cd6fc51ceafec 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -26,10 +26,10 @@
#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
-#include "llvm/Passes/OptimizationLevel.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/OptimizationLevel.h"
#include "llvm/Support/PGOOptions.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Target/TargetMachine.h"
@@ -2355,4 +2355,4 @@ AAManager PassBuilder::buildDefaultAAPipeline() {
bool PassBuilder::isInstrumentedPGOUse() const {
return (PGOOpt && PGOOpt->Action == PGOOptions::IRUse) ||
!UseCtxProfile.empty();
-}
\ No newline at end of file
+}
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index b29dda46b757f..cb882f80bc467 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -224,6 +224,7 @@ add_llvm_component_library(LLVMSupport
MSP430AttributeParser.cpp
Mustache.cpp
NativeFormatting.cpp
+ OptimizationLevel.cpp
OptimizedStructLayout.cpp
Optional.cpp
OptionStrCmp.cpp
diff --git a/llvm/lib/Passes/OptimizationLevel.cpp b/llvm/lib/Support/OptimizationLevel.cpp
similarity index 95%
rename from llvm/lib/Passes/OptimizationLevel.cpp
rename to llvm/lib/Support/OptimizationLevel.cpp
index a1f8c1e14b1f0..28b742f609065 100644
--- a/llvm/lib/Passes/OptimizationLevel.cpp
+++ b/llvm/lib/Support/OptimizationLevel.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Passes/OptimizationLevel.h"
+#include "llvm/Support/OptimizationLevel.h"
using namespace llvm;
More information about the llvm-commits
mailing list