-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][spirv] Fix a crash of typeConverter with non supported type #79955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir-spirv Author: Kohei Yamaguchi (sott0n) ChangesFixes a crash in the Fixes #60017 Full diff: https://github.com/llvm/llvm-project/pull/79955.diff 1 Files Affected:
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
index c62e676efc159..c7c67c04c8919 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
@@ -367,12 +367,13 @@ class AccessChainPattern : public SPIRVToLLVMConversion<spirv::AccessChainOp> {
Value zero = rewriter.create<LLVM::ConstantOp>(
op.getLoc(), llvmIndexType, rewriter.getIntegerAttr(indexType, 0));
indices.insert(indices.begin(), zero);
- rewriter.replaceOpWithNewOp<LLVM::GEPOp>(
- op, dstType,
- typeConverter.convertType(
- cast<spirv::PointerType>(op.getBasePtr().getType())
- .getPointeeType()),
- adaptor.getBasePtr(), indices);
+
+ auto elementType = typeConverter.convertType(
+ cast<spirv::PointerType>(op.getBasePtr().getType()).getPointeeType());
+ if (!elementType)
+ return failure();
+ rewriter.replaceOpWithNewOp<LLVM::GEPOp>(op, dstType, elementType,
+ adaptor.getBasePtr(), indices);
return success();
}
};
|
@llvm/pr-subscribers-mlir Author: Kohei Yamaguchi (sott0n) ChangesFixes a crash in the Fixes #60017 Full diff: https://github.com/llvm/llvm-project/pull/79955.diff 1 Files Affected:
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
index c62e676efc159..c7c67c04c8919 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp
@@ -367,12 +367,13 @@ class AccessChainPattern : public SPIRVToLLVMConversion<spirv::AccessChainOp> {
Value zero = rewriter.create<LLVM::ConstantOp>(
op.getLoc(), llvmIndexType, rewriter.getIntegerAttr(indexType, 0));
indices.insert(indices.begin(), zero);
- rewriter.replaceOpWithNewOp<LLVM::GEPOp>(
- op, dstType,
- typeConverter.convertType(
- cast<spirv::PointerType>(op.getBasePtr().getType())
- .getPointeeType()),
- adaptor.getBasePtr(), indices);
+
+ auto elementType = typeConverter.convertType(
+ cast<spirv::PointerType>(op.getBasePtr().getType()).getPointeeType());
+ if (!elementType)
+ return failure();
+ rewriter.replaceOpWithNewOp<LLVM::GEPOp>(op, dstType, elementType,
+ adaptor.getBasePtr(), indices);
return success();
}
};
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes a crash in the
convert-to-spirv-llvm
pass caused by unsupported types (e.g.spirv.matrix
). This PR fixes it by checking the converted type.Fixes #60017