Subzero: Add memory usage to "-szstats" output.
Requires the LLVM option -track-memory to get meaningful results.
BUG= none
R=kschimpf@google.com
Review URL: https://codereview.chromium.org/795063003
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index 84d7b68..2903dde 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -16,6 +16,8 @@
#include <locale> // locale
#include <unordered_map>
+#include "llvm/Support/Timer.h"
+
#include "IceCfg.h"
#include "IceClFlags.h"
#include "IceDefs.h"
@@ -105,6 +107,23 @@
UndefPool Undefs;
};
+void CodeStats::dump(const IceString &Name, Ostream &Str) {
+ if (!ALLOW_DUMP)
+ return;
+ Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n";
+ Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n";
+ Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n";
+ Str << "|" << Name << "|Spills |" << Spills << "\n";
+ Str << "|" << Name << "|Fills |" << Fills << "\n";
+ Str << "|" << Name << "|Spills+Fills|" << Spills + Fills << "\n";
+ Str << "|" << Name << "|Memory Usage|";
+ if (ssize_t MemUsed = llvm::TimeRecord::getCurrentTime(false).getMemUsed())
+ Str << MemUsed;
+ else
+ Str << "(requires '-track-memory')";
+ Str << "\n";
+}
+
GlobalContext::GlobalContext(Ostream *OsDump, Ostream *OsEmit,
ELFStreamer *ELFStr, VerboseMask Mask,
TargetArch Arch, OptLevel Opt,