aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorKai Nacke <kai.peter.nacke@ibm.com>2024-04-17 16:07:35 -0400
committerGitHub <noreply@github.com>2024-04-17 16:07:35 -0400
commitd0c51f7d5496015ce410cc758a7caf976ffaaec7 (patch)
tree0e182af42209b3751e0a76d011ad25f47ad0cf3b /llvm/lib/CodeGen/MachineBasicBlock.cpp
parent2583b2eea4a509424e5e5f51dffedd9beede76a3 (diff)
downloadllvm-d0c51f7d5496015ce410cc758a7caf976ffaaec7.zip
llvm-d0c51f7d5496015ce410cc758a7caf976ffaaec7.tar.gz
llvm-d0c51f7d5496015ce410cc758a7caf976ffaaec7.tar.bz2
[LiveIns] Improve recomputeLiveIns() (#88951)
Some small changes to recomputeLiveIns() to improve performance: - Instead of copying the list of old live-ins, and then clearing them, a new method swaps the list for an empty one. - getLiveIns() now returns a constant reference to the list As result, the list-data is never copied. Depending on the implementation details of the vector container, it can also save calls to allocate and deallocate memory. I see a small improvement on CTMark with these changes. --------- Co-authored-by: Nikita Popov <github@npopov.com>
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index b2114c2..0bd5f09 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1728,6 +1728,12 @@ void MachineBasicBlock::clearLiveIns() {
LiveIns.clear();
}
+void MachineBasicBlock::clearLiveIns(
+ std::vector<RegisterMaskPair> &OldLiveIns) {
+ assert(OldLiveIns.empty() && "Vector must be empty");
+ std::swap(LiveIns, OldLiveIns);
+}
+
MachineBasicBlock::livein_iterator MachineBasicBlock::livein_begin() const {
assert(getParent()->getProperties().hasProperty(
MachineFunctionProperties::Property::TracksLiveness) &&