Skip to content

Commit 53f348a

Browse files
maarquitos14sys-ce-bb
authored andcommitted
Don't call getName() on literal structs. (#2499)
Signed-off-by: Marcos Maronas <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@0d83f2233e1f7f6
1 parent c857425 commit 53f348a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

llvm-spirv/lib/SPIRV/SPIRVUtil.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,11 @@ bool getParameterTypes(Function *F, SmallVectorImpl<Type *> &ArgTys,
806806
HasSret = true;
807807
unsigned AS = Arg.getType()->getPointerAddressSpace();
808808
if (auto *STy = dyn_cast<StructType>(Ty))
809-
ArgTys.push_back(
810-
TypedPointerType::get(GetStructType(STy->getName()), AS));
809+
if (STy->hasName())
810+
ArgTys.push_back(
811+
TypedPointerType::get(GetStructType(STy->getName()), AS));
812+
else
813+
ArgTys.push_back(TypedPointerType::get(STy, AS));
811814
else
812815
ArgTys.push_back(TypedPointerType::get(Ty, AS));
813816
} 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)