[llvm] [LLParser] Allow comparing ValIDs with different kinds (PR #119834)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 12 23:45:16 PST 2024
https://github.com/dtcxzyw created https://github.com/llvm/llvm-project/pull/119834
This patch allows comparing `t_[Local|Global]ID` with `t_[Local|Global]Name`.
Closes https://github.com/llvm/llvm-project/issues/119818.
>From 059e4eb6a65629ae9fd236dbe912c18be19e3e65 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: Fri, 13 Dec 2024 15:42:48 +0800
Subject: [PATCH] [LLParser] Allow comparing ValIDs with different kinds
---
llvm/include/llvm/AsmParser/LLParser.h | 11 +++++++----
llvm/test/Assembler/pr119818.ll | 23 +++++++++++++++++++++++
2 files changed, 30 insertions(+), 4 deletions(-)
create mode 100644 llvm/test/Assembler/pr119818.ll
diff --git a/llvm/include/llvm/AsmParser/LLParser.h b/llvm/include/llvm/AsmParser/LLParser.h
index 1ef8b8ffc39660..8b195b028783f0 100644
--- a/llvm/include/llvm/AsmParser/LLParser.h
+++ b/llvm/include/llvm/AsmParser/LLParser.h
@@ -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;
}
};
diff --git a/llvm/test/Assembler/pr119818.ll b/llvm/test/Assembler/pr119818.ll
new file mode 100644
index 00000000000000..38b732f9ec298c
--- /dev/null
+++ b/llvm/test/Assembler/pr119818.ll
@@ -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
+
+ at vm_exec_core.insns_address_table = internal constant [2 x ptr] [ptr blockaddress(@vm_exec_core, %2), ptr blockaddress(@vm_exec_core, %.lr.ph.i2526)], align 16
+
+define void @vm_exec_core() {
+; CHECK-LABEL: define void @vm_exec_core() {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: br [[DOTLR_PH_I2526:label %.*]]
+; CHECK: [[_LR_PH_I2526:.*:]]
+; CHECK-NEXT: br label %[[BB0:.*]]
+; CHECK: [[BB0]]:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %.lr.ph.i2526
+
+.lr.ph.i2526:
+ br label %2
+
+2:
+ ret void
+}
More information about the llvm-commits
mailing list