File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed
Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -139,8 +139,8 @@ void SPIRVAsmPrinter::emitEndOfAsmFile(Module &M) {
139139// anymore.
140140void SPIRVAsmPrinter::cleanUp (Module &M) {
141141 // Verifier disallows uses of intrinsic global variables.
142- for (StringRef GVName : { " llvm.global_ctors " , " llvm.global_dtors " ,
143- " llvm.used " , " llvm.compiler .used" }) {
142+ for (StringRef GVName :
143+ { " llvm.global_ctors " , " llvm.global_dtors " , " llvm .used" }) {
144144 if (GlobalVariable *GV = M.getNamedGlobal (GVName))
145145 GV->setName (" " );
146146 }
Original file line number Diff line number Diff line change 1717#include " SPIRVTargetMachine.h"
1818#include " SPIRVUtils.h"
1919#include " llvm/ADT/DenseSet.h"
20+ #include " llvm/ADT/StringSet.h"
2021#include " llvm/IR/IRBuilder.h"
2122#include " llvm/IR/InstIterator.h"
2223#include " llvm/IR/InstVisitor.h"
@@ -2028,9 +2029,13 @@ Instruction *SPIRVEmitIntrinsics::visitUnreachableInst(UnreachableInst &I) {
20282029
20292030void SPIRVEmitIntrinsics::processGlobalValue (GlobalVariable &GV,
20302031 IRBuilder<> &B) {
2031- // Skip special artifical variable llvm.global.annotations.
2032- if (GV.getName () == " llvm.global.annotations" )
2032+ // Skip special artificial variables.
2033+ static const StringSet<> ArtificialGlobals{" llvm.global.annotations" ,
2034+ " llvm.compiler.used" };
2035+
2036+ if (ArtificialGlobals.contains (GV.getName ()))
20332037 return ;
2038+
20342039 Constant *Init = nullptr ;
20352040 if (hasInitializer (&GV)) {
20362041 // Deduce element type and store results in Global Registry.
Original file line number Diff line number Diff line change 1+ ; RUN: llc -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
2+ ; RUN: %if spirv-tools %{ llc -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+ ; RUN: llc -verify-machineinstrs -mtriple=spirv-unknown-vulkan %s -o - | FileCheck %s
4+ ; RUN: %if spirv-tools %{ llc -mtriple=spirv-unknown-vulkan %s -o - -filetype=obj | spirv-val %}
5+
6+ ; Verify that llvm.compiler.used is not lowered.
7+ ; CHECK: OpName %{{[0-9]+}} "unused"
8+ ; CHECK-NOT: OpName %{{[0-9]+}} "llvm.compiler.used"
9+
10+ ; Check that the type of llvm.compiler.used is not emitted too.
11+ ; CHECK-NOT: OpTypeArray
12+
13+ @unused = private addrspace (3 ) global i32 0
14+ @llvm.compiler.used = appending addrspace (2 ) global [1 x ptr addrspace (4 )] [ptr addrspace (4 ) addrspacecast (ptr addrspace (3 ) @unused to ptr addrspace (4 ))]
15+
16+ define spir_func void @foo () {
17+ entry:
18+ ret void
19+ }
You can’t perform that action at this time.
0 commit comments