[PATCH] D18474: [OPENMP] Enable correct generation of runtime call when target directive is separated from teams directive by multiple curly brackets
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 12 04:19:22 PDT 2016
ABataev added inline comments.
================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4260-4273
@@ -4259,2 +4259,16 @@
+/// \brief look inside a Body stmt for a LF statement discarding any
+/// intervening CompoundStmt's
+template <typename LF>
+const static LF *hasEnclosingOpenMPDirective(const Stmt *Body) {
+ const CompoundStmt *S = nullptr;
+ // keep iterating until we find an LF or not a CompoundStmt or a nullptr
+ while ((S = dyn_cast_or_null<CompoundStmt>(Body)) &&
+ (!dyn_cast_or_null<LF>(Body)))
+ Body = S->body_front();
+
+ return (Body) ? dyn_cast_or_null<LF>(Body) :
+ nullptr;
+}
+
/// \brief Emit the num_teams clause of an enclosed teams directive at the
----------------
I don't like this function at all. We need to add a template function. Each instantiation will produce a new function with almost the same body. MI prepfer to see another solution, like:
```
static const Stmt *ignoreCompoundStmts(const Stmt *Body) {
while (auto *CS = dyn_cast_or_null<CompoundStmt>(Body))
Body = CS->body_front();
return Body;
}
...
if (auto *TeamsDir = dyn_cast<OMPTeamsDirective>(ignoreCompoundStmts(CS.getCapturedStmt()))) {
...
```
Repository:
rL LLVM
http://reviews.llvm.org/D18474
More information about the cfe-commits
mailing list