49 #define DEBUG_TYPE "commgep" 71 using NodeSet = std::set<GepNode *>;
72 using NodeToValueMap = std::map<GepNode *, Value *>;
73 using NodeVect = std::vector<GepNode *>;
74 using NodeChildrenMap = std::map<GepNode *, NodeVect>;
76 using NodeToUsesMap = std::map<GepNode *, UseSet>;
81 NodeOrdering() =
default;
83 void insert(
const GepNode *
N) { Map.insert(std::make_pair(N, ++LastNum)); }
84 void clear() { Map.clear(); }
86 bool operator()(
const GepNode *N1,
const GepNode *N2)
const {
87 auto F1 = Map.find(N1), F2 = Map.find(N2);
88 assert(F1 != Map.end() && F2 != Map.end());
89 return F1->second < F2->second;
93 std::map<const GepNode *, unsigned> Map;
106 StringRef getPassName()
const override {
return "Hexagon Common GEP"; }
119 using ValueToNodeMap = std::map<Value *, GepNode *>;
120 using ValueVect = std::vector<Value *>;
121 using NodeToValuesMap = std::map<GepNode *, ValueVect>;
123 void getBlockTraversalOrder(
BasicBlock *Root, ValueVect &Order);
129 BasicBlock *recalculatePlacement(GepNode *Node, NodeChildrenMap &NCM,
130 NodeToValueMap &Loc);
131 BasicBlock *recalculatePlacementRec(GepNode *Node, NodeChildrenMap &NCM,
132 NodeToValueMap &Loc);
134 bool isInvariantIn(GepNode *Node,
Loop *L);
136 BasicBlock *adjustForInvariance(GepNode *Node, NodeChildrenMap &NCM,
137 NodeToValueMap &Loc);
138 void separateChainForNode(GepNode *Node,
Use *U, NodeToValueMap &Loc);
139 void separateConstantChains(GepNode *Node, NodeChildrenMap &NCM,
140 NodeToValueMap &Loc);
141 void computeNodePlacement(NodeToValueMap &Loc);
145 void getAllUsersForNode(GepNode *Node, ValueVect &Values,
146 NodeChildrenMap &NCM);
147 void materialize(NodeToValueMap &Loc);
149 void removeDeadCode();
205 if (
auto *PTy = dyn_cast<PointerType>(Ty))
206 return PTy->getElementType();
209 Type *NexTy = cast<SequentialType>(Ty)->getElementType();
214 assert(CI &&
"Struct type with non-constant index");
216 Type *NextTy = cast<StructType>(Ty)->getElementType(i);
223 if (GN.
Flags & GepNode::Root) {
227 if (GN.
Flags & GepNode::Internal) {
233 if (GN.
Flags & GepNode::Used) {
238 if (GN.
Flags & GepNode::InBounds) {
244 if (GN.
Flags & GepNode::Root)
247 OS <<
"Parent:" << GN.
Parent;
251 OS << CI->getValue().getSExtValue();
255 OS <<
"<anon> =" << *GN.
Idx;
263 OS <<
"<anon-struct>:" << *STy;
271 template <
typename NodeContainer>
273 using const_iterator =
typename NodeContainer::const_iterator;
275 for (const_iterator
I = S.begin(),
E = S.end();
I !=
E; ++
I)
276 OS << *
I <<
' ' << **
I <<
'\n';
289 using const_iterator = NodeToUsesMap::const_iterator;
291 for (const_iterator
I = M.begin(),
E = M.end();
I !=
E; ++
I) {
292 const UseSet &Us =
I->second;
293 OS <<
I->first <<
" -> #" << Us.size() <<
'{';
294 for (UseSet::const_iterator J = Us.begin(),
F = Us.end(); J !=
F; ++J) {
295 User *R = (*J)->getUser();
299 OS <<
" <?>(" << *R <<
')';
310 return NS.find(N) != NS.end();
323 void HexagonCommonGEP::getBlockTraversalOrder(
BasicBlock *Root,
329 Order.push_back(Root);
330 for (
auto *DTN : children<DomTreeNode*>(DT->getNode(Root)))
331 getBlockTraversalOrder(DTN->getBlock(), Order);
345 ValueToNodeMap &NM) {
347 GepNode *N =
new (*Mem) GepNode;
350 ValueToNodeMap::iterator
F = NM.find(PtrOp);
353 N->Flags |= GepNode::Root | InBounds;
358 N->Parent = F->second;
370 if (isa<GetElementPtrInst>(*UI)) {
372 if (isHandledGepForm(UserG))
375 Us.insert(&UI.getUse());
383 Type *PtrTy = cast<PointerType>(PtrOp->
getType())->getElementType();
387 GepNode *Nx =
new (*Mem) GepNode;
389 Nx->Flags |= GepNode::Internal | InBounds;
401 PN->Flags |= GepNode::Used;
402 Uses[PN].insert(Us.begin(), Us.end());
407 NM.insert(std::make_pair(GepI, PN));
410 void HexagonCommonGEP::collect() {
413 getBlockTraversalOrder(&Fn->front(), BO);
419 for (ValueVect::iterator
I = BO.begin(),
E = BO.end();
I !=
E; ++
I) {
422 if (!isa<GetElementPtrInst>(J))
425 if (isHandledGepForm(GepI))
426 processGepInst(GepI, NM);
430 LLVM_DEBUG(
dbgs() <<
"Gep nodes after initial collection:\n" << Nodes);
435 using const_iterator = NodeVect::const_iterator;
437 for (const_iterator
I = Nodes.begin(),
E = Nodes.end();
I !=
E; ++
I) {
439 if (N->Flags & GepNode::Root) {
443 GepNode *PN = N->Parent;
444 NCM[PN].push_back(N);
451 Work.push_back(Root);
454 while (!Work.empty()) {
455 NodeVect::iterator First = Work.begin();
458 NodeChildrenMap::iterator CF = NCM.find(N);
459 if (CF != NCM.end()) {
460 Work.insert(Work.end(), CF->second.begin(), CF->second.end());
461 Nodes.
insert(CF->second.begin(), CF->second.end());
468 using NodeSymRel = std::set<NodeSet>;
469 using NodePair = std::pair<GepNode *, GepNode *>;
470 using NodePairSet = std::set<NodePair>;
475 for (NodeSymRel::iterator
I = Rel.begin(),
E = Rel.end();
I !=
E; ++
I)
485 uintptr_t P1 = uintptr_t(N1), P2 = uintptr_t(N2);
487 return std::make_pair(N1, N2);
488 return std::make_pair(N2, N1);
499 static bool node_eq(GepNode *N1, GepNode *N2, NodePairSet &Eq,
507 NodePairSet::iterator FEq = Eq.find(NP);
510 NodePairSet::iterator FNe = Ne.find(NP);
514 bool Root1 = N1->Flags & GepNode::Root;
515 bool Root2 = N2->Flags & GepNode::Root;
520 if (Root1 != Root2 || (Root1 && N1->BaseVal != N2->BaseVal)) {
527 if (Root1 ||
node_eq(N1->Parent, N2->Parent, Eq, Ne)) {
534 void HexagonCommonGEP::common() {
539 using NodeSetMap = std::map<unsigned, NodeSet>;
542 for (NodeVect::iterator
I = Nodes.begin(),
E = Nodes.end();
I !=
E; ++
I) {
545 MaybeEq[
H].insert(N);
552 for (NodeSetMap::iterator
I = MaybeEq.begin(),
E = MaybeEq.end();
572 std::pair<NodeSymRel::iterator, bool>
Ins = EqRel.insert(C);
574 assert(Ins.second &&
"Cannot add a class");
580 dbgs() <<
"Gep node equality:\n";
581 for (NodePairSet::iterator
I = Eq.begin(),
E = Eq.end();
I !=
E; ++
I)
582 dbgs() <<
"{ " <<
I->first <<
", " <<
I->second <<
" }\n";
584 dbgs() <<
"Gep equivalence classes:\n";
585 for (NodeSymRel::iterator
I = EqRel.begin(),
E = EqRel.end();
I !=
E; ++
I) {
588 for (NodeSet::const_iterator J = S.
begin(),
F = S.
end(); J !=
F; ++J) {
598 using ProjMap = std::map<const NodeSet *, GepNode *>;
600 for (NodeSymRel::iterator
I = EqRel.begin(),
E = EqRel.end();
I !=
E; ++
I) {
603 std::pair<ProjMap::iterator,bool>
Ins = PM.insert(std::make_pair(&S, Min));
605 assert(Ins.second &&
"Cannot add minimal element");
609 UseSet &MinUs = Uses[Min];
615 if (NF & GepNode::Used)
616 MinUs.insert(Uses[N].
begin(), Uses[N].
end());
623 assert((Min->Flags & Flags) == Min->Flags);
631 for (NodeVect::iterator
I = Nodes.begin(),
E = Nodes.end();
I !=
E; ++
I) {
633 if (N->Flags & GepNode::Root)
638 ProjMap::iterator
F = PM.find(PC);
642 GepNode *Rep = F->second;
650 for (NodeVect::iterator
I = Nodes.begin(),
E = Nodes.end();
I !=
E; ++
I) {
655 ProjMap::iterator
F = PM.find(PC);
663 NodeVect::iterator NewE =
remove_if(Nodes, in_set(Erase));
664 Nodes.resize(std::distance(Nodes.begin(), NewE));
666 LLVM_DEBUG(
dbgs() <<
"Gep nodes after post-commoning cleanup:\n" << Nodes);
669 template <
typename T>
672 dbgs() <<
"NCD of {";
673 for (
typename T::iterator
I = Blocks.begin(),
E = Blocks.end();
I !=
E;
684 typename T::iterator
I = Blocks.begin(),
E = Blocks.end();
698 template <
typename T>
702 typename T::iterator
I = Blocks.begin(),
E = Blocks.end();
704 while (I !=
E && !*I)
724 template <
typename T>
728 using iterator =
typename T::iterator;
730 for (iterator
I = Values.begin(),
E = Values.end();
I !=
E; ++
I) {
739 if (!isa<Instruction>(V))
745 if (std::distance(FirstUse, BEnd) < std::distance(It, BEnd))
755 BasicBlock *HexagonCommonGEP::recalculatePlacement(GepNode *Node,
756 NodeChildrenMap &NCM, NodeToValueMap &Loc) {
768 if (Node->Flags & GepNode::Used) {
771 NodeToUsesMap::iterator UF = Uses.find(Node);
772 assert(UF != Uses.end() &&
"Used node with no use information");
773 UseSet &Us = UF->second;
774 for (UseSet::iterator
I = Us.begin(),
E = Us.end();
I !=
E; ++
I) {
776 User *R = U->getUser();
777 if (!isa<Instruction>(R))
780 ? cast<PHINode>(R)->getIncomingBlock(*U)
786 NodeChildrenMap::iterator CF = NCM.find(Node);
787 if (CF != NCM.end()) {
788 NodeVect &Cs = CF->second;
789 for (NodeVect::iterator
I = Cs.begin(),
E = Cs.end();
I !=
E; ++
I) {
791 NodeToValueMap::iterator LF = Loc.find(CN);
797 Bs.push_back(LF->second);
806 if (IdxI && !DT->dominates(IdxI->
getParent(), DomB))
822 BasicBlock *HexagonCommonGEP::recalculatePlacementRec(GepNode *Node,
823 NodeChildrenMap &NCM, NodeToValueMap &Loc) {
827 NodeChildrenMap::iterator CF = NCM.find(Node);
828 if (CF != NCM.end()) {
829 NodeVect &Cs = CF->second;
830 for (NodeVect::iterator
I = Cs.begin(),
E = Cs.end();
I !=
E; ++
I)
831 recalculatePlacementRec(*
I, NCM, Loc);
833 BasicBlock *LB = recalculatePlacement(Node, NCM, Loc);
838 bool HexagonCommonGEP::isInvariantIn(
Value *Val,
Loop *L) {
839 if (isa<Constant>(Val) || isa<Argument>(Val))
845 return DT->properlyDominates(DefB, HdrB);
848 bool HexagonCommonGEP::isInvariantIn(GepNode *Node,
Loop *L) {
849 if (Node->Flags & GepNode::Root)
850 if (!isInvariantIn(Node->BaseVal, L))
852 return isInvariantIn(Node->Idx, L);
859 if (PDT->dominates(B, HB))
861 if (LB && DT->dominates(B, LB))
877 BasicBlock *HexagonCommonGEP::adjustForInvariance(GepNode *Node,
878 NodeChildrenMap &NCM, NodeToValueMap &Loc) {
883 if (Node->Flags & GepNode::Root) {
884 if (
Instruction *PIn = dyn_cast<Instruction>(Node->BaseVal))
885 Bs.push_back(PIn->getParent());
887 Bs.push_back(Loc[Node->Parent]);
889 if (
Instruction *IIn = dyn_cast<Instruction>(Node->Idx))
890 Bs.push_back(IIn->getParent());
901 BasicBlock *LocB = cast_or_null<BasicBlock>(Loc[Node]);
903 Loop *Lp = LI->getLoopFor(LocB);
905 if (!isInvariantIn(Node, Lp) || !isInMainPath(LocB, Lp))
908 if (!NewLoc || !DT->dominates(TopB, NewLoc))
917 NodeChildrenMap::iterator CF = NCM.find(Node);
918 if (CF != NCM.end()) {
919 NodeVect &Cs = CF->second;
920 for (NodeVect::iterator
I = Cs.begin(),
E = Cs.end();
I !=
E; ++
I)
921 adjustForInvariance(*
I, NCM, Loc);
928 struct LocationAsBlock {
929 LocationAsBlock(
const NodeToValueMap &L) : Map(L) {}
931 const NodeToValueMap ⤅
937 for (NodeToValueMap::const_iterator
I = Loc.Map.begin(),
E = Loc.Map.end();
939 OS <<
I->first <<
" -> ";
941 OS << B->
getName() <<
'(' << B <<
')';
947 inline bool is_constant(GepNode *N) {
948 return isa<ConstantInt>(N->Idx);
953 void HexagonCommonGEP::separateChainForNode(GepNode *Node,
Use *U,
954 NodeToValueMap &Loc) {
955 User *R = U->getUser();
956 LLVM_DEBUG(
dbgs() <<
"Separating chain for node (" << Node <<
") user: " << *R
961 GepNode *
C =
nullptr, *NewNode =
nullptr;
962 while (is_constant(N) && !(N->Flags & GepNode::Root)) {
964 GepNode *NewN =
new (*Mem) GepNode(N);
965 Nodes.push_back(NewN);
970 NewN->Flags &= ~GepNode::Used;
980 NodeToUsesMap::iterator UF = Uses.find(Node);
982 UseSet &Us = UF->second;
985 if (U->getUser() == R)
992 Node->Flags &= ~GepNode::Used;
997 NewNode->Flags |= GepNode::Used;
998 LLVM_DEBUG(
dbgs() <<
"new node: " << NewNode <<
" " << *NewNode <<
'\n');
1000 Uses[NewNode] = NewUs;
1003 void HexagonCommonGEP::separateConstantChains(GepNode *Node,
1004 NodeChildrenMap &NCM, NodeToValueMap &Loc) {
1009 LLVM_DEBUG(
dbgs() <<
"Separating constant chains for node: " << Node <<
'\n');
1015 if (!(N->Flags & GepNode::Used))
1017 NodeToUsesMap::iterator UF = Uses.find(N);
1018 assert(UF != Uses.end());
1019 UseSet &Us = UF->second;
1022 for (UseSet::iterator J = Us.begin(),
F = Us.end(); J !=
F; ++J) {
1024 User *R = U->getUser();
1028 if (
LoadInst *Ld = dyn_cast<LoadInst>(R)) {
1030 if (&Ld->getOperandUse(PtrX) == U)
1032 }
else if (
StoreInst *St = dyn_cast<StoreInst>(R)) {
1034 if (&St->getOperandUse(PtrX) == U)
1043 FNs.insert(std::make_pair(N, LSs));
1048 for (NodeToUsesMap::iterator
I = FNs.begin(),
E = FNs.end();
I !=
E; ++
I) {
1049 GepNode *N =
I->first;
1050 UseSet &Us =
I->second;
1051 for (UseSet::iterator J = Us.begin(),
F = Us.end(); J !=
F; ++J)
1052 separateChainForNode(N, *J, Loc);
1056 void HexagonCommonGEP::computeNodePlacement(NodeToValueMap &Loc) {
1059 NodeChildrenMap NCM;
1065 for (NodeVect::iterator
I = Roots.begin(),
E = Roots.end();
I !=
E; ++
I)
1066 recalculatePlacementRec(*
I, NCM, Loc);
1068 LLVM_DEBUG(
dbgs() <<
"Initial node placement:\n" << LocationAsBlock(Loc));
1071 for (NodeVect::iterator
I = Roots.begin(),
E = Roots.end();
I !=
E; ++
I)
1072 adjustForInvariance(*
I, NCM, Loc);
1074 LLVM_DEBUG(
dbgs() <<
"Node placement after adjustment for invariance:\n" 1075 << LocationAsBlock(Loc));
1078 for (NodeVect::iterator
I = Roots.begin(),
E = Roots.end();
I !=
E; ++
I)
1079 separateConstantChains(*
I, NCM, Loc);
1087 LLVM_DEBUG(
dbgs() <<
"Final node placement:\n" << LocationAsBlock(Loc));
1095 unsigned Num = NA.size();
1096 GepNode *
RN = NA[0];
1097 assert((RN->Flags & GepNode::Root) &&
"Creating GEP for non-root");
1100 Value *Input = RN->BaseVal;
1108 if (!NA[nax]->PTy->isPointerTy()) {
1115 while (++nax <= Num) {
1116 GepNode *N = NA[nax-1];
1117 IdxList[IdxC++] = N->Idx;
1122 if (NextTy != NA[nax]->PTy)
1133 }
while (nax <= Num);
1139 void HexagonCommonGEP::getAllUsersForNode(GepNode *Node, ValueVect &Values,
1140 NodeChildrenMap &NCM) {
1142 Work.push_back(Node);
1144 while (!Work.empty()) {
1145 NodeVect::iterator First = Work.begin();
1146 GepNode *N = *First;
1148 if (N->Flags & GepNode::Used) {
1149 NodeToUsesMap::iterator UF = Uses.find(N);
1150 assert(UF != Uses.end() &&
"No use information for used node");
1151 UseSet &Us = UF->second;
1152 for (UseSet::iterator
I = Us.begin(),
E = Us.end();
I !=
E; ++
I)
1153 Values.push_back((*I)->getUser());
1155 NodeChildrenMap::iterator CF = NCM.find(N);
1156 if (CF != NCM.end()) {
1157 NodeVect &Cs = CF->second;
1158 Work.insert(Work.end(), Cs.begin(), Cs.end());
1163 void HexagonCommonGEP::materialize(NodeToValueMap &Loc) {
1164 LLVM_DEBUG(
dbgs() <<
"Nodes before materialization:\n" << Nodes <<
'\n');
1165 NodeChildrenMap NCM;
1171 while (!Roots.empty()) {
1172 NodeVect::iterator First = Roots.begin();
1173 GepNode *Root = *First, *Last = *First;
1182 bool LastUsed =
false;
1183 unsigned LastCN = 0;
1186 Value *LocV = Loc[Last];
1192 LastUsed = (Last->Flags & GepNode::Used);
1195 NodeChildrenMap::iterator CF = NCM.find(Last);
1196 LastCN = (CF != NCM.end()) ? CF->second.size() : 0;
1199 GepNode *Child = CF->second.front();
1200 BasicBlock *ChildB = cast_or_null<BasicBlock>(Loc[Child]);
1201 if (ChildB !=
nullptr && LastB != ChildB)
1207 if (LastUsed || LastCN > 0) {
1209 getAllUsersForNode(Root, Urs, NCM);
1211 if (FirstUse != LastB->
end())
1212 InsertAt = FirstUse;
1216 Value *NewInst = fabricateGEP(NA, InsertAt, LastB);
1221 NodeVect &Cs = NCM[Last];
1222 for (NodeVect::iterator
I = Cs.begin(),
E = Cs.end();
I !=
E; ++
I) {
1224 CN->Flags &= ~GepNode::Internal;
1225 CN->Flags |= GepNode::Root;
1226 CN->BaseVal = NewInst;
1227 Roots.push_back(CN);
1234 NodeToUsesMap::iterator UF = Uses.find(Last);
1235 assert(UF != Uses.end() &&
"No use information found");
1236 UseSet &Us = UF->second;
1237 for (UseSet::iterator
I = Us.begin(),
E = Us.end();
I !=
E; ++
I) {
1245 void HexagonCommonGEP::removeDeadCode() {
1247 BO.push_back(&Fn->front());
1249 for (
unsigned i = 0; i < BO.size(); ++i) {
1251 for (
auto DTN : children<DomTreeNode*>(DT->getNode(B)))
1252 BO.push_back(DTN->getBlock());
1255 for (
unsigned i = BO.size(); i > 0; --i) {
1262 for (reverse_iterator
I = IL.rbegin(),
E = IL.rend();
I !=
E; ++
I)
1264 for (ValueVect::iterator
I = Ins.begin(),
E = Ins.end();
I !=
E; ++
I) {
1273 if (skipFunction(F))
1279 if (isa<InvokeInst>(
I) || isa<LandingPadInst>(
I))
1283 DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1284 PDT = &getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();
1285 LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
1299 computeNodePlacement(Loc);
1303 #ifdef EXPENSIVE_CHECKS 1313 return new HexagonCommonGEP();
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
const_iterator end(StringRef path)
Get end iterator over path.
Value * getPointerOperand()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
BlockT * getLoopLatch() const
If there is a single latch block for this loop, return it.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
static BasicBlock::iterator first_use_of_in_block(T &Values, BasicBlock *B)
static void nodes_for_root(GepNode *Root, NodeChildrenMap &NCM, NodeSet &Nodes)
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value *> IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
static bool is_empty(const BasicBlock *B)
static cl::opt< bool > OptEnableInv("commgep-inv", cl::init(true), cl::Hidden, cl::ZeroOrMore)
NodeT * findNearestCommonDominator(NodeT *A, NodeT *B) const
findNearestCommonDominator - Find nearest common dominator basic block for basic block A and B...
An instruction for reading from memory.
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...
This defines the Use class.
unsigned ComputeHash() const
ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used to lookup the node in the F...
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
static void invert_find_roots(const NodeVect &Nodes, NodeChildrenMap &NCM, NodeVect &Roots)
iterator begin()
Instruction iterator methods.
FunctionPass * createHexagonCommonGEP()
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
void setIsInBounds(bool b=true)
Set or clear the inbounds flag on this GEP instruction.
BlockT * getHeader() const
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
int64_t getSExtValue() const
Get sign extended value.
Type * getType() const
All values are typed, get the type of this value.
bool isInBounds() const
Determine whether the GEP has the inbounds flag.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
An instruction for storing to memory.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
static cl::opt< bool > OptEnableConst("commgep-const", cl::init(true), cl::Hidden, cl::ZeroOrMore)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
Type * next_type(Type *Ty, Value *Idx)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
static unsigned getPointerOperandIndex()
This is an important class for using LLVM in a threaded context.
DomTreeNodeBase * getIDom() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isPointerTy() const
True if this is an instance of PointerType.
static unsigned node_hash(GepNode *N)
Represent the analysis usage information of a pass.
#define LLVM_ATTRIBUTE_UNUSED
FunctionPass class - This class is used to implement most global optimizations.
self_iterator getIterator()
static BasicBlock * preheader(DominatorTree *DT, Loop *L)
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static cl::opt< bool > OptSpeculate("commgep-speculate", cl::init(true), cl::Hidden, cl::ZeroOrMore)
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
SetVector< SUnit * >::const_iterator iterator
const InstListType & getInstList() const
Return the underlying instruction list container.
Iterator for intrusive lists based on ilist_node.
GepNode(const GepNode *N)
This is the shared class of boolean and integer constants.
void initializeHexagonCommonGEPPass(PassRegistry &)
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
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.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
static BasicBlock * nearest_common_dominator(DominatorTree *DT, T &Blocks)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static NodePair node_pair(GepNode *N1, GepNode *N2)
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition...
InstListType::iterator iterator
Instruction iterators...
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
static void clear(coro::Shape &Shape)
LoopT * getParentLoop() const
static bool node_eq(GepNode *N1, GepNode *N2, NodePairSet &Eq, NodePairSet &Ne)
static IntegerType * getInt32Ty(LLVMContext &C)
Represents a single loop in the control flow graph.
StringRef getName() const
Return a constant reference to the value's name.
user_iterator_impl< User > user_iterator
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
INITIALIZE_PASS_BEGIN(HexagonCommonGEP, "hcommgep", "Hexagon Common GEP", false, false) INITIALIZE_PASS_END(HexagonCommonGEP
static unsigned getPointerOperandIndex()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction has no side ef...
LLVM Value Representation.
A vector that has set insertion semantics.
static const Function * getParent(const Value *V)
This class implements an extremely fast bulk output stream that can only output to a stream...
The legacy pass manager's analysis pass to compute loop information.
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Legacy analysis pass which computes a DominatorTree.
static BasicBlock * nearest_common_dominatee(DominatorTree *DT, T &Blocks)
base_list_type::reverse_iterator reverse_iterator
void dump_node_container(raw_ostream &OS, const NodeContainer &S)
static const NodeSet * node_class(GepNode *N, NodeSymRel &Rel)
bool isStructTy() const
True if this is an instance of StructType.
const BasicBlock * getParent() const
A NodeSet contains a set of SUnit DAG nodes with additional information that assigns a priority to th...
StringRef getStructName() const