Patch by David Meyer to avoid a O(N^2) behaviour when relaxing fragments.
Since we now don't update addresses so early, we might relax a bit more than
we need to. This is simillar to the issue in PR8467.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121856 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 5bc477d..f05f6ac 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -738,6 +738,7 @@
bool WasRelaxed = false;
for (iterator it = begin(), ie = end(); it != ie; ++it) {
MCSectionData &SD = *it;
+ MCFragment *FirstInvalidFragment = NULL;
for (MCSectionData::iterator it2 = SD.begin(),
ie2 = SD.end(); it2 != ie2; ++it2) {
@@ -762,10 +763,12 @@
break;
}
// Update the layout, and remember that we relaxed.
- if (relaxedFrag)
- Layout.Invalidate(it2);
+ if (relaxedFrag && !FirstInvalidFragment)
+ FirstInvalidFragment = it2;
WasRelaxed |= relaxedFrag;
}
+ if (FirstInvalidFragment)
+ Layout.Invalidate(FirstInvalidFragment);
}
return WasRelaxed;