[PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2)

Joel E. Denny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 20 21:16:32 PDT 2020


jdenny marked 2 inline comments as done.
jdenny added inline comments.


================
Comment at: clang/lib/Parse/ParseOpenMP.cpp:3067-3068
+  unsigned Type = getOpenMPSimpleClauseType(OMPC_map, PP.getSpelling(Tok));
+  if (Type < OMPC_MAP_MODIFIER_unknown)
+    return OMPC_MAP_MODIFIER_unknown;
+  return static_cast<OpenMPMapModifierKind>(Type);
----------------
ABataev wrote:
> jdenny wrote:
> > ABataev wrote:
> > > Why do we need this?
> > When called with `OMPC_map`, `getOpenMPSimpleClauseType` can return either an `OpenMPMapModifierKind` or `OpenMPMapClauseKind` depending on `Tok`.  Thus, without this change, both `isMapModifier` and `isMapType` can return either of those despite the difference in their names and documentation.
> > 
> > I found that, when `Parser::parseMapTypeModifiers` ignores `present` as if it's not a modifier because OpenMP < 5.1, then `isMapType` later returns `OMPC_MAP_MODIFIER_present` and causes the following assert to fail in `Sema::ActOnOpenMPVarListClause`:
> > 
> > ```
> > assert(0 <= ExtraModifier && ExtraModifier <= OMPC_MAP_unknown &&
> >            "Unexpected map modifier.");
> > ```
> > 
> > To me, the most obvious solution is to fix `isMapType` and `isMapModifier`.  Fortunately, looking in `OpenMPKinds.h`, the enumerator values in `OpenMPMapModifierKind` and `OpenMPMapClauseKind` are disjoint so we can tell which we have.
> Can we have something like:
> ```
> if (LangOpts.OpenMP <= 50 && Type == OMPC_MAP_MODIFIER_present)
>   return OMPC_MAP_MODIFIER_unknown;
> ```
> or extend `getOpenMPSimpleClauseType` function with the version parameter and check there is modifier is allowed and return `unknown` if it is not compatible with provided version?
As far as I can tell, my changes general fix this bug in `isMapType` and `isMapModifier`.  It makes them behave as documented.  The suggestions you're making only fix them for the case of `present`.  Why is that better?


================
Comment at: clang/test/OpenMP/target_data_codegen.cpp:258-260
+// CK1A: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1021]]]
+
+// CK1A: [[MTYPE01:@.+]] = {{.+}}constant [1 x i64] [i64 [[#0x1425]]]
----------------
ABataev wrote:
> Add a comment with interpretaion of the map flags, like `OMP_TO = 0x1 | OMP_FROM=0x2 | OMP_PRESENT = 0x1000 = 0x1003`
Are you asking me to add that comment to every map type encoding appearing in this patch?  Or just this one?



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83061/new/

https://reviews.llvm.org/D83061





More information about the cfe-commits mailing list