[llvm-commits] [llvm-gcc-4.2] r59286 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp testsuite/gcc.apple/StaticInit.c
Devang Patel
dpatel at apple.com
Thu Nov 13 17:43:41 PST 2008
Author: dpatel
Date: Thu Nov 13 19:43:41 2008
New Revision: 59286
URL: http://llvm.org/viewvc/llvm-project?rev=59286&view=rev
Log:
static int i;
void foo() { /* use i */ }
static int i = 42;
Convert this properly.
Added:
llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/StaticInit.c
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=59286&r1=59285&r2=59286&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Thu Nov 13 19:43:41 2008
@@ -1013,6 +1013,11 @@
if (TREE_CODE(decl) == VAR_DECL && DECL_REGISTER(decl))
return;
+ // If tree nodes says defer output then do not emit global yet.
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_WITH_VIS)
+ && (DECL_DEFER_OUTPUT(decl)))
+ return;
+
timevar_push(TV_LLVM_GLOBALS);
// Get or create the global variable now.
Added: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/StaticInit.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/StaticInit.c?rev=59286&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/StaticInit.c (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/StaticInit.c Thu Nov 13 19:43:41 2008
@@ -0,0 +1,16 @@
+/* LLVM LOCAL file */
+/* { dg-do run } */
+static int (*foo)(long int key);
+static int bar(long int key)
+{
+ foo = 0;
+ return key;
+}
+static int (*foo)(long int key) = bar;
+
+int main() {
+ foo(123);
+ return 0;
+}
+
+
More information about the llvm-commits
mailing list