summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/llvm-prof/Makefile2
-rw-r--r--tools/llvm-prof/llvm-prof.cpp20
-rw-r--r--tools/opt/opt.cpp8
3 files changed, 20 insertions, 10 deletions
diff --git a/tools/llvm-prof/Makefile b/tools/llvm-prof/Makefile
index b745e65492..72e2bcf184 100644
--- a/tools/llvm-prof/Makefile
+++ b/tools/llvm-prof/Makefile
@@ -9,7 +9,7 @@
LEVEL = ../..
TOOLNAME = llvm-prof
-LINK_COMPONENTS = bcreader analysis
+LINK_COMPONENTS = bcreader bitreader analysis
REQUIRES_EH := 1
include $(LEVEL)/Makefile.common
diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp
index 6b1d514bcd..7b1e292253 100644
--- a/tools/llvm-prof/llvm-prof.cpp
+++ b/tools/llvm-prof/llvm-prof.cpp
@@ -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";
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 6c77085893..218e5f0b1d 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -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 + "'";