-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reland "[TypeProf][InstrPGO] Introduce raw and instr profile format change for type profiling." #82711
Conversation
change, to get smaller PRs.
Co-authored-by: modiking <modiking213@gmail.com>
…er fields in raw profile header
profile version is outdated. - update llvm/test/tools/llvm-profdata/Inputs/compressed.profraw along with raw profile version bump - The test requires '!zlib', so I generate raw profile with DLLVM_ENABLE_ZLIB=1 and run the test with DLLVM_ENABLE_ZLIB=0.
✅ With the latest revision this PR passed the C/C++ code formatter. |
This is a link (https://lab.llvm.org/buildbot/#/builders/127/builds/62532/steps/8/logs/stdio) for previously broken builds. |
const char *__llvm_profile_begin_names(void) { return &NamesStart + 1; } | ||
const char *__llvm_profile_end_names(void) { return &NamesEnd; } | ||
|
||
const char *__llvm_profile_begin_vtabnames(void) { return NULL; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://gcc.godbolt.org/z/faMzTbGh3 as a compile test.
@w2yehia I wonder if you could help take a look at the changes to compiler-rt/lib/profile/InstrProfilingPlatformAIX.c? I expect them to be no-op in terms of new features, but would like a second pair of eyes. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AIX changes lgtm.
…plement the linker magic. also remove one unused variable
Update: I got the Windows machine. Windows linker magic [1] works out without compile errors or bad side effects, but the current type profiling won't work under MSVC ABI. Thereby helper functions in To elaborate on why current type profiling implementation doesn't work under MSVC ABI
As the godbolt example shows, the MSVC mangled name is still in the IR (just not vtable's variable name). I added some comments. [1] diff in https://gist.github.com/minglotus-6/9df208e14f7c20b352cdb7f89d38c228 |
Given this is a reland to make the patch work on non-ELF platforms, I'll go ahead to commit this. |
Several profdata tests pass the byte 012 to printf. This causes these tests to fail when using GnuWin32's version of printf because printf will detect that 012 is the LF character and will prepend the byte 015 (CR) in front of LF. This change is required after #82711 which bumped the version number.
This is a follow-up to the profile format change in #82711
Hi @minglotus-6 , can you please also update this place: llvm-project/llvm/include/llvm/ProfileData/InstrProf.h Lines 1183 to 1198 in 82c6eee
And may I ask whether you plan to back port this to branch 18? (I'm asking because we have some dependency on this version and would like to know in advance). Thanks! |
- The raw profile format change is in #82711
Thanks for the catch! Updated in f87bde2
Before seeing your comment, I don't have plans to back port the version update to LLVM version 18. Could you elaborate on how back porting a version bump to LLVM branch 18 helps? I have seen back-ports for bug fixes but haven't done it myself. I'm glad to back port if it helps. |
Thanks! By the way, https://llvm.org/docs/InstrProfileFormat.html is a really informative page. Thanks for your contributions!
Sorry for not making it clear -- in fact, not backporting it can better help our use cases. :)) or :(( In short, we are instrumenting some OS kernels, like what this patch does. In kernel space, it's impossible to dump the profiles using any "runtime". So instead, some kernel code itself has to do this job. As a result, this piece of kernel code has to keep synchronized with LLVM code, e.g. in terms of profile format. That's why a stable format is certainly more desirable for us. You may notice in the linked patch: they were using raw profile version 5 three years ago and now we are 10 already. (In user space, this should not be a problem, because whatever produces or consumes the profile usually comes from the same version of LLVM.) That being said, please make the decision at your own discretion, or based on broader community feedback. :)) |
Ack, thanks for sharing! |
In 16e74fd (for #82711) a duplicate definition of `IntPtrT` was added to `InstrProfiling.h`, leading to warnings: compiler-rt/lib/profile/InstrProfiling.h:52:15: warning: redefinition of typedef 'IntPtrT' is a C11 feature [-Wtypedef-redefinition] 52 | typedef void *IntPtrT; | ^ compiler-rt/lib/profile/InstrProfiling.h:34:15: note: previous definition is here 34 | typedef void *IntPtrT; | ^ Fix the warnings by removing the duplicate typedef.
In 16e74fd (for llvm#82711) a duplicate definition of `IntPtrT` was added to `InstrProfiling.h`, leading to warnings: compiler-rt/lib/profile/InstrProfiling.h:52:15: warning: redefinition of typedef 'IntPtrT' is a C11 feature [-Wtypedef-redefinition] 52 | typedef void *IntPtrT; | ^ compiler-rt/lib/profile/InstrProfiling.h:34:15: note: previous definition is here 34 | typedef void *IntPtrT; | ^ Fix the warnings by removing the duplicate typedef. (cherry picked from commit 2c376fe)
In 16e74fd (for llvm#82711) a duplicate definition of `IntPtrT` was added to `InstrProfiling.h`, leading to warnings: compiler-rt/lib/profile/InstrProfiling.h:52:15: warning: redefinition of typedef 'IntPtrT' is a C11 feature [-Wtypedef-redefinition] 52 | typedef void *IntPtrT; | ^ compiler-rt/lib/profile/InstrProfiling.h:34:15: note: previous definition is here 34 | typedef void *IntPtrT; | ^ Fix the warnings by removing the duplicate typedef. (cherry picked from commit 2c376fe)
In 16e74fd (for llvm#82711) a duplicate definition of `IntPtrT` was added to `InstrProfiling.h`, leading to warnings: compiler-rt/lib/profile/InstrProfiling.h:52:15: warning: redefinition of typedef 'IntPtrT' is a C11 feature [-Wtypedef-redefinition] 52 | typedef void *IntPtrT; | ^ compiler-rt/lib/profile/InstrProfiling.h:34:15: note: previous definition is here 34 | typedef void *IntPtrT; | ^ Fix the warnings by removing the duplicate typedef.
Do you know by any chance how raw-{32, 64}-bits-{le, be}.test were generated? |
I don't know how they were generated initially. When I updated these tests, I manually added the bytes in Given a binary raw profile, hexdump should print the bytes (example). But it is still painful to map output bytes to the (likely multi-byte) fields in a (multi-section) raw profile.
Is there a pointer showing the failed test? And which section (profile header, per function profile data, etc) is failing the raw profile reader? I remember I got stumbled on updating |
The offset in to name section is wrong. |
New change on top of reviewed patch are in commits after this one. Previous commits are restored from the remote branch with timestamps.
Fix build breakage for non-ELF platforms, by defining the missing functions {
__llvm_profile_begin_vtables
,__llvm_profile_end_vtables
,__llvm_profile_begin_vtabnames
,__llvm_profile_end_vtabnames
} everywhere.InstrProfilingPlatformWindows.c
returnsNULL
to make it more explicit that type prof isn't supported; see comments for the reason.Rename
__llvm_prf_vtabnames
->__llvm_prf_vns
for shorter section name, and make returned pointers constOriginal Description
VTableProfData
). Header also records padded bytes of each section.VTableProfData
. Both sections are padded so the size is a multiple of 8.llvm-profdata
to show the list of vtables profiled for an instrumented site.The originally reviewed patch will have profile reader/write change and llvm-profdata change.
rfc in https://discourse.llvm.org/t/rfc-dynamic-type-profiling-and-optimizations-in-llvm/74600