[llvm-commits] [123569] Read bytecodes from PCH file.

dpatel at apple.com dpatel at apple.com
Wed Feb 7 20:36:09 PST 2007


Revision: 123569
Author:   dpatel
Date:     2007-02-07 20:36:09 -0800 (Wed, 07 Feb 2007)

Log Message:
-----------
Read bytecodes from PCH file.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/Makefile.in
    apple-local/branches/llvm/gcc/c-pch.c
    apple-local/branches/llvm/gcc/llvm-backend.cpp
    apple-local/branches/llvm/gcc/llvm-linker-hack.cpp
    apple-local/branches/llvm/gcc/llvm.h

Modified: apple-local/branches/llvm/gcc/Makefile.in
===================================================================
--- apple-local/branches/llvm/gcc/Makefile.in	2007-02-08 04:34:00 UTC (rev 123568)
+++ apple-local/branches/llvm/gcc/Makefile.in	2007-02-08 04:36:09 UTC (rev 123569)
@@ -1069,7 +1069,7 @@
 
 # We use llvm-config to determine the libraries that we need to link in our
 # target, optimizations analyses and the bcwriter.
-LLVMCOMPONENTS := $(LLVMTARGETOBJ) scalaropts transformutils analysis bcwriter ipo
+LLVMCOMPONENTS := $(LLVMTARGETOBJ) scalaropts transformutils analysis bcwriter ipo bcreader
 LLVMLIBFILES := $(shell $(LLVMBINPATH)/llvm-config --libfiles $(LLVMCOMPONENTS))
 LLVMLDFLAGS := $(shell $(LLVMBINPATH)/llvm-config --ldflags)
 LIBS += $(LLVMLDFLAGS)

Modified: apple-local/branches/llvm/gcc/c-pch.c
===================================================================
--- apple-local/branches/llvm/gcc/c-pch.c	2007-02-08 04:34:00 UTC (rev 123568)
+++ apple-local/branches/llvm/gcc/c-pch.c	2007-02-08 04:36:09 UTC (rev 123569)
@@ -429,6 +429,12 @@
 	  written += size;
 	}
       free (buf);
+      /* APPLE LOCAL begin LLVM */
+#ifdef ENABLE_LLVM
+      llvm_pch_read();
+#endif
+  /* APPLE LOCAL end LLVM */
+
     }
   else
     {
@@ -438,6 +444,7 @@
 	cpp_errno (pfile, CPP_DL_ERROR, "seeking");
     }
 
+
   cpp_prepare_state (pfile, &smd);
 
   gt_pch_restore (f);

Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-02-08 04:34:00 UTC (rev 123568)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp	2007-02-08 04:36:09 UTC (rev 123569)
@@ -32,6 +32,7 @@
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Assembly/PrintModulePass.h"
 #include "llvm/Bytecode/WriteBytecodePass.h"
+#include "llvm/Bytecode/Reader.h"
 #include "llvm/CodeGen/RegAllocRegistry.h"
 #include "llvm/CodeGen/SchedulerRegistry.h"
 #include "llvm/CodeGen/ScheduleDAG.h"
@@ -184,6 +185,21 @@
 
 oFILEstream *AsmOutStream = 0;
 
+void llvm_pch_read(void) {
+
+  if (TheModule)
+    delete TheModule;
+
+  fclose (asm_out_file);
+  std::string ErrMsg;
+  TheModule = ParseBytecodeFile(asm_file_name, &ErrMsg);
+  if (!TheModule) {
+    cerr << "Error reading bytecodes from PCH file\n";
+    cerr << ErrMsg << "\n";
+    exit(1);
+  }
+}
+
 // Initialize PCH writing. 
 void llvm_pch_write_init(void) {
   timevar_push(TV_LLVM_INIT);

Modified: apple-local/branches/llvm/gcc/llvm-linker-hack.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-linker-hack.cpp	2007-02-08 04:34:00 UTC (rev 123568)
+++ apple-local/branches/llvm/gcc/llvm-linker-hack.cpp	2007-02-08 04:36:09 UTC (rev 123569)
@@ -26,6 +26,7 @@
 #include "llvm/Analysis/LoadValueNumbering.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Bytecode/Writer.h"
+#include "llvm/Bytecode/Reader.h"
 #include "llvm/CodeGen/ScheduleDAG.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Support/Streams.h"
@@ -41,6 +42,7 @@
   new llvm::ExistingModuleProvider(0);
   llvm::createVerifierPass();
   llvm::WriteBytecodeToFile(0, llvm::cout);
+  llvm::ParseBytecodeFile(NULL,NULL);
 
   llvm::createInstructionCombiningPass();
   llvm::createScalarReplAggregatesPass();

Modified: apple-local/branches/llvm/gcc/llvm.h
===================================================================
--- apple-local/branches/llvm/gcc/llvm.h	2007-02-08 04:34:00 UTC (rev 123568)
+++ apple-local/branches/llvm/gcc/llvm.h	2007-02-08 04:36:09 UTC (rev 123569)
@@ -83,6 +83,9 @@
 /* Init pch writing. */
 void llvm_pch_write_init(void);
 
+/* Read bytecodes from PCH file.  */
+void llvm_pch_read(void);
+
 /* llvm_asm_file_start - Start the .s file. */
 void llvm_asm_file_start(void);
 





More information about the llvm-commits mailing list