[llvm-commits] [llvm] r111909 - in /llvm/trunk/tools: CMakeLists.txt Makefile llvm-diff/DifferenceEngine.cpp llvm-diff/llvm-diff.cpp

John McCall rjmccall at apple.com
Tue Aug 24 02:16:51 PDT 2010


Author: rjmccall
Date: Tue Aug 24 04:16:51 2010
New Revision: 111909

URL: http://llvm.org/viewvc/llvm-project?rev=111909&view=rev
Log:
Check in a couple of changes that I apparently never committed:
  - 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


Modified:
    llvm/trunk/tools/CMakeLists.txt
    llvm/trunk/tools/Makefile
    llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp
    llvm/trunk/tools/llvm-diff/llvm-diff.cpp

Modified: llvm/trunk/tools/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/CMakeLists.txt?rev=111909&r1=111908&r2=111909&view=diff
==============================================================================
--- llvm/trunk/tools/CMakeLists.txt (original)
+++ llvm/trunk/tools/CMakeLists.txt Tue Aug 24 04:16:51 2010
@@ -27,6 +27,7 @@
 add_subdirectory(lli)
 
 add_subdirectory(llvm-extract)
+add_subdirectory(llvm-diff)
 
 add_subdirectory(bugpoint)
 add_subdirectory(bugpoint-passes)

Modified: llvm/trunk/tools/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/Makefile?rev=111909&r1=111908&r2=111909&view=diff
==============================================================================
--- llvm/trunk/tools/Makefile (original)
+++ llvm/trunk/tools/Makefile Tue Aug 24 04:16:51 2010
@@ -21,7 +21,7 @@
                  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

Modified: llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp?rev=111909&r1=111908&r2=111909&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp (original)
+++ llvm/trunk/tools/llvm-diff/DifferenceEngine.cpp Tue Aug 24 04:16:51 2010
@@ -590,6 +590,39 @@
     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));
+  }
 }
 
 }

Modified: llvm/trunk/tools/llvm-diff/llvm-diff.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-diff/llvm-diff.cpp?rev=111909&r1=111908&r2=111909&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-diff/llvm-diff.cpp (original)
+++ llvm/trunk/tools/llvm-diff/llvm-diff.cpp Tue Aug 24 04:16:51 2010
@@ -75,7 +75,6 @@
 };
 
 void ComputeNumbering(Function *F, DenseMap<Value*,unsigned> &Numbering) {
-  unsigned BBN = 0;
   unsigned IN = 0;
 
   // Arguments get the first numbers.
@@ -86,9 +85,8 @@
 
   // 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())
-      Numbering[&*FI] = BBN++;
+      Numbering[&*FI] = IN++;
 
     // Walk the instructions in order.
     for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI)





More information about the llvm-commits mailing list