Skip to content

Commit b8fa033

Browse files
aratajewpszymich
authored andcommitted
Define rtfence_t and rtglobals_t types if they are not defined
If user code doesn't call builtins requiring `rtfence_t` and `rtglobals_t` types, but calls builtins requiring `intel_ray_query_opaque_t` type, then `rtfence_t` and `rtglobals_t` might not be defined while setting body for `intel_ray_query_opaque_t` type.
1 parent 81bc370 commit b8fa033

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

IGC/Compiler/Optimizer/OpenCLPasses/RayTracing/ResolveOCLRaytracingBuiltins.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,15 @@ void ResolveOCLRaytracingBuiltins::defineOpaqueTypes(){
139139

140140
if (!rayQueryTy) return;
141141

142-
StructType* rtFenceTy = IGCLLVM::getTypeByName(*M, "struct.rtfence_t");
143-
StructType* rtGlobalsTy = IGCLLVM::getTypeByName(*M, "struct.rtglobals_t");
142+
auto getOrCreateOpaqueType = [](Module* M, const std::string& Name) {
143+
StructType* opaqueType = IGCLLVM::getTypeByName(*M, Name);
144+
if (!opaqueType)
145+
opaqueType = StructType::create(M->getContext(), Name);
146+
return opaqueType;
147+
};
148+
149+
StructType* rtFenceTy = getOrCreateOpaqueType(M, "struct.rtfence_t");
150+
StructType* rtGlobalsTy = getOrCreateOpaqueType(M, "struct.rtglobals_t");
144151

145152
IGC_ASSERT(rtFenceTy && rtGlobalsTy);
146153

0 commit comments

Comments
 (0)