[llvm-commits] [dragonegg] r102903 - in /dragonegg/trunk: llvm-backend.cpp llvm-internal.h
Duncan Sands
baldrick at free.fr
Mon May 3 07:09:08 PDT 2010
Author: baldrick
Date: Mon May 3 09:09:08 2010
New Revision: 102903
URL: http://llvm.org/viewvc/llvm-project?rev=102903&view=rev
Log:
Do not zero initialize global variables without an initial
value when compiling Ada.
Modified:
dragonegg/trunk/llvm-backend.cpp
dragonegg/trunk/llvm-internal.h
Modified: dragonegg/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=102903&r1=102902&r2=102903&view=diff
==============================================================================
--- dragonegg/trunk/llvm-backend.cpp (original)
+++ dragonegg/trunk/llvm-backend.cpp Mon May 3 09:09:08 2010
@@ -513,6 +513,10 @@
getStringRepresentation());
}
+/// flag_default_initialize_globals - Whether global variables with no explicit
+/// initial value should be zero initialized.
+bool flag_default_initialize_globals = true; // GCC always initializes to zero
+
/// flag_odr - Whether the language being compiled obeys the One Definition Rule
/// (i.e. if the same function is defined in multiple compilation units, all the
/// definitions are equivalent).
@@ -531,18 +535,19 @@
StringRef LanguageName = lang_hooks.name;
if (LanguageName == "GNU Ada") {
- flag_odr = true; // Ada obeys the one-definition-rule.
+ flag_default_initialize_globals = false; // Uninitialized means what it says
+ flag_odr = true; // Ada obeys the one-definition-rule
} else if (LanguageName == "GNU C") {
flag_vararg_requires_arguments = true; // "T foo() {}" -> "T foo(void) {}"
} else if (LanguageName == "GNU C++") {
- flag_odr = true; // C++ obeys the one-definition-rule.
+ flag_odr = true; // C++ obeys the one-definition-rule
} else if (LanguageName == "GNU Fortran") {
- } else if (LanguageName == "GNU GIMPLE") { // LTO gold plugin.
+ } else if (LanguageName == "GNU GIMPLE") { // LTO gold plugin
} else if (LanguageName == "GNU Java") {
} else if (LanguageName == "GNU Objective-C") {
flag_vararg_requires_arguments = true; // "T foo() {}" -> "T foo(void) {}"
} else if (LanguageName == "GNU Objective-C++") {
- flag_odr = true; // Objective C++ obeys the one-definition-rule.
+ flag_odr = true; // Objective C++ obeys the one-definition-rule
}
}
@@ -1002,10 +1007,14 @@
// Convert the initializer over.
Constant *Init;
if (DECL_INITIAL(decl) == 0 || DECL_INITIAL(decl) == error_mark_node) {
- // 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]').
- Init = Constant::getNullValue(ConvertType(TREE_TYPE(decl)));
+ // 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]').
+ const Type *Ty = ConvertType(TREE_TYPE(decl));
+
+ if (flag_default_initialize_globals)
+ Init = Constant::getNullValue(Ty);
+ else
+ Init = UndefValue::get(Ty);
} else {
assert((TREE_CONSTANT(DECL_INITIAL(decl)) ||
TREE_CODE(DECL_INITIAL(decl)) == STRING_CST) &&
Modified: dragonegg/trunk/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=102903&r1=102902&r2=102903&view=diff
==============================================================================
--- dragonegg/trunk/llvm-internal.h (original)
+++ dragonegg/trunk/llvm-internal.h Mon May 3 09:09:08 2010
@@ -87,6 +87,10 @@
/// getTargetData - Return the current TargetData object from TheTarget.
const TargetData &getTargetData();
+/// flag_default_initialize_globals - Whether global variables with no explicit
+/// initial value should be zero initialized.
+extern bool flag_default_initialize_globals;
+
/// flag_odr - Whether the language being compiled obeys the One Definition Rule
/// (i.e. if the same function is defined in multiple compilation units, all the
/// definitions are equivalent).
More information about the llvm-commits
mailing list