[PATCH] D30226: [BranchFolding] Merge debug locations from common tail instead of removing

Andrea Di Biagio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 11:13:12 PST 2017


andreadb added a comment.

In https://reviews.llvm.org/D30226#685947, @twoh wrote:

> Yes I observed the case from refresh_potential function in spec2006 429.mcf. The original C code snippet is below:
>
>    81     while( node != root )
>    82     {
>    83         while( node )
>    84         {
>    85             if( node->orientation == UP )
>    86                 node->potential = node->basic_arc->cost + node->pred->potential;
>    87             else /* == DOWN */
>    88             {
>    89                 node->potential = node->pred->potential - node->basic_arc->cost;
>    90                 checksum++;
>    91             }
>   ...
>
>
> Before Control Flow Optimizer pass (which runs BranchFolder pass), instructions for line 83 are located in two places, one in the loop preheader and the other in the loop body:
>
>   BB#4: derived from LLVM BB %while.cond3.preheader
>     TEST64rr %RDX, %RDX, %EFLAGS<imp-def>; dbg:mcfutil.c:83:9
>     JE_1 <BB#5>, %EFLAGS<imp-use>; dbg:mcfutil.c:83:9
>     JMP_1 <BB#6>; dbg:mcfutil.c:83:9
>  
>   ...
>  
>   BB#6: derived from LLVM BB %while.body4
>   ...
>     TEST64rr %RDX, %RDX, %EFLAGS<imp-def>; dbg:mcfutil.c:83:9
>     JE_1 <BB#5>, %EFLAGS<imp-use>; dbg:mcfutil.c:83:9
>     JMP_1 <BB#6>; dbg:mcfutil.c:83:9
>
>
> And these two blocks are tail merged by BranchFolder pass, but without this patch, debug locations are gone in the common tail.


Thanks for the example!
I guess, part of the reason why we end up in that situation is because the loop is rotated, so the original loop check now exists in two places (and the debugloc for those instructions is the same).

> I confirmed that AddDiscriminator pass has been executed with '-Xclang -fdebug-info-for-profiling'. (By the way @andreadb, do we need to explicitly add the flag to have discriminators? As far as I remember I could have discriminators for expressions in the same source line even without the flag. Thanks!)

You remember it right. I think that there is an hidden option to disable discriminators (but just for debugging purposes).


https://reviews.llvm.org/D30226





More information about the llvm-commits mailing list