[llvm] 22bc029 - [CodeGen] Avoid repeated hash lookups (NFC) (#125463)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 12:29:37 PST 2025
Author: Kazu Hirata
Date: 2025-02-03T12:29:34-08:00
New Revision: 22bc029e2be51951e2be749bf89a1087beb265b1
URL: https://github.com/llvm/llvm-project/commit/22bc029e2be51951e2be749bf89a1087beb265b1
DIFF: https://github.com/llvm/llvm-project/commit/22bc029e2be51951e2be749bf89a1087beb265b1.diff
LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#125463)
Added:
Modified:
llvm/include/llvm/CodeGen/LiveIntervals.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/LiveIntervals.h b/llvm/include/llvm/CodeGen/LiveIntervals.h
index 540651ea114427c..708917be497ef69 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