From fe14fbb74847f805c4ee583dad4aad5753313069 Mon Sep 17 00:00:00 2001 From: qiaojbao Date: Fri, 22 Mar 2024 15:02:04 +0800 Subject: [PATCH] Fix cpp static check. --- llpc/lower/llpcSpirvLowerRayQuery.cpp | 22 +++++++++++----------- llpc/lower/llpcSpirvLowerRayQuery.h | 3 ++- llpc/lower/llpcSpirvLowerRayTracing.cpp | 14 +++++++------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/llpc/lower/llpcSpirvLowerRayQuery.cpp b/llpc/lower/llpcSpirvLowerRayQuery.cpp index 1e7416c1d3..04d0924406 100644 --- a/llpc/lower/llpcSpirvLowerRayQuery.cpp +++ b/llpc/lower/llpcSpirvLowerRayQuery.cpp @@ -293,8 +293,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) { - CrossModuleInliner cmi; - m_crossModuleInliner = &cmi; + m_crossModuleInliner.reset(); + m_crossModuleInliner = std::make_optional(); LLVM_DEBUG(dbgs() << "Run the pass Spirv-Lower-ray-query\n"); SpirvLower::init(&module); createGlobalRayQueryObj(); @@ -1069,11 +1069,11 @@ void SpirvLowerRayQuery::createRayQueryFuncgetFloatTy(), 3); - auto triangleData = m_crossModuleInliner - ->inlineCall(*m_builder, - getGpurtFunction(m_context->getPipelineContext()->getRayTracingFunctionName( - Vkgc::RT_ENTRY_FETCH_HIT_TRIANGLE_FROM_RAY_QUERY)), - {rayQuery, intersectPtr}) + auto triangleData = m_crossModuleInliner.value() + .inlineCall(*m_builder, + getGpurtFunction(m_context->getPipelineContext()->getRayTracingFunctionName( + Vkgc::RT_ENTRY_FETCH_HIT_TRIANGLE_FROM_RAY_QUERY)), + {rayQuery, intersectPtr}) .returnValue; // Return type of OpRayQueryGetIntersectionTriangleVertexPositionsKHR is array of vec3 (vec3[3]). @@ -1251,7 +1251,7 @@ Value *SpirvLowerRayQuery::createLoadInstanceIndexOrId(Value *instNodeAddr, bool ? m_context->getPipelineContext()->getRayTracingFunctionName(Vkgc::RT_ENTRY_INSTANCE_INDEX) : m_context->getPipelineContext()->getRayTracingFunctionName(Vkgc::RT_ENTRY_INSTANCE_ID); - auto cmiResult = m_crossModuleInliner->inlineCall(*m_builder, getGpurtFunction(getterName), {instanceIdPtr}); + auto cmiResult = m_crossModuleInliner.value().inlineCall(*m_builder, getGpurtFunction(getterName), {instanceIdPtr}); return cmiResult.returnValue; } @@ -1279,7 +1279,7 @@ Value *SpirvLowerRayQuery::createGetInstanceNodeAddr(Value *instNodePtr, Value * m_builder->CreateStore(instNodePtr, nodePtr); auto cmiResult = - m_crossModuleInliner->inlineCall(*m_builder, getGpurtFunction(getInstanceNodeAddr), {bvhPtr, nodePtr}); + m_crossModuleInliner.value().inlineCall(*m_builder, getGpurtFunction(getInstanceNodeAddr), {bvhPtr, nodePtr}); return cmiResult.returnValue; } @@ -1320,8 +1320,8 @@ Value *SpirvLowerRayQuery::createLoadMatrixFromFunc(Value *instanceNodeAddr, uns m_builder->CreateStore(col, colPtr); m_builder->CreateStore(row, rowPtr); - auto cmiMatrixResult = m_crossModuleInliner->inlineCall(*m_builder, getGpurtFunction(getMatrixFunc), - {instandeNodeAddrPtr, rowPtr, colPtr}); + auto cmiMatrixResult = m_crossModuleInliner.value().inlineCall(*m_builder, getGpurtFunction(getMatrixFunc), + {instandeNodeAddrPtr, rowPtr, colPtr}); matrixRow[j] = m_builder->CreateInsertElement(matrixRow[j], cmiMatrixResult.returnValue, uint64_t(i)); } } diff --git a/llpc/lower/llpcSpirvLowerRayQuery.h b/llpc/lower/llpcSpirvLowerRayQuery.h index 4071b300bc..6c4df2e191 100644 --- a/llpc/lower/llpcSpirvLowerRayQuery.h +++ b/llpc/lower/llpcSpirvLowerRayQuery.h @@ -31,6 +31,7 @@ #pragma once #include "SPIRVInternal.h" +#include "compilerutils/CompilerUtils.h" #include "llpcSpirvLower.h" #include "llvm/IR/PassManager.h" @@ -143,7 +144,7 @@ class SpirvLowerRayQuery : public SpirvLower, public llvm::PassInfoMixin m_crossModuleInliner; private: template void createRayQueryFunc(llvm::Function *func); diff --git a/llpc/lower/llpcSpirvLowerRayTracing.cpp b/llpc/lower/llpcSpirvLowerRayTracing.cpp index eb63242d33..95555275f5 100644 --- a/llpc/lower/llpcSpirvLowerRayTracing.cpp +++ b/llpc/lower/llpcSpirvLowerRayTracing.cpp @@ -420,8 +420,8 @@ PreservedAnalyses SpirvLowerRayTracing::run(Module &module, ModuleAnalysisManage mode.workgroupSizeZ = rtState->threadGroupSizeZ; lgc::Pipeline::setComputeShaderMode(module, mode); - CrossModuleInliner cmi; - m_crossModuleInliner = &cmi; + m_crossModuleInliner.reset(); + m_crossModuleInliner = std::make_optional(); // Create empty raygen main module if (module.empty()) { @@ -2136,11 +2136,11 @@ void SpirvLowerRayTracing::createSetHitTriangleNodePointer(Function *func) { m_builder->CreateStore(bvh, bvhPtr); m_builder->CreateStore(nodePtr, nodePtrPtr); - auto triangleData = m_crossModuleInliner - ->inlineCall(*m_builder, - getGpurtFunction(m_context->getPipelineContext()->getRayTracingFunctionName( - Vkgc::RT_ENTRY_FETCH_HIT_TRIANGLE_FROM_NODE_POINTER)), - {bvhPtr, nodePtrPtr}) + auto triangleData = m_crossModuleInliner.value() + .inlineCall(*m_builder, + getGpurtFunction(m_context->getPipelineContext()->getRayTracingFunctionName( + Vkgc::RT_ENTRY_FETCH_HIT_TRIANGLE_FROM_NODE_POINTER)), + {bvhPtr, nodePtrPtr}) .returnValue; m_builder->CreateStore(triangleData, vertexPos); }