aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/SampleProfile.cpp
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2015-11-29 18:23:26 +0000
committerDiego Novillo <dnovillo@google.com>2015-11-29 18:23:26 +0000
commit7ff0a174d1220cc7b4b5ab44d650eca6fd08805c (patch)
tree478d7fbed0ac37ffdf13ed10479c6caaaeea21ef /llvm/lib/Transforms/IPO/SampleProfile.cpp
parent6066164454f58589bee8c4ac857b393b33c65929 (diff)
downloadllvm-7ff0a174d1220cc7b4b5ab44d650eca6fd08805c.zip
llvm-7ff0a174d1220cc7b4b5ab44d650eca6fd08805c.tar.gz
llvm-7ff0a174d1220cc7b4b5ab44d650eca6fd08805c.tar.bz2
SamplePGO - Do not use std::to_string in diagnostics.
This fixes buildbots in systems that std::to_string is not present. It also tidies the output of the diagnostic to render doubles a bit better (thanks Ben Kramer for help with string streams and format). llvm-svn: 254261
Diffstat (limited to 'llvm/lib/Transforms/IPO/SampleProfile.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/SampleProfile.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 5cb71f7..2ce1fce 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -44,6 +44,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/Cloning.h"
@@ -629,12 +630,14 @@ bool SampleProfileLoader::emitInlineHints(Function &F) {
// it globally hot.
if (SamplesPercent >= SampleProfileGlobalHotThreshold) {
F.addFnAttr(llvm::Attribute::InlineHint);
- emitOptimizationRemark(
- F.getContext(), DEBUG_TYPE, F, DebugLoc(),
- Twine("Applied inline hint to globally hot function '" + F.getName() +
- "' with " + Twine(std::to_string(SamplesPercent)) +
- "% of samples (threshold: " +
- Twine(std::to_string(SampleProfileGlobalHotThreshold)) + "%)"));
+ std::string Msg;
+ raw_string_ostream S(Msg);
+ S << "Applied inline hint to globally hot function '" << F.getName()
+ << "' with " << format("%.2f", SamplesPercent)
+ << "% of samples (threshold: "
+ << format("%.2f", SampleProfileGlobalHotThreshold.getValue()) << "%)";
+ S.flush();
+ emitOptimizationRemark(F.getContext(), DEBUG_TYPE, F, DebugLoc(), Msg);
return true;
}
@@ -642,12 +645,14 @@ bool SampleProfileLoader::emitInlineHints(Function &F) {
// it globally cold.
if (SamplesPercent <= SampleProfileGlobalColdThreshold) {
F.addFnAttr(llvm::Attribute::Cold);
- emitOptimizationRemark(
- F.getContext(), DEBUG_TYPE, F, DebugLoc(),
- Twine("Applied cold hint to globally cold function '" + F.getName() +
- "' with " + Twine(std::to_string(SamplesPercent)) +
- "% of samples (threshold: " +
- Twine(std::to_string(SampleProfileGlobalColdThreshold)) + "%)"));
+ std::string Msg;
+ raw_string_ostream S(Msg);
+ S << "Applied cold hint to globally cold function '" << F.getName()
+ << "' with " << format("%.2f", SamplesPercent)
+ << "% of samples (threshold: "
+ << format("%.2f", SampleProfileGlobalColdThreshold.getValue()) << "%)";
+ S.flush();
+ emitOptimizationRemark(F.getContext(), DEBUG_TYPE, F, DebugLoc(), Msg);
return true;
}