From: Lei Zhang Date: Sun, 29 Aug 2021 16:01:19 +0000 (-0400) Subject: [mlir][spirv] Use type dyn_cast when scanning spv.GlobalVariable X-Git-Tag: upstream/15.0.7~32777 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a5621e26dbc90be3d5af164978f6fcc398f0a1d1;p=platform%2Fupstream%2Fllvm.git [mlir][spirv] Use type dyn_cast when scanning spv.GlobalVariable This avoids crashes when there are spv.GlobalVariable without pointer type. --- diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp index 9097ef5..76abf15 100644 --- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp @@ -700,7 +700,10 @@ static spirv::PointerType getPushConstantStorageType(unsigned elementCount, static spirv::GlobalVariableOp getPushConstantVariable(Block &body, unsigned elementCount) { for (auto varOp : body.getOps()) { - auto ptrType = varOp.type().cast(); + auto ptrType = varOp.type().dyn_cast(); + if (!ptrType) + continue; + // Note that Vulkan requires "There must be no more than one push constant // block statically used per shader entry point." So we should always reuse // the existing one.