From ead837a4f89cbbb18e73d4d65d2d51164a0dfb9b Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Fri, 15 Aug 2025 01:39:21 +0100 Subject: [PATCH 1/2] [Transforms] Move createLogCheriSetBoundsPass to Transforms/Utils.h This lets us drop dependencies on any CodeGen headers. Also add a LogCheriSetBoundsID like the other passes. --- llvm/include/llvm/CodeGen/Passes.h | 3 --- llvm/include/llvm/Transforms/Utils.h | 7 +++++++ llvm/lib/Transforms/Utils/CheriLogSetBoundsPass.cpp | 13 +++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/llvm/include/llvm/CodeGen/Passes.h b/llvm/include/llvm/CodeGen/Passes.h index edf25d1515b94..f4f4ae283bc3c 100644 --- a/llvm/include/llvm/CodeGen/Passes.h +++ b/llvm/include/llvm/CodeGen/Passes.h @@ -514,9 +514,6 @@ namespace llvm { /// This pass performs merging similar functions globally. ModulePass *createGlobalMergeFuncPass(); - /// This pass logs information on generated CSetBounds calls - FunctionPass *createLogCheriSetBoundsPass(); - /// This pass performs outlining on machine instructions directly before /// printing assembly. ModulePass *createMachineOutlinerPass(bool RunOnAllFunctions = true); diff --git a/llvm/include/llvm/Transforms/Utils.h b/llvm/include/llvm/Transforms/Utils.h index ff306dbe35803..fe5b403f6d79e 100644 --- a/llvm/include/llvm/Transforms/Utils.h +++ b/llvm/include/llvm/Transforms/Utils.h @@ -20,6 +20,13 @@ class ModulePass; class FunctionPass; class Pass; +//===----------------------------------------------------------------------===// +// LogCheriSetBounds - This pass logs information on generated CSetBounds +// calls. +// +FunctionPass *createLogCheriSetBoundsPass(); +extern char &LogCheriSetBoundsID; + //===----------------------------------------------------------------------===// // // LowerInvoke - This pass removes invoke instructions, converting them to call diff --git a/llvm/lib/Transforms/Utils/CheriLogSetBoundsPass.cpp b/llvm/lib/Transforms/Utils/CheriLogSetBoundsPass.cpp index 4c4e422b38953..eaeaea9ac87aa 100644 --- a/llvm/lib/Transforms/Utils/CheriLogSetBoundsPass.cpp +++ b/llvm/lib/Transforms/Utils/CheriLogSetBoundsPass.cpp @@ -7,13 +7,10 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Transforms/Utils/CheriLogSetBounds.h" - #include "llvm/Analysis/AssumptionCache.h" -#include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/MachineModuleInfo.h" -#include "llvm/CodeGen/Passes.h" #include "llvm/IR/Module.h" +#include "llvm/Transforms/Utils.h" +#include "llvm/Transforms/Utils/CheriLogSetBounds.h" #include "llvm/Transforms/Utils/CheriSetBounds.h" #include "llvm/Transforms/Utils/Local.h" @@ -137,12 +134,16 @@ class CheriLogSetBoundsLegacyPass : public FunctionPass { char CheriLogSetBoundsLegacyPass::ID; -FunctionPass *llvm::createLogCheriSetBoundsPass() { +namespace llvm { +char &LogCheriSetBoundsID = CheriLogSetBoundsLegacyPass::ID; + +FunctionPass *createLogCheriSetBoundsPass() { static bool created = false; assert(!created && "Should only be created once"); created = true; return new CheriLogSetBoundsLegacyPass(); } +} // namespace llvm PreservedAnalyses CheriLogSetBoundsPass::run(Function &F, FunctionAnalysisManager &AM) { From f3d8f1a61ef95532e78b9eb1daa84ff4f02ab93c Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Fri, 15 Aug 2025 01:41:12 +0100 Subject: [PATCH 2/2] Revert "Utils: add missing dep for llvm/CodeGen/GenVT.inc" This was needed due to a layering violation, and the dependency itself is also a layering violation. The underlying cause has now been fixed. This reverts commit 430ebd25b415e800666a212f11a2dfca8a08cc6c. --- llvm/lib/Transforms/Utils/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/llvm/lib/Transforms/Utils/CMakeLists.txt b/llvm/lib/Transforms/Utils/CMakeLists.txt index bb95f578002d7..886e93eb082b8 100644 --- a/llvm/lib/Transforms/Utils/CMakeLists.txt +++ b/llvm/lib/Transforms/Utils/CMakeLists.txt @@ -97,7 +97,6 @@ add_llvm_component_library(LLVMTransformUtils ${LLVM_MAIN_INCLUDE_DIR}/llvm/Transforms/Utils DEPENDS - vt_gen intrinsics_gen LINK_COMPONENTS