[llvm] a25b2ba - [AsmParser] Allow comparing ValIDs with different kinds (#119834)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 04:10:10 PST 2024
Author: Yingwei Zheng
Date: 2024-12-13T20:10:06+08:00
New Revision: a25b2ba782dd5839492b135518f0a58d4a19e1f9
URL: https://github.com/llvm/llvm-project/commit/a25b2ba782dd5839492b135518f0a58d4a19e1f9
DIFF: https://github.com/llvm/llvm-project/commit/a25b2ba782dd5839492b135518f0a58d4a19e1f9.diff
LOG: [AsmParser] Allow comparing ValIDs with different kinds (#119834)
This patch allows comparing `t_[Local|Global]ID` with
`t_[Local|Global]Name`.
Closes https://github.com/llvm/llvm-project/issues/119818.
Added:
llvm/test/Assembler/pr119818.ll
Modified:
llvm/include/llvm/AsmParser/LLParser.h
Removed:
################################################################################
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
diff erent 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
diff erent 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..568648424e4ac6
--- /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, %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
+}
More information about the llvm-commits
mailing list