Check in a couple of changes that I apparently never committed:
authorJohn McCall <rjmccall@apple.com>
Tue, 24 Aug 2010 09:16:51 +0000 (09:16 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 24 Aug 2010 09:16:51 +0000 (09:16 +0000)
  - teach DifferenceEngine to unify successors of calls and invokes
    in certain circumstances
  - basic blocks actually don't have their own numbering;  did that change?
  - add llvm-diff to the Makefile and CMake build systems

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111909 91177308-0d34-0410-b5e6-96231b3b80d8

tools/CMakeLists.txt
tools/Makefile
tools/llvm-diff/DifferenceEngine.cpp
tools/llvm-diff/llvm-diff.cpp

index 6ca57302d23bcc0d7dd0aab238e5c845f30bc622..7ed10e9729dea114282bf3c54c89585027775882 100644 (file)
@@ -27,6 +27,7 @@ add_subdirectory(llvm-link)
 add_subdirectory(lli)
 
 add_subdirectory(llvm-extract)
 add_subdirectory(lli)
 
 add_subdirectory(llvm-extract)
+add_subdirectory(llvm-diff)
 
 add_subdirectory(bugpoint)
 add_subdirectory(bugpoint-passes)
 
 add_subdirectory(bugpoint)
 add_subdirectory(bugpoint-passes)
index e6d9207a1dc066e8c69d3eacdea682cb229065fc..aa07a2b1b77f8d196fcc508948f52d7ced8c1ae5 100644 (file)
@@ -21,7 +21,7 @@ PARALLEL_DIRS := opt llvm-as llvm-dis \
                  llvm-ld llvm-prof llvm-link \
                  lli llvm-extract llvm-mc \
                  bugpoint llvm-bcanalyzer llvm-stub \
                  llvm-ld llvm-prof llvm-link \
                  lli llvm-extract llvm-mc \
                  bugpoint llvm-bcanalyzer llvm-stub \
-                 llvmc
+                 llvmc llvm-diff
 
 # Let users override the set of tools to build from the command line.
 ifdef ONLY_TOOLS
 
 # Let users override the set of tools to build from the command line.
 ifdef ONLY_TOOLS
index 7436d1ed4e3cb74880c8ed123c20a815deea62b7..b0a24d0737eca606eedea8325500da9c682b41db 100644 (file)
@@ -590,6 +590,39 @@ void FunctionDifferenceEngine::runBlockDiff(BasicBlock::iterator LStart,
     unify(&*LI, &*RI);
     ++LI, ++RI;
   }
     unify(&*LI, &*RI);
     ++LI, ++RI;
   }
+
+  // If the terminators have different kinds, but one is an invoke and the
+  // other is an unconditional branch immediately following a call, unify
+  // the results and the destinations.
+  TerminatorInst *LTerm = LStart->getParent()->getTerminator();
+  TerminatorInst *RTerm = RStart->getParent()->getTerminator();
+  if (isa<BranchInst>(LTerm) && isa<InvokeInst>(RTerm)) {
+    if (cast<BranchInst>(LTerm)->isConditional()) return;
+    BasicBlock::iterator I = LTerm;
+    if (I == LStart->getParent()->begin()) return;
+    --I;
+    if (!isa<CallInst>(*I)) return;
+    CallInst *LCall = cast<CallInst>(&*I);
+    InvokeInst *RInvoke = cast<InvokeInst>(RTerm);
+    if (!equivalentAsOperands(LCall->getCalledValue(), RInvoke->getCalledValue()))
+      return;
+    if (!LCall->use_empty())
+      Values[LCall] = RInvoke;
+    tryUnify(LTerm->getSuccessor(0), RInvoke->getNormalDest());
+  } else if (isa<InvokeInst>(LTerm) && isa<BranchInst>(RTerm)) {
+    if (cast<BranchInst>(RTerm)->isConditional()) return;
+    BasicBlock::iterator I = RTerm;
+    if (I == RStart->getParent()->begin()) return;
+    --I;
+    if (!isa<CallInst>(*I)) return;
+    CallInst *RCall = cast<CallInst>(I);
+    InvokeInst *LInvoke = cast<InvokeInst>(LTerm);
+    if (!equivalentAsOperands(LInvoke->getCalledValue(), RCall->getCalledValue()))
+      return;
+    if (!LInvoke->use_empty())
+      Values[LInvoke] = RCall;
+    tryUnify(LInvoke->getNormalDest(), RTerm->getSuccessor(0));
+  }
 }
 
 }
 }
 
 }
index cc5d233db3be51d586b3f2ae1346b8a8ff81fb03..16a990fb2812921ce0ab7964b3b46d016fcc2694 100644 (file)
@@ -75,7 +75,6 @@ struct DiffContext {
 };
 
 void ComputeNumbering(Function *F, DenseMap<Value*,unsigned> &Numbering) {
 };
 
 void ComputeNumbering(Function *F, DenseMap<Value*,unsigned> &Numbering) {
-  unsigned BBN = 0;
   unsigned IN = 0;
 
   // Arguments get the first numbers.
   unsigned IN = 0;
 
   // Arguments get the first numbers.
@@ -86,9 +85,8 @@ void ComputeNumbering(Function *F, DenseMap<Value*,unsigned> &Numbering) {
 
   // Walk the basic blocks in order.
   for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) {
 
   // Walk the basic blocks in order.
   for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) {
-    // Basic blocks have their own 'namespace'.
     if (!FI->hasName())
     if (!FI->hasName())
-      Numbering[&*FI] = BBN++;
+      Numbering[&*FI] = IN++;
 
     // Walk the instructions in order.
     for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI)
 
     // Walk the instructions in order.
     for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI)