[llvm-commits] [llvm-gcc-4.2] r127940 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp

Bob Wilson bob.wilson at apple.com
Mon Mar 21 14:42:07 PDT 2011


The default implementation in getLLVMScalarTypeForStructReturn() appears to have the same issue.  Aggregate sizes are rounded up to the nearest power of two.  I think we should fix that as well but I can't find any targets that use it so we can test it.  ARM, PowerPC and i386 all use "sret" for returning aggregates (at least the ones I tried).  Does anyone know of a target that uses that default?

On Mar 18, 2011, at 6:40 PM, Devang Patel wrote:

> Author: dpatel
> Date: Fri Mar 18 20:40:19 2011
> New Revision: 127940
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=127940&view=rev
> Log:
> Trust gcc tree nodes for struct size.
> This fixes radar 9156771.
> 
> Modified:
>    llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
> 
> Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=127940&r1=127939&r2=127940&view=diff
> ==============================================================================
> --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Fri Mar 18 20:40:19 2011
> @@ -1539,7 +1539,7 @@
>     return Type::getInt8Ty(Context);
>   else if (Size == 2)
>     return Type::getInt16Ty(Context);
> -  else if (Size <= 4)
> +  else if (Size == 4)
>     return Type::getInt32Ty(Context);
> 
>   // Check if Ty should be returned using multiple value return instruction.
> @@ -1565,14 +1565,17 @@
>                               (int) GET_MODE_SIZE(Mode);
>         if (Bytes==8 && Class[0] == X86_64_POINTER_CLASS)
>           return Type::getInt8PtrTy(Context);
> -        if (Bytes>4)
> -          return Type::getInt64Ty(Context);
> -        else if (Bytes>2)
> -          return Type::getInt32Ty(Context);
> -        else if (Bytes>1)
> -          return Type::getInt16Ty(Context);
> -        else
> -          return Type::getInt8Ty(Context);
> +        switch (Bytes) {
> +          case 8: return Type::getInt64Ty(Context);
> +          case 7: return Type::getIntNTy(Context, 7*8);
> +          case 6: return Type::getIntNTy(Context, 6*8);
> +          case 5: return Type::getIntNTy(Context, 5*8);
> +          case 4: return Type::getInt32Ty(Context);
> +          case 3: return Type::getIntNTy(Context, 3*8);
> +          case 2: return Type::getInt16Ty(Context);
> +          case 1: return Type::getInt8Ty(Context);
> +          default: assert (0 && "Unexpected type!");
> +        }
>       }
>       assert(0 && "Unexpected type!"); 
>     }
> 
> 
> _______________________________________________
> 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