From b1f609e6cb38ef1db6bbd3a87caa4c09f080cb3a Mon Sep 17 00:00:00 2001 From: qiaojbao Date: Fri, 22 Mar 2024 18:07:53 +0800 Subject: [PATCH] Fix cpp static check (2) update. --- llpc/lower/llpcSpirvLowerRayQuery.cpp | 3 ++- llpc/lower/llpcSpirvLowerRayTracing.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/llpc/lower/llpcSpirvLowerRayQuery.cpp b/llpc/lower/llpcSpirvLowerRayQuery.cpp index 04d0924406..48eded8142 100644 --- a/llpc/lower/llpcSpirvLowerRayQuery.cpp +++ b/llpc/lower/llpcSpirvLowerRayQuery.cpp @@ -37,6 +37,7 @@ #include "llvmraytracing/GpurtContext.h" #include "lgc/Builder.h" #include "lgc/GpurtDialect.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/IntrinsicsAMDGPU.h" @@ -293,8 +294,8 @@ SpirvLowerRayQuery::SpirvLowerRayQuery(bool rayQueryLibrary) // @param [in/out] module : LLVM module to be run on // @param [in/out] analysisManager : Analysis manager to use for this transformation PreservedAnalyses SpirvLowerRayQuery::run(Module &module, ModuleAnalysisManager &analysisManager) { - m_crossModuleInliner.reset(); m_crossModuleInliner = std::make_optional(); + auto onExit = make_scope_exit([&] { m_crossModuleInliner.reset(); }); LLVM_DEBUG(dbgs() << "Run the pass Spirv-Lower-ray-query\n"); SpirvLower::init(&module); createGlobalRayQueryObj(); diff --git a/llpc/lower/llpcSpirvLowerRayTracing.cpp b/llpc/lower/llpcSpirvLowerRayTracing.cpp index 95555275f5..b95541eea6 100644 --- a/llpc/lower/llpcSpirvLowerRayTracing.cpp +++ b/llpc/lower/llpcSpirvLowerRayTracing.cpp @@ -46,6 +46,7 @@ #include "lgc/LgcRtDialect.h" #include "lgc/Pipeline.h" #include "llvm-dialects/Dialect/Visitor.h" +#include "llvm/ADT/ScopeExit.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/BlockFrequencyInfo.h" #include "llvm/Analysis/ProfileSummaryInfo.h" @@ -420,8 +421,8 @@ PreservedAnalyses SpirvLowerRayTracing::run(Module &module, ModuleAnalysisManage mode.workgroupSizeZ = rtState->threadGroupSizeZ; lgc::Pipeline::setComputeShaderMode(module, mode); - m_crossModuleInliner.reset(); m_crossModuleInliner = std::make_optional(); + auto onExit = make_scope_exit([&] { m_crossModuleInliner.reset(); }); // Create empty raygen main module if (module.empty()) {