diff options
author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2019-03-11 19:00:37 +0000 |
---|---|---|
committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2019-03-11 19:00:37 +0000 |
commit | 8b8dc50e79d4002281627f52b8b60807dab25a7a (patch) | |
tree | d23a63145002068e306738b1a6bf7751c6f68dd1 /llvm/lib/CodeGen/TargetRegisterInfo.cpp | |
parent | 20e7c0c450f0fdc66b2c4ede934516804a6bdff7 (diff) | |
download | bcm5719-llvm-8b8dc50e79d4002281627f52b8b60807dab25a7a.tar.gz bcm5719-llvm-8b8dc50e79d4002281627f52b8b60807dab25a7a.zip |
[RegAlloc] Avoid compile time regression with multiple copy hints.
As a fix for https://bugs.llvm.org/show_bug.cgi?id=40986 ("excessive compile
time building opencollada"), this patch makes sure that no phys reg is hinted
more than once from getRegAllocationHints().
This handles the case were many virtual registers are assigned to the same
physreg. The previous compile time fix (r343686) in weightCalcHelper() only
made sure that physical/virtual registers are passed no more than once to
addRegAllocationHint().
Review: Dimitry Andric, Quentin Colombet
https://reviews.llvm.org/D59201
llvm-svn: 355854
Diffstat (limited to 'llvm/lib/CodeGen/TargetRegisterInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetRegisterInfo.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetRegisterInfo.cpp b/llvm/lib/CodeGen/TargetRegisterInfo.cpp index 264999804a1..f1b2ecf3243 100644 --- a/llvm/lib/CodeGen/TargetRegisterInfo.cpp +++ b/llvm/lib/CodeGen/TargetRegisterInfo.cpp @@ -13,6 +13,7 @@ #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -397,6 +398,7 @@ TargetRegisterInfo::getRegAllocationHints(unsigned VirtReg, const std::pair<unsigned, SmallVector<unsigned, 4>> &Hints_MRI = MRI.getRegAllocationHints(VirtReg); + SmallSet<unsigned, 32> HintedRegs; // First hint may be a target hint. bool Skip = (Hints_MRI.first != 0); for (auto Reg : Hints_MRI.second) { @@ -410,6 +412,10 @@ TargetRegisterInfo::getRegAllocationHints(unsigned VirtReg, if (VRM && isVirtualRegister(Phys)) Phys = VRM->getPhys(Phys); + // Don't add the same reg twice (Hints_MRI may contain multiple virtual + // registers allocated to the same physreg). + if (!HintedRegs.insert(Phys).second) + continue; // Check that Phys is a valid hint in VirtReg's register class. if (!isPhysicalRegister(Phys)) continue; |