Chris Lattner | ee99d15 | 2008-04-20 20:35:01 +0000 | [diff] [blame^] | 1 | //===- JumpThreading.cpp - Thread control through conditional blocks ------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This pass performs 'jump threading', which looks at blocks that have multiple |
| 11 | // predecessors and multiple successors. If one or more of the predecessors of |
| 12 | // the block can be proven to always jump to one of the successors, we forward |
| 13 | // the edge from the predecessor to the successor by duplicating the contents of |
| 14 | // this block. |
| 15 | // |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | |
| 18 | #define DEBUG_TYPE "jump-threading" |
| 19 | #include "llvm/Transforms/Scalar.h" |
| 20 | #include "llvm/Pass.h" |
| 21 | #include "llvm/ADT/Statistic.h" |
| 22 | #include "llvm/Support/CommandLine.h" |
| 23 | #include "llvm/Support/Compiler.h" |
| 24 | using namespace llvm; |
| 25 | |
| 26 | //STATISTIC(NumThreads, "Number of jumps threaded"); |
| 27 | |
| 28 | namespace { |
| 29 | cl::opt<unsigned> |
| 30 | Threshold("jump-threading-threshold", |
| 31 | cl::desc("Max block size to duplicate for jump threading"), |
| 32 | cl::init(6), cl::Hidden); |
| 33 | class VISIBILITY_HIDDEN JumpThreading : public FunctionPass { |
| 34 | public: |
| 35 | static char ID; // Pass identification |
| 36 | JumpThreading() : FunctionPass((intptr_t)&ID) {} |
| 37 | |
| 38 | bool runOnFunction(Function &F); |
| 39 | }; |
| 40 | char JumpThreading::ID = 0; |
| 41 | RegisterPass<JumpThreading> X("jump-threading", "Jump Threading"); |
| 42 | } |
| 43 | |
| 44 | // Public interface to the Jump Threading pass |
| 45 | FunctionPass *llvm::createJumpThreadingPass() { return new JumpThreading(); } |
| 46 | |
| 47 | /// runOnFunction - Top level algorithm. |
| 48 | /// |
| 49 | bool JumpThreading::runOnFunction(Function &F) { |
| 50 | bool Changed = false; |
| 51 | return Changed; |
| 52 | } |