OSDN Git Service

[RA CopyHints] Fix compile-time regression
authorJonas Paulsson <paulsson@linux.vnet.ibm.com>
Wed, 3 Oct 2018 12:51:19 +0000 (12:51 +0000)
committerJonas Paulsson <paulsson@linux.vnet.ibm.com>
Wed, 3 Oct 2018 12:51:19 +0000 (12:51 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343686 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CalcSpillWeights.cpp

index 5754118..7f89601 100644 (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())