diff options
author | dim <dim@FreeBSD.org> | 2012-04-14 13:54:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-04-14 13:54:10 +0000 |
commit | 1fc08f5e9ef733ef1ce6f363fecedc2260e78974 (patch) | |
tree | 19c69a04768629f2d440944b71cbe90adae0b615 /tools/llvm-diff | |
parent | 07637c87f826cdf411f0673595e9bc92ebd793f2 (diff) | |
download | FreeBSD-src-1fc08f5e9ef733ef1ce6f363fecedc2260e78974.zip FreeBSD-src-1fc08f5e9ef733ef1ce6f363fecedc2260e78974.tar.gz |
Vendor import of llvm trunk r154661:
http://llvm.org/svn/llvm-project/llvm/trunk@r154661
Diffstat (limited to 'tools/llvm-diff')
-rw-r--r-- | tools/llvm-diff/DiffConsumer.cpp | 6 | ||||
-rw-r--r-- | tools/llvm-diff/DiffConsumer.h | 1 | ||||
-rw-r--r-- | tools/llvm-diff/DifferenceEngine.cpp | 18 | ||||
-rw-r--r-- | tools/llvm-diff/DifferenceEngine.h | 4 | ||||
-rw-r--r-- | tools/llvm-diff/LLVMBuild.txt | 22 | ||||
-rw-r--r-- | tools/llvm-diff/Makefile | 6 | ||||
-rw-r--r-- | tools/llvm-diff/llvm-diff.cpp | 2 |
7 files changed, 48 insertions, 11 deletions
diff --git a/tools/llvm-diff/DiffConsumer.cpp b/tools/llvm-diff/DiffConsumer.cpp index c23e8fb..0528039 100644 --- a/tools/llvm-diff/DiffConsumer.cpp +++ b/tools/llvm-diff/DiffConsumer.cpp @@ -44,6 +44,8 @@ static void ComputeNumbering(Function *F, DenseMap<Value*,unsigned> &Numbering){ } +void Consumer::anchor() { } + void DiffConsumer::printValue(Value *V, bool isL) { if (V->hasName()) { out << (isa<GlobalValue>(V) ? '@' : '%') << V->getName(); @@ -64,6 +66,10 @@ void DiffConsumer::printValue(Value *V, bool isL) { } return; } + if (isa<Constant>(V)) { + out << *V; + return; + } unsigned N = contexts.size(); while (N > 0) { diff --git a/tools/llvm-diff/DiffConsumer.h b/tools/llvm-diff/DiffConsumer.h index b95d427..2060fe1 100644 --- a/tools/llvm-diff/DiffConsumer.h +++ b/tools/llvm-diff/DiffConsumer.h @@ -29,6 +29,7 @@ namespace llvm { /// The interface for consumers of difference data. class Consumer { + virtual void anchor(); public: /// Record that a local context has been entered. Left and /// Right are IR "containers" of some sort which are being diff --git a/tools/llvm-diff/DifferenceEngine.cpp b/tools/llvm-diff/DifferenceEngine.cpp index b240d8c..a5a99f5 100644 --- a/tools/llvm-diff/DifferenceEngine.cpp +++ b/tools/llvm-diff/DifferenceEngine.cpp @@ -319,15 +319,19 @@ class FunctionDifferenceEngine { bool Difference = false; DenseMap<ConstantInt*,BasicBlock*> LCases; - for (unsigned I = 1, E = LI->getNumCases(); I != E; ++I) - LCases[LI->getCaseValue(I)] = LI->getSuccessor(I); - for (unsigned I = 1, E = RI->getNumCases(); I != E; ++I) { - ConstantInt *CaseValue = RI->getCaseValue(I); + + for (SwitchInst::CaseIt I = LI->case_begin(), E = LI->case_end(); + I != E; ++I) + LCases[I.getCaseValue()] = I.getCaseSuccessor(); + + for (SwitchInst::CaseIt I = RI->case_begin(), E = RI->case_end(); + I != E; ++I) { + ConstantInt *CaseValue = I.getCaseValue(); BasicBlock *LCase = LCases[CaseValue]; if (LCase) { - if (TryUnify) tryUnify(LCase, RI->getSuccessor(I)); + if (TryUnify) tryUnify(LCase, I.getCaseSuccessor()); LCases.erase(CaseValue); - } else if (!Difference) { + } else if (Complain || !Difference) { if (Complain) Engine.logf("right switch has extra case %r") << CaseValue; Difference = true; @@ -628,6 +632,8 @@ void FunctionDifferenceEngine::runBlockDiff(BasicBlock::iterator LStart, } +void DifferenceEngine::Oracle::anchor() { } + void DifferenceEngine::diff(Function *L, Function *R) { Context C(*this, L, R); diff --git a/tools/llvm-diff/DifferenceEngine.h b/tools/llvm-diff/DifferenceEngine.h index 5b4f80b..7ea79e4 100644 --- a/tools/llvm-diff/DifferenceEngine.h +++ b/tools/llvm-diff/DifferenceEngine.h @@ -50,7 +50,9 @@ namespace llvm { /// An oracle for answering whether two values are equivalent as /// operands. - struct Oracle { + class Oracle { + virtual void anchor(); + public: virtual bool operator()(Value *L, Value *R) = 0; protected: diff --git a/tools/llvm-diff/LLVMBuild.txt b/tools/llvm-diff/LLVMBuild.txt new file mode 100644 index 0000000..fa06a03 --- /dev/null +++ b/tools/llvm-diff/LLVMBuild.txt @@ -0,0 +1,22 @@ +;===- ./tools/llvm-diff/LLVMBuild.txt --------------------------*- Conf -*--===; +; +; The LLVM Compiler Infrastructure +; +; This file is distributed under the University of Illinois Open Source +; License. See LICENSE.TXT for details. +; +;===------------------------------------------------------------------------===; +; +; This is an LLVMBuild description file for the components in this subdirectory. +; +; For more information on the LLVMBuild system, please see: +; +; http://llvm.org/docs/LLVMBuild.html +; +;===------------------------------------------------------------------------===; + +[component_0] +type = Tool +name = llvm-diff +parent = Tools +required_libraries = AsmParser BitReader diff --git a/tools/llvm-diff/Makefile b/tools/llvm-diff/Makefile index 58e49fa..f7fa715 100644 --- a/tools/llvm-diff/Makefile +++ b/tools/llvm-diff/Makefile @@ -7,11 +7,11 @@ # ##===----------------------------------------------------------------------===## -LEVEL = ../.. -TOOLNAME = llvm-diff +LEVEL := ../.. +TOOLNAME := llvm-diff LINK_COMPONENTS := asmparser bitreader # This tool has no plugins, optimize startup time. -TOOL_NO_EXPORTS = 1 +TOOL_NO_EXPORTS := 1 include $(LEVEL)/Makefile.common diff --git a/tools/llvm-diff/llvm-diff.cpp b/tools/llvm-diff/llvm-diff.cpp index 76853f1..774169b 100644 --- a/tools/llvm-diff/llvm-diff.cpp +++ b/tools/llvm-diff/llvm-diff.cpp @@ -38,7 +38,7 @@ static Module *ReadModule(LLVMContext &Context, StringRef Name) { SMDiagnostic Diag; Module *M = ParseIRFile(Name, Diag, Context); if (!M) - Diag.Print("llvmdiff", errs()); + Diag.print("llvm-diff", errs()); return M; } |