diff options
| author | Alexis Engelke <engelke@in.tum.de> | 2024-08-07 07:56:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-07 07:56:32 +0200 |
| commit | 41491c77231e9d389ef18593be1fab4f4e810e88 (patch) | |
| tree | f16ef7e53cb75b483c0e4aa401e5190b40ca5988 /llvm/lib/CodeGen/TargetRegisterInfo.cpp | |
| parent | 90e1c292e3745acdd2b89ac9aafdfdaaa7f13f6c (diff) | |
[CodeGen] Allocate RegAllocHints map lazily (#102186)
This hint map is not required whenever a new register is added, in fact,
at -O0, it is not used at all. Growing this map is quite expensive, as
SmallVectors are not trivially copyable.
Grow this map only when hints are actually added to avoid multiple grows
and grows when no hints are added at all.
Diffstat (limited to 'llvm/lib/CodeGen/TargetRegisterInfo.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/TargetRegisterInfo.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetRegisterInfo.cpp b/llvm/lib/CodeGen/TargetRegisterInfo.cpp index ffc8055dd27e..16dab974efac 100644 --- a/llvm/lib/CodeGen/TargetRegisterInfo.cpp +++ b/llvm/lib/CodeGen/TargetRegisterInfo.cpp @@ -421,13 +421,16 @@ bool TargetRegisterInfo::getRegAllocationHints( SmallVectorImpl<MCPhysReg> &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const { const MachineRegisterInfo &MRI = MF.getRegInfo(); - const std::pair<unsigned, SmallVector<Register, 4>> &Hints_MRI = + const std::pair<unsigned, SmallVector<Register, 4>> *Hints_MRI = MRI.getRegAllocationHints(VirtReg); + if (!Hints_MRI) + return false; + SmallSet<Register, 32> HintedRegs; // First hint may be a target hint. - bool Skip = (Hints_MRI.first != 0); - for (auto Reg : Hints_MRI.second) { + bool Skip = (Hints_MRI->first != 0); + for (auto Reg : Hints_MRI->second) { if (Skip) { Skip = false; continue; |
