[PATCH] D110422: [AIX] Enable PGO without LTO

Jinsong Ji via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 27 13:25:13 PDT 2021


jsji added a comment.

OK, I may not describe the example clearly.

Let me use example code with offsets and llvm internal calculations as the example, so that you might be clearer.

Let us say we have 2 objects , which both have weak function foo (and some non-weak functions).

  [2054]  m   0x110000ec0     .data     1  unamex                    __llvm_prf_cnts
  [2056]  m   0x110000ef8     .data     1    weak                    __profc__foo
  [1389]  m   0x110001540     .data     1  unamex                    __llvm_prf_cnts
  [1391]  m   0x1100015a8     .data     1    weak                    __profc__foo                <====== chosen by binder
  
  [2290]  m   0x110001ca8     .data     1  unamex                    __llvm_prf_data
  [2292]  m   0x110001ce0     .data     1    weak                    __profd__foo
  [1633]  m   0x110003678     .data     1  unamex                    __llvm_prf_data
  [1635]  m   0x1100036b0     .data     1    weak                    __profd__foo                <=======  chosen by binder

In binding, binder chose 0x1100015a8 for `__profc__foo`, and 0x1100036b0 for `__profd__foo`. 
(Not the 1st in the csect, but 1st seen by binder)

At the beginning `CountersDelta` is 0xfffffffffffff218. ( 0x110000ec0 [2054]  - 0x110001ca8 [2290] ) .

The first record is for non-weak function, so we are OK.

Then we move forward to read foo counters, 
`CountersDelta` is then updated to 0xfffffffffffff1e0 ( 0xfffffffffffff218 - sizeof(Data))
`CounterPtr` is now 0x1100015a8 - 0x1100036b0 = 0xffffffffffffdef8

CountersOffset is now 0x1ffffffffffffda3  ( CounterPtr - CountersDelta / sizeof(unit64_6))

CountersOffset > MaxNumCounters !

If we have more weak symbols, the symbols chosen by binder may be  interleaving in the csects,
we won't be able to calculate the CountersOffset correctly for all of them.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110422/new/

https://reviews.llvm.org/D110422



More information about the cfe-commits mailing list