[PATCH] D104060: Machine IR Profile

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 24 13:19:12 PDT 2021


MaskRay added a comment.

> Unfortunately this is not sufficient because we need to find the references once they are extracted out because the address ranges (either in the original binary and the extracted binary) are not valid or can be altered.

I think extraction works but maybe your extraction operation is different?

The `__llvm_prf_{data,cnts}` sections with D104556 <https://reviews.llvm.org/D104556> work this way. In the notation below, the address differences are in-memory.

  raw profile header:
    CountersDelta = &D0 - &C0
  
  D0:
    CounterPtr = (in-memory address difference) &D0 - &C0
  D1:
    CounterPtr = (in-memory address difference) &D1 - &C1
  
  C0: ...
  C1: ...

One can subtract CountersDelta from CounterPtr to get the on-disk D/C offset.

D104556 <https://reviews.llvm.org/D104556> doesn't touch the `FunctionPointer` (absolute address) field in D.

> Use the ELF::SHF_GNU_RETAIN flag for the __llvm_mipmap section so that it doesn't get stripped by --gc-sections. The ELF::SHF_NOTE flag is not necessary.

The problem is that all `__llvm_mipmap` sections will be retained, even if the referenced text sections are discarded.
According to https://reviews.llvm.org/D96757#2567631 there could be a lot of waste.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104060



More information about the llvm-commits mailing list