Skip to content

[SPIR-V] Stop re-writing SPIR-V type map #3856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion llvm-spirv/lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,10 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
}

SPIRVType *LLVMToSPIRVBase::mapType(Type *T, SPIRVType *BT) {
TypeMap[T] = BT;
auto EmplaceStatus = TypeMap.try_emplace(T, BT);
(void)EmplaceStatus;
// TODO: Uncomment the assertion, once the type mapping issue is resolved
// assert(EmplaceStatus.second && "The type was already added to the map");
SPIRVDBG(dbgs() << "[mapType] " << *T << " => "; spvdbgs() << *BT << '\n');
return BT;
}
Expand Down
30 changes: 30 additions & 0 deletions llvm-spirv/test/pointer_type_mapping.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv %t.bc --spirv-ext=+all -spirv-text -o %t
; RUN: FileCheck < %t %s

; CHECK: Name [[#NAME:]] "struct._ZTS6Object.Object"
; CHECK-COUNT-1: TypeStruct [[#NAME]]
; TODO add check count one and remove unused, when the type mapping bug is fixed
; CHECK: TypePointer [[#UNUSED:]] {{.*}} [[#NAME]]
; CHECK: TypePointer [[#PTRTY:]] {{.*}} [[#NAME]]
; CHECK: FunctionParameter [[#PTRTY]]
; CHECK-NOT: FunctionParameter [[#UNUSED]]

; ModuleID = 'sycl_test.bc'
source_filename = "sycl_test.cpp"
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
target triple = "spir64-unknown-unknown-sycldevice"

%struct._ZTS4Args.Args = type { %struct._ZTS6Object.Object addrspace(4)* }
%struct._ZTS6Object.Object = type { i32 (%struct._ZTS6Object.Object addrspace(4)*, i32)* }

; Function Attrs: convergent norecurse nounwind mustprogress
define dso_local spir_func i32 @_Z9somefunc0P4Args(%struct._ZTS4Args.Args addrspace(4)* %a, %struct._ZTS6Object.Object addrspace(4)* %b) {
entry:
ret i32 0
}

!opencl.spir.version = !{!0}
!spirv.Source = !{!1}
!0 = !{i32 1, i32 2}
!1 = !{i32 4, i32 100000}