[LLVMdev] fix for loop scale limiting in BFI

Xinliang David Li xinliangli at gmail.com
Fri Mar 27 16:50:38 PDT 2015


For PGO, there is a solution to it.

See small example:

#include <stdlib.h>
int g;
__attribute__((noinline)) void foo()
{
  g++;
  if (g==1000)
    exit(0);
}

int main()
{
  while (1) {
    foo();
  }

}

The profile count for the loop is generated, but Clang simply can not find
a conditional branch instruction to attach the MD_prof data.  Very simply
speaking, this can be fixed by allowing MD_prof to be attached to
unconditional branch in the infinite loop (such that
taken_weight/exit_weight represents trip count). In block frequency
propagation, the trip count for infinite loop can be read from the meta
data.

We probably need a different bug tracking the issue.

David




On Fri, Mar 27, 2015 at 1:46 PM, Chandler Carruth <chandlerc at google.com>
wrote:

>
> On Fri, Mar 27, 2015 at 1:36 PM, Xinliang David Li <xinliangli at gmail.com>
> wrote:
>
>> To be on the safe side, my patch is mapping them down to a 32bit
>>> space, but I am squishing them too much on  the lower end. So regions
>>> of the CFG that before had distinct temperatures are now showing up
>>> with frequency == 1.
>>>
>>> I need a better smoother for the mapping from the Scale64 floats down
>>> to 64bit (or 32bit) integers.
>>>
>>
>>
>> This seems to show another weakness of the block frequency propagation --
>>  it can not handle infinite loops.  We need to think about how to handle it
>> ..
>>
>
> I think we should just have a synthetic "max" and not balloon the range
> due to it. Then we can pin the max at some fixed multiple of the actual max
> when scaling it down.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150327/e487089e/attachment.html>


More information about the llvm-dev mailing list