Skip to content

Commit 79c29c6

Browse files
committed
Merging r355854:
------------------------------------------------------------------------ r355854 | jonpa | 2019-03-11 12:00:37 -0700 (Mon, 11 Mar 2019) | 13 lines [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: 358905
1 parent 25895ad commit 79c29c6

File tree

2 files changed

+811
-0
lines changed

2 files changed

+811
-0
lines changed

llvm/lib/CodeGen/TargetRegisterInfo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/CodeGen/TargetRegisterInfo.h"
1515
#include "llvm/ADT/ArrayRef.h"
1616
#include "llvm/ADT/BitVector.h"
17+
#include "llvm/ADT/SmallSet.h"
1718
#include "llvm/ADT/STLExtras.h"
1819
#include "llvm/ADT/StringExtras.h"
1920
#include "llvm/CodeGen/MachineFrameInfo.h"
@@ -398,6 +399,7 @@ TargetRegisterInfo::getRegAllocationHints(unsigned VirtReg,
398399
const std::pair<unsigned, SmallVector<unsigned, 4>> &Hints_MRI =
399400
MRI.getRegAllocationHints(VirtReg);
400401

402+
SmallSet<unsigned, 32> HintedRegs;
401403
// First hint may be a target hint.
402404
bool Skip = (Hints_MRI.first != 0);
403405
for (auto Reg : Hints_MRI.second) {
@@ -411,6 +413,10 @@ TargetRegisterInfo::getRegAllocationHints(unsigned VirtReg,
411413
if (VRM && isVirtualRegister(Phys))
412414
Phys = VRM->getPhys(Phys);
413415

416+
// Don't add the same reg twice (Hints_MRI may contain multiple virtual
417+
// registers allocated to the same physreg).
418+
if (!HintedRegs.insert(Phys).second)
419+
continue;
414420
// Check that Phys is a valid hint in VirtReg's register class.
415421
if (!isPhysicalRegister(Phys))
416422
continue;

0 commit comments

Comments
 (0)