Commit d72385f2 by Jim Stichnoth

Subzero: Remove a couple clumsy uses of snprintf.

We can use llvm::format() to achieve the same result in these cases. BUG= none R=jpp@chromium.org, kschimpf@google.com Review URL: https://codereview.chromium.org/1866633003 .
parent 11756b51
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "IceOperand.h" #include "IceOperand.h"
#include "IceTargetLowering.h" #include "IceTargetLowering.h"
#include "llvm/Support/Format.h"
namespace Ice { namespace Ice {
namespace { namespace {
...@@ -626,13 +628,11 @@ void Inst::dumpDecorated(const Cfg *Func) const { ...@@ -626,13 +628,11 @@ void Inst::dumpDecorated(const Cfg *Func) const {
if (!Func->isVerbose(IceV_Deleted) && (isDeleted() || isRedundantAssign())) if (!Func->isVerbose(IceV_Deleted) && (isDeleted() || isRedundantAssign()))
return; return;
if (Func->isVerbose(IceV_InstNumbers)) { if (Func->isVerbose(IceV_InstNumbers)) {
char buf[30];
InstNumberT Number = getNumber(); InstNumberT Number = getNumber();
if (Number == NumberDeleted) if (Number == NumberDeleted)
snprintf(buf, llvm::array_lengthof(buf), "[XXX]"); Str << "[XXX]";
else else
snprintf(buf, llvm::array_lengthof(buf), "[%3d]", Number); Str << llvm::format("[%3d]", Number);
Str << buf;
} }
Str << " "; Str << " ";
if (isDeleted()) if (isDeleted())
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-parameter"
#endif // __clang__ #endif // __clang__
#include "llvm/Support/Format.h"
#include "llvm/Support/Timer.h" #include "llvm/Support/Timer.h"
#ifdef __clang__ #ifdef __clang__
...@@ -231,10 +232,8 @@ void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { ...@@ -231,10 +232,8 @@ void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) {
if (!BuildDefs::timers()) if (!BuildDefs::timers())
return; return;
for (auto &I : reverse_range(Map)) { for (auto &I : reverse_range(Map)) {
char buf[80]; Str << llvm::format(" %10.6f (%4.1f%%): ", I.first,
snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I.first, I.first * 100 / TotalTime) << I.second << "\n";
I.first * 100 / TotalTime);
Str << buf << I.second << "\n";
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment