Skip to content

Commit 9c11e95

Browse files
committed
[Clang][RISCV] Fix upper bound of RISC-V V type in debug info
The UpperBound of RVV type in debug info should be elements count minus one, as the LowerBound start from zero. Reviewed By: HsiangKai Differential Revision: https://reviews.llvm.org/D115430
1 parent 0060060 commit 9c11e95

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
768768
}
769769

770770
// Element count = (VLENB / SEW) x LMUL
771-
SmallVector<int64_t, 9> Expr(
771+
SmallVector<int64_t, 12> Expr(
772772
// The DW_OP_bregx operation has two operands: a register which is
773773
// specified by an unsigned LEB128 number, followed by a signed LEB128
774774
// offset.
@@ -782,6 +782,8 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
782782
Expr.push_back(llvm::dwarf::DW_OP_div);
783783
else
784784
Expr.push_back(llvm::dwarf::DW_OP_mul);
785+
// Element max index = count - 1
786+
Expr.append({llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
785787

786788
auto *LowerBound =
787789
llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(

clang/test/CodeGen/RISCV/riscv-v-debuginfo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ __rvv_int16m2_t f1(__rvv_int16m2_t arg_0, __rvv_int16m2_t arg_1, int64_t arg_2)
99
}
1010

1111
// !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, DW_OP_con
12-
// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul))
12+
// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
1313

1414
__rvv_int16mf2_t f2(__rvv_int16mf2_t arg_0, __rvv_int16mf2_t arg_1, int64_t arg_2) {
1515
__rvv_int16mf2_t ret;
1616
return ret;
1717
}
1818

1919
// !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, DW_OP_con
20-
// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_div))
20+
// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 1, DW_OP_minus))
2121

2222
__rvv_int32mf2_t f3(__rvv_int32mf2_t arg_0, __rvv_int32mf2_t arg_1, int64_t arg_2) {
2323
__rvv_int32mf2_t ret;
2424
return ret;
2525
}
2626

2727
// !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, DW_OP_con
28-
// DEBUGINFO: stu, 4, DW_OP_div, DW_OP_constu, 2, DW_OP_div))
28+
// DEBUGINFO: stu, 4, DW_OP_div, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 1, DW_OP_minus))

0 commit comments

Comments
 (0)