[clang] Correctly link and optimize device libraries with -mlink-builtin-bitcode (PR #69371)

Jacob Lambert via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 17 14:26:04 PDT 2023


lamb-j wrote:

> This approach assumes that whatever the function call was transformed into also exists in the same library, which isn't necessarily true.

True, good point. But I don't think it's necessarily due to this approach, but more of how AMDGPULibCalls is implemented. It seems like the instruction folding implementations are assuming the definitions of the new functions they're inserting will be linked in at a later point?

Previously we were doing it via a separate _llvm-link_ call to re-link all the device libraries. With this approach, we're doing it as part of the clang optimization pipeline, and would no longer need that extra link step.

Maybe this approach could be a solution for the time being? With a longer term solution being to think more carefully about the legality of AMDGPULibCalls inserting function calls that may or may not exist? Maybe device library calls are the exception?



https://github.com/llvm/llvm-project/pull/69371


More information about the cfe-commits mailing list