[llvm-commits] [PATCH] PERF: Reuse data fragments while lowering

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Nov 17 08:00:09 PST 2010


On 16 November 2010 17:24, David Meyer <pdox at google.com> wrote:
> Hi Dan & Rafael,
> This patch makes it possible to re-use existing data fragments when lowering
> (instead of creating new ones).

+  /// \brief Update the layout to coalesce Src into Dst.
+  void CoalesceFragments(MCFragment *Src, MCFragment *Dst);

Add a note that the actual contents are not copied.

+  if (isFragmentUpToDate(Src)) {
+    if (LastValidFragment == Src)
+      LastValidFragment = Dst;
+    Dst->EffectiveSize += Src->EffectiveSize;
+  } else {
+    // We don't know the effective size of Src, so we have to invalidate Dst.
+    UpdateForSlide(Dst, 0);
+  }

You have to invalidate Dst in any case, no? Adding something to the
fragment will cause the addresses in fragment following it to change.
This probably works in the current case since we are scanning the
fragments in order.

Is it too expensive to just call UpdateForSlide for both cases?

+      // Since we may have removed fragments, fix the layout order.
+      it2->setLayoutOrder(FragmentIndex++)

merged would probably be a better description.

+        it2 = CurDF;

Setting an iterator in this for loop is a bit strange. Would you mind
removing the ++it2 so that we have a

if (...)
  it2 = CurDF;
else
 ++it2;

That way all the iterator updates are close to each other.

> - David Meyer

Thanks a lot for working on this. Hopefully it will close some of the
performance gap of "llc -filetype=obj" X "llc && llvm-mc".

Cheers,
Rafael



More information about the llvm-commits mailing list