[llvm-branch-commits] [OpenMP] Add graph_id and graph_reset clause support (for taskgraph directive) (PR #194048)

Julian Brown via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri May 29 07:22:11 PDT 2026


================
@@ -8541,6 +8541,101 @@ class OMPIsDevicePtrClause final
   }
 };
 
+/// This represents clause 'graph_id' in the '#pragma omp taskgraph"
+/// directives.
+///
+/// \code
+/// #pragma omp taskgraph graph_id(a)
+class OMPGraphIdClause final
+    : public OMPOneStmtClause<llvm::omp::OMPC_graph_id, OMPClause> {
+  friend class OMPClauseReader;
+
+  /// Set condition.
+  void setId(Expr *Id) { setStmt(Id); }
+
+public:
+  /// Build 'graph_id' clause with identifier value \a Id.
+  ///
+  /// \param Id Id value for the clause.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  OMPGraphIdClause(Expr *Id, SourceLocation StartLoc, SourceLocation LParenLoc,
+                   SourceLocation EndLoc)
+      : OMPOneStmtClause(Id, StartLoc, LParenLoc, EndLoc) {}
+
+  /// Build an empty clause.
+  OMPGraphIdClause() : OMPOneStmtClause() {}
+
+  /// Returns condition.
+  Expr *getId() const { return getStmtAs<Expr>(); }
+};
+
+// This represents clause 'graph_reset' in the '#pragma omp taskgraph"
+/// directives.
+///
+/// \code
+/// #pragma omp taskgraph graph_reset(true)
+class OMPGraphResetClause final : public OMPClause {
----------------
jtb20 wrote:

The reason it isn't is because the argument is optional for graph_reset -- although without it, the graph would always be reset, which doesn't seem very useful. All the same, the spec says it can be omitted, so there we are.

I don't think OMPOneStmtClause can have a null stmt, but I could be wrong?

https://github.com/llvm/llvm-project/pull/194048


More information about the llvm-branch-commits mailing list