[llvm-commits] [llvm] r81632 - in /llvm/trunk/tools/llvm-link: CMakeLists.txt Makefile llvm-link.cpp
Dan Gohman
gohman at apple.com
Sat Sep 12 14:55:12 PDT 2009
Author: djg
Date: Sat Sep 12 16:55:12 2009
New Revision: 81632
URL: http://llvm.org/viewvc/llvm-project?rev=81632&view=rev
Log:
Convert llvm-link to IRReader.
Modified:
llvm/trunk/tools/llvm-link/CMakeLists.txt
llvm/trunk/tools/llvm-link/Makefile
llvm/trunk/tools/llvm-link/llvm-link.cpp
Modified: llvm/trunk/tools/llvm-link/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/CMakeLists.txt?rev=81632&r1=81631&r2=81632&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-link/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-link/CMakeLists.txt Sat Sep 12 16:55:12 2009
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS linker bitreader bitwriter)
+set(LLVM_LINK_COMPONENTS linker bitreader bitwriter asmparser)
add_llvm_tool(llvm-link
llvm-link.cpp
Modified: llvm/trunk/tools/llvm-link/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/Makefile?rev=81632&r1=81631&r2=81632&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-link/Makefile (original)
+++ llvm/trunk/tools/llvm-link/Makefile Sat Sep 12 16:55:12 2009
@@ -9,7 +9,7 @@
LEVEL = ../..
TOOLNAME = llvm-link
-LINK_COMPONENTS = linker bitreader bitwriter
+LINK_COMPONENTS = linker bitreader bitwriter asmparser
# This tool has no plugins, optimize startup time.
TOOL_NO_EXPORTS = 1
Modified: llvm/trunk/tools/llvm-link/llvm-link.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=81632&r1=81631&r2=81632&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-link/llvm-link.cpp (original)
+++ llvm/trunk/tools/llvm-link/llvm-link.cpp Sat Sep 12 16:55:12 2009
@@ -23,6 +23,7 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/SystemUtils.h"
+#include "llvm/Support/IRReader.h"
#include "llvm/System/Signals.h"
#include "llvm/System/Path.h"
#include <memory>
@@ -48,7 +49,8 @@
// LoadFile - Read the specified bitcode file in and return it. This routine
// searches the link path for the specified file to try to find it...
//
-static inline std::auto_ptr<Module> LoadFile(const std::string &FN,
+static inline std::auto_ptr<Module> LoadFile(const char *argv0,
+ const std::string &FN,
LLVMContext& Context) {
sys::Path Filename;
if (!Filename.set(FN)) {
@@ -56,24 +58,17 @@
return std::auto_ptr<Module>();
}
- std::string ErrorMessage;
+ SMDiagnostic Err;
if (Filename.exists()) {
if (Verbose) errs() << "Loading '" << Filename.c_str() << "'\n";
Module* Result = 0;
const std::string &FNStr = Filename.str();
- if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(FNStr,
- &ErrorMessage)) {
- Result = ParseBitcodeFile(Buffer, Context, &ErrorMessage);
- delete Buffer;
- }
+ Result = ParseIRFile(FNStr, Err, Context);
if (Result) return std::auto_ptr<Module>(Result); // Load successful!
- if (Verbose) {
- errs() << "Error opening bitcode file: '" << Filename.c_str() << "'";
- if (ErrorMessage.size()) errs() << ": " << ErrorMessage;
- errs() << "\n";
- }
+ if (Verbose)
+ Err.Print(argv0, errs());
} else {
errs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n";
}
@@ -93,7 +88,8 @@
unsigned BaseArg = 0;
std::string ErrorMessage;
- std::auto_ptr<Module> Composite(LoadFile(InputFilenames[BaseArg], Context));
+ std::auto_ptr<Module> Composite(LoadFile(argv[0],
+ InputFilenames[BaseArg], Context));
if (Composite.get() == 0) {
errs() << argv[0] << ": error loading file '"
<< InputFilenames[BaseArg] << "'\n";
@@ -101,7 +97,8 @@
}
for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
- std::auto_ptr<Module> M(LoadFile(InputFilenames[i], Context));
+ std::auto_ptr<Module> M(LoadFile(argv[0],
+ InputFilenames[i], Context));
if (M.get() == 0) {
errs() << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n";
return 1;
More information about the llvm-commits
mailing list