[MLIR][OpenMP] Add a constraint to the Threadprivate Op
authorKiran Chandramohan <kiran.chandramohan@arm.com>
Fri, 22 Jul 2022 13:03:59 +0000 (13:03 +0000)
committerKiran Chandramohan <kiran.chandramohan@arm.com>
Fri, 22 Jul 2022 13:12:24 +0000 (13:12 +0000)
Add a constraint to ensure that the operand and result of the
threadprivate operation are the same.

Reviewed By: peixin

Differential Revision: https://reviews.llvm.org/D128609

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/test/Dialect/OpenMP/invalid.mlir

index d2a232b0801903b8f59b7883c5c0cb9183b79e6f..b39328be4d618b4f0b717b3d698385337161c1d4 100644 (file)
@@ -1234,7 +1234,8 @@ def AtomicCaptureOp : OpenMP_Op<"atomic.capture",
 // [5.1] 2.21.2 threadprivate Directive
 //===----------------------------------------------------------------------===//
 
-def ThreadprivateOp : OpenMP_Op<"threadprivate"> {
+def ThreadprivateOp : OpenMP_Op<"threadprivate",
+                                [AllTypesMatch<["sym_addr", "tls_addr"]>]> {
   let summary = "threadprivate directive";
   let description = [{
     The threadprivate directive specifies that variables are replicated, with
index 379b8f4bfe1cc09dcf40901c3a8e1dc6070d020b..f1401a7b31954a9a500c711d6e57f823fb6e2efd 100644 (file)
@@ -1419,3 +1419,14 @@ func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {
   }
   return
 }
+
+// -----
+
+func.func @omp_threadprivate() {
+  %1 = llvm.mlir.addressof @_QFsubEx : !llvm.ptr<i32>
+  // expected-error @below {{op failed to verify that all of {sym_addr, tls_addr} have same type}}
+  %2 = omp.threadprivate %1 : !llvm.ptr<i32> -> memref<i32>
+  return
+}
+
+llvm.mlir.global internal @_QFsubEx() : i32