[PATCH] D116549: [OpenMP][Clang] Allow passing target features in ISA trait for metadirective clause

Saiyedul Islam via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 3 10:46:40 PST 2022


saiislam created this revision.
saiislam added reviewers: jdoerfert, alokmishra.besu, cchen, JonChesterfield.
Herald added subscribers: guansong, yaxunl.
saiislam requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Passing any feature in the device-isa trait which is not supported by the host
was causing a compilation failure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116549

Files:
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp


Index: clang/test/OpenMP/metadirective_implementation_codegen.cpp
===================================================================
--- clang/test/OpenMP/metadirective_implementation_codegen.cpp
+++ clang/test/OpenMP/metadirective_implementation_codegen.cpp
@@ -35,6 +35,9 @@
                                : parallel) default(parallel for)
   for (int i = 0; i < 100; i++)
     ;
+#pragma omp metadirective when(device = {isa("flat-address-space")}               \
+                               : parallel) default(target teams)
+  bar();
 }
 
 // CHECK-LABEL: void @_Z3foov()
@@ -44,6 +47,7 @@
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_5:@.+]] to void
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_6:@.+]] to void
 // CHECK: @__kmpc_fork_call(%struct.ident_t* {{.+}}, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* [[OUTLINED_7:@.+]] to void
+// CHECK: call void @__omp_offloading_{{.*}}()
 // CHECK: ret void
 
 // CHECK: define internal void [[OUTLINED_2]](
@@ -73,4 +77,11 @@
 // NO-CHECK: call void @__kmpc_for_static_fini
 // CHECK: ret void
 
+// CHECK: define internal void @__omp_offloading_
+// CHECK: ...) @__kmpc_fork_teams({{.*}}@.omp_outlined..6
+// CHECK: ret void
+
+// CHECK: define internal void @.omp_outlined..6(
+// CHECK: @_Z3barv
+// CHECK: ret void
 #endif
Index: clang/test/OpenMP/metadirective_implementation_codegen.c
===================================================================
--- clang/test/OpenMP/metadirective_implementation_codegen.c
+++ clang/test/OpenMP/metadirective_implementation_codegen.c
@@ -35,10 +35,14 @@
                                : parallel) default(parallel for)
   for (int i = 0; i < 100; i++)
     ;
+#pragma omp metadirective when(device = {isa("flat-address-space")}               \
+                               : parallel) default(target teams)
+  bar();
 }
 
 // CHECK: void @foo()
 // CHECK-COUNT-6: ...) @__kmpc_fork_call(
+// CHECK: call void @__omp_offloading_{{.*}}()
 // CHECK: ret void
 
 // CHECK: define internal void @.omp_outlined.(
@@ -68,4 +72,11 @@
 // NO-CHECK: call void @__kmpc_for_static_fini
 // CHECK: ret void
 
+// CHECK: define internal void @__omp_offloading_
+// CHECK: ...) @__kmpc_fork_teams({{.*}}@.omp_outlined..6
+// CHECK: ret void
+
+// CHECK: define internal void @.omp_outlined..6(
+// CHECK: @bar
+// CHECK: ret void
 #endif
Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -2529,7 +2529,9 @@
     TPA.Revert();
     // End of the first iteration. Parser is reset to the start of metadirective
 
-    TargetOMPContext OMPCtx(ASTContext, /* DiagUnknownTrait */ nullptr,
+    std::function<void(StringRef)> DiagUnknownTrait = [this, Loc](
+                                                        StringRef ISATrait) {};
+    TargetOMPContext OMPCtx(ASTContext, std::move(DiagUnknownTrait),
                             /* CurrentFunctionDecl */ nullptr,
                             ArrayRef<llvm::omp::TraitProperty>());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116549.397104.patch
Type: text/x-patch
Size: 3236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220103/1c1ea559/attachment.bin>


More information about the cfe-commits mailing list