llvm.org GIT mirror llvm / 68d4922
bitcodify git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36838 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
2 changed file(s) with 24 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
2323 BUILD_ARCHIVE = 1
2424 endif
2525
26 LINK_COMPONENTS := $(TARGETS_TO_BUILD) ipo scalaropts linker bcreader bcwriter
26 LINK_COMPONENTS := $(TARGETS_TO_BUILD) ipo scalaropts linker bcreader bcwriter bitreader bitwriter
2727
2828 include $(LEVEL)/Makefile.common
2929
1616 #include "llvm/Linker.h"
1717 #include "llvm/Constants.h"
1818 #include "llvm/DerivedTypes.h"
19 #include "llvm/Bitcode/ReaderWriter.h"
1920 #include "llvm/Bytecode/Reader.h"
2021 #include "llvm/Bytecode/Writer.h"
2122 #include "llvm/Support/CommandLine.h"
2223 #include "llvm/Support/FileUtilities.h"
2324 #include "llvm/Support/SystemUtils.h"
2425 #include "llvm/Support/Mangler.h"
26 #include "llvm/Support/MemoryBuffer.h"
2527 #include "llvm/System/Program.h"
2628 #include "llvm/System/Signals.h"
2729 #include "llvm/Analysis/Passes.h"
5052 return l;
5153 }
5254
53
55 static bool Bitcode = false;
5456
5557 /// If symbol is not used then make it internal and let optimizer takes
5658 /// care of it.
118120 NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str());
119121 if (pos != allModules.end())
120122 m = allModules[InputFilename.c_str()];
121 else {
123 else if (Bitcode) {
124 if (MemoryBuffer *Buffer
125 = MemoryBuffer::getFile(&InputFilename[0], InputFilename.size())) {
126 m = ParseBitcodeFile(Buffer);
127 delete Buffer;
128 }
129 allModules[InputFilename.c_str()] = m;
130 } else {
122131 m = ParseBytecodeFile(InputFilename);
123132 allModules[InputFilename.c_str()] = m;
124133 }
375384 std::string tempFileName(FinalOutputPath.c_str());
376385 tempFileName += "0.bc";
377386 std::ofstream Out(tempFileName.c_str(), io_mode);
378 OStream L(Out);
379 WriteBytecodeToFile(bigOne, L);
387 if (Bitcode) {
388 WriteBitcodeToFile(bigOne, Out);
389 } else {
390 OStream L(Out);
391 WriteBytecodeToFile(bigOne, L);
392 }
380393 }
381394
382395 // Strip leading underscore because it was added to match names
429442 std::string tempFileName(FinalOutputPath.c_str());
430443 tempFileName += "1.bc";
431444 std::ofstream Out(tempFileName.c_str(), io_mode);
432 OStream L(Out);
433 WriteBytecodeToFile(bigOne, L);
445 if (Bitcode) {
446 WriteBitcodeToFile(bigOne, Out);
447 } else {
448 OStream L(Out);
449 WriteBytecodeToFile(bigOne, L);
450 }
434451 }
435452
436453 targetTriple = bigOne->getTargetTriple();