Revision: 124571 Author: dpatel Date: 2007-03-05 14:40:18 -0800 (Mon, 05 Mar 2007)
Log Message: ----------- While reading PCH, Parse Bytecodes directly from memory. Modified Paths: -------------- apple-local/branches/llvm/gcc/c-pch.c apple-local/branches/llvm/gcc/llvm-backend.cpp apple-local/branches/llvm/gcc/llvm.h Modified: apple-local/branches/llvm/gcc/c-pch.c =================================================================== --- apple-local/branches/llvm/gcc/c-pch.c 2007-03-05 11:35:52 UTC (rev 124570) +++ apple-local/branches/llvm/gcc/c-pch.c 2007-03-05 22:40:18 UTC (rev 124571) @@ -415,6 +415,13 @@ if (!flag_preprocess_only) { + /* APPLE LOCAL begin LLVM */ +#ifdef ENABLE_LLVM + unsigned char *buf = xmalloc (h.asm_size); + if (fread (buf, h.asm_size, 1, f) != 1) + cpp_errno (pfile, CPP_DL_ERROR, "reading"); + llvm_pch_read(buf, h.asm_size); +#else unsigned long written; char * buf = xmalloc (16384); @@ -428,13 +435,9 @@ cpp_errno (pfile, CPP_DL_ERROR, "reading"); written += size; } +#endif + /* APPLE LOCAL end LLVM */ free (buf); - /* APPLE LOCAL begin LLVM */ -#ifdef ENABLE_LLVM - llvm_pch_read(); -#endif - /* APPLE LOCAL end LLVM */ - } else { Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp =================================================================== --- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-03-05 11:35:52 UTC (rev 124570) +++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-03-05 22:40:18 UTC (rev 124571) @@ -189,16 +189,16 @@ /// Read bytecode from PCH file. Initialize TheModue and setup /// LTypes vector. -void llvm_pch_read(void) { +void llvm_pch_read(const unsigned char *Buffer, unsigned Size) { + std::string ModuleName = TheModule->getModuleIdentifier(); if (TheModule) delete TheModule; - fclose (asm_out_file); - - std::string ErrMsg; clearTargetBuiltinCache(); - TheModule = ParseBytecodeFile(asm_file_name, + + std::string ErrMsg; + TheModule = ParseBytecodeBuffer(Buffer, Size, ModuleName, Compressor::decompressToNewBuffer, &ErrMsg); if (!TheModule) { @@ -207,12 +207,6 @@ exit(1); } - // Reopen asm_out_file for the rest of the compiler's use. - // This also removes llvm byte code from the asm_out_file. - asm_out_file = fopen (asm_file_name, "w+b"); - if (asm_out_file == 0) - fatal_error ("can%'t open %s for writing: %m", asm_file_name); - // Read LLVM Types string table readLLVMTypesStringTable(); readLLVMValuesStringTable(); Modified: apple-local/branches/llvm/gcc/llvm.h =================================================================== --- apple-local/branches/llvm/gcc/llvm.h 2007-03-05 11:35:52 UTC (rev 124570) +++ apple-local/branches/llvm/gcc/llvm.h 2007-03-05 22:40:18 UTC (rev 124571) @@ -89,7 +89,7 @@ void llvm_pch_write_init(void); /* Read bytecodes from PCH file. */ -void llvm_pch_read(void); +void llvm_pch_read(const unsigned char *, unsigned); /* llvm_asm_file_start - Start the .s file. */ void llvm_asm_file_start(void); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits