[clang] [IRPGO][ValueProfile] Instrument virtual table address that could be used to do virtual table address comparision for indirect-call-promotion. (PR #66825)

Hongtao Yu via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 12 09:21:10 PDT 2023


htyu wrote:

> @htyu Pretty much a drive-by question if it's convenient for you to share more, how ranges are selected out of sampled values? For example, are ranges the same for all workloads or dynamically generated based on the distribution of size from the per-workload profile data?

We group sampled values by ranges pretty much based on the current `folly::memcpy` implementation:

  ```
  0 
  1 
  [2,3] 
  [4,7] 
  [8,16] 
  [17,32] 
  [33,64] 
  [65,128] 
  [129,inf] 
  ```

Values in a range share the same memcpy code, i.e, a pair of forward and backward copies. 

The range layout is fixed and hardcoded in LLVM. The compiler can choose to prioritize a specific range based on the value profile it sees. The profile is just like a LBR profile which is collected per service. 

So at compile time we may have such transformation:

    memcpy(src, dst, size)

=> 

```
   if (33 <= size <= 64)
      vmovups  (%rsi), %ymm0
      vmovups  -32(%rsi,%rdx), %ymm1
      vmovups  %ymm0, (%rdi)
      vmovups  %ymm1, -32(%rdi,%rdx)
   else
     call memcpy(src, dst, size)
```




https://github.com/llvm/llvm-project/pull/66825


More information about the cfe-commits mailing list