[PATCH] D119325: [flang] Add type conversion for !fir.box<none>

Valentin Clement via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 9 06:14:00 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd0417a3cf7d: [flang] Add type conversion for !fir.box<none> (authored by clementval).

Changed prior to commit:
  https://reviews.llvm.org/D119325?vs=407126&id=407133#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119325/new/

https://reviews.llvm.org/D119325

Files:
  flang/lib/Optimizer/CodeGen/TypeConverter.h
  flang/test/Fir/types-to-llvm.fir


Index: flang/test/Fir/types-to-llvm.fir
===================================================================
--- flang/test/Fir/types-to-llvm.fir
+++ flang/test/Fir/types-to-llvm.fir
@@ -418,3 +418,11 @@
 func private @foo1(%arg0: !fir.type<derived8{a:i64,b:!fir.box<i32>}>)
 // CHECK-LABEL: foo1
 // CHECK-SAME: !llvm.struct<"derived8", (i64, struct<(ptr<i32>, i{{.*}})>)>
+
+// -----
+
+// Test fir.box<none> translation.
+// `none` is used for polymorphic type.
+func private @foo0(%arg0: !fir.box<none>)
+// CHECK-LABEL: foo0
+// CHECK-SAME: !llvm.ptr<struct<(ptr<struct<()>>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}})>>)
Index: flang/lib/Optimizer/CodeGen/TypeConverter.h
===================================================================
--- flang/lib/Optimizer/CodeGen/TypeConverter.h
+++ flang/lib/Optimizer/CodeGen/TypeConverter.h
@@ -124,6 +124,10 @@
       return mlir::LLVM::LLVMStructType::getLiteral(&getContext(), members,
                                                     /*isPacked=*/false);
     });
+    addConversion([&](mlir::NoneType none) {
+      return mlir::LLVM::LLVMStructType::getLiteral(
+          none.getContext(), llvm::None, /*isPacked=*/false);
+    });
   }
 
   // i32 is used here because LLVM wants i32 constants when indexing into struct


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119325.407133.patch
Type: text/x-patch
Size: 1294 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220209/c1041cd5/attachment.bin>


More information about the llvm-commits mailing list