diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-12-15 07:39:29 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-12-15 07:39:29 +0000 |
| commit | 8911d03504e34e8b3e718ad66ddba692d324b18e (patch) | |
| tree | 297058c45d799378e6053394b7893864c8f3b60a /llvm | |
| parent | 2b59fbe7198dc701adff2e03e6a686911e5ae86e (diff) | |
| download | bcm5719-llvm-8911d03504e34e8b3e718ad66ddba692d324b18e.tar.gz bcm5719-llvm-8911d03504e34e8b3e718ad66ddba692d324b18e.zip | |
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.
llvm-svn: 121856
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 7 | ||||
| -rw-r--r-- | llvm/test/MC/MachO/relax-recompute-align.s | 10 |
2 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 5bc477d7bcc..f05f6acd632 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -738,6 +738,7 @@ bool MCAssembler::LayoutOnce(const MCObjectWriter &Writer, 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 @@ bool MCAssembler::LayoutOnce(const MCObjectWriter &Writer, 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; diff --git a/llvm/test/MC/MachO/relax-recompute-align.s b/llvm/test/MC/MachO/relax-recompute-align.s index 249402502f7..b9734cebf36 100644 --- a/llvm/test/MC/MachO/relax-recompute-align.s +++ b/llvm/test/MC/MachO/relax-recompute-align.s @@ -3,16 +3,16 @@ // FIXME: This is a horrible way of checking the output, we need an llvm-mc // based 'otool'. -// This is a case where llvm-mc computes a better layout than Darwin 'as'. This -// issue is that after the first jmp slides, the .align size must be -// recomputed -- otherwise the second jump will appear to be out-of-range for a -// 1-byte jump. +// FIXME: PR8467. +// There is an unnecessary relaxation here. After the first jmp slides, +// the .align size could be recomputed so that the second jump will be in range +// for a 1-byte jump. For performance reasons, this is not currently done. // CHECK: # Section 0 // CHECK: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') // CHECK: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') // CHECK: ('address', 0) -// CHECK: ('size', 306) +// CHECK: ('size', 322) // CHECK: ('offset', 324) // CHECK: ('alignment', 4) // CHECK: ('reloc_offset', 0) |

