[PATCH] D67509: [CUDA][HIP] Fix hostness of defaulted constructor

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 19 09:29:41 PDT 2019


yaxunl marked an inline comment as done.
yaxunl added inline comments.


================
Comment at: lib/Sema/SemaCUDA.cpp:273-274
+                 MemberDecl->hasAttr<CUDAHostAttr>();
+  if (!InClass || hasAttr)
+    return false;
+
----------------
tra wrote:
> A comment here would be helpful.
> 
> I think the intent here is to look for implicit special members with *explicitly* set attributes.
> We have number of cases where we set H/D attributes implicitly. I'm not sure whether we ever see any of them here, but if we do, it will sneak through this check. I think a check for whether the attribute is explicit would be prudent.
will add the comment.

I intentionally omitted check for explicit attr because I noticed the same special member is inferred twice. Each time it is added the same attrs, which cause them to have two `__host__` and two `__device__` attrs. By checking if attrs exist (not just explicit attrs) we can avoid duplicate attrs. I tested this with real machine learning frameworks and did not see issues.


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

https://reviews.llvm.org/D67509





More information about the cfe-commits mailing list