mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
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
This commit is contained in:
parent
e96eec0c69
commit
592488a4ef
@ -9,7 +9,7 @@
|
||||
LEVEL = ../..
|
||||
|
||||
TOOLNAME = llvm-prof
|
||||
LINK_COMPONENTS = bcreader analysis
|
||||
LINK_COMPONENTS = bcreader bitreader analysis
|
||||
REQUIRES_EH := 1
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
@ -18,8 +18,10 @@
|
||||
#include "llvm/Assembly/AsmAnnotationWriter.h"
|
||||
#include "llvm/Analysis/ProfileInfoLoader.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
@ -30,6 +32,7 @@
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
cl::opt<std::string>
|
||||
BytecodeFile(cl::Positional, cl::desc("<program bytecode file>"),
|
||||
cl::Required);
|
||||
@ -116,9 +119,20 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Read in the bytecode file...
|
||||
std::string ErrorMessage;
|
||||
Module *M = ParseBytecodeFile(BytecodeFile,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMessage);
|
||||
Module *M;
|
||||
if (Bitcode) {
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&BytecodeFile[0],
|
||||
BytecodeFile.size());
|
||||
if (Buffer == 0)
|
||||
ErrorMessage = "Error reading file '" + BytecodeFile + "'";
|
||||
else
|
||||
M = ParseBitcodeFile(Buffer, &ErrorMessage);
|
||||
delete Buffer;
|
||||
} else {
|
||||
M = ParseBytecodeFile(BytecodeFile,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMessage);
|
||||
}
|
||||
if (M == 0) {
|
||||
std::cerr << argv[0] << ": " << BytecodeFile << ": "
|
||||
<< ErrorMessage << "\n";
|
||||
|
@ -268,12 +268,8 @@ int main(int argc, char **argv) {
|
||||
// Load the input module...
|
||||
std::auto_ptr<Module> M;
|
||||
if (Bitcode) {
|
||||
MemoryBuffer *Buffer;
|
||||
if (InputFilename == "-") {
|
||||
Buffer = MemoryBuffer::getSTDIN();
|
||||
} else {
|
||||
Buffer = MemoryBuffer::getFile(&InputFilename[0], InputFilename.size());
|
||||
}
|
||||
MemoryBuffer *Buffer
|
||||
= MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
|
||||
|
||||
if (Buffer == 0)
|
||||
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
||||
|
Loading…
Reference in New Issue
Block a user