allow function declarations in @llvm.compiler.used

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

allow function declarations in @llvm.compiler.used

Nathan Ridge via cfe-dev
Hi all,

CodeGenModule::addCompilerUsedGlobal() currently asserts if the global being added is a function
declaration.
https://github.com/llvm/llvm-project/blob/474d70b2204ee082854049ad691ccf435863709a/clang/lib/CodeGen/CodeGenModule.cpp#L1883

Is there is any specific requirement that a global being added here must have a definition? Or in other words, what could go wrong if a function declaration was added to @llvm.compiler.used?

The Clang toolchain for HIP language provides a set of device libraries in bitcode format that are linked into the current module being compiled. But Linker::LinkOnlyNeeded causes unused functions to be dropped while linking in the device libraries. I am working on an implementation that requires specific functions to be retained until calls for them are later generated by an LLVM pass in the AMDGPU target. As far as I can see, the simplest way is to add their declarations to @llvm.compiler.used. This has to be done before LinkInModules() is invoked in CodeGenAction.

Sameer.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev