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

Taewook Oh via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 10:00:06 PST 2017


twoh added a comment.

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.

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!)


https://reviews.llvm.org/D30226





More information about the llvm-commits mailing list