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 @@
#include "IceOperand.h"
#include "IceTargetLowering.h"
#include "llvm/Support/Format.h"
namespace Ice {
namespace {
......@@ -626,13 +628,11 @@ void Inst::dumpDecorated(const Cfg *Func) const {
if (!Func->isVerbose(IceV_Deleted) && (isDeleted() || isRedundantAssign()))
return;
if (Func->isVerbose(IceV_InstNumbers)) {
char buf[30];
InstNumberT Number = getNumber();
if (Number == NumberDeleted)
snprintf(buf, llvm::array_lengthof(buf), "[XXX]");
Str << "[XXX]";
else
snprintf(buf, llvm::array_lengthof(buf), "[%3d]", Number);
Str << buf;
Str << llvm::format("[%3d]", Number);
}
Str << " ";
if (isDeleted())
......
......@@ -22,6 +22,7 @@
#pragma clang diagnostic ignored "-Wunused-parameter"
#endif // __clang__
#include "llvm/Support/Format.h"
#include "llvm/Support/Timer.h"
#ifdef __clang__
......@@ -231,10 +232,8 @@ void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) {
if (!BuildDefs::timers())
return;
for (auto &I : reverse_range(Map)) {
char buf[80];
snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I.first,
I.first * 100 / TotalTime);
Str << buf << I.second << "\n";
Str << llvm::format(" %10.6f (%4.1f%%): ", I.first,
I.first * 100 / TotalTime) << 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