Skip to content

Commit a25b2ba

Browse files
authored
[AsmParser] Allow comparing ValIDs with different kinds (#119834)
This patch allows comparing `t_[Local|Global]ID` with `t_[Local|Global]Name`. Closes #119818.
1 parent 07aab4a commit a25b2ba

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

llvm/include/llvm/AsmParser/LLParser.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,15 @@ namespace llvm {
9191
}
9292

9393
bool operator<(const ValID &RHS) const {
94-
assert(Kind == RHS.Kind && "Comparing ValIDs of different kinds");
94+
assert((((Kind == t_LocalID || Kind == t_LocalName) &&
95+
(RHS.Kind == t_LocalID || RHS.Kind == t_LocalName)) ||
96+
((Kind == t_GlobalID || Kind == t_GlobalName) &&
97+
(RHS.Kind == t_GlobalID || RHS.Kind == t_GlobalName))) &&
98+
"Comparing ValIDs of different kinds");
99+
if (Kind != RHS.Kind)
100+
return Kind < RHS.Kind;
95101
if (Kind == t_LocalID || Kind == t_GlobalID)
96102
return UIntVal < RHS.UIntVal;
97-
assert((Kind == t_LocalName || Kind == t_GlobalName ||
98-
Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) &&
99-
"Ordering not defined for this ValID kind yet");
100103
return StrVal < RHS.StrVal;
101104
}
102105
};

llvm/test/Assembler/pr119818.ll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S < %s | FileCheck %s
3+
4+
@vm_exec_core.insns_address_table = internal constant [2 x ptr] [ptr blockaddress(@vm_exec_core, %0), ptr blockaddress(@vm_exec_core, %block)], align 16
5+
6+
define void @vm_exec_core() {
7+
; CHECK-LABEL: define void @vm_exec_core() {
8+
; CHECK-NEXT: [[ENTRY:.*:]]
9+
; CHECK-NEXT: br label %[[BLOCK:.*]]
10+
; CHECK: [[BLOCK]]:
11+
; CHECK-NEXT: br label %[[BB0:.*]]
12+
; CHECK: [[BB0]]:
13+
; CHECK-NEXT: ret void
14+
;
15+
entry:
16+
br label %block
17+
18+
block:
19+
br label %0
20+
21+
0:
22+
ret void
23+
}

0 commit comments

Comments
 (0)