[PATCH] D125904: [Cuda] Use fallback method to mangle externalized decls if no CUID given

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 05:08:59 PDT 2022


jhuber6 added a comment.

In D125904#3532608 <https://reviews.llvm.org/D125904#3532608>, @tra wrote:

> That said, I would consider compiling the same source with different preprocessor options to be a legitimate use case that we should support. 
> Explicitly passing cuid would work as a workaround in those cases, so it's not a major issue if we can't make it work out of the box without explicit cuid.

I could try to find a way to include the preprocessor options. It might be a bit more difficult to make it stable however (unless we just append the whole string).



================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6845
+    }
+    OS << llvm::format("%x", ID.getFile()) << llvm::format("%x", ID.getDevice())
+       << PLoc.getLine();
----------------
tra wrote:
> Considering that the file name may have arbitrary symbols in it, that may result in a symbol name that we can't really use.
> I'd print a hash of the (finename+device+line) -- that would guarantee that we know there are no funky characters in the suffix.
> 
> I'm also not sure if the line number makes any difference here. There's no need to differentiate between symbols within the same TU within the same compilation, only across different compilations and for that filename+device should be sufficient.
What we're using here is basically just the file's integer index on a Unix system, so it'll just be a hex number at the end of the day, the filename will look something like
```
foo__static__18a43f325834
```

Yeah, I can remove the line number. I'm not a fan of how it makes the symbol names change if you just add some white-space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125904



More information about the cfe-commits mailing list