[PATCH] D104556: [InstrProfiling] Make CountersPtr in __profd_ relative
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 23 13:21:51 PDT 2021
MaskRay added a comment.
In D104556#2836900 <https://reviews.llvm.org/D104556#2836900>, @rnk wrote:
> In D104556#2831787 <https://reviews.llvm.org/D104556#2831787>, @MaskRay wrote:
>
>> Hmm, IMGREL (`IMAGE_REL_AMD64_ADDR32NB`) looks useful and is an alternative solution to PC-relative relocations in ELF / relocation subtraction in Mach-O.
>> But leveraging it seems to need more code in the runtime and will make COFF vs non-COFF different in IR, runtime, and llvm-profdata....
>
> We can go forward with what we have, but the `signextIfWin64` helper is pretty subtle. In some ways, I think adding `__ImageBase` is clearer:
>
> #ifdef _WIN32
> extern "C" char __ImageBase;
> #endif
> uintptr_t rebaseRelativePtr(void *D, void *P) {
> #ifdef _WIN32
> return (uintptr_t)&__ImageBase + (uintptr_t)P;
> #else
> return (uintptr_t)D + (uintptr_t)P;
> #endif
> }
>
> It's not quite this easy, and the instrumentation side changes have to basically copy or refactor this code:
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/MicrosoftCXXABI.cpp#L548
>
> We aren't worried about profraw format compatibility on Windows, so I think we can change this later at any time if we like.
I think you mean that `INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta, (uintptr_t)CountersBegin - (uintptr_t)DataBegin)` (in InstrProfiling.cpp, so used by both -fprofile-generate and -fprofile-instr-generate) needs to adopt the scheme in https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/MicrosoftCXXABI.cpp#L548
Yes, seems quite a bit of complexity.
Is it possible to ask MSVC to add the 64-bit `IMAGE_REL_AMD64_REL64` and `IMAGE_REL_ARM64_REL64`?
Newer compiler metadata techniques can benefit from using the same mechanism for all three major binary formats (PE-COFF/ELF/Mach-O).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104556/new/
https://reviews.llvm.org/D104556
More information about the cfe-commits
mailing list