[llvm-commits] [127876] Explicitly set alignment for Objective-C protocols.

Chris Lattner clattner at apple.com
Thu May 31 17:33:29 CDT 2007


Nice! Thanks Devang,

-Chris

On May 31, 2007, at 2:56 PM, dpatel at apple.com wrote:

> Revision: 127876
> Author:   dpatel
> Date:     2007-05-31 14:56:52 -0700 (Thu, 31 May 2007)
>
> Log Message:
> -----------
> Explicitly set alignment for Objective-C protocols.
> Set Global Value alignment if it is specified by User.
>
> Modified Paths:
> --------------
>     apple-local/branches/llvm/gcc/llvm-backend.cpp
>     apple-local/branches/llvm/gcc/objc/objc-act.c
>
> Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
> ===================================================================
> --- apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-05-31  
> 20:27:28 UTC (rev 127875)
> +++ apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-05-31  
> 21:56:52 UTC (rev 127876)
> @@ -68,8 +68,6 @@
>  #include "langhooks.h"
>  }
>
> -extern int flag_next_runtime;
> -
>  // Non-zero if bytecode from PCH is successfully read.
>  int flag_llvm_pch_read;
>
> @@ -735,17 +733,17 @@
>      } else if (const char *Section =
>                  LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)) {
>        GV->setSection(Section);
> -      // Next runtime expects 4 byte alignment for Objective-C data.
> -      if (flag_next_runtime)
> -        GV->setAlignment(4);
>  #endif
>      }
>
> -    // Set the alignment for the global.
> -    if (DECL_ALIGN_UNIT(decl) &&
> -        getTargetData().getABITypeAlignment(GV->getType()- 
> >getElementType()) !=
> -        DECL_ALIGN_UNIT(decl))
> -      GV->setAlignment(DECL_ALIGN_UNIT(decl));
> +    // Set the alignment for the global if one of the following  
> condition is met
> +    // 1) DECL_ALIGN_UNIT does not match alignment as per ABI  
> specification
> +    // 2) DECL_ALIGN is set by user.
> +    if (DECL_ALIGN_UNIT(decl)) {
> +      unsigned TargetAlign = getTargetData().getABITypeAlignment 
> (GV->getType()->getElementType());
> +      if (DECL_USER_ALIGN(decl) || TargetAlign != DECL_ALIGN_UNIT 
> (decl))
> +        GV->setAlignment(DECL_ALIGN_UNIT(decl));
> +    }
>
>      // Handle used decls
>      if (DECL_PRESERVE_P (decl))
>
> Modified: apple-local/branches/llvm/gcc/objc/objc-act.c
> ===================================================================
> --- apple-local/branches/llvm/gcc/objc/objc-act.c	2007-05-31  
> 20:27:28 UTC (rev 127875)
> +++ apple-local/branches/llvm/gcc/objc/objc-act.c	2007-05-31  
> 21:56:52 UTC (rev 127876)
> @@ -9270,6 +9270,11 @@
>  					     /* APPLE LOCAL radar 4695109 */
>  					     UOBJC_PROTOCOL_EXT_decl, NULL_TREE);
>        /* APPLE LOCAL end radar 4585769 - Objective-C 1.0  
> extensions */
> +      /* APPLE LOCAL begin LLVM */
> +      /* Force 4 byte alignment for protocols */
> +      DECL_ALIGN(decl) = 32;
> +      DECL_USER_ALIGN(decl) = 1;
> +      /* APPLE LOCAL end LLVM */
>        finish_var_decl (decl, initlist);
>      }
>  }
>
>
> _______________________________________________
> 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