[llvm-commits] [llvm] r50000 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/JumpThreading.cpp

Chris Lattner sabre at nondot.org
Sun Apr 20 13:35:02 PDT 2008


Author: lattner
Date: Sun Apr 20 15:35:01 2008
New Revision: 50000

URL: http://llvm.org/viewvc/llvm-project?rev=50000&view=rev
Log:
Add a new Jump Threading pass, which will handle cases
such as those in PR2235.  Right now the pass is not very
effective. :)

Added:
    llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
Modified:
    llvm/trunk/include/llvm/LinkAllPasses.h
    llvm/trunk/include/llvm/Transforms/Scalar.h

Modified: llvm/trunk/include/llvm/LinkAllPasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllPasses.h?rev=50000&r1=49999&r2=50000&view=diff

==============================================================================
--- llvm/trunk/include/llvm/LinkAllPasses.h (original)
+++ llvm/trunk/include/llvm/LinkAllPasses.h Sun Apr 20 15:35:01 2008
@@ -103,6 +103,7 @@
       (void) llvm::createStripDeadPrototypesPass();
       (void) llvm::createTailCallEliminationPass();
       (void) llvm::createTailDuplicationPass();
+      (void) llvm::createJumpThreadingPass();
       (void) llvm::createUnifyFunctionExitNodesPass();
       (void) llvm::createCondPropagationPass();
       (void) llvm::createNullProfilerRSPass();

Modified: llvm/trunk/include/llvm/Transforms/Scalar.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar.h?rev=50000&r1=49999&r2=50000&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar.h Sun Apr 20 15:35:01 2008
@@ -199,6 +199,13 @@
 
 //===----------------------------------------------------------------------===//
 //
+// JumpThreading - Thread control through mult-pred/multi-succ blocks where some
+// preds always go to some succ.
+//
+FunctionPass *createJumpThreadingPass();
+  
+  //===----------------------------------------------------------------------===//
+//
 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
 // simplify terminator instructions, etc...
 //

Added: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=50000&view=auto

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (added)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Apr 20 15:35:01 2008
@@ -0,0 +1,52 @@
+//===- JumpThreading.cpp - Thread control through conditional blocks ------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This pass performs 'jump threading', which looks at blocks that have multiple
+// predecessors and multiple successors.  If one or more of the predecessors of
+// the block can be proven to always jump to one of the successors, we forward
+// the edge from the predecessor to the successor by duplicating the contents of
+// this block.
+//
+//===----------------------------------------------------------------------===//
+
+#define DEBUG_TYPE "jump-threading"
+#include "llvm/Transforms/Scalar.h"
+#include "llvm/Pass.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
+using namespace llvm;
+
+//STATISTIC(NumThreads, "Number of jumps threaded");
+
+namespace {
+  cl::opt<unsigned>
+  Threshold("jump-threading-threshold", 
+            cl::desc("Max block size to duplicate for jump threading"),
+            cl::init(6), cl::Hidden);
+  class VISIBILITY_HIDDEN JumpThreading : public FunctionPass {
+  public:
+    static char ID; // Pass identification
+    JumpThreading() : FunctionPass((intptr_t)&ID) {}
+
+    bool runOnFunction(Function &F);
+  };
+  char JumpThreading::ID = 0;
+  RegisterPass<JumpThreading> X("jump-threading", "Jump Threading");
+}
+
+// Public interface to the Jump Threading pass
+FunctionPass *llvm::createJumpThreadingPass() { return new JumpThreading(); }
+
+/// runOnFunction - Top level algorithm.
+///
+bool JumpThreading::runOnFunction(Function &F) {
+  bool Changed = false;
+  return Changed;
+}





More information about the llvm-commits mailing list