From c71f1074328b6ab57312e4278c572b71833d4a48 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Thu, 15 Nov 2018 01:01:26 +0000
Subject: [PATCH] [llvm,Darwin9] For earlier Darwin, round is in the
 global namespace, not std::.

---
 llvm/tools/llvm-dwarfdump/Statistics.cpp  | 6 ++++--
 llvm/tools/llvm-exegesis/lib/Analysis.cpp | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp
index 5af853d4ef2..1dcb9c02641 100644
--- a/llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -4,6 +4,8 @@
 #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
 #include "llvm/Object/ObjectFile.h"
 
+#include <cmath>
+
 #define DEBUG_TYPE "dwarfdump"
 using namespace llvm;
 using namespace object;
@@ -243,9 +245,9 @@ bool collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
   OS << "}\n";
   LLVM_DEBUG(
       llvm::dbgs() << "Total Availability: "
-                   << (int)std::round((VarWithLoc * 100.0) / VarTotal) << "%\n";
+                   << (int) ::round((VarWithLoc * 100.0) / VarTotal) << "%\n";
       llvm::dbgs() << "PC Ranges covered: "
-                   << (int)std::round((GlobalStats.ScopeBytesCovered * 100.0) /
+                   << (int) ::round((GlobalStats.ScopeBytesCovered * 100.0) /
                                       GlobalStats.ScopeBytesFromFirstDefinition)
                    << "%\n");
   return true;
diff --git a/llvm/tools/llvm-exegesis/lib/Analysis.cpp b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
index bb511808096..f803f3a475c 100644
--- a/llvm/tools/llvm-exegesis/lib/Analysis.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Analysis.cpp
@@ -14,6 +14,7 @@
 #include "llvm/Support/FormatVariadic.h"
 #include <unordered_set>
 #include <vector>
+#include <cmath>
 
 namespace exegesis {
 
@@ -360,7 +361,7 @@ getNonRedundantWriteProcRes(const llvm::MCSchedClassDesc &SCDesc,
       }
       // The ProcResGroup contributes `RemainingCycles` cycles of its own.
       Result.push_back({WPR->ProcResourceIdx,
-                        static_cast<uint16_t>(std::round(RemainingCycles))});
+                        static_cast<uint16_t>(::round(RemainingCycles))});
       // Spread the remaining cycles over all subunits.
       for (const auto *SubResIdx = ProcResDesc->SubUnitsIdxBegin;
            SubResIdx != ProcResDesc->SubUnitsIdxBegin + ProcResDesc->NumUnits;
