[llvm-commits] [llvm-gcc-4.2] r40580 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp toplev.c

Anton Korobeynikov asl at math.spbu.ru
Sun Jul 29 09:46:08 PDT 2007


Author: asl
Date: Sun Jul 29 11:46:07 2007
New Revision: 40580

URL: http://llvm.org/viewvc/llvm-project?rev=40580&view=rev
Log:
Unbreak C++ FE. libstdc++ can be compiled now and even tests from llvm-testsuite passed!

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    llvm-gcc-4.2/trunk/gcc/toplev.c

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=40580&r1=40579&r2=40580&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Sun Jul 29 11:46:07 2007
@@ -69,6 +69,13 @@
 
 #define ITANIUM_STYLE_EXCEPTIONS
 
+// Check for GCC bug 17347: C++ FE sometimes creates bogus ctor trees
+// which we should throw out
+#define BOGUS_CTOR(exp)                                                \
+  (DECL_INITIAL(exp) &&                                                \
+   TREE_CODE(DECL_INITIAL(exp)) == CONSTRUCTOR &&                      \
+   !TREE_TYPE(DECL_INITIAL(exp)))
+
 //===----------------------------------------------------------------------===//
 //                   Matching LLVM Values with GCC DECL trees
 //===----------------------------------------------------------------------===//
@@ -5106,7 +5113,9 @@
     // If this is an aggregate, emit it to LLVM now.  GCC happens to
     // get this case right by forcing the initializer into memory.
     if (TREE_CODE(exp) == CONST_DECL || TREE_CODE(exp) == VAR_DECL) {
-      if ((DECL_INITIAL(exp) || !TREE_PUBLIC(exp)) && GV->isDeclaration()) {
+      if ((DECL_INITIAL(exp) || !TREE_PUBLIC(exp)) && !DECL_EXTERNAL(exp) &&
+          GV->isDeclaration() &&
+          !BOGUS_CTOR(exp)) {
         emit_global_to_llvm(exp);
         Decl = DECL_LLVM(exp);     // Decl could have change if it changed type.
       }
@@ -6224,7 +6233,9 @@
   // If this is an aggregate, emit it to LLVM now.  GCC happens to
   // get this case right by forcing the initializer into memory.
   if (TREE_CODE(exp) == CONST_DECL || TREE_CODE(exp) == VAR_DECL) {
-    if ((DECL_INITIAL(exp) || !TREE_PUBLIC(exp)) && Val->isDeclaration()) {
+    if ((DECL_INITIAL(exp) || !TREE_PUBLIC(exp)) && !DECL_EXTERNAL(exp) &&
+        Val->isDeclaration() &&
+        !BOGUS_CTOR(exp)) {
       emit_global_to_llvm(exp);
       // Decl could have change if it changed type.
       Val = cast<GlobalValue>(DECL_LLVM(exp));

Modified: llvm-gcc-4.2/trunk/gcc/toplev.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/toplev.c?rev=40580&r1=40579&r2=40580&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/toplev.c (original)
+++ llvm-gcc-4.2/trunk/gcc/toplev.c Sun Jul 29 11:46:07 2007
@@ -2135,6 +2135,7 @@
   /* LLVM LOCAL begin */
 #ifdef ENABLE_LLVM
   llvm_lang_dependent_init(name);
+  init_eh();
   return 1; /* don't initialize the RTL backend */
 #endif
   /* LLVM LOCAL end */





More information about the llvm-commits mailing list