[RA CopyHints] Fix compile-time regression

This patch makes sure that a register is only hinted once to RA. In extreme
cases the same register can otherwise be hinted numerous times and cause a
compile time slowdown.

Review: Simon Pilgrim
https://reviews.llvm.org/D52826

llvm-svn: 343686
This commit is contained in:
Jonas Paulsson 2018-10-03 12:51:19 +00:00
parent 5a768ddd44
commit fb3a97bec0
1 changed files with 4 additions and 2 deletions

View File

@ -287,9 +287,11 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &li, SlotIndex *start,
if (TargetHint.first == 0 && TargetHint.second)
mri.clearSimpleHint(li.reg);
std::set<unsigned> HintedRegs;
for (auto &Hint : CopyHints) {
if (TargetHint.first != 0 && Hint.Reg == TargetHint.second)
// Don't add again the target-type hint.
if (!HintedRegs.insert(Hint.Reg).second ||
(TargetHint.first != 0 && Hint.Reg == TargetHint.second))
// Don't add the same reg twice or the target-type hint again.
continue;
mri.addRegAllocationHint(li.reg, Hint.Reg);
if (!tri.enableMultipleCopyHints())