aboutsummaryrefslogtreecommitdiff
path: root/lib/Archive/ArchiveWriter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-06 06:18:07 +0000
committerChris Lattner <sabre@nondot.org>2007-05-06 06:18:07 +0000
commite07c15c734fcac9f6a82ae20a93b18799d6ca992 (patch)
tree1dcc0696afa32dd6e0d76014419f54eb3ef02eb3 /lib/Archive/ArchiveWriter.cpp
parent1a019e5ffd0d8643ddffc7ed5736eb78065c5f88 (diff)
add bitcode support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36856 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Archive/ArchiveWriter.cpp')
-rw-r--r--lib/Archive/ArchiveWriter.cpp46
1 files changed, 3 insertions, 43 deletions
diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp
index b8e3280c12..f08526ce82 100644
--- a/lib/Archive/ArchiveWriter.cpp
+++ b/lib/Archive/ArchiveWriter.cpp
@@ -13,6 +13,7 @@
#include "ArchiveInternals.h"
#include "llvm/Bytecode/Reader.h"
+#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/Compressor.h"
#include "llvm/System/Signals.h"
#include "llvm/System/Process.h"
@@ -178,6 +179,7 @@ Archive::addFileBefore(const sys::Path& filePath, iterator where,
std::string magic;
mbr->path.getMagicNumber(magic,4);
switch (sys::IdentifyFileType(magic.c_str(),4)) {
+ case sys::Bitcode_FileType:
case sys::Bytecode_FileType:
flags |= ArchiveMember::BytecodeFlag;
break;
@@ -261,40 +263,7 @@ Archive::writeMember(
}
}
- // Determine if we actually should compress this member
- bool willCompress =
- (ShouldCompress &&
- !member.isCompressed() &&
- !member.isCompressedBytecode() &&
- !member.isLLVMSymbolTable() &&
- !member.isSVR4SymbolTable() &&
- !member.isBSD4SymbolTable());
-
- // Perform the compression. Note that if the file is uncompressed bytecode
- // then we turn the file into compressed bytecode rather than treating it as
- // compressed data. This is necessary since it allows us to determine that the
- // file contains bytecode instead of looking like a regular compressed data
- // member. A compressed bytecode file has its content compressed but has a
- // magic number of "llvc". This acounts for the +/-4 arithmetic in the code
- // below.
- int hdrSize;
- if (willCompress) {
- char* output = 0;
- if (member.isBytecode()) {
- data +=4;
- fSize -= 4;
- }
- fSize = Compressor::compressToNewBuffer(data,fSize,output,ErrMsg);
- if (fSize == 0)
- return true;
- data = output;
- if (member.isBytecode())
- hdrSize = -fSize-4;
- else
- hdrSize = -fSize;
- } else {
- hdrSize = fSize;
- }
+ int hdrSize = fSize;
// Compute the fields of the header
ArchiveMemberHeader Hdr;
@@ -309,10 +278,6 @@ Archive::writeMember(
member.getPath().toString().length());
}
- // Make sure we write the compressed bytecode magic number if we should.
- if (willCompress && member.isBytecode())
- ARFile.write("llvc",4);
-
// Write the (possibly compressed) member's content to the file.
ARFile.write(data,fSize);
@@ -320,11 +285,6 @@ Archive::writeMember(
if ((ARFile.tellp() & 1) == 1)
ARFile << ARFILE_PAD;
- // Free the compressed data, if necessary
- if (willCompress) {
- free((void*)data);
- }
-
// Close the mapped file if it was opened
if (mFile != 0) {
mFile->close();