[llvm] [GlobalISel] Lazily reserve worklist maps (NFC) (PR #221900)
Cullen Rhodes via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 00:31:35 PDT 2026
https://github.com/c-rhodes created https://github.com/llvm/llvm-project/pull/221900
Small -0.03% geomean improvement on CTMark aarch64-O0-g, but consistent little improvements across the board.
https://llvm-compile-time-tracker.com/compare.php?from=97cbc1e404b980edc58bfbcabb6f1c61793b624b&to=1729db67721b79fcb72469111d543e6df28c1185&stat=instructions:u
Assisted-by: codex
>From 1729db67721b79fcb72469111d543e6df28c1185 Mon Sep 17 00:00:00 2001
From: Cullen Rhodes <cullen.rhodes at arm.com>
Date: Mon, 4 May 2026 10:21:41 +0000
Subject: [PATCH] [GlobalISel] Lazily reserve worklist maps (NFC)
Assisted-by: codex
---
llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h b/llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h
index dba3a8a14480c..709490fcfc0f8 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/GISelWorkList.h
@@ -33,8 +33,6 @@ class GISelWorkList {
#endif
public:
- GISelWorkList() : WorklistMap(N) {}
-
bool empty() const { return WorklistMap.empty(); }
unsigned size() const { return WorklistMap.size(); }
@@ -60,8 +58,8 @@ class GISelWorkList {
// It also asserts if there are any duplicate elements found.
void finalize() {
assert(WorklistMap.empty() && "Expecting empty worklistmap");
- if (Worklist.size() > N)
- WorklistMap.reserve(Worklist.size());
+ if (!Worklist.empty())
+ WorklistMap.reserve(Worklist.size() > N ? Worklist.size() : N);
for (unsigned i = 0; i < Worklist.size(); ++i)
if (!WorklistMap.try_emplace(Worklist[i], i).second)
llvm_unreachable("Duplicate elements in the list");
More information about the llvm-commits
mailing list