[cfe-commits] r66455 - /cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Fariborz Jahanian fjahanian at apple.com
Mon Mar 9 13:57:30 PDT 2009


We should assert if Align is not passed down. Relying on llvm's  
default alignment wrecks havoc
with objc's runtime.

- Fariborz

On Mar 9, 2009, at 1:50 PM, Daniel Dunbar wrote:

> Author: ddunbar
> Date: Mon Mar  9 15:50:13 2009
> New Revision: 66455
>
> URL: http://llvm.org/viewvc/llvm-project?rev=66455&view=rev
> Log:
> Tweak CreateMetadataVar, take the exact alignment instead of relying
> on LLVM TargetData.
>
> Modified:
>    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=66455&r1=66454&r2=66455&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Mar  9 15:50:13 2009
> @@ -436,11 +436,19 @@
>   /// This is a convenience wrapper which not only creates the
>   /// variable, but also sets the section and alignment and adds the
>   /// global to the UsedGlobals list.
> +  ///
> +  /// \param Name - The variable name.
> +  /// \param Init - The variable initializer; this is also used to
> +  /// define the type of the variable.
> +  /// \param Section - The section the variable should go into, or 0.
> +  /// \param Align - The alignment for the variable, or 0.
> +  /// \param AddToUsed - Whether the variable should be added to
> +  /// llvm.
>   llvm::GlobalVariable *CreateMetadataVar(const std::string &Name,
>                                           llvm::Constant *Init,
>                                           const char *Section,
> -                                          bool SetAlignment,
> -                                          bool IsUsed);
> +                                          unsigned Align,
> +                                          bool AddToUsed);
>
> public:
>   CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm)
> @@ -1857,8 +1865,8 @@
> CGObjCCommonMac::CreateMetadataVar(const std::string &Name,
>                                    llvm::Constant *Init,
>                                    const char *Section,
> -                                   bool SetAlignment,
> -                                   bool IsUsed) {
> +                                   unsigned Align,
> +                                   bool AddToUsed) {
>   const llvm::Type *Ty = Init->getType();
>   llvm::GlobalVariable *GV =
>     new llvm::GlobalVariable(Ty, false,
> @@ -1868,9 +1876,9 @@
>                              &CGM.getModule());
>   if (Section)
>     GV->setSection(Section);
> -  if (SetAlignment)
> -    GV->setAlignment(CGM.getTargetData().getPrefTypeAlignment(Ty));
> -  if (IsUsed)
> +  if (Align)
> +    GV->setAlignment(Align);
> +  if (AddToUsed)
>     UsedGlobals.push_back(GV);
>   return GV;
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list