[llvm-commits] [llvm-gcc-4.2] r133482 - in /llvm-gcc-4.2/trunk/gcc: c-pch.c llvm-backend.cpp llvm.h testsuite/g++.dg/pch/template-2.C testsuite/g++.dg/pch/template-2.Hs

Devang Patel dpatel at apple.com
Mon Jun 20 16:55:02 PDT 2011


Author: dpatel
Date: Mon Jun 20 18:55:02 2011
New Revision: 133482

URL: http://llvm.org/viewvc/llvm-project?rev=133482&view=rev
Log:
If TypeUsers are lazily read from PCH only when a function is emitted then they may never happen. Read TypeUsers after reading PCH.

Added:
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/pch/template-2.C
    llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/pch/template-2.Hs
Modified:
    llvm-gcc-4.2/trunk/gcc/c-pch.c
    llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
    llvm-gcc-4.2/trunk/gcc/llvm.h

Modified: llvm-gcc-4.2/trunk/gcc/c-pch.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-pch.c?rev=133482&r1=133481&r2=133482&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-pch.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-pch.c Mon Jun 20 18:55:02 2011
@@ -446,6 +446,12 @@
      been loaded.  */
   if (lang_post_pch_load)
     (*lang_post_pch_load) ();
+  /* LLVM LOCAL begin */
+#ifdef ENABLE_LLVM
+  llvm_post_pch_read();
+#endif
+  /* LLVM LOCAL end */
+
 }
 
 /* Indicate that no more PCH files should be read.  */

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=133482&r1=133481&r2=133482&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Jun 20 18:55:02 2011
@@ -633,6 +633,11 @@
   flag_llvm_pch_read = 1;
 }
 
+// Initialize remainign llvm specific data structures after pch is loaded.
+void llvm_post_pch_read() {
+  readLLVMTypeUsers();
+}
+
 /// llvm_pch_write_init - Initialize PCH writing. 
 void llvm_pch_write_init(void) {
   timevar_push(TV_LLVM_INIT);
@@ -1123,17 +1128,6 @@
     return;  // Do not process broken code.
   }
 
-  // Initial fill of TypeRefinementDatabase::TypeUsers[] if we're
-  // using a PCH.  Won't work until the GCC PCH has been read in and
-  // digested.
-  {
-    static bool done = false;
-    if (!done && flag_llvm_pch_read) {
-      readLLVMTypeUsers();
-      done = true;
-    }
-  }
-
   timevar_push(TV_LLVM_FUNCS);
 
   // Convert the AST to raw/ugly LLVM code.

Modified: llvm-gcc-4.2/trunk/gcc/llvm.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm.h?rev=133482&r1=133481&r2=133482&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm.h Mon Jun 20 18:55:02 2011
@@ -103,6 +103,9 @@
 /* Read bytecodes from PCH file.  */
 void llvm_pch_read(const unsigned char *, unsigned);
 
+/* Initialize remainign llvm specific data structures after pch is loaded.  */
+void llvm_post_pch_read(void);
+
 /* llvm_asm_file_start - Start the .s file. */
 void llvm_asm_file_start(void);
 

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/pch/template-2.C
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.dg/pch/template-2.C?rev=133482&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/pch/template-2.C (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/pch/template-2.C Mon Jun 20 18:55:02 2011
@@ -0,0 +1,2 @@
+/* { dg-options "-m32 -I." } */
+#include "template-2.H"

Added: llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/pch/template-2.Hs
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.dg/pch/template-2.Hs?rev=133482&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/pch/template-2.Hs (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/pch/template-2.Hs Mon Jun 20 18:55:02 2011
@@ -0,0 +1,34 @@
+/* { dg-options "-m32 -I." } */
+
+
+namespace ATL
+{
+
+typedef struct 
+{
+unsigned int size;
+} my_module;
+
+class CAM1;
+__attribute__((weak)) CAM1* _p1 = __null;
+class CAM1 : public my_module
+{
+};
+
+template <class T>
+class CAM1T : public CAM1
+{
+public :
+	CAM1T() throw() {}
+};
+
+class CAM2;
+__attribute__((weak)) CAM2* _pModule = __null;
+class CAM2 : public CAM1T<CAM2>
+{
+public :
+	CAM2() {}
+};
+
+}
+





More information about the llvm-commits mailing list