[PATCH] D42720: [CodeGen] Switch non-SJLJ EH encoding to uleb128

Ryan Prichard via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 6 21:43:16 PST 2018


On Tue, Feb 6, 2018 at 3:09 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Ryan Prichard <rprichard at google.com> writes:
>
> > I don't think the optimization prevents the creation of new fragments.
> For
> > an absolute (Hi - Lo) expression, the general code path calls
> > MCObjectStreamer::EmitValueImpl,
> > then MCObjectStreamer::EmitBytes. EmitValueImpl and EmitBytes do a lot of
> > the same work. With the optimization, EmitValueImpl is skipped, and
> EmitBytes
> > is called more directly. I think the important part is that it avoids
> > allocating and evaluating an MCExpr tree.
>
> Oh, that is less than what I would expect. It is tempting to remove the
> optimization in a followup patch.
>

The optimization was added in 2015 to reduce memory usage on Mach-O. There
was some discussion of it on llvm-commits:

 - http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-
20150601/279975.html
 - http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-
20150608/281392.html

Removing it for ULEB output would create 6 or 9 MCExpr nodes per entry in
the call site table. That seems acceptable to me, though I'm not sure why
there was a memory issue with Mach-O in the first place.

I noticed that the comment on emitAbsoluteSymbolDiff in MCObjectStreamer.h
was out-of-date regarding the return type:

  /// Emit the absolute difference between two symbols if possible.
>   ///
>   /// Emit the absolute difference between \c Hi and \c Lo, as long as we
> can
>   /// compute it.  Currently, that requires that both symbols are in the
> same
>   /// data fragment.  Otherwise, do nothing and return \c false.
>   ///
>   /// \pre Offset of \c Hi is greater than the offset \c Lo.
>   void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
>                               unsigned Size) override;


I've split the patch into two parts now:
- https://reviews.llvm.org/D42720: uses assembler directives
- https://reviews.llvm.org/D43001: switches to uleb128

-Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180206/74243b36/attachment.html>


More information about the llvm-commits mailing list