Skip to content

Commit a9f8fed

Browse files
KornevNikitavmaksimo
authored andcommitted
Fix DISubrange translation
If there is count field in DISubrange, then lowerBound may not be equal to zero. Original commit: KhronosGroup/SPIRV-LLVM-Translator@984ce6e
1 parent 7d1609c commit a9f8fed

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

llvm-spirv/lib/SPIRV/SPIRVToLLVMDbgTran.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ SPIRVToLLVMDbgTran::transTypeArray(const SPIRVExtInst *DebugInst) {
224224
if (!getDbgInst<SPIRVDebug::DebugInfoNone>(Ops[I])) {
225225
SPIRVConstant *C = BM->get<SPIRVConstant>(Ops[I]);
226226
int64_t Count = static_cast<int64_t>(C->getZExtIntValue());
227-
Subscripts.push_back(Builder.getOrCreateSubrange(0, Count));
227+
C = BM->get<SPIRVConstant>(Ops[Ops.size() / 2 + I]);
228+
int64_t LowerBound = static_cast<int64_t>(C->getZExtIntValue());
229+
Subscripts.push_back(Builder.getOrCreateSubrange(LowerBound, Count));
228230
TotalCount *= static_cast<uint64_t>(Count);
229231
continue;
230232
}

llvm-spirv/test/DebugInfo/DebugInfoSubrange.ll

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
; CHECK-LLVM: [[#SubrangeExpr1]] = !{![[#SubrangeExpr2:]]}
3030
; CHECK-LLVM: ![[#SubrangeExpr2]] = !DISubrange(lowerBound: !DIExpression(), upperBound: !DIExpression())
3131

32+
; CHECK-LLVM: !DISubrange(count: 1000, lowerBound: 1)
33+
3234
; ModuleID = 'DebugInfoSubrangeUpperBound.bc'
3335
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024"
3436
target triple = "spir64-unknown-unknown"
@@ -38,11 +40,12 @@ target triple = "spir64-unknown-unknown"
3840
%structtype2 = type { i64, i64, i64 }
3941

4042
; Function Attrs: noinline nounwind
41-
define spir_kernel void @__omp_offloading_811_198142f_random_fill_sp_l25(%structtype* byval(%structtype) %"ascast$val") #0 !kernel_arg_addr_space !9 !kernel_arg_access_qual !10 !kernel_arg_type !11 !kernel_arg_type_qual !12 !kernel_arg_base_type !11 {
43+
define spir_kernel void @__omp_offloading_811_198142f_random_fill_sp_l25(%structtype* byval(%structtype) %"ascast$val", [1000 x i32] addrspace(1)* noalias %"ascastB$val") #0 !kernel_arg_addr_space !9 !kernel_arg_access_qual !10 !kernel_arg_type !11 !kernel_arg_type_qual !12 !kernel_arg_base_type !11 {
4244
newFuncRoot:
4345
%.ascast = bitcast %structtype* %"ascast$val" to %"QNCA_a0$float"*
4446
call void @llvm.dbg.value(metadata %"QNCA_a0$float"* %.ascast, metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !27
4547
call void @llvm.dbg.value(metadata %"QNCA_a0$float"* %.ascast, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !42
48+
call void @llvm.dbg.value(metadata [1000 x i32] addrspace(1)* %"ascastB$val", metadata !47, metadata !DIExpression(DW_OP_deref)), !dbg !56
4649
ret void
4750
}
4851

@@ -106,3 +109,12 @@ attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
106109
!40 = !{!38}
107110
!41 = !DIBasicType(name: "INTEGER*8", size: 64, encoding: DW_ATE_signed)
108111
!42 = !DILocation(line: 15, column: 67, scope: !29)
112+
!43 = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed)
113+
!44 = !{}
114+
!45 = !DISubroutineType(types: !44)
115+
!46 = distinct !DISubprogram(name: "test_target_map_array_default_IP_test_array_map_no_map_type_.DIR.OMP.TARGET.340.split", scope: !3, file: !3, line: 32, type: !45, scopeLine: 32, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !2)
116+
!47 = !DILocalVariable(name: "compute_array", scope: !46, file: !3, line: 27, type: !48)
117+
!48 = !DICompositeType(tag: DW_TAG_array_type, baseType: !43, elements: !49)
118+
!49 = !{!50}
119+
!50 = !DISubrange(count: 1000, lowerBound: 1)
120+
!56 = !DILocation(line: 27, column: 24, scope: !46)

0 commit comments

Comments
 (0)