allow function declarations in @llvm.compiler.used

Hi all,

CodeGenModule::addCompilerUsedGlobal() currently asserts if the global being added is a function
declaration.

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.