#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/ADT/SCCIterator.h"
+#include "llvm/IR/CallSite.h"
+#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/PassManager.h"
-#include "llvm/Support/CallSite.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/InstVisitor.h"
using namespace llvm;
continue;
}
- for (User::value_op_iterator OI = C->value_op_begin(),
- OE = C->value_op_end();
- OI != OE; ++OI)
- if (Visited.insert(cast<Constant>(*OI)))
- Worklist.push_back(cast<Constant>(*OI));
+ for (Value *Op : C->operand_values())
+ if (Visited.insert(cast<Constant>(Op)))
+ Worklist.push_back(cast<Constant>(Op));
}
}
for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE; ++BBI)
for (BasicBlock::iterator II = BBI->begin(), IE = BBI->end(); II != IE;
++II)
- for (User::value_op_iterator OI = II->value_op_begin(),
- OE = II->value_op_end();
- OI != OE; ++OI)
- if (Constant *C = dyn_cast<Constant>(*OI))
+ for (Value *Op : II->operand_values())
+ if (Constant *C = dyn_cast<Constant>(Op))
if (Visited.insert(C))
Worklist.push_back(C);
Callees.push_back(G.copyInto(*OI->get<Node *>()));
}
-#if LLVM_HAS_RVALUE_REFERENCES
LazyCallGraph::Node::Node(LazyCallGraph &G, Node &&OtherN)
: G(G), F(OtherN.F), Callees(std::move(OtherN.Callees)),
CalleeSet(std::move(OtherN.CalleeSet)) {
if (Node *ChildN = CI->dyn_cast<Node *>())
*CI = G.moveInto(std::move(*ChildN));
}
-#endif
LazyCallGraph::LazyCallGraph(Module &M) : M(M) {
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI)
LazyCallGraph::LazyCallGraph(const LazyCallGraph &G)
: M(G.M), EntryNodeSet(G.EntryNodeSet) {
- EntryNodes.reserve(EntryNodes.size());
- for (NodeVectorImplT::iterator EI = EntryNodes.begin(),
- EE = EntryNodes.end();
+ EntryNodes.reserve(G.EntryNodes.size());
+ for (NodeVectorImplT::const_iterator EI = G.EntryNodes.begin(),
+ EE = G.EntryNodes.end();
EI != EE; ++EI)
if (Function *Callee = EI->dyn_cast<Function *>())
EntryNodes.push_back(Callee);
EntryNodes.push_back(copyInto(*EI->get<Node *>()));
}
-#if LLVM_HAS_RVALUE_REFERENCES
// FIXME: This would be crazy simpler if BumpPtrAllocator were movable without
// invalidating any of the allocated memory. We should make that be the case at
// some point and delete this.
LazyCallGraph::LazyCallGraph(LazyCallGraph &&G)
: M(G.M), EntryNodes(std::move(G.EntryNodes)),
EntryNodeSet(std::move(G.EntryNodeSet)) {
- // Loop over our EntryNodes. They've been moved from another graph, but we
- // need to move the Node*s to live under our bump ptr allocator.
- for (NodeVectorImplT::iterator EI = EntryNodes.begin(), EE = EntryNodes.end();
+ // Loop over our EntryNodes. They've been moved from another graph, so we
+ // need to move the Node*s to live under our bump ptr allocator. We can just
+ // do this in-place.
+ for (NodeVectorImplT::iterator EI = EntryNodes.begin(),
+ EE = EntryNodes.end();
EI != EE; ++EI)
if (Node *EntryN = EI->dyn_cast<Node *>())
- *EI = G.moveInto(std::move(*EntryN));
+ *EI = moveInto(std::move(*EntryN));
}
-#endif
LazyCallGraph::Node *LazyCallGraph::insertInto(Function &F, Node *&MappedN) {
return new (MappedN = BPA.Allocate()) Node(*this, F);
return new (N = BPA.Allocate()) Node(*this, OtherN);
}
-#if LLVM_HAS_RVALUE_REFERENCES
LazyCallGraph::Node *LazyCallGraph::moveInto(Node &&OtherN) {
Node *&N = NodeMap[&OtherN.F];
if (N)
return new (N = BPA.Allocate()) Node(*this, std::move(OtherN));
}
-#endif
char LazyCallGraphAnalysis::PassID;