diff --git a/mlir/test/mlir-link/single-global-usage.mlir b/mlir/test/mlir-link/single-global-usage.mlir new file mode 100644 index 0000000000000..66e87938d8959 --- /dev/null +++ b/mlir/test/mlir-link/single-global-usage.mlir @@ -0,0 +1,12 @@ +// RUN: mlir-link -split-input-file %s | FileCheck %s + +// CHECK: llvm.mlir.global external @number(7 : i32) {addr_space = 0 : i32} : i32 + +// ----- + +llvm.mlir.global @number(7 : i32) : i32 + + +// ----- +llvm.mlir.global @number() : i32 + diff --git a/mlir/test/mlir-link/single-global.mlir b/mlir/test/mlir-link/single-global.mlir new file mode 100644 index 0000000000000..28c61fa51c6ab --- /dev/null +++ b/mlir/test/mlir-link/single-global.mlir @@ -0,0 +1,32 @@ +// RUN: mlir-link -split-input-file %s | FileCheck %s + +// CHECK: llvm.mlir.global external @number(7 : i32) {addr_space = 0 : i32} : i32 +// CHECK-NEXT: llvm.func @f2() -> i32 { +// CHECK-NEXT: %0 = llvm.call @f1() : () -> i32 +// CHECK-NEXT: llvm.return %0 : i32 +// CHECK-NEXT: } +// CHECK-NEXT: llvm.func @f1() -> i32 { +// CHECK-NEXT: %0 = llvm.mlir.addressof @number : !llvm.ptr +// CHECK-NEXT: %1 = llvm.load %0 : !llvm.ptr -> i32 +// CHECK-NEXT: llvm.return %1 : i32 +// CHECK-NEXT: } + +// ----- + +llvm.mlir.global @number(7 : i32) : i32 + +llvm.func @f1() -> i32 + +llvm.func @f2() -> i32 { + %0 = llvm.call @f1() : () -> i32 + llvm.return %0 : i32 +} + +// ----- +llvm.mlir.global @number() {} : i32 + +llvm.func @f1() -> i32 { + %0 = llvm.mlir.addressof @number : !llvm.ptr + %1 = llvm.load %0 : !llvm.ptr -> i32 + llvm.return %1 : i32 +}