Index: src/IceCfg.cpp |
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp |
index 5c51ae6d3893316efe28aff8793de937b902931b..5e5957e866e4429a9aa100c6c314bf63b01132d5 100644 |
--- a/src/IceCfg.cpp |
+++ b/src/IceCfg.cpp |
@@ -1076,6 +1076,14 @@ void Cfg::emitIAS() { |
emitJumpTables(); |
} |
+size_t Cfg::getTotalMemoryMB() { |
+ constexpr size_t OneMB = 1024 * 1024; |
+ using ArbitraryType = int; |
+ // CfgLocalAllocator draws from the same memory pool regardless of allocated |
+ // object type, so pick an arbitrary type for the template parameter. |
+ return CfgLocalAllocator<ArbitraryType>().current()->getTotalMemory() / OneMB; |
+} |
+ |
// Dumps the IR with an optional introductory message. |
void Cfg::dump(const IceString &Message) { |
if (!BuildDefs::dump()) |
@@ -1087,10 +1095,7 @@ void Cfg::dump(const IceString &Message) { |
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"; |
+ Str << "Memory size = " << getTotalMemoryMB() << " MB\n"; |
} |
setCurrentNode(getEntryNode()); |
// Print function name+args |