This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][xray] Fix alignment of XRayFileHeader
ClosedPublic

Authored by luporl on Jul 11 2023, 1:23 PM.

Details

Summary

XRayFileHeader storage was obtained from std::aligned_storage
using its default alignment and not the struct's alignment
requirement. This was causing a bus error on AArch32, on armv8
machines, where vld1.64/vst1.64 instructions with 128-bit
alignment requirement were being used to copy XRayFileHeader.

There is still another issue with fdr-single-thread.cpp test on
armv7. Now it runs until completion and produces a valid log file,
but for some reason the function name appears as _end in it,
instead of the expected mangled fn name.

Diff Detail

Event Timeline

luporl created this revision.Jul 11 2023, 1:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 1:23 PM
luporl published this revision for review.Jul 11 2023, 1:29 PM
luporl added reviewers: MaskRay, DavidSpickett.
luporl added a subscriber: llvm-commits.
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 1:29 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
MaskRay accepted this revision.Jul 11 2023, 1:36 PM

Thank you for the patch!

If it's not too much work, consider migrating away from C++23 deprecated std::aligned_storage while you are modifying these lines:
https://stackoverflow.com/questions/71828288/why-is-stdaligned-storage-to-be-deprecated-in-c23-and-what-to-use-instead

This revision is now accepted and ready to land.Jul 11 2023, 1:36 PM
luporl updated this revision to Diff 539632.Jul 12 2023, 10:44 AM

Migrate away from C++23 deprecated std::aligned_storage

fmayer added a subscriber: fmayer.Jul 12 2023, 10:59 AM
fmayer added inline comments.
compiler-rt/lib/xray/xray_fdr_logging.cpp
18–19

Random driveby: why do we mix <cfoo> and <foo.h>?

luporl added inline comments.Jul 12 2023, 11:34 AM
compiler-rt/lib/xray/xray_fdr_logging.cpp
18–19

I don't know why, but to my knowledge it's better to use <cfoo> in C++, when possible, to avoid polluting the global namespace.

MaskRay added inline comments.Jul 12 2023, 11:56 AM
compiler-rt/lib/xray/xray_fdr_logging.cpp
18–19

Yes, but in practice <cfoo> and <foo.h> can be mixed: https://maskray.me/blog/2022-05-15-c-standard-library-headers-in-c++

This revision was automatically updated to reflect the committed changes.