Add suffix parameter to DumpCFG
In a lot of cases it is practical to dump CFGs. However the current dumper
has a unique naming convention. By adding an optional suffix, we can dump
the same CompilationUnit before and after an optimization by using a different
suffix.
Also, by making it optional, the change is minimal.
Change-Id: Ibd7f217ed59c093580cad9c177f9fc174a0afc11
Signed-off-by: Jean Christophe Beyler <jean.christophe.beyler@intel.com>
diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc
index 79edb87..b1c0b28 100644
--- a/compiler/dex/mir_graph.cc
+++ b/compiler/dex/mir_graph.cc
@@ -707,12 +707,13 @@
// TODO: use a configurable base prefix, and adjust callers to supply pass name.
/* Dump the CFG into a DOT graph */
-void MIRGraph::DumpCFG(const char* dir_prefix, bool all_blocks) {
+void MIRGraph::DumpCFG(const char* dir_prefix, bool all_blocks, const char *suffix) {
FILE* file;
std::string fname(PrettyMethod(cu_->method_idx, *cu_->dex_file));
ReplaceSpecialChars(fname);
- fname = StringPrintf("%s%s%x.dot", dir_prefix, fname.c_str(),
- GetBasicBlock(GetEntryBlock()->fall_through)->start_offset);
+ fname = StringPrintf("%s%s%x%s.dot", dir_prefix, fname.c_str(),
+ GetBasicBlock(GetEntryBlock()->fall_through)->start_offset,
+ suffix == nullptr ? "" : suffix);
file = fopen(fname.c_str(), "w");
if (file == NULL) {
return;