Skip to content

Commit

Permalink
Fix cpp static check.
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaojbao committed Mar 22, 2024
1 parent e91a935 commit fe14fbb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
22 changes: 11 additions & 11 deletions llpc/lower/llpcSpirvLowerRayQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CrossModuleInliner>();
LLVM_DEBUG(dbgs() << "Run the pass Spirv-Lower-ray-query\n");
SpirvLower::init(&module);
createGlobalRayQueryObj();
Expand Down Expand Up @@ -1069,11 +1069,11 @@ void SpirvLowerRayQuery::createRayQueryFunc<OpRayQueryGetIntersectionTriangleVer
// Call {vec3, vec3, vec3} FetchTrianglePositionFromRayQuery(rayquery* rayquery, int* intersect)
// return 3 triangle vertices
auto floatx3Ty = FixedVectorType::get(m_builder->getFloatTy(), 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]).
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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));
}
}
Expand Down
3 changes: 2 additions & 1 deletion llpc/lower/llpcSpirvLowerRayQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#pragma once

#include "SPIRVInternal.h"
#include "compilerutils/CompilerUtils.h"
#include "llpcSpirvLower.h"
#include "llvm/IR/PassManager.h"

Expand Down Expand Up @@ -143,7 +144,7 @@ class SpirvLowerRayQuery : public SpirvLower, public llvm::PassInfoMixin<SpirvLo

bool m_rayQueryLibrary; // Whether the module is ray query library
unsigned m_spirvOpMetaKindId; // Metadata kind ID for "spirv.op"
CompilerUtils::CrossModuleInliner *m_crossModuleInliner = nullptr;
std::optional<CompilerUtils::CrossModuleInliner> m_crossModuleInliner;

private:
template <spv::Op> void createRayQueryFunc(llvm::Function *func);
Expand Down
14 changes: 7 additions & 7 deletions llpc/lower/llpcSpirvLowerRayTracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CrossModuleInliner>();

// Create empty raygen main module
if (module.empty()) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit fe14fbb

Please sign in to comment.