LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

LoopUnswitch.cpp File Reference

#include "llvm/Transforms/Scalar.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
#include <algorithm>

Include dependency graph for LoopUnswitch.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "loop-unswitch"

Functions

FunctionPass * createLoopUnswitchPass ()
static void RemapInstruction (Instruction *I, std::map< const Value *, Value * > &ValueMap)
static Loop * CloneLoop (Loop *L, Loop *PL, std::map< const Value *, Value * > &VM, LoopInfo *LI)
static AllocaInst * InsertPHINodesForUsesOutsideLoop (Instruction *OI, Instruction *NI, DominatorSet &DS, Loop *OL, Loop *NL, std::vector< BasicBlock * > &OldExitBlocks, std::map< const Value *, Value * > &ValueMap)


Define Documentation

#define DEBUG_TYPE   "loop-unswitch"
 

Definition at line 29 of file LoopUnswitch.cpp.


Function Documentation

static Loop* CloneLoop (  Loop *  L,
Loop *  PL,
std::map< const Value *, Value * > &  VM,
LoopInfo *  LI
)  [static]
 

CloneLoop - Recursively clone the specified loop and all of its children, mapping the blocks with the specified map.

Definition at line 170 of file LoopUnswitch.cpp.

References llvm::Loop::addChildLoop(), llvm::LoopInfo::addTopLevelLoop(), llvm::Loop::begin(), llvm::Loop::block_begin(), llvm::Loop::block_end(), E, llvm::Loop::end(), llvm::LoopInfo::getLoopFor(), and I.

FunctionPass* createLoopUnswitchPass (   ) 
 

Definition at line 71 of file LoopUnswitch.cpp.

static AllocaInst* InsertPHINodesForUsesOutsideLoop (  Instruction *  OI,
Instruction *  NI,
DominatorSet &  DS,
Loop *  OL,
Loop *  NL,
std::vector< BasicBlock * > &  OldExitBlocks,
std::map< const Value *, Value * > &  ValueMap
)  [static]
 

InsertPHINodesForUsesOutsideLoop - If this instruction is used outside of the specified loop, insert a PHI node in the appropriate exit block to merge the values in the two different loop versions.

Most values are not used outside of the loop they are defined in, so be efficient for this case.

Definition at line 201 of file LoopUnswitch.cpp.

References llvm::Loop::contains(), llvm::DemoteRegToStack(), E, llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm::Value::use_begin(), and llvm::Value::use_end().

static void RemapInstruction (  Instruction *  I,
std::map< const Value *, Value * > &  ValueMap
)  [inline, static]
 

Definition at line 158 of file LoopUnswitch.cpp.

References E, llvm::User::getNumOperands(), llvm::User::getOperand(), and llvm::User::setOperand().


Variable Documentation

Statistic NumUnswitched("loop-unswitch","Number of loops unswitched") [static]
 

RegisterOpt<LoopUnswitch> X("loop-unswitch","Unswitch loops") [static]