yaxunl marked an inline comment as done.
yaxunl added inline comments.
================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1099-1108
+ auto *FD = const_cast<NamedDecl *>((ND));
+ if (auto *TD = cast<FunctionDecl>(FD)->getPrimaryTemplate())
+ FD = TD->getTemplatedDecl();
+ auto OldDeclName = FD->getDeclName();
+ auto NewNameStr = std::string("__device_stub__") +
OldDeclName.getAsString();
+ auto *NewId = &Context.Idents.get(NewNameStr);
+ auto NewDeclName = DeclarationName(NewId);
----------------
tra wrote:
> On one hand I like this patch variant much better than the one that changed
> the mangling itself.
> On the other hand this code appears to reply on implementation details. I.e.
> we're setting new name on `FD` which may or may not be the same as `ND`, but
> we're always passing `ND` to `getMangledNameImpl()`.
>
> Perhaps we could implement name-tweaking as another `MultiVersionKind` which
> we already plumb into getMangledNameImpl() and which allows changing the name
> for target attributes & features.
>
>
The mangled name of an instantiated template function does not depends on its
own name, but on the template. If we do not want to depend on this
implementation detail, it seems I have to clone the template and instantiate
from the clone.
MultiVersion does not help us here since it only appends .postfix to mangled
name. The obstacle we are facing is how to change the unmangled name.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68578/new/
https://reviews.llvm.org/D68578
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits