[PATCH] D122734: [CUDA][HIP] Fix mangling number for local struct

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 19 11:21:07 PDT 2022


tra added inline comments.


================
Comment at: clang/lib/AST/ASTContext.cpp:11760-11763
+  auto Cutoff = [](unsigned V) { return V > 1 ? V : 1; };
+  if (CUDANameMangleCtx.MangleDeviceNameInHostCompilation)
+    return Cutoff(Res >> 16);
+  return Cutoff(Res & 0xffff);
----------------
rnk wrote:
> rnk wrote:
> > tra wrote:
> > > I think we should change the `MangleNumbers` instead to use uin64_t or, perhaps `unsigned[2]` or even `struct{ unsigned host; unsigned device;}`.
> > > Reducing the max number of anything to just 64K will be prone to failing sooner or later. 
> > IMO it would be simpler to set up a ternary instead of a lambda and two returns:
> >   Res = Cond ? (Res >> 16) : (Res & 0xFFFF);
> >   return Res > 1 ? Res : 1;
> I suspect we could live with a 64K mangling number limit, but that is low enough that we need to put in a check for overflow somewhere.
If we'd produce a reasonable diagnostic for that, it might work. 




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

https://reviews.llvm.org/D122734



More information about the cfe-commits mailing list