[llvm] r343686 - [RA CopyHints] Fix compile-time regression
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 3 05:51:19 PDT 2018
Author: jonpa
Date: Wed Oct 3 05:51:19 2018
New Revision: 343686
URL: http://llvm.org/viewvc/llvm-project?rev=343686&view=rev
Log:
[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
Modified:
llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp
Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=343686&r1=343685&r2=343686&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original)
+++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Wed Oct 3 05:51:19 2018
@@ -287,9 +287,11 @@ float VirtRegAuxInfo::weightCalcHelper(L
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())
More information about the llvm-commits
mailing list