[COMMITTED 1/3] Abstract range tracing routines into a class.

Andrew MacLeod amacleod@redhat.com
Tue Aug 17 23:30:54 GMT 2021


I originally implemented range tracing as a derived class so I wouldn't 
mess-up the basic range routines in ranger.  Having tracing enabled this 
way had its advantages, but also had some disadvantages, such as 
requiring a different class to be instantiated when we want to turn on 
tracing.

Regardless,there is an ongoing need to be able to debug range-ops and 
GORI. It seems that the tracing mechanism can be utilized there as well, 
so this patch abstracts the tracing routines into a class and 
re-implements range tracing in ranger using it.

If you have never looked at a ranger trace, it looks something like this 
(an early part of a run where the backedge hasn't been resolved fully yet) :

42                 range_of_stmt (j_32) at stmt j_32 = j_14 + 1;
43                   range_of_expr(j_14) at stmt j_32 = j_14 + 1;
44                     range_on_entry (j_14) to BB 8
45                       range_of_stmt (j_14) at stmt j_14 = PHI <0(19), 
j_32(8)>
                          TRUE : (45)  cached (j_14) int VARYING
                        TRUE : (44) range_on_entry (j_14) int [-INF, 31]
                      TRUE : (43) range_of_expr (j_14) int [-INF, 31]
  Registering value_relation (j_32 > j_14) (bb8) at j_32 = j_14 + 1;
                    TRUE : (42) range_of_stmt (j_32) int [-2147483647, 32]

It follows all the various range query calls and shows ranges as they 
are requested/calculated.

Request 42 is asking for the range of j_32 on it's defining statement.
That is followed by request 43 which asks for the range of j_14 on that 
statement, and the series of requests that go off and find that value.
Eventually we see the TRUE returned for request 43 and the range of j_14 
was determined to be int [-INF, 31].
When that is applied to request 42, we see true returned and [-INF, 31] 
+ 1 is calculated as int [-2147483647, 32]

This allows us to trace the range calculations based on each request, 
and see where something has gone wrong.

Furthermore, the trace index is now static, so the index is unique 
across the compilation unit, and a 'breakpoint' routine has been added 
to the range_tracer class which allows one to easily set a breakpoint on 
a specific index.  so within gdb,
    b range_tracer::breakpoint if index == 43
Will cause the debugger to stop when we are beginning to process request 
43... making it much easier to look around when something is wrong.

Bootstrapped on x86_64-pc-linux-gnu  with no regressions. Pushed.

Andrew





-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Abstract-tracing-routines-into-a-class.patch
Type: text/x-patch
Size: 27465 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210817/22421538/attachment-0001.bin>


More information about the Gcc-patches mailing list