LLParser: Handle BlockAddresses on-the-fly
[oota-llvm.git] / lib / Transforms / Scalar / SampleProfile.cpp
index 8e3583a1237854f7c05a31d33a46d846b872aa9b..56c57373a7673f348c8f21cb9c8ff9f2c8c4b274 100644 (file)
@@ -457,8 +457,8 @@ bool SampleModuleProfile::loadText() {
     M.getContext().diagnose(DiagnosticInfoSampleProfile(Filename.data(), Msg));
     return false;
   }
-  std::unique_ptr<MemoryBuffer> Buffer = std::move(BufferOrErr.get());
-  line_iterator LineIt(*Buffer, '#');
+  MemoryBuffer &Buffer = *BufferOrErr.get();
+  line_iterator LineIt(Buffer, '#');
 
   // Read the profile of each function. Since each function may be
   // mentioned more than once, and we are collecting flat profiles,
@@ -865,7 +865,8 @@ void SampleFunctionProfile::buildEdges(Function &F) {
     SmallPtrSet<BasicBlock *, 16> Visited;
     if (!Predecessors[B1].empty())
       llvm_unreachable("Found a stale predecessors list in a basic block.");
-    for (BasicBlock *B2 : predecessors(B1)) {
+    for (pred_iterator PI = pred_begin(B1), PE = pred_end(B1); PI != PE; ++PI) {
+      BasicBlock *B2 = *PI;
       if (Visited.insert(B2))
         Predecessors[B1].push_back(B2);
     }
@@ -874,7 +875,8 @@ void SampleFunctionProfile::buildEdges(Function &F) {
     Visited.clear();
     if (!Successors[B1].empty())
       llvm_unreachable("Found a stale successors list in a basic block.");
-    for (BasicBlock *B2 : successors(B1)) {
+    for (succ_iterator SI = succ_begin(B1), SE = succ_end(B1); SI != SE; ++SI) {
+      BasicBlock *B2 = *SI;
       if (Visited.insert(B2))
         Successors[B1].push_back(B2);
     }