[PATCH] D104060: Machine IR Profile

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 16 17:32:09 PDT 2021


MaskRay added a comment.

I think people's main question is what distinguishing features make MachineFunction instrumentation appealing.

> MIP Edge Profile, Optimization

The two are very inconvenient at the MachineFunction/MachineBasicBlock level...

I don't know how you can make edge profiling work for BB transitions...

I changed clang -fprofile-arcs to use critical edge splitting insert of PHI nodes and noticed some code generation improvement.
I know this is difficult/infeasible if you cannot split machine basic blocks...

For the profile format, there is indeed a bit redundancy in -fprofile-generate/-fprofile-instr-generate.
Some fields are reserved even if value profiling is not used. I do not have a good idea how we can save the space for coverage usage.
Some fields are 64-bit for generality. As I mentioned, a 32-bit CFG signature makes it less robust when the number of functions exceed roughly 2**16.
The 32-bit Function PC Offset is probably sufficient for most usage but will not work with medium/large code model programs.

I have been slowly trying to making -fprofile-generate/-fprofile-instr-generate object files/linkaged images smaller (e.g. D103372 <https://reviews.llvm.org/D103372>).
(I can test on Linux and Windows, so I'll try making both work. I don't have Mach-O but I am happy to report whatever issues I have found, though.)
I do plan to try PC-relative relocations (I made such improvement for XRay: D78082 <https://reviews.llvm.org/D78082>/D78590 <https://reviews.llvm.org/D78590>/D87977 <https://reviews.llvm.org/D87977>; the only portability issue is that we will require the integrated assembler for mips64)
and probably make the symbol in `__llvm_prf_data` local alias to avoid an `R_*_RELATIVE` dynamic relocation.
(I need to study more about llvm-profdata.)


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