[PATCH] D17738: [NVPTX] Fix function identifiers that are invalid in PTX and a bug fix for the case of name collisions.

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 16:13:47 PST 2017

hfinkel added a comment.

In https://reviews.llvm.org/D17738#416060, @rnk wrote:

> In https://reviews.llvm.org/D17738#367459, @rafael wrote:
> > The real stable solution I think is for the IR name to be the final
> >  name. No further mangling involved. It will take a lot of work to get
> >  there, but we can avoid making the situation worse.
> The problem there is that we would have to make the IR symbol renamer not append '.N' when renaming symbols with name collisions. Until then, we need something like this.
> I thought we used to have machinery in our assembler for mangling away invalid characters. Did you remove that stuff?

How would we like to move forward here?

What @rafael said, that we should not re-mangle IR names, sounds appealing. This holds obvious tooling advantages. It is also true that we need some way to generate unique symbol names that does not interfere with existing mangling schemes. This means that we need to have some character that is not in `[A-Za-z0-9_]`, and is not `@` (because that's used by ELF symbol versioning). `?$@'` are used by MSVC mangling. PTX allows only `[A-Za-z0-9_$]` (and also `%`, but only as the first character, so that doesn't help). Unfortunately, this does not seem to leave anything we can use (we can use '$' for PTX, but not for MSVC). How do we want to move forward here?

One option is that we add a function to LLVM get an available separator character, which can default to '.', but we set to '$' for nvptx, and use that for generating new names at the IR level. Thoughts?


More information about the llvm-commits mailing list