diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-06-29 09:56:40 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-06-29 09:56:40 +0000 |
commit | 6475e077a091ea57b7442ed35feaf031728bdeb2 (patch) | |
tree | 51378b372948340b17f7da85b6fb2375dfa3a031 /gcc/dumpfile.h | |
parent | 6fdce073fc342fab76363e9169f7bcf49d8ab98b (diff) |
dumpfile.c: add indentation via DUMP_VECT_SCOPE
This patch adds a concept of nested "scopes" to dumpfile.c's dump_*_loc
calls, and wires it up to the DUMP_VECT_SCOPE macro in tree-vectorizer.h,
so that the nested structure is shown in -fopt-info by indentation.
For example, this converts -fopt-info-all e.g. from:
test.c:8:3: note: === analyzing loop ===
test.c:8:3: note: === analyze_loop_nest ===
test.c:8:3: note: === vect_analyze_loop_form ===
test.c:8:3: note: === get_loop_niters ===
test.c:8:3: note: symbolic number of iterations is (unsigned int) n_9(D)
test.c:8:3: note: not vectorized: loop contains function calls or data references that cannot be analyzed
test.c:8:3: note: vectorized 0 loops in function
to:
test.c:8:3: note: === analyzing loop ===
test.c:8:3: note: === analyze_loop_nest ===
test.c:8:3: note: === vect_analyze_loop_form ===
test.c:8:3: note: === get_loop_niters ===
test.c:8:3: note: symbolic number of iterations is (unsigned int) n_9(D)
test.c:8:3: note: not vectorized: loop contains function calls or data references that cannot be analyzed
test.c:8:3: note: vectorized 0 loops in function
showing that the "symbolic number of iterations" message is within
the "=== analyze_loop_nest ===" (and not within the
"=== vect_analyze_loop_form ===").
This is also enabling work for followups involving optimization records
(allowing the records to directly capture the nested structure of the
dump messages).
gcc/ChangeLog:
* dumpfile.c (dump_loc): Add indentation based on scope depth.
(dump_scope_depth): New variable.
(get_dump_scope_depth): New function.
(dump_begin_scope): New function.
(dump_end_scope): New function.
* dumpfile.h (get_dump_scope_depth): New declaration.
(dump_begin_scope): New declaration.
(dump_end_scope): New declaration.
(class auto_dump_scope): New class.
(AUTO_DUMP_SCOPE): New macro.
* tree-vectorizer.h (DUMP_VECT_SCOPE): Reimplement in terms of
AUTO_DUMP_SCOPE.
From-SVN: r262246
Diffstat (limited to 'gcc/dumpfile.h')
-rw-r--r-- | gcc/dumpfile.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 489f92e6d1a..9828a3f550c 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -459,6 +459,45 @@ dump_enabled_p (void) return dumps_are_enabled; } +/* Managing nested scopes, so that dumps can express the call chain + leading to a dump message. */ + +extern unsigned int get_dump_scope_depth (); +extern void dump_begin_scope (const char *name, const dump_location_t &loc); +extern void dump_end_scope (); + +/* Implementation detail of the AUTO_DUMP_SCOPE macro below. + + A RAII-style class intended to make it easy to emit dump + information about entering and exiting a collection of nested + function calls. */ + +class auto_dump_scope +{ + public: + auto_dump_scope (const char *name, dump_location_t loc) + { + if (dump_enabled_p ()) + dump_begin_scope (name, loc); + } + ~auto_dump_scope () + { + if (dump_enabled_p ()) + dump_end_scope (); + } +}; + +/* A macro for calling: + dump_begin_scope (NAME, LOC); + via an RAII object, thus printing "=== MSG ===\n" to the dumpfile etc, + and then calling + dump_end_scope (); + once the object goes out of scope, thus capturing the nesting of + the scopes. */ + +#define AUTO_DUMP_SCOPE(NAME, LOC) \ + auto_dump_scope scope (NAME, LOC) + namespace gcc { class dump_manager |