[PATCH] D104556: [InstrProfiling] Make CountersPtr in __profd_ relative
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 23 12:36:15 PDT 2021
rnk added a comment.
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.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104556/new/
https://reviews.llvm.org/D104556
More information about the llvm-commits
mailing list