|
LLVM
7.0.0
|
#include "llvm/Transforms/Scalar/ConstantHoisting.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/None.h"#include "llvm/ADT/Optional.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/BlockFrequencyInfo.h"#include "llvm/Analysis/TargetTransformInfo.h"#include "llvm/Transforms/Utils/Local.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DebugInfoMetadata.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Value.h"#include "llvm/Pass.h"#include "llvm/Support/BlockFrequency.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Scalar.h"#include <algorithm>#include <cassert>#include <cstdint>#include <iterator>#include <tuple>#include <utility>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "consthoist" |
Functions | |
| STATISTIC (NumConstantsHoisted, "Number of constants hoisted") | |
| STATISTIC (NumConstantsRebased, "Number of constants rebased") | |
| INITIALIZE_PASS_BEGIN (ConstantHoistingLegacyPass, "consthoist", "Constant Hoisting", false, false) INITIALIZE_PASS_END(ConstantHoistingLegacyPass | |
| static void | findBestInsertionSet (DominatorTree &DT, BlockFrequencyInfo &BFI, BasicBlock *Entry, SmallPtrSet< BasicBlock *, 8 > &BBs) |
Given BBs as input, find another set of BBs which collectively dominates BBs and have the minimal sum of frequencies. More... | |
| static Optional< APInt > | calculateOffsetDiff (const APInt &V1, const APInt &V2) |
| static bool | updateOperand (Instruction *Inst, unsigned Idx, Instruction *Mat) |
| Updates the operand at Idx in instruction Inst with the result of instruction Mat. More... | |
Variables | |
| static cl::opt< bool > | ConstHoistWithBlockFrequency ("consthoist-with-block-frequency", cl::init(true), cl::Hidden, cl::desc("Enable the use of the block frequency analysis to reduce the " "chance to execute const materialization more frequently than " "without hoisting.")) |
| consthoist | |
| Constant | Hoisting |
| Constant | false |
| #define DEBUG_TYPE "consthoist" |
Definition at line 74 of file ConstantHoisting.cpp.
Definition at line 451 of file ConstantHoisting.cpp.
References llvm::consthoist::ConstantInfo::BaseConstant, llvm::consthoist::ConstantCandidate::ConstInt, llvm::dbgs(), E, llvm::ConstantInt::get(), llvm::IntegerType::getBitWidth(), llvm::APInt::getBitWidth(), llvm::APInt::getLimitedValue(), llvm::APInt::getSExtValue(), llvm::ConstantInt::getType(), llvm::ConstantInt::getValue(), llvm::Optional< T >::getValue(), LLVM_DEBUG, llvm::None, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::consthoist::ConstantInfo::RebasedConstants, llvm::sort(), and llvm::APInt::ult().
|
static |
Given BBs as input, find another set of BBs which collectively dominates BBs and have the minimal sum of frequencies.
Return the BB set found in BBs.
Definition at line 193 of file ConstantHoisting.cpp.
References assert(), llvm::BasicBlock::begin(), llvm::SmallPtrSetImpl< PtrType >::begin(), llvm::AMDGPUISD::BFI, llvm::canReplaceOperandWithVariable(), llvm::SmallPtrSetImplBase::clear(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), E, llvm::SmallVectorBase::empty(), llvm::SmallPtrSetImpl< PtrType >::end(), llvm::SmallPtrSetImpl< PtrType >::erase(), llvm::DomTreeNodeBase< NodeT >::getBlock(), llvm::BlockFrequencyInfo::getBlockFreq(), llvm::DomTreeNodeBase< NodeT >::getChildren(), llvm::DomTreeNodeBase< NodeT >::getIDom(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::ConstantInt::getType(), llvm::ConstantInt::getValue(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::Instruction::isCast(), llvm::BasicBlock::isEHPad(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateCommon< T >::rbegin(), llvm::consthoist::ConstantInfo::RebasedConstants, llvm::SmallVectorTemplateCommon< T >::rend(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::reserve(), llvm::SmallVectorBase::size(), llvm::SmallPtrSetImplBase::size(), and llvm::TargetTransformInfo::TCC_Basic.
| INITIALIZE_PASS_BEGIN | ( | ConstantHoistingLegacyPass | , |
| "consthoist" | , | ||
| "Constant Hoisting" | , | ||
| false | , | ||
| false | |||
| ) |
| STATISTIC | ( | NumConstantsHoisted | , |
| "Number of constants hoisted" | |||
| ) |
| STATISTIC | ( | NumConstantsRebased | , |
| "Number of constants rebased" | |||
| ) |
|
static |
Updates the operand at Idx in instruction Inst with the result of instruction Mat.
If the instruction is a PHI node then special handling for duplicate values form the same incoming basic block is required.
Definition at line 610 of file ConstantHoisting.cpp.
References llvm::MCID::Add, assert(), llvm::consthoist::ConstantInfo::BaseConstant, llvm::Instruction::clone(), llvm::BinaryOperator::Create(), llvm::dbgs(), llvm::SmallPtrSetImplBase::empty(), llvm::Instruction::eraseFromParent(), llvm::Instruction::getDebugLoc(), llvm::DILocation::getMergedLocation(), llvm::Value::getName(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::ConstantInt::getType(), I, llvm::Instruction::insertBefore(), llvm::consthoist::ConstantUser::Inst, llvm::Instruction::isCast(), LLVM_DEBUG, llvm::consthoist::ConstantUser::OpndIdx, llvm::consthoist::ConstantInfo::RebasedConstants, llvm::Instruction::setDebugLoc(), llvm::User::setOperand(), llvm::SmallVectorBase::size(), llvm::Value::use_empty(), and llvm::Instruction::user_back().
| consthoist |
Definition at line 123 of file ConstantHoisting.cpp.
|
static |
Referenced by llvm::createConstantHoistingPass(), and llvm::ConstantHoistingPass::run().
| Constant false |
Definition at line 123 of file ConstantHoisting.cpp.
| Constant Hoisting |
Definition at line 123 of file ConstantHoisting.cpp.
1.8.13