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

Chris Lattner lattner at cs.uiuc.edu
Sat Feb 12 11:08:42 PST 2005



Changes in directory llvm-gcc/gcc:

llvm-expand.c updated: 1.78 -> 1.79
---
Log message:

Deal with PR450: http://llvm.cs.uiuc.edu/PR450  and 502.  There is still an llvm linker patch required to 
make this work though.

This will also give us better optimization capabilities for C++ programs in
some cases.


---
Diffs of the changes:  (+8 -3)

 llvm-expand.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)


Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.78 llvm-gcc/gcc/llvm-expand.c:1.79
--- llvm-gcc/gcc/llvm-expand.c:1.78	Fri Feb 11 13:26:43 2005
+++ llvm-gcc/gcc/llvm-expand.c	Sat Feb 12 13:08:27 2005
@@ -7274,10 +7274,15 @@
 
     if (TREE_READONLY(decl) && !TREE_SIDE_EFFECTS(decl)) {
       if (DECL_EXTERNAL(decl)) {
-        /* Mark external globals constant only if they are lacking ctors/dtors.
+        /* Mark external globals constant even though they could be marked
+         * non-constant in the defining translation unit.  The definition of the
+         * global determines whether the global is ultimately constant or not,
+         * marking this constant will allow us to do some extra (legal)
+         * optimizations that we would otherwise not be able to do.  (In C++,
+         * any global that is 'C++ const' may not be readonly: it could have a
+         * dynamic initializer.
          */
-        if (!TYPE_NEEDS_CONSTRUCTING(TREE_TYPE(decl)))
-          G->isConstant = 1;
+        G->isConstant = 1;
       } else {
         /* Mark readonly globals with constant initializes constant. */
         if (DECL_INITIAL(decl) != error_mark_node && /* uninitialized? */






More information about the llvm-commits mailing list