« Return to Thread: [RFC] Track discriminators by instruction instead of by basic block

Re: [RFC] Track discriminators by instruction instead of by basic block

by Richard Guenther-2 :: Rate this Message:

Reply to Author | View in Thread

On Wed, Nov 11, 2009 at 1:39 PM, Cary Coutant <ccoutant@...> wrote:

> The attached patch reworks discriminator assignment so that it
> attaches the discriminator to the source location of each instruction
> instead of to the basic block itself. I had hoped not to have to do it
> this way, but we've found that we're losing too much discriminator
> information when basic blocks get combined and resplit in later
> optimization passes, and the loss of accuracy in the sample profiling
> is hurting the performance. This approach turned out not to be as hard
> as I originally thought it would be: When I need to assign a
> discrimator, I allocate a new location_t value larger than any
> assigned by libcpp, and keep two vectors that map each new location_t
> value to its original libcpp-assigned value and to the discriminator
> value itself.
>
> I'm not looking to put this into mainline during Stage 3, since the
> problem it solves is only for sample-based profiling, but I would like
> to get this reviewed anyway. If it looks generally OK, I'll hold it in
> the dwarf4 branch until the next Stage 1.

What's a discriminator?  Why is it worth bloating locations with it?
How much more memory do we need when keeping discriminators
with LTO (which you don't - patches to lto-streamer-{in,out} are missing).

Thanks,
Richard.

> -cary
>
>        * basic-block.h (struct basic_block_def): Remove discriminator field.
>        * cfghooks.c (split_block): Remove discriminator field.
>        * cfglayout.c (insn_discriminator): New function.
>        * final.c (discriminator): Remove.
>        (override_discriminator): New file-scope variable.
>        (final_start_function): Remove tracking of discriminator by basic
>        block.
>        (final_scan_insn): Track discriminator by instruction.
>        (notice_source_line): Check for discriminator override. Get
>        discriminator from instruction.
>        * gimple-pretty-print.c (dump_gimple_stmt): Print discriminator.
>        (dump_bb_header): Don't print discriminator.
>        * print-rtl.c (print_rtx): Print discriminator.
>        * rtl.h (insn_discriminator): New function.
>        * tree.h (min_discriminator_location): New global.
>        (map_discriminator_location): New function.
>        (get_discriminator_from_locus): New function.
>        * tree.c (expand_location): Use map_discriminator_location.
>        * tree-cfg.c: Include vecprim.h.
>        (discriminator_location_locations): New variable.
>        (discriminator_location_discriminators): New variable.
>        (min_discriminator_location): New variable.
>        (location_with_discriminator): New function.
>        (has_discriminator): New function.
>        (map_discriminator_location): New function.
>        (get_discriminator_from_locus): New function.
>        (assign_discriminator): Assign discriminators to instructions rather
>        than to the basic block.
>        * tree-pretty-print.c (dump_location): Print discriminator.
>

 « Return to Thread: [RFC] Track discriminators by instruction instead of by basic block