[LLVMdev] Patch to compile LLVM with MSVC 2010

Gordon Keiser gkeiser at arxan.com
Sat Apr 27 17:01:54 PDT 2013


Right, I filed the VS2012 bug with MS and they've fixed it with SP 2.  Verified locally building LLVM + Clang 3.2, all available tools built without errors.

I never saw it in VS2010, but the last time I built with that would have been with the LLVM 3.0 codeline, I believe.   Honestly a cleaner option than inserting the noinline is to modify the CMakeFiles for the specific directory / file where this happens to force /Ob0 when the broken version of the MS compiler is in use.

I don't think GCC will like a blind insertion of __declspec(noinline) but I could be wrong.

-Gordon

From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Kuperstein, Michael M
Sent: Thursday, April 18, 2013 4:56 AM
To: Sergiy Migdalskiy; David Blaikie
Cc: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] Patch to compile LLVM with MSVC 2010

The original thread on this ICE, including a link to the bug submitted to MS is here:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056683.html

Michael

From: llvmdev-bounces at cs.uiuc.edu<mailto:llvmdev-bounces at cs.uiuc.edu> [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Sergiy Migdalskiy
Sent: Thursday, April 18, 2013 10:28
To: David Blaikie
Cc: llvmdev at cs.uiuc.edu<mailto:llvmdev at cs.uiuc.edu>
Subject: Re: [LLVMdev] Patch to compile LLVM with MSVC 2010

>From the DeveloperPolicy.html<http://llvm.org/docs/DeveloperPolicy.html> document I gathered I need to send a patch to this list (which I did); could you clarify if I misunderstood it?

The second patch is really trivial and I think it's worth applying - it seems like a typo by someone who tested on MSVC 11 but not 10; or maybe my local instance of MSVC10 is somehow deficient, of course.

The first patch is adding MSVC-specific __declspec(noinline) - that's the whole patch - so if someone experienced who has access to all the platforms LLVM compiles on could test it (and/or replace it with something cross-platform; or #ifdef it out everywhere non-MS), I think that would be worth applying to the trunk. I don't have those resources.

The cause of ICE is pretty much right here - inlining utostr crashes MSVC cl.exe. I read about it a few months ago elsewhere and I think the bug was filed with MS (I'm not positive and I have no idea how/where to check it). I don't think I can find much more precise cause within reasonable time, ICE doesn't reproduce in simple cases and I'm not committed enough to do a lengthy binary search of the combination of factors that causes this particular ICE when I only have a lukewarm hope MS would ever give this bug a look.

Either way, I thought I'd try to push this through. It's not high-value enough to try harder, but it'd be great if someone could help me submit it - it's a really simple couple of patches that make LLVM/clang compile on MSVC10 without further modifications.

Regards,
Sergiy

> Date: Wed, 17 Apr 2013 21:56:43 -0700
> Subject: Re: [LLVMdev] Patch to compile LLVM with MSVC 2010
> From: dblaikie at gmail.com<mailto:dblaikie at gmail.com>
> To: migdalskiy at hotmail.com<mailto:migdalskiy at hotmail.com>
> CC: llvmdev at cs.uiuc.edu<mailto:llvmdev at cs.uiuc.edu>
>
> On Wed, Apr 17, 2013 at 11:36 AM, Sergiy Migdalskiy
> <migdalskiy at hotmail.com<mailto:migdalskiy at hotmail.com>> wrote:
> > In order to get llvm to compile on Windows with MSVC 10, I have to disable
> > inline on utostr to avoid internal compiler failure, and disable _xgetbv
> > call in OsSupportsAVX because it's only defined in MSVC 2012 compiler. The
> > first patch (noinline) is known for many months now. I'm a casual llvm user,
> > and don't know the proper channels to go through to submit a patch. Could
> > someone tell me, where do I submit patches like this one below?
>
> http://llvm.org/docs/DeveloperPolicy.html
>
> > Or maybe why
> > I shouldn't try to do it.
>
> We're generally happy to apply patches to ensure LLVM compiles on
> relevant compilers. For ICEs it might help to know what the precise
> problem is & to have a bug filed on the compiler.
>
> >
> > Sincerely,
> > Sergiy
> >
> > Index: include/llvm/ADT/StringExtras.h
> > ===================================================================
> > --- include/llvm/ADT/StringExtras.h (revision 179701)
> > +++ include/llvm/ADT/StringExtras.h (working copy)
> > @@ -84,7 +84,7 @@
> > return std::string(BufPtr, Buffer+11);
> > }
> >
> > -static inline std::string utostr(uint64_t X, bool isNeg = false) {
> > +static __declspec(noinline) inline std::string utostr(uint64_t X, bool
> > isNeg = false) {
> > char Buffer[21];
> > char *BufPtr = Buffer+21;
> >
> > Index: lib/Support/Host.cpp
> > ===================================================================
> > --- lib/Support/Host.cpp (revision 179701)
> > +++ lib/Support/Host.cpp (working copy)
> > @@ -119,7 +119,7 @@
> > // there is no easy way to conditionally compile based on the assembler
> > used.
> > int rEAX, rEDX;
> > __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a" (rEAX), "=d" (rEDX) : "c" (0));
> > -#elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040219
> > +#elif defined(_MSC_FULL_VER) && _MSC_FULL_VER > 160040219
> > unsigned long long rEAX = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
> > #else
> > int rEAX = 0; // Ensures we return false
> >
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu<mailto:LLVMdev at cs.uiuc.edu> http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> >

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130427/61025f1a/attachment.html>


More information about the llvm-dev mailing list