Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jun 12, 2021 at 3:47 PM Bill Wendling <morbo@xxxxxxxxxx> wrote:
>
> On Sat, Jun 12, 2021 at 1:56 PM Bill Wendling <morbo@xxxxxxxxxx> wrote:
> > On Sat, Jun 12, 2021 at 1:25 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> > > On Sat, Jun 12, 2021 at 12:10:03PM -0700, Bill Wendling wrote:
> > > Yes it is, but is that sufficient in this case? It very much isn't for
> > > KASAN, UBSAN, and a whole host of other instrumentation crud. They all
> > > needed their own 'bugger-off' attributes.
> > >
> > Now, for the "nointr" issue. I'll see if we need an additional change for that.
> >
> The GCOV implementation disables profiling in those directories where
> instrumentation would fail. We do the same. Both clang and gcc seem to
> treat the no_instrument_function attribute similarly.
>
An example:

$ cat n.c
int g(int);

int __attribute__((__no_instrument_function__))
__attribute__((no_instrument_function))
no_instr(int a) {
  int sum = 0;
  for (int i = 0; i < a; i++)
    sum += g(i);
  return sum;
}

int instr(int a) {
  int sum = 0;
  for (int i = 0; i < a; i++)
    sum += g(i);
  return sum;
}

$ gcc -S -o - n.c -fprofile-arcs -ftest-coverage -O2
        .globl  no_instr
        .type   no_instr, @function
no_instr:
.LFB0:
 ...
        addq    $1, __gcov0.no_instr(%rip)
        pushq   %rbp
 ...
.L3:
 ...
        addq    $1, 8+__gcov0.no_instr(%rip)
 ...
        addq    $1, 16+__gcov0.no_instr(%rip)
 ...
        addq    $1, 16+__gcov0.no_instr(%rip)
 ...
        ret
        .globl  instr
        .type   instr, @function
instr:
.LFB1:
 ...
        addq    $1, __gcov0.instr(%rip)
 ...
        addq    $1, 8+__gcov0.instr(%rip)
 ...
        addq    $1, 16+__gcov0.instr(%rip)
 ...
        addq    $1, 16+__gcov0.instr(%rip)
 ...
        ret

$ clang -S -o - n.c -fprofile-generate -O2
        .globl  no_instr                        # -- Begin function no_instr
        .p2align        4, 0x90
        .type   no_instr,@function
no_instr:                               # @no_instr
 ...
        addq    $1, .L__profc_no_instr+8(%rip)
 ...
        movq    .L__profc_no_instr(%rip), %rax
 ...
        movq    %rax, .L__profc_no_instr(%rip)
 ...
        retq
        .globl  instr                           # -- Begin function instr
        .p2align        4, 0x90
        .type   instr,@function
instr:                                  # @instr
 ...
        addq    $1, .L__profc_instr+8(%rip)
 ...
        movq    .L__profc_instr(%rip), %rax
 ...
        movq    %rax, .L__profc_instr(%rip)
 ...
        retq
.Lfunc_end1:



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux