1// RUN: mlir-opt -convert-memref-to-llvm %s | FileCheck %s
2
3// CHECK-LABEL: @empty
4func.func @empty() {
5  // CHECK: llvm.intr.stacksave
6  // CHECK: llvm.br
7  memref.alloca_scope {
8    memref.alloca_scope.return
9  }
10  // CHECK: llvm.intr.stackrestore
11  // CHECK: llvm.br
12  return
13}
14
15// CHECK-LABEL: @returns_nothing
16func.func @returns_nothing(%b: f32) {
17  %a = arith.constant 10.0 : f32
18  // CHECK: llvm.intr.stacksave
19  memref.alloca_scope {
20    %c = arith.addf %a, %b : f32
21    memref.alloca_scope.return
22  }
23  // CHECK: llvm.intr.stackrestore
24  return
25}
26
27// CHECK-LABEL: @returns_one_value
28func.func @returns_one_value(%b: f32) -> f32 {
29  %a = arith.constant 10.0 : f32
30  // CHECK: llvm.intr.stacksave
31  %result = memref.alloca_scope -> f32 {
32    %c = arith.addf %a, %b : f32
33    memref.alloca_scope.return %c: f32
34  }
35  // CHECK: llvm.intr.stackrestore
36  return %result : f32
37}
38
39// CHECK-LABEL: @returns_multiple_values
40func.func @returns_multiple_values(%b: f32) -> f32 {
41  %a = arith.constant 10.0 : f32
42  // CHECK: llvm.intr.stacksave
43  %result1, %result2 = memref.alloca_scope -> (f32, f32) {
44    %c = arith.addf %a, %b : f32
45    %d = arith.subf %a, %b : f32
46    memref.alloca_scope.return %c, %d: f32, f32
47  }
48  // CHECK: llvm.intr.stackrestore
49  %result = arith.addf %result1, %result2 : f32
50  return %result : f32
51}
52