LLVM API Documentation

CodeGenPrepare.cpp File Reference

#include "llvm/Transforms/Scalar.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/InlineAsm.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Transforms/Utils/AddrModeMatcher.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/PatternMatch.h"
#include "llvm/Support/raw_ostream.h"

Include dependency graph for CodeGenPrepare.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "codegenprepare"

Functions

FunctionPass * llvm::createCodeGenPreparePass (const TargetLowering *TLI=0)
static void SplitEdgeNicely (TerminatorInst *TI, unsigned SuccNum, SmallSet< std::pair< const BasicBlock *, const BasicBlock * >, 8 > &BackEdges, Pass *P)
static bool OptimizeNoopCopyExpression (CastInst *CI, const TargetLowering &TLI)
static bool OptimizeCmpExpression (CmpInst *CI)
static bool IsNonLocalValue (Value *V, BasicBlock *BB)

Variables

static cl::opt< bool > FactorCommonPreds ("split-critical-paths-tweak", cl::init(false), cl::Hidden)
static RegisterPass
< CodeGenPrepare > 
X ("codegenprepare","Optimize for code generation")


Define Documentation

#define DEBUG_TYPE   "codegenprepare"

Definition at line 16 of file CodeGenPrepare.cpp.


Function Documentation

static bool IsNonLocalValue ( Value *  V,
BasicBlock *  BB 
) [static]

IsNonLocalValue - Return true if the specified values are defined in a different basic block than BB.

Definition at line 545 of file CodeGenPrepare.cpp.

static bool OptimizeCmpExpression ( CmpInst *  CI  )  [static]

OptimizeCmpExpression - sink the given CmpInst into user blocks to reduce the number of virtual registers that must be created and coalesced. This is a clear win except on targets with multiple condition code registers (PowerPC), where it might lose; some adjustment may be wanted there.

Return true if any changes are made.

InsertedCmp - Only insert a cmp in each block once.

Definition at line 490 of file CodeGenPrepare.cpp.

References llvm::CmpInst::Create(), E, llvm::Instruction::eraseFromParent(), llvm::BasicBlock::getContext(), llvm::BasicBlock::getFirstNonPHI(), llvm::CmpInst::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::CmpInst::getPredicate(), llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().

static bool OptimizeNoopCopyExpression ( CastInst *  CI,
const TargetLowering &  TLI 
) [static]

OptimizeNoopCopyExpression - If the specified cast instruction is a noop copy (e.g. it's casting from one pointer type to another, i32->i8 on PPC), sink it into user blocks to reduce the number of virtual registers that must be created and coalesced.

Return true if any changes are made.

InsertedCasts - Only insert a cast in each block once.

Definition at line 410 of file CodeGenPrepare.cpp.

References llvm::EVT::bitsLT(), llvm::CastInst::Create(), E, llvm::Instruction::eraseFromParent(), llvm::Value::getContext(), llvm::BasicBlock::getFirstNonPHI(), llvm::PHINode::getIncomingBlock(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::TargetLowering::getTypeAction(), llvm::TargetLowering::getTypeToTransformTo(), llvm::TargetLowering::getValueType(), llvm::EVT::isInteger(), llvm::TargetLowering::Promote, llvm::Value::use_begin(), llvm::Value::use_empty(), and llvm::Value::use_end().

static void SplitEdgeNicely ( TerminatorInst *  TI,
unsigned  SuccNum,
SmallSet< std::pair< const BasicBlock *, const BasicBlock * >, 8 > &  BackEdges,
Pass *  P 
) [static]

SplitEdgeNicely - Split the critical edge from TI to its specified successor if it will improve codegen. We only do this if the successor has phi nodes (otherwise critical edges are ok). If there is already another predecessor of the succ that is empty (and thus has no phi nodes), use it instead of introducing a new block.

TIPHIValues - This array is lazily computed to determine the values of PHIs in Dest that TI would provide.

Definition at line 296 of file CodeGenPrepare.cpp.

References BackEdges, llvm::BasicBlock::begin(), Dest, llvm::dyn_cast(), E, llvm::SmallVectorImpl< T >::empty(), FactorCommonPreds, llvm::Function::getEntryBlock(), llvm::PHINode::getIncomingValueForBlock(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::TerminatorInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::BranchInst::isUnconditional(), PI, llvm::pred_begin(), llvm::pred_end(), llvm::SmallVectorImpl< T >::push_back(), llvm::BasicBlock::removePredecessor(), llvm::TerminatorInst::setSuccessor(), llvm::SmallVectorImpl< T >::size(), llvm::SplitBlockPredecessors(), and llvm::SplitCriticalEdge().


Variable Documentation

SmallSet<std::pair<const BasicBlock*, const BasicBlock*>, 8> BackEdges

BackEdges - Keep a set of all the loop back edges.

Definition at line 55 of file CodeGenPrepare.cpp.

Referenced by SplitEdgeNicely().

cl::opt<bool> FactorCommonPreds("split-critical-paths-tweak", cl::init(false), cl::Hidden) [static]

Referenced by SplitEdgeNicely().

char ID [static]

Definition at line 57 of file CodeGenPrepare.cpp.

TLI - Keep a pointer of a TargetLowering to consult for determining transformation profitability.

Definition at line 51 of file CodeGenPrepare.cpp.

RegisterPass<CodeGenPrepare> X("codegenprepare","Optimize for code generation") [static]