Go to the documentation of this file.
77 #define DEBUG_TYPE "consthoist"
79 STATISTIC(NumConstantsHoisted,
"Number of constants hoisted");
80 STATISTIC(NumConstantsRebased,
"Number of constants rebased");
84 cl::desc(
"Enable the use of the block frequency analysis to reduce the "
85 "chance to execute const materialization more frequently than "
86 "without hoisting."));
90 cl::desc(
"Try hoisting constant gep expressions"));
94 cl::desc(
"Do not rebase if number of dependent constants of a Base is less "
101 class ConstantHoistingLegacyPass :
public FunctionPass {
111 StringRef getPassName()
const override {
return "Constant Hoisting"; }
131 "Constant Hoisting",
false,
false)
140 return new ConstantHoistingLegacyPass();
145 if (skipFunction(Fn))
148 LLVM_DEBUG(
dbgs() <<
"********** Begin Constant Hoisting **********\n");
152 Impl.runImpl(Fn, getAnalysis<TargetTransformInfoWrapperPass>().getTTI(Fn),
153 getAnalysis<DominatorTreeWrapperPass>().getDomTree(),
155 ? &getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI()
158 &getAnalysis<ProfileSummaryInfoWrapperPass>().getPSI());
161 LLVM_DEBUG(
dbgs() <<
"********** Function after Constant Hoisting: "
165 LLVM_DEBUG(
dbgs() <<
"********** End Constant Hoisting **********\n");
172 unsigned Idx)
const {
177 if (
auto CastInst = dyn_cast<Instruction>(Opnd))
183 if (!isa<PHINode>(Inst) && !Inst->
isEHPad())
188 assert(Entry != Inst->
getParent() &&
"PHI or landing pad in entry block!");
190 if (Idx != ~0U && isa<PHINode>(Inst)) {
191 InsertionBlock = cast<PHINode>(Inst)->getIncomingBlock(Idx);
192 if (!InsertionBlock->
isEHPad()) {
202 auto *IDom = DT->getNode(InsertionBlock)->getIDom();
203 while (IDom->getBlock()->isEHPad()) {
204 assert(Entry != IDom->getBlock() &&
"eh pad in entry block");
205 IDom = IDom->getIDom();
208 return IDom->getBlock()->getTerminator();
217 assert(!BBs.
count(Entry) &&
"Assume Entry is not in BBs");
224 for (
auto BB : BBs) {
233 bool isCandidate =
false;
236 if (Node == Entry || Candidates.
count(Node)) {
241 "Entry doens't dominate current Node");
243 }
while (!BBs.count(Node));
251 Candidates.
insert(Path.begin(), Path.end());
258 Orders.push_back(Entry);
259 while (Idx != Orders.size()) {
262 if (Candidates.
count(ChildDomNode->getBlock()))
263 Orders.push_back(ChildDomNode->getBlock());
268 using InsertPtsCostPair =
274 InsertPtsMap.
reserve(Orders.size() + 1);
276 bool NodeInBBs = BBs.count(Node);
277 auto &InsertPts = InsertPtsMap[Node].first;
283 if (InsertPtsFreq >
BFI.getBlockFreq(Node) ||
284 (InsertPtsFreq ==
BFI.getBlockFreq(Node) && InsertPts.size() > 1))
287 BBs.insert(InsertPts.begin(), InsertPts.end());
294 auto &ParentInsertPts = InsertPtsMap[Parent].first;
304 (InsertPtsFreq >
BFI.getBlockFreq(Node) ||
305 (InsertPtsFreq ==
BFI.getBlockFreq(Node) && InsertPts.size() > 1)))) {
306 ParentInsertPts.
insert(Node);
307 ParentPtsFreq +=
BFI.getBlockFreq(Node);
309 ParentInsertPts.insert(InsertPts.begin(), InsertPts.end());
310 ParentPtsFreq += InsertPtsFreq;
323 for (
auto const &U : RCI.Uses)
324 BBs.
insert(findMatInsertPt(U.Inst, U.OpndIdx)->getParent());
326 if (BBs.
count(Entry)) {
327 InsertPts.
insert(&Entry->front());
333 for (
auto BB : BBs) {
335 for (; isa<PHINode>(InsertPt) || InsertPt->isEHPad(); ++InsertPt)
337 InsertPts.
insert(&*InsertPt);
342 while (BBs.size() >= 2) {
344 BB1 = BBs.pop_back_val();
345 BB2 = BBs.pop_back_val();
346 BB = DT->findNearestCommonDominator(BB1, BB2);
348 InsertPts.
insert(&Entry->front());
353 assert((BBs.size() == 1) &&
"Expected only one element.");
355 InsertPts.
insert(findMatInsertPt(&FirstInst));
365 void ConstantHoistingPass::collectConstantCandidates(
366 ConstCandMapType &ConstCandMap,
Instruction *Inst,
unsigned Idx,
371 if (
auto IntrInst = dyn_cast<IntrinsicInst>(Inst))
382 ConstCandMapType::iterator Itr;
384 ConstPtrUnionType Cand = ConstInt;
385 std::tie(Itr, Inserted) = ConstCandMap.insert(std::make_pair(Cand, 0));
388 Itr->second = ConstIntCandVec.size() - 1;
390 ConstIntCandVec[Itr->second].addUser(Inst, Idx, *Cost.
getValue());
392 <<
"Collect constant " << *ConstInt <<
" from " << *Inst
393 <<
" with cost " << Cost <<
'\n';
394 else dbgs() <<
"Collect constant " << *ConstInt
395 <<
" indirectly from " << *Inst <<
" via "
396 << *Inst->
getOperand(Idx) <<
" with cost " << Cost
402 void ConstantHoistingPass::collectConstantCandidates(
403 ConstCandMapType &ConstCandMap,
Instruction *Inst,
unsigned Idx,
417 auto *GEPO = cast<GEPOperator>(ConstExpr);
423 if (!GEPO->isInBounds())
426 if (!GEPO->accumulateConstantOffset(*
DL, Offset))
439 ConstCandVecType &ExprCandVec = ConstGEPCandMap[BaseGV];
440 ConstCandMapType::iterator Itr;
442 ConstPtrUnionType Cand = ConstExpr;
443 std::tie(Itr, Inserted) = ConstCandMap.insert(std::make_pair(Cand, 0));
448 Itr->second = ExprCandVec.size() - 1;
450 ExprCandVec[Itr->second].addUser(Inst, Idx, *Cost.
getValue());
454 void ConstantHoistingPass::collectConstantCandidates(
455 ConstCandMapType &ConstCandMap,
Instruction *Inst,
unsigned Idx) {
459 if (
auto ConstInt = dyn_cast<ConstantInt>(Opnd)) {
460 collectConstantCandidates(ConstCandMap, Inst, Idx, ConstInt);
465 if (
auto CastInst = dyn_cast<Instruction>(Opnd)) {
474 collectConstantCandidates(ConstCandMap, Inst, Idx, ConstInt);
480 if (
auto ConstExpr = dyn_cast<ConstantExpr>(Opnd)) {
483 collectConstantCandidates(ConstCandMap, Inst, Idx, ConstExpr);
489 if (
auto ConstInt = dyn_cast<ConstantInt>(ConstExpr->
getOperand(0))) {
492 collectConstantCandidates(ConstCandMap, Inst, Idx, ConstInt);
500 void ConstantHoistingPass::collectConstantCandidates(
501 ConstCandMapType &ConstCandMap,
Instruction *Inst) {
514 collectConstantCandidates(ConstCandMap, Inst, Idx);
521 void ConstantHoistingPass::collectConstantCandidates(
Function &Fn) {
522 ConstCandMapType ConstCandMap;
525 if (!DT->isReachableFromEntry(&
BB))
528 collectConstantCandidates(ConstCandMap, &Inst);
543 if (LimVal1 == ~0ULL || LimVal2 == ~0ULL)
547 return APInt(BW, Diff,
true);
574 ConstantHoistingPass::maximizeConstantsInRange(ConstCandVecType::iterator
S,
575 ConstCandVecType::iterator
E,
576 ConstCandVecType::iterator &MaxCostItr) {
577 unsigned NumUses = 0;
579 bool OptForSize = Entry->getParent()->hasOptSize() ||
582 if (!OptForSize || std::distance(
S,
E) > 100) {
583 for (
auto ConstCand =
S; ConstCand !=
E; ++ConstCand) {
584 NumUses += ConstCand->Uses.size();
585 if (ConstCand->CumulativeCost > MaxCostItr->CumulativeCost)
586 MaxCostItr = ConstCand;
593 for (
auto ConstCand =
S; ConstCand !=
E; ++ConstCand) {
594 auto Value = ConstCand->ConstInt->getValue();
595 Type *Ty = ConstCand->ConstInt->getType();
597 NumUses += ConstCand->Uses.size();
598 LLVM_DEBUG(
dbgs() <<
"= Constant: " << ConstCand->ConstInt->getValue()
601 for (
auto User : ConstCand->Uses) {
602 unsigned Opcode =
User.Inst->getOpcode();
603 unsigned OpndIdx =
User.OpndIdx;
608 for (
auto C2 =
S; C2 !=
E; ++C2) {
610 C2->ConstInt->getValue(),
611 ConstCand->ConstInt->getValue());
617 <<
"has penalty: " << ImmCosts <<
"\n"
618 <<
"Adjusted cost: " << Cost <<
"\n");
623 if (Cost > MaxCost) {
625 MaxCostItr = ConstCand;
626 LLVM_DEBUG(
dbgs() <<
"New candidate: " << MaxCostItr->ConstInt->getValue()
635 void ConstantHoistingPass::findAndMakeBaseConstant(
636 ConstCandVecType::iterator
S, ConstCandVecType::iterator
E,
639 unsigned NumUses = maximizeConstantsInRange(
S,
E, MaxCostItr);
653 for (
auto ConstCand =
S; ConstCand !=
E; ++ConstCand) {
654 APInt Diff = ConstCand->ConstInt->getValue() - ConstInt->
getValue();
657 ConstCand->ConstExpr ? ConstCand->ConstExpr->getType() :
nullptr;
661 ConstInfoVec.push_back(
std::move(ConstInfo));
666 void ConstantHoistingPass::findBaseConstants(
GlobalVariable *BaseGV) {
669 ConstCandVecType &ConstCandVec = BaseGV ?
670 ConstGEPCandMap[BaseGV] : ConstIntCandVec;
671 ConstInfoVecType &ConstInfoVec = BaseGV ?
672 ConstGEPInfoMap[BaseGV] : ConstIntInfoVec;
678 return LHS.ConstInt->
getType()->getBitWidth() <
680 return LHS.ConstInt->getValue().ult(
RHS.ConstInt->getValue());
685 auto MinValItr = ConstCandVec.begin();
686 for (
auto CC = std::next(ConstCandVec.begin()),
E = ConstCandVec.end();
688 if (MinValItr->ConstInt->getType() == CC->ConstInt->getType()) {
689 Type *MemUseValTy =
nullptr;
690 for (
auto &U : CC->Uses) {
692 if (
LoadInst *LI = dyn_cast<LoadInst>(UI)) {
693 MemUseValTy = LI->getType();
695 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(UI)) {
697 if (
SI->getPointerOperand() ==
SI->getOperand(U.OpndIdx)) {
698 MemUseValTy =
SI->getValueOperand()->getType();
705 APInt Diff = CC->ConstInt->getValue() - MinValItr->ConstInt->getValue();
717 findAndMakeBaseConstant(MinValItr, CC, ConstInfoVec);
722 findAndMakeBaseConstant(MinValItr, ConstCandVec.end(), ConstInfoVec);
732 if (
auto PHI = dyn_cast<PHINode>(Inst)) {
739 BasicBlock *IncomingBB = PHI->getIncomingBlock(Idx);
740 for (
unsigned i = 0;
i < Idx; ++
i) {
741 if (PHI->getIncomingBlock(
i) == IncomingBB) {
742 Value *IncomingVal = PHI->getIncomingValue(
i);
762 if (!Offset && Ty && Ty !=
Base->getType())
774 Offset,
"mat_gep", InsertionPt);
775 Mat =
new BitCastInst(Mat, Ty,
"mat_bitcast", InsertionPt);
779 "const_mat", InsertionPt);
782 <<
" + " << *Offset <<
") in BB "
790 if (isa<ConstantInt>(Opnd)) {
799 if (
auto CastInst = dyn_cast<Instruction>(Opnd)) {
804 if (!ClonedCastInst) {
811 <<
"To : " << *ClonedCastInst <<
'\n');
821 if (
auto ConstExpr = dyn_cast<ConstantExpr>(Opnd)) {
822 if (isa<GEPOperator>(ConstExpr)) {
829 assert(ConstExpr->
isCast() &&
"ConstExpr should be a cast");
831 findMatInsertPt(ConstUser.
Inst, ConstUser.
OpndIdx));
837 LLVM_DEBUG(
dbgs() <<
"Create instruction: " << *ConstExprInst <<
'\n'
838 <<
"From : " << *ConstExpr <<
'\n');
852 bool ConstantHoistingPass::emitBaseConstants(
GlobalVariable *BaseGV) {
853 bool MadeChange =
false;
855 BaseGV ? ConstGEPInfoMap[BaseGV] : ConstIntInfoVec;
856 for (
auto const &ConstInfo : ConstInfoVec) {
862 unsigned UsesNum = 0;
863 unsigned ReBasesNum = 0;
864 unsigned NotRebasedNum = 0;
868 using RebasedUse = std::tuple<Constant *, Type *, ConstantUser>;
871 for (
auto const &U : RCI.Uses) {
874 findMatInsertPt(U.Inst, U.OpndIdx)->
getParent();
877 if (IPSet.size() == 1 ||
878 DT->dominates(
IP->getParent(), OrigMatInsertBB))
879 ToBeRebased.push_back(RebasedUse(RCI.Offset, RCI.Ty, U));
887 NotRebasedNum += ToBeRebased.size();
895 assert(BaseGV &&
"A base constant expression must have an base GV");
903 Base->setDebugLoc(
IP->getDebugLoc());
906 <<
") to BB " <<
IP->getParent()->getName() <<
'\n'
910 for (
auto const &R : ToBeRebased) {
912 Type *Ty = std::get<1>(R);
914 emitBaseConstants(
Base, Off, Ty, U);
920 assert(!
Base->use_empty() &&
"The use list is empty!?");
922 "All uses should be instructions.");
928 assert(UsesNum == (ReBasesNum + NotRebasedNum) &&
929 "Not all uses are rebased");
931 NumConstantsHoisted++;
944 void ConstantHoistingPass::deleteDeadCastInst()
const {
945 for (
auto const &
I : ClonedCastMap)
946 if (
I.first->use_empty())
947 I.first->eraseFromParent();
959 this->Entry = &Entry;
962 collectConstantCandidates(Fn);
966 if (!ConstIntCandVec.empty())
967 findBaseConstants(
nullptr);
968 for (
const auto &MapEntry : ConstGEPCandMap)
969 if (!MapEntry.second.empty())
970 findBaseConstants(MapEntry.first);
974 bool MadeChange =
false;
975 if (!ConstIntInfoVec.empty())
976 MadeChange = emitBaseConstants(
nullptr);
977 for (
const auto &MapEntry : ConstGEPInfoMap)
978 if (!MapEntry.second.empty())
979 MadeChange |= emitBaseConstants(MapEntry.first);
983 deleteDeadCastInst();
A set of analyses that are preserved following a run of a transformation pass.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
Analysis pass providing the TargetTransformInfo.
This is an optimization pass for GlobalISel generic memory operations.
Optional< CostType > getValue() const
This function is intended to be used as sparingly as possible, since the class provides the full rang...
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
InstListType::iterator iterator
Instruction iterators...
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
Keeps track of a constant candidate and its uses.
const Function * getParent() const
Return the enclosing method, or null if none.
static const DILocation * getMergedLocation(const DILocation *LocA, const DILocation *LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
RebasedConstantListType RebasedConstants
Instruction * getAsInstruction(Instruction *InsertBefore=nullptr) const
Returns an Instruction which implements the same operation as this ConstantExpr.
Legacy analysis pass which computes BlockFrequencyInfo.
This class represents a no-op cast from one type to another.
const APInt & getValue() const
Return the constant as an APInt value reference.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
int64_t getSExtValue() const
Get sign extended value.
const BasicBlock & getEntryBlock() const
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
static void cleanup(BlockFrequencyInfoImplBase &BFI)
Clear all memory not needed downstream.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getBitWidth() const
Return the number of bits in the APInt.
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
DomTreeNodeBase * getIDom() const
static IntegerType * getInt8Ty(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
SmallPtrSet< MachineInstr *, 2 > Uses
LLVM Basic Block Representation.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
AddressSpace getAddressSpace(T *V)
This is the shared class of boolean and integer constants.
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
bool shouldOptimizeForSize(const MachineFunction *MF, ProfileSummaryInfo *PSI, const MachineBlockFrequencyInfo *BFI, PGSOQueryType QueryType=PGSOQueryType::Other)
Returns true if machine function MF is suggested to be size-optimized based on the profile.
bool runImpl(Function &F, TargetTransformInfo &TTI, DominatorTree &DT, BlockFrequencyInfo *BFI, BasicBlock &Entry, ProfileSummaryInfo *PSI)
Optimize expensive integer constants in the given function.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
FunctionPass * createConstantHoistingPass()
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
bool canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx)
Given an instruction, is it legal to set operand OpIdx to a non-constant value?
Represent the analysis usage information of a pass.
static bool runImpl(const TargetLibraryInfo &TLI, Function &F)
iterator_range< iterator > children()
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
bool isVectorTy() const
True if this is an instance of VectorType.
Class to represent integer types.
Legacy analysis pass which computes a DominatorTree.
STATISTIC(NumFunctions, "Total number of functions")
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Analysis pass which computes BlockFrequencyInfo.
bool empty() const
Determine if the SetVector is empty or not.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Keeps track of the user of a constant and the operand index where the constant is used.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Analysis providing profile information.
bool isCast() const
Return true if this is a convert constant expression.
An instruction for storing to memory.
static bool updateOperand(Instruction *Inst, unsigned Idx, Instruction *Mat)
Updates the operand at Idx in instruction Inst with the result of instruction Mat.
This is an important base class in LLVM.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static cl::opt< unsigned > MinNumOfDependentToRebase("consthoist-min-num-to-rebase", cl::desc("Do not rebase if number of dependent constants of a Base is less " "than this number."), cl::init(0), cl::Hidden)
Module * getParent()
Get the module that this global value is contained inside of...
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
initializer< Ty > init(const Ty &Val)
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
Class to represent pointers.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
constexpr const T & getValue() const &
StandardInstrumentations SI(Debug, VerifyEach)
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Class for arbitrary precision integers.
void setOperand(unsigned i, Value *Val)
bool insert(const value_type &X)
Insert a new element into the SetVector.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
void setPreservesCFG()
This function should be called by the pass, iff they do not:
StringRef - Represent a constant reference to a string, i.e.
Type * getType() const
All values are typed, get the type of this value.
Represents analyses that only rely on functions' control flow.
INITIALIZE_PASS_BEGIN(ConstantHoistingLegacyPass, "consthoist", "Constant Hoisting", false, false) INITIALIZE_PASS_END(ConstantHoistingLegacyPass
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
This is the base class for all instructions that perform data casts.
StringRef getName() const
Return a constant reference to the value's name.
An instruction for reading from memory.
A base constant and all its rebased constants.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static bool runOnFunction(Function &F, bool PostInlining)
static void findBestInsertionSet(DominatorTree &DT, BlockFrequencyInfo &BFI, BasicBlock *Entry, SetVector< BasicBlock * > &BBs)
Given BBs as input, find another set of BBs which collectively dominates BBs and have the minimal sum...
void stable_sort(R &&Range)
A constant value that is initialized with an expression using other constant values.
void initializeConstantHoistingLegacyPassPass(PassRegistry &)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Analysis pass which computes a DominatorTree.
void preserveSet()
Mark an analysis set as preserved.
unsigned getNumOperands() const
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
const BasicBlock * getParent() const
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
This represents a constant that has been rebased with respect to a base constant.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
static cl::opt< bool > ConstHoistGEP("consthoist-gep", cl::init(false), cl::Hidden, cl::desc("Try hoisting constant gep expressions"))
PointerType * getType() const
Global values are always pointers.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
AnalysisUsage & addRequired()
Value * getOperand(unsigned i) const
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."))
A vector that has set insertion semantics.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
bool isEHPad() const
Return true if this basic block is an exception handling block.
LLVM Value Representation.
static Optional< APInt > calculateOffsetDiff(const APInt &V1, const APInt &V2)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.