r333044 - Use zeroinitializer for (trailing zero portion of) large array initializers

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed May 23 01:44:29 PDT 2018


OK, thanks for the revert.

On Wed, 23 May 2018, 01:28 Hans Wennborg via cfe-commits, <
cfe-commits at lists.llvm.org> wrote:

> We're hitting asserts after this in Chromium. I've filed PR37560 and
> reverted in r333067.
>
> On Wed, May 23, 2018 at 2:09 AM, Richard Smith via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> > Author: rsmith
> > Date: Tue May 22 17:09:29 2018
> > New Revision: 333044
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=333044&view=rev
> > Log:
> > Use zeroinitializer for (trailing zero portion of) large array
> initializers
> > more reliably.
> >
> > Clang has two different ways it emits array constants (from
> InitListExprs and
> > from APValues), and both had some ability to emit zeroinitializer, but
> neither
> > was able to catch all cases where we could use zeroinitializer reliably.
> In
> > particular, emitting from an APValue would fail to notice if all the
> explicit
> > array elements happened to be zero. In addition, for large arrays where
> only an
> > initial portion has an explicit initializer, we would emit the complete
> > initializer (which could be huge) rather than emitting only the non-zero
> > portion. With this change, when the element would have a suffix of more
> than 8
> > zero elements, we emit the array constant as a packed struct of its
> initial
> > portion followed by a zeroinitializer constant for the trailing zero
> portion.
> >
> > In passing, I found a bug where SemaInit would sometimes walk the entire
> array
> > when checking an initializer that only covers the first few elements;
> that's
> > fixed here to unblock testing of the rest.
> >
> > Differential Revision: https://reviews.llvm.org/D47166
> >
> > Modified:
> >     cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> >     cfe/trunk/lib/Sema/SemaInit.cpp
> >     cfe/trunk/test/CodeGen/init.c
> >     cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
> >     cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180523/c6822742/attachment.html>


More information about the cfe-commits mailing list