[cfe-commits] [PATCH] Win64 (esp. mingw64) stuff

Douglas Gregor dgregor at apple.com
Mon Jan 17 11:41:02 PST 2011


On Jan 14, 2011, at 12:43 AM, NAKAMURA Takumi wrote:

> Good evening guys!
> 
> I can build Win64 clang/llvm with clang selfhost.
> At the first step, I disclose patches I think obvious.
> 
> Please give me any feedbacks, thank you!
> 
> * 0001-lib-Basic-Targets.cpp-Set-user_label_prefix-on-W.patch.txt
> 
>  Both mingw64 and msvc do not use prefix "_".
> 
> * 0002-lib-Basic-Targets.cpp-Fix-__declspec-on-Mingw-w6.patch.txt
> 
>  On mingw64, -D__declspec=__declspec would be required as same as mingw32.
> 
> * 0003-lib-Basic-Targets.cpp-__builtin_va_list-is-as-sa.patch.txt
> 
>  On win64, the implementation of va_list is not same as AMD64.

These three look fine to me. Please go ahead and commit them; if someone with more knowledge of Win64 has any more feedback, it would be greatly appreciated.

> * 0004-lib-Sema-SemaExpr.cpp-__null-should-be-LongLongT.patch.txt
> 
>  On Win64, __null should be i64. it is neither IntTy nor LongTy with LLP64.

diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 902afac..f7bbf3e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -8575,10 +8575,13 @@ ExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) {
   // The type of __null will be int or long, depending on the size of
   // pointers on the target.
   QualType Ty;
-  if (Context.Target.getPointerWidth(0) == Context.Target.getIntWidth())
-    Ty = Context.IntTy;
-  else
+  unsigned pw = Context.Target.getPointerWidth(0);
+  if (pw == Context.Target.getLongWidth())
     Ty = Context.LongTy;
+  else if (pw == Context.Target.getLongLongWidth())
+    Ty = Context.LongLongTy;
+  else
+    Ty = Context.IntTy;
 
   return Owned(new (Context) GNUNullExpr(Ty, TokenLoc));
 }

I don't think we want this change in behavior. Previously, when sizeof(int) == sizeof(long), we would get 'int' rather than 'long', and we want to keep that. Please check sizeof(int) first, then sizeof(long), then sizeof(long long).


> * 0005-lib-CodeGen-TargetInfo.cpp-Add-Win64-calling-con.patch.txt
> 
>  Win64 calling conversion is quite different from AMD64 cc.


I don't know enough to review this change, but on cursory review it looks fine. Please go ahead and commit; others will chime in after the fact if there's a problem here.

	- Doug



More information about the cfe-commits mailing list