@@ -220,6 +220,9 @@ ResourceAliasAnalysis::ResourceAliasAnalysis(Operation *root) {
220
220
}
221
221
222
222
bool ResourceAliasAnalysis::shouldUnify (Operation *op) const {
223
+ if (!op)
224
+ return false ;
225
+
223
226
if (auto varOp = dyn_cast<spirv::GlobalVariableOp>(op)) {
224
227
auto canonicalOp = getCanonicalResource (varOp);
225
228
return canonicalOp && varOp != canonicalOp;
@@ -566,16 +569,15 @@ class UnifyAliasedResourcePass final
566
569
private:
567
570
spirv::GetTargetEnvFn getTargetEnvFn;
568
571
};
569
- } // namespace
570
572
571
573
void UnifyAliasedResourcePass::runOnOperation () {
572
574
spirv::ModuleOp moduleOp = getOperation ();
573
575
MLIRContext *context = &getContext ();
574
576
575
577
if (getTargetEnvFn) {
576
- // This pass is only needed for targeting WebGPU, Metal, or layering Vulkan
577
- // on Metal via MoltenVK, where we need to translate SPIR-V into WGSL or
578
- // MSL. The translation has limitations.
578
+ // This pass is only needed for targeting WebGPU, Metal, or layering
579
+ // Vulkan on Metal via MoltenVK, where we need to translate SPIR-V into
580
+ // WGSL or MSL. The translation has limitations.
579
581
spirv::TargetEnvAttr targetEnv = getTargetEnvFn (moduleOp);
580
582
spirv::ClientAPI clientAPI = targetEnv.getClientAPI ();
581
583
bool isVulkanOnAppleDevices =
@@ -614,6 +616,7 @@ void UnifyAliasedResourcePass::runOnOperation() {
614
616
resources.front ()->removeAttr (" aliased" );
615
617
}
616
618
}
619
+ } // namespace
617
620
618
621
std::unique_ptr<mlir::OperationPass<spirv::ModuleOp>>
619
622
spirv::createUnifyAliasedResourcePass (spirv::GetTargetEnvFn getTargetEnv) {
0 commit comments