[PATCH] -fms-extensions: Implement half of #pragma init_seg

Reid Kleckner rnk at google.com
Thu Jul 17 17:26:46 PDT 2014


On Thu, Jul 17, 2014 at 5:28 AM, Aaron Ballman <aaron at aaronballman.com>
wrote:

> On Wed, Jul 16, 2014 at 8:47 PM, Reid Kleckner <rnk at google.com> wrote:
> > Hi rsmith, majnemer,
> >
> > This pragma is very rare.  We could *hypothetically* lower some uses of
> > it down to @llvm.global_ctors, but given that GlobalOpt isn't able to
> > optimize prioritized global ctors today, there's really no point.
> >
> > If we wanted to do this in the future, I would check if the section used
> > in the pragma started with ".CRT$XC" and had up to two characters after
> > it.  Those two characters could form the 16-bit initialization priority
> > that we support in @llvm.global_ctors.  We would have to teach LLVM to
> > lower prioritized global ctors on COFF as well.
> >
> > This should let us compile some silly uses of this pragma in WebKit /
> > Blink.
> >
>
> > +  assert(SegmentName->getCharByteWidth() == 1 &&
> > +         "only C strings are accepted here");
>
> Please do not assert here -- this should be an error instead.
>

There was a missing case here for tokens other than identifiers or string
literals, but the intention was that if a string starts with a string
literal (not a wide string literal), then we know the whole string will be
a C string, and I wanted to assert that we got one back.  This turned out
to be wrong, given init_seg("a" L"b"), so I committed r213337 to fix the
other pragma section handling code.


> I'd like to see some parser test cases for the situation where
> something other than a string literal is given to the pragma. A test
> using a wide string literal would also be good.


Sure.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140717/b06b52e6/attachment.html>


More information about the cfe-commits mailing list