R600/SI: Using SGPRs is illegal for instructions that read carry-out from VCC
[oota-llvm.git] / lib / Analysis / LazyCallGraph.cpp
index b89bf70b43305a73778a048fecad70c9ca72fc38..e86b266411107f316b3a1f7d5bc61cd10eae5426 100644 (file)
@@ -9,11 +9,11 @@
 
 #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;
 
@@ -40,11 +40,9 @@ static void findCallees(
       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));
   }
 }
 
@@ -56,10 +54,8 @@ LazyCallGraph::Node::Node(LazyCallGraph &G, Function &F) : G(G), F(F) {
   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);
 
@@ -83,7 +79,6 @@ LazyCallGraph::Node::Node(LazyCallGraph &G, const Node &OtherN)
       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)) {
@@ -94,7 +89,6 @@ LazyCallGraph::Node::Node(LazyCallGraph &G, Node &&OtherN)
     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)
@@ -115,9 +109,9 @@ LazyCallGraph::LazyCallGraph(Module &M) : M(M) {
 
 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);
@@ -125,21 +119,21 @@ LazyCallGraph::LazyCallGraph(const LazyCallGraph &G)
       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);
@@ -153,7 +147,6 @@ LazyCallGraph::Node *LazyCallGraph::copyInto(const Node &OtherN) {
   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)
@@ -161,7 +154,6 @@ LazyCallGraph::Node *LazyCallGraph::moveInto(Node &&OtherN) {
 
   return new (N = BPA.Allocate()) Node(*this, std::move(OtherN));
 }
-#endif
 
 char LazyCallGraphAnalysis::PassID;