[llvm-commits] [llvm-gcc-4.2] r45804 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm.h objc/objc-act.c

Chris Lattner clattner at apple.com
Wed Jan 9 17:57:10 PST 2008


On Jan 9, 2008, at 5:28 PM, Bill Wendling wrote:

> Author: void
> Date: Wed Jan  9 19:28:25 2008
> New Revision: 45804
>
> URL: http://llvm.org/viewvc/llvm-project?rev=45804&view=rev
> Log:
> We're creating incorrect metadata. LLVM gives this for class  
> references:

Hey Bill,

Is it possible to avoid having the llvm-front-end called on the objc  
metadata before its fully formed?  Alternatively, perhaps the objc  
front-end should set the early version of the metadata as being an  
extern instead of definition?

-Chris

>
> L_OBJC_CLASS_REFERENCES_0:
>  .space 4
> ..
> L_OBJC_CLASS_NAME_0:
>  ...
>
> while GCC gives:
>
> L_OBJC_CLASS_REFERENCES_0:
>  .long L_OBJC_CLASS_NAME_0
> ..
> L_OBJC_CLASS_NAME_0:
>  ...
>
> which is correct. What's happening is that the reference is being  
> created and
> LLVM is setting it's initializer to "null" because it's not pointing  
> to
> something at that time. But then reference is modified to point to  
> some
> object. However, LLVM wasn't updating its initializer information at  
> that point.
>
>
> Modified:
>    llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
>    llvm-gcc-4.2/trunk/gcc/llvm.h
>    llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=45804&r1=45803&r2=45804&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Jan  9 19:28:25 2008
> @@ -798,6 +798,17 @@
>   }
> }
>
> +/// reset_initializer_llvm - Change the initializer for a global  
> variable.
> +void reset_initializer_llvm(tree decl) {
> +  // Get or create the global variable now.
> +  GlobalVariable *GV = cast<GlobalVariable>(DECL_LLVM(decl));
> +
> +  // Convert the initializer over.
> +  Constant *Init = TreeConstantToLLVM::Convert(DECL_INITIAL(decl));
> +
> +  // Set the initializer.
> +  GV->setInitializer(Init);
> +}
>
> /// emit_global_to_llvm - Emit the specified VAR_DECL or aggregate  
> CONST_DECL to
> /// LLVM as a global variable.  This function implements the end of
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm.h
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm.h?rev=45804&r1=45803&r2=45804&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm.h (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm.h Wed Jan  9 19:28:25 2008
> @@ -44,12 +44,15 @@
> /* make_decl_llvm - This is also defined in tree.h and used by  
> macros there. */
> void make_decl_llvm(union tree_node*);
>
> +/* reset_initializer_llvm - Change the initializer for a global  
> variable. */
> +void reset_initializer_llvm(union tree_node*);
> +
> /* emit_global_to_llvm - Emit the specified VAR_DECL to LLVM as a  
> global
>  * variable.
>  */
> void emit_global_to_llvm(union tree_node*);
>
> -/* emit_global_to_llvm - Emit the specified alias to LLVM
> +/* emit_alias_to_llvm - Emit the specified alias to LLVM
>  */
> void emit_alias_to_llvm(union tree_node*, union tree_node*, union  
> tree_node*);
>
>
> Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=45804&r1=45803&r2=45804&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original)
> +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Wed Jan  9 19:28:25 2008
> @@ -76,6 +76,9 @@
> #include "langhooks-def.h"
> /* APPLE LOCAL optimization pragmas 3124235/3420242 */
> #include "opts.h"
> +#ifdef ENABLE_LLVM
> +#include "llvm.h"               /* for reset_initializer_llvm */
> +#endif
>
> #define OBJC_VOID_AT_END	void_list_node
>
> @@ -5541,6 +5544,13 @@
> 	{
> 	  decl = TREE_PURPOSE (chain);
> 	  finish_var_decl (decl, expr);
> +          /* APPLE LOCAL LLVM begin - radar 5676233 */
> +#ifdef ENABLE_LLVM
> +          /* Reset the initializer for this reference as it most  
> likely
> +             changed.  */
> +          reset_initializer_llvm(decl);
> +#endif
> +          /* APPLE LOCAL LLVM end - radar 5676233 */
> 	}
>       else
> 	{
> @@ -18172,8 +18182,16 @@
>   for (chain = cls_ref_chain; chain; chain = TREE_CHAIN (chain))
>     {
>       handle_class_ref (chain);
> -      if (TREE_PURPOSE (chain))
> +      /* APPLE LOCAL LLVM begin - radar 5676233 */
> +      if (TREE_PURPOSE (chain)) {
> 	generate_classref_translation_entry (chain);
> +#ifdef ENABLE_LLVM
> +        /* Reset the initializer for this reference as it most likely
> +           changed.  */
> +        reset_initializer_llvm(TREE_PURPOSE (chain));
> +#endif
> +      }
> +      /* APPLE LOCAL LLVM end - radar 5676233 */
>     }
>
>   for (impent = imp_list; impent; impent = impent->next)
>
>
> _______________________________________________
> 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