[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 17 22:24:35 PDT 2004



Changes in directory llvm-gcc/gcc:

llvm-expand.c updated: 1.52 -> 1.53
---
Log message:

If a global variable is of a type that has a ctor, we don't need to zero 
initialize it (the ctor will init it).  This patch allows us to mark many
globals as starting out undef in C++ programs (for example, 2014 in eon).

This allows us to do more aggressive globalopt on the program among other 
things.


---
Diffs of the changes:  (+9 -2)

Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.52 llvm-gcc/gcc/llvm-expand.c:1.53
--- llvm-gcc/gcc/llvm-expand.c:1.52	Sun Oct 17 23:19:04 2004
+++ llvm-gcc/gcc/llvm-expand.c	Mon Oct 18 00:24:21 2004
@@ -7150,8 +7150,15 @@
       G->Init = llvm_decode_string_constant(DECL_INITIAL(decl), Len, ElTy);
     }
   } else {
-    /* An initializer wasn't specified, give it a zero initializer */
-    G->Init = V2C(llvm_constant_get_null(BaseTy));
+    if (TYPE_NEEDS_CONSTRUCTING(TREE_TYPE(decl))) {
+      /* This global has a ctor that will initialize it.  For now, init to
+       * undef.
+       */
+      G->Init = V2C(llvm_constant_new(BaseTy, "undef"));
+    } else {
+      /* An initializer wasn't specified, give it a zero initializer */
+      G->Init = V2C(llvm_constant_get_null(BaseTy));
+    }
   }
 
   TREE_ASM_WRITTEN(decl) = 1;






More information about the llvm-commits mailing list