[llvm-commits] [dragonegg] r95386 - in /dragonegg/trunk: llvm-backend.cpp llvm-internal.h

Duncan Sands baldrick at free.fr
Fri Feb 5 07:05:03 PST 2010


Author: baldrick
Date: Fri Feb  5 09:05:02 2010
New Revision: 95386

URL: http://llvm.org/viewvc/llvm-project?rev=95386&view=rev
Log:
Tweak the decision as to whether an initial value is present to use
TREE_STATIC rather than !TREE_PUBLIC.  The final result is probably
the same, but this seems more logical.

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=95386&r1=95385&r2=95386&view=diff

==============================================================================
--- dragonegg/trunk/llvm-backend.cpp (original)
+++ dragonegg/trunk/llvm-backend.cpp Fri Feb  5 09:05:02 2010
@@ -1347,12 +1347,22 @@
 }
 
 /// make_definition_llvm - Ensures that the body or initial value of the given
-/// GCC declaration will be output, and returns a declaration for it.
+/// GCC global will be output, and returns a declaration for it.
 Value *make_definition_llvm(tree decl) {
   // Only need to do something special for global variables.
   if (TREE_CODE(decl) != CONST_DECL && TREE_CODE(decl) != VAR_DECL)
     return DECL_LLVM(decl);
-  if ((!DECL_INITIAL(decl) && TREE_PUBLIC(decl)) || DECL_EXTERNAL(decl))
+  // Do not allocate storage for external references (eg: a "weakref" alias).
+  if (DECL_EXTERNAL(decl))
+    return DECL_LLVM(decl);
+  // Can only assign initial values to global variables in static storage.
+  if (!TREE_STATIC(decl)) {
+    assert(!DECL_INITIAL(decl) && "Non-static global has initial value!");
+    return DECL_LLVM(decl);
+  }
+  // Public static variables will be output later anyway, so there is no point
+  // in outputting them here.
+  if (TREE_CODE(decl) == VAR_DECL && TREE_PUBLIC(decl))
     return DECL_LLVM(decl);
   GlobalValue *GV = cast<GlobalValue>(DECL_LLVM(decl));
   // If we already output a definition for this declaration, then reuse it.

Modified: dragonegg/trunk/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=95386&r1=95385&r2=95386&view=diff

==============================================================================
--- dragonegg/trunk/llvm-internal.h (original)
+++ dragonegg/trunk/llvm-internal.h Fri Feb  5 09:05:02 2010
@@ -118,7 +118,7 @@
 #define DECL_LLVM_SET_P(NODE) (DECL_LLVM_IF_SET(NODE) != NULL)
 
 /// DEFINITION_LLVM - Ensures that the body or initial value of the given GCC
-/// declaration will be output, and returns a declaration for it.
+/// global will be output, and returns a declaration for it.
 Value *make_definition_llvm(union tree_node *decl);
 #define DEFINITION_LLVM(NODE) make_definition_llvm(NODE)
 





More information about the llvm-commits mailing list