diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-04-20 20:35:01 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-04-20 20:35:01 +0000 |
| commit | b3b6007c8b46c38ac9ab3913bacc36f036ea82b5 (patch) | |
| tree | 7df0b45a293b974277080ef5b68811a306a8e951 /llvm | |
| parent | 912bec79ca9bfc4e27634248fbb84257ee2b772b (diff) | |
| download | bcm5719-llvm-b3b6007c8b46c38ac9ab3913bacc36f036ea82b5.tar.gz bcm5719-llvm-b3b6007c8b46c38ac9ab3913bacc36f036ea82b5.zip | |
Add a new Jump Threading pass, which will handle cases
such as those in PR2235. Right now the pass is not very
effective. :)
llvm-svn: 50000
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/LinkAllPasses.h | 1 | ||||
| -rw-r--r-- | llvm/include/llvm/Transforms/Scalar.h | 7 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 52 |
3 files changed, 60 insertions, 0 deletions
diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h index 360f9dff94a..c13b1e63bc2 100644 --- a/llvm/include/llvm/LinkAllPasses.h +++ b/llvm/include/llvm/LinkAllPasses.h @@ -103,6 +103,7 @@ namespace { (void) llvm::createStripDeadPrototypesPass(); (void) llvm::createTailCallEliminationPass(); (void) llvm::createTailDuplicationPass(); + (void) llvm::createJumpThreadingPass(); (void) llvm::createUnifyFunctionExitNodesPass(); (void) llvm::createCondPropagationPass(); (void) llvm::createNullProfilerRSPass(); diff --git a/llvm/include/llvm/Transforms/Scalar.h b/llvm/include/llvm/Transforms/Scalar.h index c7e87239c4f..bcb791617b2 100644 --- a/llvm/include/llvm/Transforms/Scalar.h +++ b/llvm/include/llvm/Transforms/Scalar.h @@ -199,6 +199,13 @@ FunctionPass *createTailDuplicationPass(); //===----------------------------------------------------------------------===// // +// 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... // diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp new file mode 100644 index 00000000000..7773edb7e7e --- /dev/null +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -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; +} |

