- Add correct pc, sp and bp for FreeBSD.
- Since there's no personality.h header on FreeBSD, move SANITIZER_PPC64V2 case below FREEBSD case.
- __ppc_get_timebase_freq() is glibc-specific. Add a shim for FreeBSD that does the same.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Note that __ppc_get_timebase is pretty much copied from glibc (writing it here to make sure that there are no licensing issues).
That said, I don't think there's any other way to read TBR.
I followed lint suggestions for SANITIZER_FREEBSD.
As for SANITIZER_PPC64V2 and below, lint seems to be mistaken.
Bring the diff to the current state of sanitizer_linux.cpp and adjust indents to the convention used in the file.
Also drop 32-bit path from xray_powerpc64.inc since the file is for 64-bits.
Not that there's anything wrong with this implementation (in 64-bit mode), but there is also __builtin_ppc_get_timebase()/__builtin_readcyclecounter().
While it probably wouldn't hurt to use compiler builtins, isn't it better to use system-specific functions? They are probably best tailored for specific systems.
Using builtins IMO would be fine as a fallback (for platforms other than Linux with glibc or FreeBSD).
I meant this for __ppc_get_timebase_freq, which uses sysctlbyname. __ppc_get_timebase could actually use a builtin.
Make __ppc_get_timebase use __builtin_ppc_get_timebase since it's an assembly function anyway.
Is there anything I'm doing wrong here?
If not, would it be possible to get this merged? It would be awesome to have this patch merged to 14.0, if possible, as well.
I can't vouch for any of the PowerPC specific stuff, but I would like to get it into FreeBSD if at all possible. :)
compiler-rt/lib/xray/xray_powerpc64.inc | ||
---|---|---|
23 | Looking at https://man7.org/linux/man-pages/man3/__ppc_get_timebase.3.html, this function should return a uint64_t, could you please double check? |
compiler-rt/lib/xray/xray_powerpc64.inc | ||
---|---|---|
23 | Fixed. |
It's not actually a problem but tb_freq should be initialized as integer. Otherwise looks good to me!
I validated the code snippet on FreeBSD13/powerpc64 and it's consistent with linux/glibc output on same machine.
compiler-rt/lib/xray/xray_powerpc64.inc | ||
---|---|---|
25 | uint64_t tb_freq = 0; |
Removing kcc from reviewers since he seems inactive for the part half a year.
@adalava
As this is now accepted, can you commit it and if possible (since this is a build fix) merge for 14.0.1?
I am not familiar with the FreeBSD-specific stuff, but there is nothing I see any issues with here.
LGTM.
Committed in https://reviews.llvm.org/rG315d79213025
I forgot to add the review in the commit message.
Looking at https://man7.org/linux/man-pages/man3/__ppc_get_timebase.3.html, this function should return a uint64_t, could you please double check?