[llvm] Make default size MBB.size() (PR #83526)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 29 21:19:55 PST 2024
https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/83526
No way to do this in C++ directly, so let's reserve 0 as a special value.
>From d8a142126e9cd46d7546e26d8e98d877a3d0b887 Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Fri, 1 Mar 2024 00:19:21 -0500
Subject: [PATCH] Make default size MBB.size()
No way to do this in C++ directly, so let's reserve 0 as a special value.
---
llvm/include/llvm/CodeGen/MachineBasicBlock.h | 2 +-
llvm/lib/CodeGen/MachineBasicBlock.cpp | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
index dc2035fa598c46..99e3e33283472b 100644
--- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h
@@ -1150,7 +1150,7 @@ class MachineBasicBlock
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI,
MCRegister Reg,
const_iterator Before,
- unsigned Neighborhood = 10) const;
+ unsigned Neighborhood = 0) const;
// Debugging methods.
void dump() const;
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 4410fb7ecd23b6..fcb1a7db4bcb20 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1604,12 +1604,16 @@ MachineBasicBlock::getProbabilityIterator(MachineBasicBlock::succ_iterator I) {
/// Search is localised to a neighborhood of
/// Neighborhood instructions before (searching for defs or kills) and N
/// instructions after (searching just for defs) MI.
+/// Special value of 0: Check size of the whole block
MachineBasicBlock::LivenessQueryResult
MachineBasicBlock::computeRegisterLiveness(const TargetRegisterInfo *TRI,
MCRegister Reg, const_iterator Before,
unsigned Neighborhood) const {
unsigned N = Neighborhood;
+ if (!N)
+ N = this->size();
+
// Try searching forwards from Before, looking for reads or defs.
const_iterator I(Before);
for (; I != end() && N > 0; ++I) {
More information about the llvm-commits
mailing list