From 5ece343bdc0beeb6bf7c25a24469fc463ffd835e Mon Sep 17 00:00:00 2001 From: eastb233 Date: Thu, 28 Aug 2025 16:02:42 +0800 Subject: [PATCH] [NFC] Retire LLVM_BUILD_FOR_COMMON macro --- llvm/cmake/modules/HandleLLVMOptions.cmake | 8 --- llvm/lib/Transforms/Scalar/LICM.cpp | 52 ++++++++----------- .../Transforms/LICM/signal-before-loop-2.ll | 3 +- .../Transforms/LICM/signal-before-loop.ll | 3 +- llvm/test/lit.site.cfg.py.in | 1 - 5 files changed, 24 insertions(+), 43 deletions(-) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 7c86dbe41521..30290576301e 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -121,14 +121,6 @@ else() set(LLVM_ENABLE_AUTOTUNER 0) endif() -option(LLVM_BUILD_FOR_COMMON "" ON) -if(LLVM_BUILD_FOR_COMMON) - set(LLVM_BUILD_FOR_COMMON 1) - add_definitions( -DBUILD_FOR_COMMON ) -else() - set(LLVM_BUILD_FOR_COMMON 0) -endif() - if(LLVM_ENABLE_EXPENSIVE_CHECKS) add_compile_definitions(EXPENSIVE_CHECKS) diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index 2feec759f240..71b567bc7c96 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -44,9 +44,7 @@ #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/CaptureTracking.h" -#ifdef BUILD_FOR_COMMON #include "llvm/Analysis/CFG.h" -#endif // BUILD_FOR_COMMON #include "llvm/Analysis/GuardUtils.h" #include "llvm/Analysis/LazyBlockFrequencyInfo.h" #include "llvm/Analysis/Loads.h" @@ -125,12 +123,10 @@ static cl::opt SingleThread("licm-force-thread-model-single", cl::Hidden, cl::init(false), cl::desc("Force thread model single in LICM pass")); -#ifdef BUILD_FOR_COMMON static cl::opt DisableMovStoreInsOutsideOfLoopInSigFun( - "disable-move-store-ins-outside-of-loop", - cl::Hidden, cl::init(true), cl::desc("Disable move store instruction" - "outside of loop in signal function.")); -#endif // BUILD_FOR_COMMON + "disable-move-store-ins-outside-of-loop", cl::Hidden, cl::init(true), + cl::desc( + "Disable move store instruction outside of loop in signal function.")); static cl::opt MaxNumUsesTraversed( "licm-max-num-uses-traversed", cl::Hidden, cl::init(8), @@ -2085,31 +2081,31 @@ bool llvm::promoteLoopAccessesToScalars( for (Use &U : ASIV->uses()) { // Ignore instructions that are outside the loop. Instruction *UI = dyn_cast(U.getUser()); - #if defined(BUILD_FOR_COMMON) + if (DisableMovStoreInsOutsideOfLoopInSigFun) { if (!UI) continue; - // In the following scenario, there will be a loop index store - // instruction that is moved outside the loop and when the termination - // loop is triggered by the signal function, the store instruction is not - // executed.However, the function registered by the signal will read the - // data sored in the store instruction, so the data read is incorrect. - // Solution: Prevent the store instruction form going outside the loop. - // NOTE: The sys_signal function takes the same arguments and performs - // the same task as signal. They all belong to glic. - if(StoreSafety == StoreSafe && !CurLoop->contains(UI)) { - if(LoadInst *NotCurLoopLoad = dyn_cast(UI)) { + // In the following scenario, there will be a loop index store + // instruction that is moved outside the loop and when the termination + // loop is triggered by the signal function, the store instruction is + // not executed.However, the function registered by the signal will read + // the data sored in the store instruction, so the data read is + // incorrect. Solution: Prevent the store instruction form going outside + // the loop. NOTE: The sys_signal function takes the same arguments and + // performs the same task as signal. They all belong to glic. + if (StoreSafety == StoreSafe && !CurLoop->contains(UI)) { + if (LoadInst *NotCurLoopLoad = dyn_cast(UI)) { Function *NotCurLoopFun = UI->getParent()->getParent(); for (Use &UseFun : NotCurLoopFun->uses()) { - CallInst *Call = dyn_cast(UseFun.getUser()); - if (Call && Call->getCalledFunction() && - (Call->getCalledFunction()->getName() == "__sysv_signal" || - Call->getCalledFunction()->getName() == "signal") && - isPotentiallyReachable(Call->getParent(), - CurLoop->getLoopPreheader(),NULL,DT, - LI)) - return false; + CallInst *Call = dyn_cast(UseFun.getUser()); + if (Call && Call->getCalledFunction() && + (Call->getCalledFunction()->getName() == "__sysv_signal" || + Call->getCalledFunction()->getName() == "signal") && + isPotentiallyReachable(Call->getParent(), + CurLoop->getLoopPreheader(), NULL, DT, + LI)) + return false; } } } @@ -2120,10 +2116,6 @@ bool llvm::promoteLoopAccessesToScalars( if (!UI || !CurLoop->contains(UI)) continue; } -#else - if (!UI || !CurLoop->contains(UI)) - continue; -#endif // BUILD_FOR_COMMON // If there is an non-load/store instruction in the loop, we can't promote // it. diff --git a/llvm/test/Transforms/LICM/signal-before-loop-2.ll b/llvm/test/Transforms/LICM/signal-before-loop-2.ll index da878c6c691b..41a3f4ce91ee 100644 --- a/llvm/test/Transforms/LICM/signal-before-loop-2.ll +++ b/llvm/test/Transforms/LICM/signal-before-loop-2.ll @@ -1,5 +1,4 @@ -; REQUIRES: enable_build_for_common -; RUN:opt -disable-move-store-ins-outside-of-loop=true -S < %s | FileCheck %s +; RUN:opt -disable-move-store-ins-outside-of-loop=true -S < %s | FileCheck %s @Run_Index = external global i64 diff --git a/llvm/test/Transforms/LICM/signal-before-loop.ll b/llvm/test/Transforms/LICM/signal-before-loop.ll index cfae4e87db56..c792a55fe9be 100644 --- a/llvm/test/Transforms/LICM/signal-before-loop.ll +++ b/llvm/test/Transforms/LICM/signal-before-loop.ll @@ -1,5 +1,4 @@ -; REQUIRES: enable_build_for_common -; RUN:opt -disable-move-store-ins-outside-of-loop=true -S < %s | FileCheck %s +; RUN:opt -disable-move-store-ins-outside-of-loop=true -S < %s | FileCheck %s @Run_Index = external global i64 diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in index cecf7d8c7b35..b9002c34f293 100644 --- a/llvm/test/lit.site.cfg.py.in +++ b/llvm/test/lit.site.cfg.py.in @@ -63,7 +63,6 @@ config.dxil_tests = @LLVM_INCLUDE_DXIL_TESTS@ config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@ config.use_classic_flang = @LLVM_ENABLE_CLASSIC_FLANG@ config.enable_enable_autotuner = @LLVM_ENABLE_AUTOTUNER@ -config.enable_build_for_common = @LLVM_BUILD_FOR_COMMON@ config.spirv_tools_tests = @LLVM_INCLUDE_SPIRV_TOOLS_TESTS@ config.have_vc_rev = @LLVM_APPEND_VC_REV@ config.force_vc_rev = "@LLVM_FORCE_VC_REVISION@" -- Gitee