llvm.org GIT mirror llvm / 592488a
add support to llvm-prof for reading from a bitcode file git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36836 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
3 changed file(s) with 20 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
88 LEVEL = ../..
99
1010 TOOLNAME = llvm-prof
11 LINK_COMPONENTS = bcreader analysis
11 LINK_COMPONENTS = bcreader bitreader analysis
1212 REQUIRES_EH := 1
1313
1414 include $(LEVEL)/Makefile.common
1717 #include "llvm/Assembly/AsmAnnotationWriter.h"
1818 #include "llvm/Analysis/ProfileInfoLoader.h"
1919 #include "llvm/Bytecode/Reader.h"
20 #include "llvm/Bitcode/ReaderWriter.h"
2021 #include "llvm/Support/CommandLine.h"
2122 #include "llvm/Support/ManagedStatic.h"
23 #include "llvm/Support/MemoryBuffer.h"
2224 #include "llvm/System/Signals.h"
2325 #include
2426 #include
2931 using namespace llvm;
3032
3133 namespace {
34 cl::opt Bitcode("bitcode");
3235 cl::opt
3336 BytecodeFile(cl::Positional, cl::desc(""),
3437 cl::Required);
115118
116119 // Read in the bytecode file...
117120 std::string ErrorMessage;
118 Module *M = ParseBytecodeFile(BytecodeFile,
119 Compressor::decompressToNewBuffer,
120 &ErrorMessage);
121 Module *M;
122 if (Bitcode) {
123 MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&BytecodeFile[0],
124 BytecodeFile.size());
125 if (Buffer == 0)
126 ErrorMessage = "Error reading file '" + BytecodeFile + "'";
127 else
128 M = ParseBitcodeFile(Buffer, &ErrorMessage);
129 delete Buffer;
130 } else {
131 M = ParseBytecodeFile(BytecodeFile,
132 Compressor::decompressToNewBuffer,
133 &ErrorMessage);
134 }
121135 if (M == 0) {
122136 std::cerr << argv[0] << ": " << BytecodeFile << ": "
123137 << ErrorMessage << "\n";
267267 // Load the input module...
268268 std::auto_ptr M;
269269 if (Bitcode) {
270 MemoryBuffer *Buffer;
271 if (InputFilename == "-") {
272 Buffer = MemoryBuffer::getSTDIN();
273 } else {
274 Buffer = MemoryBuffer::getFile(&InputFilename[0], InputFilename.size());
275 }
270 MemoryBuffer *Buffer
271 = MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
276272
277273 if (Buffer == 0)
278274 ErrorMessage = "Error reading file '" + InputFilename + "'";