[llvm-commits] [llvm-gcc-4.2] r98646 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp

Duncan Sands baldrick at free.fr
Tue Mar 16 11:14:00 PDT 2010


Author: baldrick
Date: Tue Mar 16 13:13:59 2010
New Revision: 98646

URL: http://llvm.org/viewvc/llvm-project?rev=98646&view=rev
Log:
Revert commit 98626.  Chris says:
"I originally tried to do this for llvm-gcc 3 and was defeated by libstdc++.
 It assumes (and it turns out the c++ standard allows this) that global variables
 are zero initialized before the constructor for a type is run on it."

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp

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=98646&r1=98645&r2=98646&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Mar 16 13:13:59 2010
@@ -1320,17 +1320,10 @@
   // Convert the initializer over.
   Constant *Init;
   if (DECL_INITIAL(decl) == 0 || DECL_INITIAL(decl) == error_mark_node) {
-    // This global does not have an explicit initializer.  This usually means
-    // that it should be zero initialized.  Reconvert the type in case the
+    // This global should be zero initialized.  Reconvert the type in case the
     // forward def of the global and the real def differ in type (e.g. declared
     // as 'int A[]', and defined as 'int A[100]').
-    if (TYPE_NEEDS_CONSTRUCTING(TREE_TYPE(decl))) {
-      // The global will be initialized by a code sequence - it does not need to
-      // be zero initialized.
-      Init = UndefValue::get(ConvertType(TREE_TYPE(decl)));
-    } else {
-      Init = Constant::getNullValue(ConvertType(TREE_TYPE(decl)));
-    }
+    Init = Constant::getNullValue(ConvertType(TREE_TYPE(decl)));
   } else {
     assert((TREE_CONSTANT(DECL_INITIAL(decl)) || 
             TREE_CODE(DECL_INITIAL(decl)) == STRING_CST) &&





More information about the llvm-commits mailing list