llvm-project
caa2f91e - [clang-repl] Link builtin bitcode into every PTU (#229788)

Commit
7 days ago
[clang-repl] Link builtin bitcode into every PTU (#229788) BackendConsumer::LinkInModules links the -mlink-builtin-bitcode modules into the first module it finalizes and clears the list. The interpreter runs the consumer once per PTU, so only the initial PTU links libdevice. A kernel using device math in a later PTU references undefined `__nv_*` symbols and the PTX JIT rejects it with cudaErrorInvalidPtx. Reload the builtin bitcode for every PTU in incremental mode. The modules get internalized into whatever links them, so each PTU needs its own copy. loadLinkModules now takes a flag to open only those entries, so plain -mlink-bitcode-file inputs are linked once and never reopened. Add a lit test that calls sinf and expf from a kernel (needs a GPU) and a unittest that links one bitcode library as builtin and an empty one as a plain bitcode file, deletes the plain one once the interpreter is up, and checks that two device PTUs define the builtin function rather than declare it.
Author
Parents
Loading