xref: /llvm-project/llvm/lib/Transforms/Scalar/JumpThreading.cpp (revision b3b6007c8b46c38ac9ab3913bacc36f036ea82b5)
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 }
53