Skip to content

Commit 0d83f22

Browse files
authored
Don't call getName() on literal structs. (#2499)
Signed-off-by: Marcos Maronas <[email protected]>
1 parent 14301c2 commit 0d83f22

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,11 @@ bool getParameterTypes(Function *F, SmallVectorImpl<Type *> &ArgTys,
804804
HasSret = true;
805805
unsigned AS = Arg.getType()->getPointerAddressSpace();
806806
if (auto *STy = dyn_cast<StructType>(Ty))
807-
ArgTys.push_back(
808-
TypedPointerType::get(GetStructType(STy->getName()), AS));
807+
if (STy->hasName())
808+
ArgTys.push_back(
809+
TypedPointerType::get(GetStructType(STy->getName()), AS));
810+
else
811+
ArgTys.push_back(TypedPointerType::get(STy, AS));
809812
else
810813
ArgTys.push_back(TypedPointerType::get(Ty, AS));
811814
} else {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
;; This test checks if functions in LLVM IR generated from OpenCL_CPP sources
2+
;; including unnamed structs are correctly translated to SPIR-V.
3+
4+
; RUN: llvm-as %s -o %t.bc
5+
; RUN: llvm-spirv %t.bc -o %t.spv
6+
; RUN: spirv-val %t.spv
7+
8+
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
9+
target triple = "spir-unknown-unknown"
10+
11+
%opencl.event_t = type opaque
12+
13+
declare spir_func void @_ZNKSt7complexIfE5__repEv(ptr addrspace(4) dead_on_unwind noalias writable sret({ float, float }) align 4)
14+
15+
!spirv.Source = !{!0}
16+
17+
!0 = !{i32 4, i32 100000}

0 commit comments

Comments
 (0)