[Mlir-commits] [mlir] [mlir] fix LLVM type converter for structs (PR #73231)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Thu Nov 23 12:45:51 PST 2023
================
@@ -110,10 +102,26 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
if (failed(convertTypes(type.getBody(), convertedElemTypes)))
return std::nullopt;
- if (failed(convertedType.setBody(convertedElemTypes, type.isPacked())))
- return failure();
- results.push_back(convertedType);
- return success();
+ // If the converted type has not been initialized yet, just set its body
+ // to be the converted arguments and return.
+ if (!convertedType.isInitialized()) {
+ if (failed(
+ convertedType.setBody(convertedElemTypes, type.isPacked()))) {
+ return failure();
+ }
+ results.push_back(convertedType);
+ return success();
+ }
+
+ // If it has been initialized and has the same body, just use it. This
+ // ensures that recursive structs keep being recursive rather than
+ // including a non-updated name.
+ if (TypeRange(convertedType.getBody()) == TypeRange(convertedElemTypes)) {
----------------
ftynse wrote:
Good point, updating!
https://github.com/llvm/llvm-project/pull/73231
More information about the Mlir-commits
mailing list