r245084 - WindowsX86: long double is x87DoubleExtended on mingw

Yaron Keren via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 19 10:22:03 PDT 2015


Sorry to notice late (just diagnosed the issue from a failing boost::math
test), according to i686 ABI, long double size on x86 is 12 bytes (the
memory allocated, not the underlying 80 bits register), see

https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/i386-and-x86-64-Options.html

-m128bit-long-double
Control the size of long double type. i386 application binary interface
specify the size to be 12 bytes, while modern architectures (Pentium and
newer) prefer long double aligned to 8 or 16 byte boundary. This is
impossible to reach with 12 byte long doubles in the array accesses.
Warning: if you use the -m128bit-long-double switch, the structures and
arrays containing long double will change their size as well as function
calling convention for function taking long double will be modified.

-m96bit-long-double
Set the size of long double to 96 bits as required by the i386 application
binary interface. This is the default.


You can check long double size out by running

#include <iostream>
int main() {
  long double a;
  std::cout<<sizeof(a)<<std::endl;
}

which outputs 12 with mingw 32 bit, 16 with mingw 64 bit but always 16 with
current clang.
I fixed this and added test in r245459+r245462.


2015-08-19 19:41 GMT+03:00 Hans Wennborg via cfe-commits <
cfe-commits at lists.llvm.org>:

> On Tue, Aug 18, 2015 at 6:11 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
> > On Tue, Aug 18, 2015 at 3:01 PM, Hans Wennborg <hans at chromium.org>
> wrote:
> >>
> >> Richard, I tried to ping you on the review thread but I'm not sure it
> >> got through. Martell requested this be merged to 3.7. What do you
> >> think?
> >
> >
> > LGTM
>
> Thanks! r245456.
>
> >
> >>
> >> On Fri, Aug 14, 2015 at 12:05 PM, Martell Malone via cfe-commits
> >> <cfe-commits at lists.llvm.org> wrote:
> >> > Author: martell
> >> > Date: Fri Aug 14 14:05:56 2015
> >> > New Revision: 245084
> >> >
> >> > URL: http://llvm.org/viewvc/llvm-project?rev=245084&view=rev
> >> > Log:
> >> > WindowsX86: long double is x87DoubleExtended on mingw
> >> >
> >> >     Summary:
> >> >     long double on x86 mingw is 80bits and is aligned to 16bytes
> >> >
> >> >         Fixes:
> >> >     https://llvm.org/bugs/show_bug.cgi?id=24398
> >> >
> >> >     Reviewers: rnk
> >> >
> >> >     Subscribers: cfe-commits
> >> >
> >> >     Differential Revision: http://reviews.llvm.org/D12037
> >> >
> >> > Modified:
> >> >     cfe/trunk/lib/Basic/Targets.cpp
> >> >
> >> > Modified: cfe/trunk/lib/Basic/Targets.cpp
> >> > URL:
> >> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=245084&r1=245083&r2=245084&view=diff
> >> >
> >> >
> ==============================================================================
> >> > --- cfe/trunk/lib/Basic/Targets.cpp (original)
> >> > +++ cfe/trunk/lib/Basic/Targets.cpp Fri Aug 14 14:05:56 2015
> >> > @@ -3784,7 +3784,10 @@ namespace {
> >> >  class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo {
> >> >  public:
> >> >    MinGWX86_32TargetInfo(const llvm::Triple &Triple)
> >> > -      : WindowsX86_32TargetInfo(Triple) {}
> >> > +      : WindowsX86_32TargetInfo(Triple) {
> >> > +    LongDoubleWidth = LongDoubleAlign = 128;
> >> > +    LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
> >> > +  }
> >> >    void getTargetDefines(const LangOptions &Opts,
> >> >                          MacroBuilder &Builder) const override {
> >> >      WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
> >> > @@ -4014,7 +4017,10 @@ public:
> >> >  class MinGWX86_64TargetInfo : public WindowsX86_64TargetInfo {
> >> >  public:
> >> >    MinGWX86_64TargetInfo(const llvm::Triple &Triple)
> >> > -      : WindowsX86_64TargetInfo(Triple) {}
> >> > +      : WindowsX86_64TargetInfo(Triple) {
> >> > +    LongDoubleWidth = LongDoubleAlign = 128;
> >> > +    LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
> >> > +  }
> >> >    void getTargetDefines(const LangOptions &Opts,
> >> >                          MacroBuilder &Builder) const override {
> >> >      WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
> >> >
> >> >
> >> > _______________________________________________
> >> > cfe-commits mailing list
> >> > cfe-commits at lists.llvm.org
> >> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
> _______________________________________________
> 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/20150819/60300a1a/attachment.html>


More information about the cfe-commits mailing list