On Dec 18, 2013, at 9:23 AM, Aaron Ballman wrote:

> Author: aaronballman
> Date: Wed Dec 18 10:23:37 2013
> New Revision: 197584
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=197584&view=rev
> Log:
> Implement the MSABI and SysVABI calling conventions for Objective-C method 
> declarations. This appears to be an omission from r189644.
It was intentional. I didn't think anyone would want or need to use any calling 
convention with an Objective-C method other than the default. And I still don't 
understand why you'd want to use a different calling convention. The methods 
are always called indirectly, by the objc_msgSend() family (at least, on 
NeXT-style runtimes), and the IMP function pointer typedef that it uses has the 
default calling convention. Any time the message for that method gets sent, the 
method implementation will get called with the wrong convention. Unless there's 
some way to communicate the correct calling convention back to the runtime, I 
think we should go back to disallowing calling convention attributes on 
Objective-C methods.

Chip

> 
> Modified:
>    cfe/trunk/lib/CodeGen/CGCall.cpp
>    cfe/trunk/test/CodeGenObjC/attr-callconv.m
> 
> Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=197584&r1=197583&r2=197584&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Dec 18 10:23:37 2013
> @@ -123,7 +123,7 @@ CodeGenTypes::arrangeFreeFunctionType(Ca
>   return ::arrangeFreeFunctionType(*this, argTypes, FTP);
> }
> 
> -static CallingConv getCallingConventionForDecl(const Decl *D) {
> +static CallingConv getCallingConventionForDecl(const Decl *D, bool 
> IsWindows) {
>   // Set the appropriate calling convention for the Function.
>   if (D->hasAttr<StdCallAttr>())
>     return CC_X86StdCall;
> @@ -146,6 +146,12 @@ static CallingConv getCallingConventionF
>   if (D->hasAttr<IntelOclBiccAttr>())
>     return CC_IntelOclBicc;
> 
> +  if (D->hasAttr<MSABIAttr>())
> +    return IsWindows ? CC_C : CC_X86_64Win64;
> +
> +  if (D->hasAttr<SysVABIAttr>())
> +    return IsWindows ? CC_X86_64SysV : CC_C;
> +
>   return CC_C;
> }
> 
> @@ -293,7 +299,8 @@ CodeGenTypes::arrangeObjCMessageSendSign
>   }
> 
>   FunctionType::ExtInfo einfo;
> -  einfo = einfo.withCallingConv(getCallingConventionForDecl(MD));
> +  bool IsWindows = getContext().getTargetInfo().getTriple().isOSWindows();
> +  einfo = einfo.withCallingConv(getCallingConventionForDecl(MD, IsWindows));
> 
>   if (getContext().getLangOpts().ObjCAutoRefCount &&
>       MD->hasAttr<NSReturnsRetainedAttr>())
> 
> Modified: cfe/trunk/test/CodeGenObjC/attr-callconv.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/attr-callconv.m?rev=197584&r1=197583&r2=197584&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenObjC/attr-callconv.m (original)
> +++ cfe/trunk/test/CodeGenObjC/attr-callconv.m Wed Dec 18 10:23:37 2013
> @@ -5,7 +5,9 @@
> @end
> 
> @implementation Test
> -- (void)test __attribute__((stdcall)) {
> +- (void)test __attribute__((stdcall)) {}
>     // CHECK: define{{.*}}x86_stdcallcc{{.*}}Test test
> -}
> +    
> +- (void)test2 __attribute__((ms_abi)) {}
> +    // CHECK: define{{.*}}x86_64_win64cc{{.*}}Test test2
> @end
> 
> 
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to