summaryrefslogtreecommitdiffstats
path: root/mlir/test/Dialect/LLVMIR
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2019-12-03 00:26:13 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-12-03 00:26:44 -0800
commitfdbb99cd6252b890b4deff7de0f67a6577c370b3 (patch)
treeaa97fac30d90826b8badea27be35b356da0a1862 /mlir/test/Dialect/LLVMIR
parent16a9296bc8a662516a7a7d9b13a2c038a39bbb1e (diff)
downloadbcm5719-llvm-fdbb99cd6252b890b4deff7de0f67a6577c370b3.tar.gz
bcm5719-llvm-fdbb99cd6252b890b4deff7de0f67a6577c370b3.zip
Add linkage support to LLVMFuncOp
A recent commit introduced the Linkage attribute to the LLVM dialect and used it in the Global Op. Also use it in LLVMFuncOp. As per LLVM Language Reference, if the linkage attribute is omitted, the function is assumed to have external linkage. PiperOrigin-RevId: 283493299
Diffstat (limited to 'mlir/test/Dialect/LLVMIR')
-rw-r--r--mlir/test/Dialect/LLVMIR/func.mlir35
1 files changed, 35 insertions, 0 deletions
diff --git a/mlir/test/Dialect/LLVMIR/func.mlir b/mlir/test/Dialect/LLVMIR/func.mlir
index 6955cd0397a..2db5d3553e9 100644
--- a/mlir/test/Dialect/LLVMIR/func.mlir
+++ b/mlir/test/Dialect/LLVMIR/func.mlir
@@ -92,6 +92,27 @@ module {
// CHECK: llvm.func @variadic_args(!llvm.i32, !llvm.i32, ...)
llvm.func @variadic_args(!llvm.i32, !llvm.i32, ...)
+
+ //
+ // Check that functions can have linkage attributes.
+ //
+
+ // CHECK: llvm.func internal
+ llvm.func internal @internal_func() {
+ llvm.return
+ }
+
+ // CHECK: llvm.func weak
+ llvm.func weak @weak_linkage() {
+ llvm.return
+ }
+
+ // Omit the `external` linkage, which is the default, in the custom format.
+ // Check that it is present in the generic format using its numeric value.
+ //
+ // CHECK: llvm.func @external_func
+ // GENERIC: linkage = 10
+ llvm.func external @external_func()
}
// -----
@@ -188,3 +209,17 @@ module {
// expected-error@+1 {{variadic arguments must be in the end of the argument list}}
llvm.func @variadic_inside(%arg0: !llvm.i32, ..., %arg1: !llvm.i32)
}
+
+// -----
+
+module {
+ // expected-error@+1 {{external functions must have 'external' or 'extern_weak' linkage}}
+ llvm.func internal @internal_external_func()
+}
+
+// -----
+
+module {
+ // expected-error@+1 {{functions cannot have 'common' linkage}}
+ llvm.func common @common_linkage_func()
+}
OpenPOWER on IntegriCloud