1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 11:33:24 +02:00

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
This commit is contained in:
Diego Novillo 2015-11-29 18:23:26 +00:00
parent 268b85343f
commit d74fdde81f

View File

@ -44,6 +44,7 @@
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorOr.h" #include "llvm/Support/ErrorOr.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/Cloning.h"
@ -629,12 +630,14 @@ bool SampleProfileLoader::emitInlineHints(Function &F) {
// it globally hot. // it globally hot.
if (SamplesPercent >= SampleProfileGlobalHotThreshold) { if (SamplesPercent >= SampleProfileGlobalHotThreshold) {
F.addFnAttr(llvm::Attribute::InlineHint); F.addFnAttr(llvm::Attribute::InlineHint);
emitOptimizationRemark( std::string Msg;
F.getContext(), DEBUG_TYPE, F, DebugLoc(), raw_string_ostream S(Msg);
Twine("Applied inline hint to globally hot function '" + F.getName() + S << "Applied inline hint to globally hot function '" << F.getName()
"' with " + Twine(std::to_string(SamplesPercent)) + << "' with " << format("%.2f", SamplesPercent)
"% of samples (threshold: " + << "% of samples (threshold: "
Twine(std::to_string(SampleProfileGlobalHotThreshold)) + "%)")); << format("%.2f", SampleProfileGlobalHotThreshold.getValue()) << "%)";
S.flush();
emitOptimizationRemark(F.getContext(), DEBUG_TYPE, F, DebugLoc(), Msg);
return true; return true;
} }
@ -642,12 +645,14 @@ bool SampleProfileLoader::emitInlineHints(Function &F) {
// it globally cold. // it globally cold.
if (SamplesPercent <= SampleProfileGlobalColdThreshold) { if (SamplesPercent <= SampleProfileGlobalColdThreshold) {
F.addFnAttr(llvm::Attribute::Cold); F.addFnAttr(llvm::Attribute::Cold);
emitOptimizationRemark( std::string Msg;
F.getContext(), DEBUG_TYPE, F, DebugLoc(), raw_string_ostream S(Msg);
Twine("Applied cold hint to globally cold function '" + F.getName() + S << "Applied cold hint to globally cold function '" << F.getName()
"' with " + Twine(std::to_string(SamplesPercent)) + << "' with " << format("%.2f", SamplesPercent)
"% of samples (threshold: " + << "% of samples (threshold: "
Twine(std::to_string(SampleProfileGlobalColdThreshold)) + "%)")); << format("%.2f", SampleProfileGlobalColdThreshold.getValue()) << "%)";
S.flush();
emitOptimizationRemark(F.getContext(), DEBUG_TYPE, F, DebugLoc(), Msg);
return true; return true;
} }