[llvm] [SPIRV] Do not emit @llvm.compiler.used (PR #162678)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 9 09:09:26 PDT 2025


================
@@ -2028,9 +2029,13 @@ Instruction *SPIRVEmitIntrinsics::visitUnreachableInst(UnreachableInst &I) {
 
 void SPIRVEmitIntrinsics::processGlobalValue(GlobalVariable &GV,
                                              IRBuilder<> &B) {
-  // Skip special artifical variable llvm.global.annotations.
-  if (GV.getName() == "llvm.global.annotations")
+  // Skip special artifical variables
+  static const StringSet<> ArtificialGlobals{"llvm.global.annotations",
+                                             "llvm.compiler.used"};
----------------
jmmartinez wrote:

I wanted to ask in fact: when `llvm.used` something should prevent the linker or any other tool after the compiler from dropping globals references by it.

I don't think that this would happen for spirv, but I'm not very familiar with the target yet. If this won't happen I'll add a test for `@llvm.used` and update the PR.

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


More information about the llvm-commits mailing list