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