10 #define DEBUG_TYPE "commgep"
53 typedef std::set<GepNode*> NodeSet;
54 typedef std::map<GepNode*,Value*> NodeToValueMap;
55 typedef std::vector<GepNode*> NodeVect;
56 typedef std::map<GepNode*,NodeVect> NodeChildrenMap;
57 typedef std::set<Use*> UseSet;
58 typedef std::map<GepNode*,UseSet> NodeToUsesMap;
62 struct NodeNumbering :
public std::map<const GepNode*,unsigned> {
65 struct NodeOrdering :
public NodeNumbering {
66 NodeOrdering() : LastNum(0) {}
68 void special_insert_for_special_msvc(
const GepNode *
N)
70 using NodeNumbering::insert;
71 void insert(
const GepNode* N)
74 insert(std::make_pair(N, ++LastNum));
76 bool operator() (
const GepNode* N1,
const GepNode *N2)
const {
77 const_iterator F1 = find(N1), F2 = find(N2);
78 assert(F1 !=
end() && F2 !=
end());
79 return F1->second < F2->second;
93 virtual const char *getPassName()
const {
94 return "Hexagon Common GEP";
108 typedef std::map<Value*,GepNode*> ValueToNodeMap;
109 typedef std::vector<Value*> ValueVect;
110 typedef std::map<GepNode*,ValueVect> NodeToValuesMap;
112 void getBlockTraversalOrder(
BasicBlock *Root, ValueVect &Order);
118 BasicBlock *recalculatePlacement(GepNode *Node, NodeChildrenMap &NCM,
119 NodeToValueMap &Loc);
120 BasicBlock *recalculatePlacementRec(GepNode *Node, NodeChildrenMap &NCM,
121 NodeToValueMap &Loc);
123 bool isInvariantIn(GepNode *Node,
Loop *L);
125 BasicBlock *adjustForInvariance(GepNode *Node, NodeChildrenMap &NCM,
126 NodeToValueMap &Loc);
127 void separateChainForNode(GepNode *Node,
Use *U, NodeToValueMap &Loc);
128 void separateConstantChains(GepNode *Node, NodeChildrenMap &NCM,
129 NodeToValueMap &Loc);
130 void computeNodePlacement(NodeToValueMap &Loc);
134 void getAllUsersForNode(GepNode *Node, ValueVect &Values,
135 NodeChildrenMap &NCM);
136 void materialize(NodeToValueMap &Loc);
138 void removeDeadCode();
142 NodeOrdering NodeOrder;
193 Type *NexTy = cast<SequentialType>(Ty)->getElementType();
198 assert(CI &&
"Struct type with non-constant index");
200 Type *NextTy = cast<StructType>(Ty)->getElementType(i);
208 if (GN.
Flags & GepNode::Root) {
212 if (GN.
Flags & GepNode::Internal) {
218 if (GN.
Flags & GepNode::Used) {
225 if (GN.
Flags & GepNode::Root)
228 OS <<
"Parent:" << GN.
Parent;
232 OS << CI->getValue().getSExtValue();
236 OS <<
"<anon> =" << *GN.
Idx;
244 OS <<
"<anon-struct>:" << *STy;
253 template <
typename NodeContainer>
255 typedef typename NodeContainer::const_iterator const_iterator;
256 for (const_iterator
I = S.begin(), E = S.end();
I != E; ++
I)
257 OS << *
I <<
' ' << **
I <<
'\n';
271 typedef NodeToUsesMap::const_iterator const_iterator;
272 for (const_iterator
I = M.begin(), E = M.end();
I != E; ++
I) {
273 const UseSet &Us =
I->second;
274 OS <<
I->first <<
" -> #" << Us.size() <<
'{';
275 for (UseSet::const_iterator J = Us.begin(),
F = Us.end(); J !=
F; ++J) {
276 User *R = (*J)->getUser();
280 OS <<
" <?>(" << *R <<
')';
291 return NS.find(N) != NS.end();
304 void HexagonCommonGEP::getBlockTraversalOrder(
BasicBlock *Root,
310 Order.push_back(Root);
313 typedef GTN::ChildIteratorType Iter;
314 for (Iter
I = GTN::child_begin(DTN), E = GTN::child_end(DTN);
I != E; ++
I)
315 getBlockTraversalOrder((*I)->getBlock(), Order);
331 ValueToNodeMap &NM) {
332 DEBUG(
dbgs() <<
"Visiting GEP: " << *GepI <<
'\n');
333 GepNode *N =
new (*Mem) GepNode;
335 ValueToNodeMap::iterator
F = NM.find(PtrOp);
338 N->Flags |= GepNode::Root;
343 N->Parent = F->second;
355 if (isa<GetElementPtrInst>(*UI)) {
357 if (isHandledGepForm(UserG))
360 Us.insert(&UI.getUse());
364 NodeOrder.special_insert_for_special_msvc(N);
372 Type *PtrTy = cast<PointerType>(PtrOp->
getType())->getElementType();
376 GepNode *Nx =
new (*Mem) GepNode;
378 Nx->Flags |= GepNode::Internal;
383 NodeOrder.special_insert_for_special_msvc(Nx);
385 NodeOrder.insert(Nx);
394 PN->Flags |= GepNode::Used;
395 Uses[PN].insert(Us.begin(), Us.end());
400 NM.insert(std::make_pair(GepI, PN));
404 void HexagonCommonGEP::collect() {
407 getBlockTraversalOrder(Fn->begin(), BO);
413 for (ValueVect::iterator
I = BO.begin(), E = BO.end();
I != E; ++
I) {
416 if (!isa<GetElementPtrInst>(J))
419 if (isHandledGepForm(GepI))
420 processGepInst(GepI, NM);
424 DEBUG(
dbgs() <<
"Gep nodes after initial collection:\n" << Nodes);
429 void invert_find_roots(
const NodeVect &Nodes, NodeChildrenMap &NCM,
431 typedef NodeVect::const_iterator const_iterator;
432 for (const_iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++
I) {
434 if (N->Flags & GepNode::Root) {
438 GepNode *PN = N->Parent;
439 NCM[PN].push_back(N);
443 void nodes_for_root(GepNode *Root, NodeChildrenMap &NCM, NodeSet &Nodes) {
445 Work.push_back(Root);
448 while (!Work.empty()) {
449 NodeVect::iterator First = Work.begin();
452 NodeChildrenMap::iterator CF = NCM.find(N);
453 if (CF != NCM.end()) {
454 Work.insert(Work.end(), CF->second.begin(), CF->second.end());
455 Nodes.insert(CF->second.begin(), CF->second.end());
463 typedef std::set<NodeSet> NodeSymRel;
464 typedef std::pair<GepNode*,GepNode*> NodePair;
465 typedef std::set<NodePair> NodePairSet;
467 const NodeSet *node_class(GepNode *N, NodeSymRel &Rel) {
468 for (NodeSymRel::iterator I = Rel.begin(), E = Rel.end(); I != E; ++
I)
477 NodePair node_pair(GepNode *N1, GepNode *N2) {
478 uintptr_t P1 = uintptr_t(N1), P2 = uintptr_t(N2);
480 return std::make_pair(N1, N2);
481 return std::make_pair(N2, N1);
484 unsigned node_hash(GepNode *N) {
492 bool node_eq(GepNode *N1, GepNode *N2, NodePairSet &Eq, NodePairSet &Ne) {
495 if (node_hash(N1) != node_hash(N2))
498 NodePair NP = node_pair(N1, N2);
499 NodePairSet::iterator FEq = Eq.find(NP);
502 NodePairSet::iterator FNe = Ne.find(NP);
506 bool Root1 = N1->Flags & GepNode::Root;
507 bool Root2 = N2->Flags & GepNode::Root;
508 NodePair
P = node_pair(N1, N2);
512 if (Root1 != Root2 || (Root1 && N1->BaseVal != N2->BaseVal)) {
519 if (Root1 || node_eq(N1->Parent, N2->Parent, Eq, Ne)) {
528 void HexagonCommonGEP::common() {
533 typedef std::map<unsigned,NodeSet> NodeSetMap;
536 for (NodeVect::iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++
I) {
538 unsigned H = node_hash(N);
539 MaybeEq[
H].insert(N);
546 for (NodeSetMap::iterator I = MaybeEq.begin(), E = MaybeEq.end();
548 NodeSet &S = I->second;
549 for (NodeSet::iterator NI = S.begin(),
NE = S.end(); NI !=
NE; ++NI) {
554 if (node_class(N, EqRel))
559 for (NodeSet::iterator NJ = std::next(NI); NJ !=
NE; ++NJ)
560 if (node_eq(N, *NJ, Eq, Ne))
566 std::pair<NodeSymRel::iterator, bool>
Ins = EqRel.insert(C);
568 assert(Ins.second &&
"Cannot add a class");
574 dbgs() <<
"Gep node equality:\n";
575 for (NodePairSet::iterator I = Eq.begin(), E = Eq.end(); I != E; ++
I)
576 dbgs() <<
"{ " << I->first <<
", " << I->second <<
" }\n";
578 dbgs() <<
"Gep equivalence classes:\n";
579 for (NodeSymRel::iterator I = EqRel.begin(), E = EqRel.end(); I != E; ++
I) {
581 const NodeSet &S = *
I;
582 for (NodeSet::const_iterator J = S.begin(), F = S.end(); J !=
F; ++J) {
593 typedef std::map<const NodeSet*,GepNode*> ProjMap;
595 for (NodeSymRel::iterator I = EqRel.begin(), E = EqRel.end(); I != E; ++
I) {
596 const NodeSet &S = *
I;
597 GepNode *Min = *std::min_element(S.begin(), S.end(), NodeOrder);
598 std::pair<ProjMap::iterator,bool>
Ins = PM.insert(std::make_pair(&S, Min));
600 assert(Ins.second &&
"Cannot add minimal element");
604 UseSet &MinUs = Uses[Min];
605 for (NodeSet::iterator J = S.begin(), F = S.end(); J !=
F; ++J) {
607 uint32_t NF = N->Flags;
610 if (NF & GepNode::Used)
611 MinUs.insert(Uses[N].
begin(), Uses[N].
end());
618 assert((Min->Flags & Flags) == Min->Flags);
626 for (NodeVect::iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++
I) {
628 if (N->Flags & GepNode::Root)
630 const NodeSet *PC = node_class(N->Parent, EqRel);
633 ProjMap::iterator F = PM.find(PC);
637 GepNode *Rep = F->second;
641 DEBUG(
dbgs() <<
"Gep nodes after commoning:\n" << Nodes);
645 for (NodeVect::iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++
I) {
647 const NodeSet *PC = node_class(N, EqRel);
650 ProjMap::iterator F = PM.find(PC);
658 NodeVect::iterator NewE = std::remove_if(Nodes.begin(), Nodes.end(),
660 Nodes.resize(std::distance(Nodes.begin(), NewE));
662 DEBUG(
dbgs() <<
"Gep nodes after post-commoning cleanup:\n" << Nodes);
667 template <
typename T>
670 dbgs() <<
"NCD of {";
671 for (
typename T::iterator I = Blocks.begin(), E = Blocks.end();
682 typename T::iterator I = Blocks.begin(), E = Blocks.end();
696 template <
typename T>
700 typename T::iterator I = Blocks.begin(), E = Blocks.end();
702 while (I != E && !*I)
722 template <
typename T>
725 typedef typename T::iterator iterator;
726 for (iterator I = Values.begin(), E = Values.end(); I != E; ++
I) {
735 if (!isa<Instruction>(V))
741 if (std::distance(FirstUse, BEnd) < std::distance(It, BEnd))
753 BasicBlock *HexagonCommonGEP::recalculatePlacement(GepNode *Node,
754 NodeChildrenMap &NCM, NodeToValueMap &Loc) {
755 DEBUG(
dbgs() <<
"Loc for node:" << Node <<
'\n');
766 if (Node->Flags & GepNode::Used) {
769 NodeToUsesMap::iterator UF = Uses.find(Node);
770 assert(UF != Uses.end() &&
"Used node with no use information");
771 UseSet &Us = UF->second;
772 for (UseSet::iterator I = Us.begin(), E = Us.end(); I != E; ++
I) {
774 User *R = U->getUser();
775 if (!isa<Instruction>(R))
778 ? cast<PHINode>(R)->getIncomingBlock(*U)
784 NodeChildrenMap::iterator CF = NCM.find(Node);
785 if (CF != NCM.end()) {
786 NodeVect &Cs = CF->second;
787 for (NodeVect::iterator I = Cs.begin(), E = Cs.end(); I != E; ++
I) {
789 NodeToValueMap::iterator LF = Loc.find(CN);
795 Bs.push_back(LF->second);
799 BasicBlock *DomB = nearest_common_dominator(DT, Bs);
808 while (is_empty(DomB)) {
821 BasicBlock *HexagonCommonGEP::recalculatePlacementRec(GepNode *Node,
822 NodeChildrenMap &NCM, NodeToValueMap &Loc) {
823 DEBUG(
dbgs() <<
"LocRec begin for node:" << Node <<
'\n');
826 NodeChildrenMap::iterator CF = NCM.find(Node);
827 if (CF != NCM.end()) {
828 NodeVect &Cs = CF->second;
829 for (NodeVect::iterator I = Cs.begin(), E = Cs.end(); I != E; ++
I)
830 recalculatePlacementRec(*I, NCM, Loc);
832 BasicBlock *LB = recalculatePlacement(Node, NCM, Loc);
833 DEBUG(
dbgs() <<
"LocRec end for node:" << Node <<
'\n');
838 bool HexagonCommonGEP::isInvariantIn(
Value *Val,
Loop *L) {
839 if (isa<Constant>(Val) || isa<Argument>(Val))
849 bool HexagonCommonGEP::isInvariantIn(GepNode *Node,
Loop *L) {
850 if (Node->Flags & GepNode::Root)
851 if (!isInvariantIn(Node->BaseVal, L))
853 return isInvariantIn(Node->Idx, L);
861 if (PDT->dominates(B, HB))
883 BasicBlock *HexagonCommonGEP::adjustForInvariance(GepNode *Node,
884 NodeChildrenMap &NCM, NodeToValueMap &Loc) {
889 if (Node->Flags & GepNode::Root) {
890 if (
Instruction *PIn = dyn_cast<Instruction>(Node->BaseVal))
891 Bs.push_back(PIn->getParent());
893 Bs.push_back(Loc[Node->Parent]);
895 if (
Instruction *IIn = dyn_cast<Instruction>(Node->Idx))
896 Bs.push_back(IIn->getParent());
897 BasicBlock *TopB = nearest_common_dominatee(DT, Bs);
907 BasicBlock *LocB = cast_or_null<BasicBlock>(Loc[Node]);
909 Loop *Lp = LI->getLoopFor(LocB);
911 if (!isInvariantIn(Node, Lp) || !isInMainPath(LocB, Lp))
914 if (!NewLoc || !DT->
dominates(TopB, NewLoc))
923 NodeChildrenMap::iterator CF = NCM.find(Node);
924 if (CF != NCM.end()) {
925 NodeVect &Cs = CF->second;
926 for (NodeVect::iterator I = Cs.begin(), E = Cs.end(); I != E; ++
I)
927 adjustForInvariance(*I, NCM, Loc);
934 struct LocationAsBlock {
935 LocationAsBlock(
const NodeToValueMap &L) : Map(L) {}
936 const NodeToValueMap ⤅
942 for (NodeToValueMap::const_iterator I = Loc.Map.begin(), E = Loc.Map.end();
944 OS << I->first <<
" -> ";
946 OS << B->
getName() <<
'(' << B <<
')';
952 inline bool is_constant(GepNode *N) {
953 return isa<ConstantInt>(N->Idx);
958 void HexagonCommonGEP::separateChainForNode(GepNode *Node,
Use *U,
959 NodeToValueMap &Loc) {
960 User *R = U->getUser();
961 DEBUG(
dbgs() <<
"Separating chain for node (" << Node <<
") user: "
966 GepNode *C = 0, *NewNode = 0;
967 while (is_constant(N) && !(N->Flags & GepNode::Root)) {
969 GepNode *NewN =
new (*Mem) GepNode(N);
970 Nodes.push_back(NewN);
975 NewN->Flags &= ~GepNode::Used;
985 NodeToUsesMap::iterator UF = Uses.find(Node);
986 assert(UF != Uses.end());
987 UseSet &Us = UF->second;
989 for (UseSet::iterator I = Us.begin(); I != Us.end(); ) {
990 User *S = (*I)->getUser();
991 UseSet::iterator Nx = std::next(I);
999 Node->Flags &= ~GepNode::Used;
1004 NewNode->Flags |= GepNode::Used;
1005 DEBUG(
dbgs() <<
"new node: " << NewNode <<
" " << *NewNode <<
'\n');
1006 assert(!NewUs.empty());
1007 Uses[NewNode] = NewUs;
1011 void HexagonCommonGEP::separateConstantChains(GepNode *Node,
1012 NodeChildrenMap &NCM, NodeToValueMap &Loc) {
1015 nodes_for_root(Node, NCM, Ns);
1017 DEBUG(
dbgs() <<
"Separating constant chains for node: " << Node <<
'\n');
1021 for (NodeSet::iterator I = Ns.begin(), E = Ns.end(); I != E; ++
I) {
1023 if (!(N->Flags & GepNode::Used))
1025 NodeToUsesMap::iterator UF = Uses.find(N);
1026 assert(UF != Uses.end());
1027 UseSet &Us = UF->second;
1030 for (UseSet::iterator J = Us.begin(), F = Us.end(); J !=
F; ++J) {
1032 User *R = U->getUser();
1036 if (
LoadInst *Ld = dyn_cast<LoadInst>(R)) {
1038 if (&Ld->getOperandUse(PtrX) == U)
1040 }
else if (
StoreInst *St = dyn_cast<StoreInst>(R)) {
1042 if (&St->getOperandUse(PtrX) == U)
1051 FNs.insert(std::make_pair(N, LSs));
1054 DEBUG(
dbgs() <<
"Nodes with foldable users:\n" << FNs);
1056 for (NodeToUsesMap::iterator I = FNs.begin(), E = FNs.end(); I != E; ++
I) {
1057 GepNode *N = I->first;
1058 UseSet &Us = I->second;
1059 for (UseSet::iterator J = Us.begin(), F = Us.end(); J !=
F; ++J)
1060 separateChainForNode(N, *J, Loc);
1065 void HexagonCommonGEP::computeNodePlacement(NodeToValueMap &Loc) {
1068 NodeChildrenMap NCM;
1070 invert_find_roots(Nodes, NCM, Roots);
1074 for (NodeVect::iterator I = Roots.begin(), E = Roots.end(); I != E; ++
I)
1075 recalculatePlacementRec(*I, NCM, Loc);
1077 DEBUG(
dbgs() <<
"Initial node placement:\n" << LocationAsBlock(Loc));
1080 for (NodeVect::iterator I = Roots.begin(), E = Roots.end(); I != E; ++
I)
1081 adjustForInvariance(*I, NCM, Loc);
1083 DEBUG(
dbgs() <<
"Node placement after adjustment for invariance:\n"
1084 << LocationAsBlock(Loc));
1087 for (NodeVect::iterator I = Roots.begin(), E = Roots.end(); I != E; ++
I)
1088 separateConstantChains(*I, NCM, Loc);
1090 DEBUG(
dbgs() <<
"Node use information:\n" << Uses);
1096 DEBUG(
dbgs() <<
"Final node placement:\n" << LocationAsBlock(Loc));
1103 <<
" for nodes:\n" << NA);
1104 unsigned Num = NA.size();
1105 GepNode *
RN = NA[0];
1106 assert((RN->Flags & GepNode::Root) &&
"Creating GEP for non-root");
1109 Value *Input = RN->BaseVal;
1117 if (!NA[nax]->PTy->isPointerTy()) {
1124 while (++nax <= Num) {
1125 GepNode *N = NA[nax-1];
1126 IdxList[IdxC++] = N->Idx;
1131 if (NextTy != NA[nax]->PTy)
1139 DEBUG(
dbgs() <<
"new GEP: " << *NewInst <<
'\n');
1141 }
while (nax <= Num);
1148 void HexagonCommonGEP::getAllUsersForNode(GepNode *Node, ValueVect &Values,
1149 NodeChildrenMap &NCM) {
1151 Work.push_back(Node);
1153 while (!Work.empty()) {
1154 NodeVect::iterator First = Work.begin();
1155 GepNode *N = *First;
1157 if (N->Flags & GepNode::Used) {
1158 NodeToUsesMap::iterator UF = Uses.find(N);
1159 assert(UF != Uses.end() &&
"No use information for used node");
1160 UseSet &Us = UF->second;
1161 for (UseSet::iterator I = Us.begin(), E = Us.end(); I != E; ++
I)
1162 Values.push_back((*I)->getUser());
1164 NodeChildrenMap::iterator CF = NCM.find(N);
1165 if (CF != NCM.end()) {
1166 NodeVect &Cs = CF->second;
1167 Work.insert(Work.end(), Cs.begin(), Cs.end());
1173 void HexagonCommonGEP::materialize(NodeToValueMap &Loc) {
1174 DEBUG(
dbgs() <<
"Nodes before materialization:\n" << Nodes <<
'\n');
1175 NodeChildrenMap NCM;
1179 invert_find_roots(Nodes, NCM, Roots);
1181 while (!Roots.empty()) {
1182 NodeVect::iterator First = Roots.begin();
1183 GepNode *Root = *First, *
Last = *First;
1192 bool LastUsed =
false;
1193 unsigned LastCN = 0;
1196 Value *LocV = Loc[Last];
1202 LastUsed = (Last->Flags & GepNode::Used);
1205 NodeChildrenMap::iterator CF = NCM.find(Last);
1206 LastCN = (CF != NCM.end()) ? CF->second.size() : 0;
1209 GepNode *Child = CF->second.front();
1210 BasicBlock *ChildB = cast_or_null<BasicBlock>(Loc[Child]);
1211 if (ChildB != 0 && LastB != ChildB)
1217 if (LastUsed || LastCN > 0) {
1219 getAllUsersForNode(Root, Urs, NCM);
1221 if (FirstUse != LastB->
end())
1222 InsertAt = FirstUse;
1226 Value *NewInst = fabricateGEP(NA, InsertAt, LastB);
1231 NodeVect &Cs = NCM[Last];
1232 for (NodeVect::iterator I = Cs.begin(), E = Cs.end(); I != E; ++
I) {
1234 CN->Flags &= ~GepNode::Internal;
1235 CN->Flags |= GepNode::Root;
1236 CN->BaseVal = NewInst;
1237 Roots.push_back(CN);
1244 NodeToUsesMap::iterator UF = Uses.find(Last);
1245 assert(UF != Uses.end() &&
"No use information found");
1246 UseSet &Us = UF->second;
1247 for (UseSet::iterator I = Us.begin(), E = Us.end(); I != E; ++
I) {
1256 void HexagonCommonGEP::removeDeadCode() {
1258 BO.push_back(&Fn->front());
1260 for (
unsigned i = 0; i < BO.size(); ++i) {
1264 typedef GTN::ChildIteratorType Iter;
1265 for (Iter I = GTN::child_begin(N), E = GTN::child_end(N); I != E; ++
I)
1266 BO.push_back((*I)->getBlock());
1269 for (
unsigned i = BO.size(); i > 0; --i) {
1274 for (reverse_iterator I = IL.rbegin(), E = IL.rend(); I != E; ++
I)
1276 for (ValueVect::iterator I = Ins.begin(), E = Ins.end(); I != E; ++
I) {
1285 bool HexagonCommonGEP::runOnFunction(
Function &F) {
1289 if (isa<InvokeInst>(I) || isa<LandingPadInst>(
I))
1293 DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1294 PDT = &getAnalysis<PostDominatorTree>();
1295 LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
1309 computeNodePlacement(Loc);
1323 return new HexagonCommonGEP();
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
iplist< Instruction >::iterator eraseFromParent()
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()
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static cl::opt< bool > OptEnableInv("commgep-inv", cl::init(true), cl::Hidden, cl::ZeroOrMore)
const_iterator begin(StringRef path)
Get begin iterator over path.
LoopT * getParentLoop() const
LoadInst - an instruction for reading from memory.
BlockT * getHeader() const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
StringRef getName() const
Return a constant reference to the value's name.
BlockT * getLoopLatch() const
getLoopLatch - If there is a single latch block for this loop, return it.
iterator begin()
Instruction iterator methods.
FunctionPass * createHexagonCommonGEP()
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
const APInt & getValue() const
Return the constant as an APInt value reference.
StructType - Class to represent struct types.
A Use represents the edge between a Value definition and its users.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
bool isLiteral() const
isLiteral - Return true if this type is uniqued by structural equivalence, false if it is a struct de...
StringRef getStructName() const
user_iterator_impl< User > user_iterator
Base class for the actual dominator tree node.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
StoreInst - 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)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
GetElementPtrInst - an instruction for type-safe pointer arithmetic to access elements of arrays and ...
initializer< Ty > init(const Ty &Val)
Type * next_type(Type *Ty, Value *Idx)
BlockT * getLoopPreheader() const
getLoopPreheader - If there is a preheader for this loop, return it.
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.
int64_t getSExtValue() const
Get sign extended value.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
const InstListType & getInstList() const
Return the underlying instruction list container.
#define LLVM_ATTRIBUTE_UNUSED
FunctionPass class - This class is used to implement most global optimizations.
NodeT * findNearestCommonDominator(NodeT *A, NodeT *B)
findNearestCommonDominator - Find nearest common dominator basic block for basic block A and B...
static cl::opt< bool > OptSpeculate("commgep-speculate", cl::init(true), cl::Hidden, cl::ZeroOrMore)
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
bool dominates(const Instruction *Def, const Use &U) const
Return true if Def dominates a use in User.
DomTreeNodeBase< NodeT > * getIDom() const
GepNode(const GepNode *N)
This is the shared class of boolean and integer constants.
void initializeHexagonCommonGEPPass(PassRegistry &)
Type * getType() const
All values are typed, get the type of this value.
SequentialType * getType() const
std::reverse_iterator< iterator > reverse_iterator
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
PostDominatorTree Class - Concrete subclass of DominatorTree that is used to compute the post-dominat...
const Type * getScalarType() const LLVM_READONLY
getScalarType - If this is a vector type, return the element type, otherwise return 'this'...
bool isStructTy() const
isStructTy - True if this is an instance of StructType.
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned ComputeHash() const
ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used to lookup the node in the F...
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
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()
user_iterator user_begin()
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
isInstructionTriviallyDead - Return true if the result produced by the instruction is not used...
LLVM Value Representation.
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.
C - The default llvm calling convention, compatible with C.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Legacy analysis pass which computes a DominatorTree.
DomTreeNodeBase< NodeT > * getNode(NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
const BasicBlock * getParent() const
void dump_node_container(raw_ostream &OS, const NodeContainer &S)