X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-diff%2Fllvm-diff.cpp;h=ae58f5caa913855d14844ac7bed46a74b6c16ccd;hb=5f3f254ed1d601c60d03e4437f75783774b03583;hp=62fc026327ea3bc7c22e4bda24ff3845312c4d8c;hpb=7d4e9934e7ca83094c5cf41346966c8350179ff2;p=oota-llvm.git diff --git a/tools/llvm-diff/llvm-diff.cpp b/tools/llvm-diff/llvm-diff.cpp index 62fc026327e..ae58f5caa91 100644 --- a/tools/llvm-diff/llvm-diff.cpp +++ b/tools/llvm-diff/llvm-diff.cpp @@ -20,7 +20,6 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/IRReader/IRReader.h" -#include "llvm/PassManager.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SourceMgr.h" @@ -33,21 +32,22 @@ using namespace llvm; /// Reads a module from a file. On error, messages are written to stderr /// and null is returned. -static Module *ReadModule(LLVMContext &Context, StringRef Name) { +static std::unique_ptr readModule(LLVMContext &Context, + StringRef Name) { SMDiagnostic Diag; - Module *M = ParseIRFile(Name, Diag, Context); + std::unique_ptr M = parseIRFile(Name, Diag, Context); if (!M) Diag.print("llvm-diff", errs()); return M; } -static void diffGlobal(DifferenceEngine &Engine, Module *L, Module *R, +static void diffGlobal(DifferenceEngine &Engine, Module &L, Module &R, StringRef Name) { // Drop leading sigils from the global name. if (Name.startswith("@")) Name = Name.substr(1); - Function *LFn = L->getFunction(Name); - Function *RFn = R->getFunction(Name); + Function *LFn = L.getFunction(Name); + Function *RFn = R.getFunction(Name); if (LFn && RFn) Engine.diff(LFn, RFn); else if (!LFn && !RFn) @@ -68,16 +68,13 @@ static cl::list GlobalsToCompare(cl::Positional, cl::desc("")); int main(int argc, char **argv) { - // Initialize PassManager for -time-passes support. - initializePassManager(); - cl::ParseCommandLineOptions(argc, argv); LLVMContext Context; // Load both modules. Die if that fails. - Module *LModule = ReadModule(Context, LeftFilename); - Module *RModule = ReadModule(Context, RightFilename); + std::unique_ptr LModule = readModule(Context, LeftFilename); + std::unique_ptr RModule = readModule(Context, RightFilename); if (!LModule || !RModule) return 1; DiffConsumer Consumer; @@ -86,15 +83,12 @@ int main(int argc, char **argv) { // If any global names were given, just diff those. if (!GlobalsToCompare.empty()) { for (unsigned I = 0, E = GlobalsToCompare.size(); I != E; ++I) - diffGlobal(Engine, LModule, RModule, GlobalsToCompare[I]); + diffGlobal(Engine, *LModule, *RModule, GlobalsToCompare[I]); // Otherwise, diff everything in the module. } else { - Engine.diff(LModule, RModule); + Engine.diff(LModule.get(), RModule.get()); } - delete LModule; - delete RModule; - return Consumer.hadDifferences(); }