[llvm-commits] [llvm] r121856 - in /llvm/trunk: lib/MC/MCAssembler.cpp test/MC/MachO/relax-recompute-align.s

Rafael Espindola rafael.espindola at gmail.com
Tue Dec 14 23:39:29 PST 2010


Author: rafael
Date: Wed Dec 15 01:39:29 2010
New Revision: 121856

URL: http://llvm.org/viewvc/llvm-project?rev=121856&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/MC/MCAssembler.cpp
    llvm/trunk/test/MC/MachO/relax-recompute-align.s

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=121856&r1=121855&r2=121856&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Wed Dec 15 01:39:29 2010
@@ -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;

Modified: llvm/trunk/test/MC/MachO/relax-recompute-align.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/relax-recompute-align.s?rev=121856&r1=121855&r2=121856&view=diff
==============================================================================
--- llvm/trunk/test/MC/MachO/relax-recompute-align.s (original)
+++ llvm/trunk/test/MC/MachO/relax-recompute-align.s Wed Dec 15 01:39:29 2010
@@ -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)





More information about the llvm-commits mailing list