r324594 - Fix for #31362 - ms_abi is implemented incorrectly for values >=16 bytes.

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 9 01:03:21 PST 2018


Merged to 6.0 in r324718.

On Thu, Feb 8, 2018 at 12:15 PM, Alexander Ivchenko via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> Author: aivchenk
> Date: Thu Feb  8 03:15:21 2018
> New Revision: 324594
>
> URL: http://llvm.org/viewvc/llvm-project?rev=324594&view=rev
> Log:
> Fix for #31362 - ms_abi is implemented incorrectly for values >=16 bytes.
>
> Summary:
> This patch is a fix for following issue:
> https://bugs.llvm.org/show_bug.cgi?id=31362 The problem was caused by front end
> lowering C calling conventions without taking into account calling conventions
> enforced by attribute. In this case win64cc was no correctly lowered on targets
> other than Windows.
>
> Reviewed By: rnk (Reid Kleckner)
>
> Differential Revision: https://reviews.llvm.org/D43016
>
> Author: belickim <mateusz.belicki at intel.com>
>
>
>
> Modified:
>     cfe/trunk/lib/CodeGen/TargetInfo.cpp
>     cfe/trunk/test/CodeGen/ms_abi.c
>
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=324594&r1=324593&r2=324594&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Feb  8 03:15:21 2018
> @@ -3529,7 +3529,17 @@ ABIArgInfo X86_64ABIInfo::classifyRegCal
>
>  void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
>
> -  bool IsRegCall = FI.getCallingConvention() == llvm::CallingConv::X86_RegCall;
> +  const unsigned CallingConv = FI.getCallingConvention();
> +  // It is possible to force Win64 calling convention on any x86_64 target by
> +  // using __attribute__((ms_abi)). In such case to correctly emit Win64
> +  // compatible code delegate this call to WinX86_64ABIInfo::computeInfo.
> +  if (CallingConv == llvm::CallingConv::Win64) {
> +    WinX86_64ABIInfo Win64ABIInfo(CGT);
> +    Win64ABIInfo.computeInfo(FI);
> +    return;
> +  }
> +
> +  bool IsRegCall = CallingConv == llvm::CallingConv::X86_RegCall;
>
>    // Keep track of the number of assigned registers.
>    unsigned FreeIntRegs = IsRegCall ? 11 : 6;
>
> Modified: cfe/trunk/test/CodeGen/ms_abi.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_abi.c?rev=324594&r1=324593&r2=324594&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGen/ms_abi.c (original)
> +++ cfe/trunk/test/CodeGen/ms_abi.c Thu Feb  8 03:15:21 2018
> @@ -146,3 +146,16 @@ void __attribute__((sysv_abi)) f6(__buil
>    // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]]
>    // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]]
>  }
> +
> +// This test checks if structs are passed according to Win64 calling convention
> +// when it's enforced by __attribute((ms_abi)).
> +struct i128 {
> +  unsigned long long a;
> +  unsigned long long b;
> +};
> +
> +__attribute__((ms_abi)) struct i128 f7(struct i128 a) {
> +  // WIN64: define void @f7(%struct.i128* noalias sret %agg.result, %struct.i128* %a)
> +  // FREEBSD: define win64cc void @f7(%struct.i128* noalias sret %agg.result, %struct.i128* %a)
> +  return a;
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list