Subzero: Print memory usage info when dumping.
Adds "-verbose mem" to enable printing the amount of CfgLocalAllocator memory allocated, each time Cfg::dump() is called.
"-verbose mem,status" is a good way to get summary info.
BUG= none
R=kschimpf@google.com
Review URL: https://codereview.chromium.org/1743043002 .
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index 480893a..5c51ae6 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -203,8 +203,10 @@
FunctionTimer.reset(new TimerMarker(
getContext()->getTimerID(GlobalContext::TSK_Funcs, Name),
getContext(), GlobalContext::TSK_Funcs));
- if (isVerbose(IceV_Status))
- getContext()->getStrDump() << ">>>Translating " << Name << "\n";
+ if (isVerbose(IceV_Status)) {
+ getContext()->getStrDump() << ">>>Translating "
+ << getFunctionNameAndSize() << "\n";
+ }
}
TimerMarker T(TimerStack::TT_translate, this);
@@ -1084,6 +1086,12 @@
Ostream &Str = Ctx->getStrDump();
if (!Message.empty())
Str << "================ " << Message << " ================\n";
+ if (isVerbose(IceV_Mem)) {
+ constexpr size_t OneMB = 1024 * 1024;
+ Str << "Memory size = "
+ << (CfgLocalAllocator<int>().current()->getTotalMemory() / OneMB)
+ << " MB\n";
+ }
setCurrentNode(getEntryNode());
// Print function name+args
if (isVerbose(IceV_Instructions)) {
diff --git a/src/IceClFlags.cpp b/src/IceClFlags.cpp
index f776634..36f53ee 100644
--- a/src/IceClFlags.cpp
+++ b/src/IceClFlags.cpp
@@ -335,6 +335,7 @@
"Print the name of the function being translated"),
clEnumValN(Ice::IceV_AvailableRegs, "registers",
"Show available registers for register allocation"),
+ clEnumValN(Ice::IceV_Mem, "mem", "Memory usage details"),
clEnumValN(Ice::IceV_All, "all", "Use all verbose options"),
clEnumValN(Ice::IceV_Most, "most",
"Use all verbose options except 'regalloc'"),
diff --git a/src/IceDefs.h b/src/IceDefs.h
index 56a3bac..b8047b4 100644
--- a/src/IceDefs.h
+++ b/src/IceDefs.h
@@ -213,6 +213,7 @@
IceV_Loop = 1 << 13,
IceV_Status = 1 << 14,
IceV_AvailableRegs = 1 << 15,
+ IceV_Mem = 1 << 16,
IceV_All = ~IceV_None,
IceV_Most = IceV_All & ~IceV_LinearScan
};