https://github.com/david-arm updated 
https://github.com/llvm/llvm-project/pull/157057

>From 38a652542beb691c14a5d4ad832302ade1f579c4 Mon Sep 17 00:00:00 2001
From: David Sherwood <david.sherw...@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.
---
 .../LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp         | 2 +-
 clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp          | 2 +-
 flang/include/flang/Optimizer/Passes/CommandLineOpts.h        | 2 +-
 flang/include/flang/Optimizer/Passes/Pipelines.h              | 2 +-
 flang/include/flang/Tools/CrossToolHelpers.h                  | 2 +-
 flang/tools/bbc/bbc.cpp                                       | 2 +-
 flang/tools/tco/tco.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 +-
 mlir/lib/ExecutionEngine/OptUtils.cpp                         | 2 +-
 offload/plugins-nextgen/common/src/JIT.cpp                    | 2 +-
 16 files changed, 15 insertions(+), 15 deletions(-)
 rename llvm/include/llvm/{Passes => Support}/OptimizationLevel.h (100%)
 rename llvm/lib/{Passes => Support}/OptimizationLevel.cpp (95%)

diff --git a/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp 
b/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp
index 79a315d5a4ee2..949ee82f5bb99 100644
--- a/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp
+++ b/clang/examples/LLVMPrintFunctionNames/LLVMPrintFunctionNames.cpp
@@ -20,8 +20,8 @@
 #include "clang/Sema/Sema.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Passes/PassBuilder.h"
+#include "llvm/Support/OptimizationLevel.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
 
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/flang/include/flang/Optimizer/Passes/CommandLineOpts.h 
b/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
index 76ac9d0622d2b..9979c273d6947 100644
--- a/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
+++ b/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
@@ -13,8 +13,8 @@
 #define FORTRAN_OPTIMIZER_PASSES_COMMANDLINEOPTS_H
 
 #include "llvm/Frontend/Debug/Options.h"
-#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/OptimizationLevel.h"
 
 /// Shared option in tools to control whether dynamically sized array
 /// allocations should always be on the heap.
diff --git a/flang/include/flang/Optimizer/Passes/Pipelines.h 
b/flang/include/flang/Optimizer/Passes/Pipelines.h
index fd8c43cc88a19..60692d0719c48 100644
--- a/flang/include/flang/Optimizer/Passes/Pipelines.h
+++ b/flang/include/flang/Optimizer/Passes/Pipelines.h
@@ -26,8 +26,8 @@
 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
 #include "mlir/Transforms/Passes.h"
 #include "llvm/Frontend/Debug/Options.h"
-#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/OptimizationLevel.h"
 
 namespace fir {
 
diff --git a/flang/include/flang/Tools/CrossToolHelpers.h 
b/flang/include/flang/Tools/CrossToolHelpers.h
index 335f0a45531c8..ff8fdb3d0fc53 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -23,7 +23,7 @@
 #include "mlir/Pass/PassRegistry.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Frontend/Debug/Options.h"
-#include "llvm/Passes/OptimizationLevel.h"
+#include "llvm/Support/OptimizationLevel.h"
 
 // Flang Extension Point Callbacks
 class FlangEPCallBacks {
diff --git a/flang/tools/bbc/bbc.cpp b/flang/tools/bbc/bbc.cpp
index 82dff2653ad09..3bcab099becd7 100644
--- a/flang/tools/bbc/bbc.cpp
+++ b/flang/tools/bbc/bbc.cpp
@@ -56,12 +56,12 @@
 #include "mlir/Transforms/GreedyPatternRewriteDriver.h"
 #include "mlir/Transforms/Passes.h"
 #include "llvm/MC/TargetRegistry.h"
-#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/OptimizationLevel.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetSelect.h"
diff --git a/flang/tools/tco/tco.cpp b/flang/tools/tco/tco.cpp
index 36939802f55a6..907b412b93606 100644
--- a/flang/tools/tco/tco.cpp
+++ b/flang/tools/tco/tco.cpp
@@ -26,12 +26,12 @@
 #include "mlir/Pass/Pass.h"
 #include "mlir/Pass/PassManager.h"
 #include "mlir/Transforms/Passes.h"
-#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/OptimizationLevel.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/ToolOutputFile.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;
 
diff --git a/mlir/lib/ExecutionEngine/OptUtils.cpp 
b/mlir/lib/ExecutionEngine/OptUtils.cpp
index b024a625fbf53..8d50335e4b7a6 100644
--- a/mlir/lib/ExecutionEngine/OptUtils.cpp
+++ b/mlir/lib/ExecutionEngine/OptUtils.cpp
@@ -15,10 +15,10 @@
 
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Passes/OptimizationLevel.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/OptimizationLevel.h"
 #include "llvm/Target/TargetMachine.h"
 #include <optional>
 
diff --git a/offload/plugins-nextgen/common/src/JIT.cpp 
b/offload/plugins-nextgen/common/src/JIT.cpp
index 00720fa2d8103..1894affe0f2fa 100644
--- a/offload/plugins-nextgen/common/src/JIT.cpp
+++ b/offload/plugins-nextgen/common/src/JIT.cpp
@@ -26,9 +26,9 @@
 #include "llvm/InitializePasses.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Object/IRObjectFile.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/Support/TimeProfiler.h"

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to