Skip to content

[AsmParser] Allow comparing ValIDs with different kinds #119834

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
Dec 13, 2024
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
11 changes: 7 additions & 4 deletions llvm/include/llvm/AsmParser/LLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ namespace llvm {
}

bool operator<(const ValID &RHS) const {
assert(Kind == RHS.Kind && "Comparing ValIDs of different kinds");
assert((((Kind == t_LocalID || Kind == t_LocalName) &&
(RHS.Kind == t_LocalID || RHS.Kind == t_LocalName)) ||
((Kind == t_GlobalID || Kind == t_GlobalName) &&
(RHS.Kind == t_GlobalID || RHS.Kind == t_GlobalName))) &&
"Comparing ValIDs of different kinds");
if (Kind != RHS.Kind)
return Kind < RHS.Kind;
if (Kind == t_LocalID || Kind == t_GlobalID)
return UIntVal < RHS.UIntVal;
assert((Kind == t_LocalName || Kind == t_GlobalName ||
Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) &&
"Ordering not defined for this ValID kind yet");
return StrVal < RHS.StrVal;
}
};
Expand Down
23 changes: 23 additions & 0 deletions llvm/test/Assembler/pr119818.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -S < %s | FileCheck %s

@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

define void @vm_exec_core() {
; CHECK-LABEL: define void @vm_exec_core() {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: br label %[[BLOCK:.*]]
; CHECK: [[BLOCK]]:
; CHECK-NEXT: br label %[[BB0:.*]]
; CHECK: [[BB0]]:
; CHECK-NEXT: ret void
;
entry:
br label %block

block:
br label %0

0:
ret void
}
Loading