[llvm-commits] [llvm] r160695 - in /llvm/trunk: include/llvm/Attributes.h test/CodeGen/X86/inreg.ll

Duncan Sands baldrick at free.fr
Wed Jul 25 00:39:59 PDT 2012


Hi Rafael, are you sure that this is correct?  Sret has some pretty funky
semantics.  What is the effect of this on generated code and ABI conformance?

Ciao, Duncan.

On 24/07/12 23:40, Rafael Espindola wrote:
> Author: rafael
> Date: Tue Jul 24 16:40:17 2012
> New Revision: 160695
>
> URL: http://llvm.org/viewvc/llvm-project?rev=160695&view=rev
> Log:
> In order to correctly compile
>
> struct s {
>    double x1;
>    float x2;
> };
> __attribute__((regparm(3))) struct s f(int a, int b, int c);
> void g(void) {
>    f(41, 42, 43);
> }
>
> We need to be able to represent passing the address of s to f (sret) in a
> register (inreg). Turns out that all that is needed is to not mark them as
> mutually incompatible.
>
> Added:
>      llvm/trunk/test/CodeGen/X86/inreg.ll
> Modified:
>      llvm/trunk/include/llvm/Attributes.h
>
> Modified: llvm/trunk/include/llvm/Attributes.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=160695&r1=160694&r2=160695&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Attributes.h (original)
> +++ llvm/trunk/include/llvm/Attributes.h Tue Jul 24 16:40:17 2012
> @@ -165,8 +165,9 @@
>   const AttrConst VarArgsIncompatible = {StructRet_i};
>
>   /// @brief Attributes that are mutually incompatible.
> -const AttrConst MutuallyIncompatible[4] = {
> -  {ByVal_i | InReg_i | Nest_i | StructRet_i},
> +const AttrConst MutuallyIncompatible[5] = {
> +  {ByVal_i | Nest_i | StructRet_i},
> +  {ByVal_i | Nest_i | InReg_i },
>     {ZExt_i  | SExt_i},
>     {ReadNone_i | ReadOnly_i},
>     {NoInline_i | AlwaysInline_i}
>
> Added: llvm/trunk/test/CodeGen/X86/inreg.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/inreg.ll?rev=160695&view=auto
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/inreg.ll (added)
> +++ llvm/trunk/test/CodeGen/X86/inreg.ll Tue Jul 24 16:40:17 2012
> @@ -0,0 +1,19 @@
> +; RUN: llc < %s -march=x86 | FileCheck %s
> +
> +%struct.s = type { double, float }
> +
> +define void @g() nounwind {
> +entry:
> +  %tmp = alloca %struct.s, align 4
> +  call void @f(%struct.s* inreg sret %tmp, i32 inreg 41, i32 inreg 42, i32 43)
> +  ret void
> +  ; CHECK: g:
> +  ; CHECK: subl {{.*}}, %esp
> +  ; CHECK-NEXT: $43, (%esp)
> +  ; CHECK-NEXT: leal    16(%esp), %eax
> +  ; CHECK-NEXT: movl    $41, %edx
> +  ; CHECK-NEXT: movl    $42, %ecx
> +  ; CHECK-NEXT: calll   f
> +}
> +
> +declare void @f(%struct.s* inreg sret, i32 inreg, i32 inreg, i32)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list