[llvm] [CodeGen] Avoid repeated hash lookups (NFC) (PR #125463)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 2 23:05:14 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/125463
None
>From 3207a796155f435c81ce43c9ca122b0d23ef290a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 2 Feb 2025 22:55:25 -0800
Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC)
---
llvm/include/llvm/CodeGen/LiveIntervals.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index 540651ea114427..708917be497ef6 100644
--- a/llvm/include/llvm/CodeGen/LiveIntervals.h
+++ b/llvm/include/llvm/CodeGen/LiveIntervals.h
@@ -149,8 +149,9 @@ class LiveIntervals {
LiveInterval &createEmptyInterval(Register Reg) {
assert(!hasInterval(Reg) && "Interval already exists!");
VirtRegIntervals.grow(Reg.id());
- VirtRegIntervals[Reg.id()] = createInterval(Reg);
- return *VirtRegIntervals[Reg.id()];
+ auto &Interval = VirtRegIntervals[Reg.id()];
+ Interval = createInterval(Reg);
+ return *Interval;
}
LiveInterval &createAndComputeVirtRegInterval(Register Reg) {
@@ -168,8 +169,9 @@ class LiveIntervals {
/// Interval removal.
void removeInterval(Register Reg) {
- delete VirtRegIntervals[Reg];
- VirtRegIntervals[Reg] = nullptr;
+ auto &Interval = VirtRegIntervals[Reg];
+ delete Interval;
+ Interval = nullptr;
}
/// Given a register and an instruction, adds a live segment from that
More information about the llvm-commits
mailing list