blob: 7773edb7e7ee5f26c08bb6fcc976c77f0be65ca9 [file] [log] [blame]
Chris Lattneree99d152008-04-20 20:35:01 +00001//===- 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"
24using namespace llvm;
25
26//STATISTIC(NumThreads, "Number of jumps threaded");
27
28namespace {
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
45FunctionPass *llvm::createJumpThreadingPass() { return new JumpThreading(); }
46
47/// runOnFunction - Top level algorithm.
48///
49bool JumpThreading::runOnFunction(Function &F) {
50 bool Changed = false;
51 return Changed;
52}