Skip to content

Commit

Permalink
[gccjit] fix missed translation of return type
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu committed Nov 7, 2024
1 parent 1314f5b commit 05a799d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Conversion/TypeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Type GCCJITTypeConverter::convertAndPackTypesIfNonSingleton(
if (types.size() == 0)
return VoidType::get(func.getContext());
if (types.size() == 1)
return types.front();
return convertType(types.front());

auto name =
Twine("__retpack_")
Expand Down
23 changes: 16 additions & 7 deletions test/lowering/alloc.mlir
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
// RUN: %gccjit-opt %s -o %t.mlir -convert-memref-to-gccjit
// RUN: %filecheck --input-file=%t.mlir %s
module @test
module @test attributes {
gccjit.opt_level = #gccjit.opt_level<O3>,
gccjit.debug_info = false
}
{

func.func @foo() {
func.func @foo() -> memref<100x100xf32> {
// CHECK: gccjit.call builtin @aligned_alloc(%{{[0-9]+}}, %{{[0-9]+}}) : (!gccjit.int<size_t>, !gccjit.int<size_t>) -> !gccjit.ptr<!gccjit.void>
%a = memref.alloc () : memref<100x100xf32>
return
return %a : memref<100x100xf32>
}

func.func @bar(%arg0 : index, %arg1: index) {
func.func @bar(%arg0 : index, %arg1: index) -> memref<?x133x723x?xf32> {
// CHECK: gccjit.call builtin @aligned_alloc(%{{[0-9]+}}, %{{[0-9]+}}) : (!gccjit.int<size_t>, !gccjit.int<size_t>) -> !gccjit.ptr<!gccjit.void>
%a = memref.alloc (%arg0, %arg1) : memref<?x133x723x?xf32>
return
return %a : memref<?x133x723x?xf32>
}

func.func @baz() {
func.func @baz() -> memref<133x723x1xi128> {
// CHECK: gccjit.call builtin @aligned_alloc(%{{[0-9]+}}, %{{[0-9]+}}) : (!gccjit.int<size_t>, !gccjit.int<size_t>) -> !gccjit.ptr<!gccjit.void>
%a = memref.alloc () {alignment = 128} : memref<133x723x1xi128>
return
return %a : memref<133x723x1xi128>
}

gccjit.func exported @qux() -> !gccjit.int<size_t> {
// CHECK: gccjit.call builtin @aligned_alloc(%{{[0-9]+}}, %{{[0-9]+}}) : (!gccjit.int<size_t>, !gccjit.int<size_t>) -> !gccjit.ptr<!gccjit.void>
%a = gccjit.alignof !gccjit.int<int64_t> : !gccjit.int<size_t>
gccjit.return %a : !gccjit.int<size_t>
}
}

0 comments on commit 05a799d

Please sign in to comment.