mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 21:35:07 +00:00
IR: Allow MDSubrange to have 'count: -1'
It turns out that `count: -1` is a special value indicating an empty array, such as `Values` in: struct T { unsigned Count; int Values[]; }; Handle it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229769 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f89d9b1c75
commit
c2c5e48ad5
lib/AsmParser
test/Assembler
unittests/IR
@ -3276,7 +3276,7 @@ bool LLParser::ParseGenericDebugNode(MDNode *&Result, bool IsDistinct) {
|
||||
/// ::= !MDSubrange(count: 30, lowerBound: 2)
|
||||
bool LLParser::ParseMDSubrange(MDNode *&Result, bool IsDistinct) {
|
||||
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
|
||||
REQUIRED(count, MDUnsignedField, (0, UINT64_MAX >> 1)); \
|
||||
REQUIRED(count, MDSignedField, (-1, -1, INT64_MAX)); \
|
||||
OPTIONAL(lowerBound, MDSignedField, );
|
||||
PARSE_MD_FIELDS();
|
||||
#undef VISIT_MD_FIELDS
|
||||
|
@ -1,4 +1,7 @@
|
||||
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: [[@LINE+1]]:25: error: expected unsigned integer
|
||||
!0 = !MDSubrange(count: -3)
|
||||
; CHECK-NOT: error
|
||||
!0 = !MDSubrange(count: -1)
|
||||
|
||||
; CHECK: <stdin>:[[@LINE+1]]:25: error: value for 'count' too small, limit is -1
|
||||
!0 = !MDSubrange(count: -2)
|
||||
|
14
test/Assembler/mdsubrange-empty-array.ll
Normal file
14
test/Assembler/mdsubrange-empty-array.ll
Normal file
@ -0,0 +1,14 @@
|
||||
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
|
||||
; RUN: verify-uselistorder %s
|
||||
|
||||
; CHECK: !named = !{!0, !0, !1, !2}
|
||||
!named = !{!0, !1, !2, !3}
|
||||
|
||||
; CHECK: !0 = !MDSubrange(count: -1)
|
||||
; CHECK-NEXT: !1 = !MDSubrange(count: -1, lowerBound: 4)
|
||||
; CHECK-NEXT: !2 = !MDSubrange(count: -1, lowerBound: -5)
|
||||
!0 = !MDSubrange(count: -1)
|
||||
!1 = !MDSubrange(count: -1, lowerBound: 0)
|
||||
|
||||
!2 = !MDSubrange(count: -1, lowerBound: 4)
|
||||
!3 = !MDSubrange(count: -1, lowerBound: -5)
|
@ -670,6 +670,14 @@ TEST_F(MDSubrangeTest, get) {
|
||||
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
|
||||
}
|
||||
|
||||
TEST_F(MDSubrangeTest, getEmptyArray) {
|
||||
auto *N = MDSubrange::get(Context, -1, 0);
|
||||
EXPECT_EQ(dwarf::DW_TAG_subrange_type, N->getTag());
|
||||
EXPECT_EQ(-1, N->getCount());
|
||||
EXPECT_EQ(0, N->getLo());
|
||||
EXPECT_EQ(N, MDSubrange::get(Context, -1, 0));
|
||||
}
|
||||
|
||||
typedef MetadataTest MDEnumeratorTest;
|
||||
|
||||
TEST_F(MDEnumeratorTest, get) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user