This is an archive of the discontinued LLVM Phabricator instance.

[XRay][compiler-rt] Support sled versioning for custom event sleds
ClosedPublic

Authored by dberris on Aug 16 2017, 9:18 PM.

Details

Summary

This change introduces versions to the instrumentation map entries we
emit for XRay instrumentaiton points. The status quo for the version is
currently set to 0 (as emitted by the LLVM back-end), and versions will
count up to 255 (unsigned char).

This change is in preparation for supporting the newer version of the
custom event sleds that will be emitted by the LLVM compiler.

While we're here, we take the opportunity to stash more registers and
align the stack properly in the __xray_CustomEvent trampoline.

Event Timeline

dberris created this revision.Aug 16 2017, 9:18 PM
kpw added inline comments.Aug 17 2017, 5:22 PM
lib/xray/xray_x86_64.cc
77

If 0x09eb is Jmp9Seq and 0x14eb is Jmp20Seq, I would expect Jmp16Seq to be 0x10eb.

0x0feb would match this pattern as Jmp15Seq. I think the confusion might come from address being relative to the *next* instruction.

test/xray/TestCases/Linux/custom-event-logging.cc
5

Is the position independent code stuff related to the sled change or just along for the ride?

dberris updated this revision to Diff 111615.Aug 17 2017, 10:03 PM
dberris marked an inline comment as done.

Address comments.

dberris added inline comments.Aug 17 2017, 10:24 PM
test/xray/TestCases/Linux/custom-event-logging.cc
5

Ah, right -- it's along for the ride, because the dependent change has to work with PIC and PIE changes.

dberris updated this revision to Diff 111889.Aug 20 2017, 8:26 AM

Update comments to be more accurate.

dberris updated this revision to Diff 112114.Aug 21 2017, 10:47 PM
  • fixup: address comments, stash more registers in __xray_CustomEvent, and add a test with a function that requires specific alignment
pcc added inline comments.Aug 22 2017, 11:10 AM
lib/xray/xray_trampoline_x86_64.S
205

Without backend support I'd expect you to need to realign the stack here. You can see how to do that by compiling any C function with -mstackrealign.

test/xray/TestCases/Linux/custom-event-handler-alignment.cc
29

Probably want to copy lines 19 and 20 from the function foo above in order to test that the stack is properly aligned in the event handler.

dberris updated this revision to Diff 112290.Aug 22 2017, 8:17 PM
  • fixup: align the stack before calling the custom handler function
dberris marked 2 inline comments as done.Aug 22 2017, 8:18 PM
dberris added inline comments.
lib/xray/xray_trampoline_x86_64.S
205

Awesome stuff, thanks @pcc!

dberris updated this revision to Diff 112291.Aug 22 2017, 8:23 PM
dberris marked an inline comment as done.
dberris edited the summary of this revision. (Show Details)

Retitle to include changes to the stack alignment for the __xray_CustomEvent trampoline.

pcc accepted this revision.Aug 22 2017, 9:28 PM

LGTM

This revision is now accepted and ready to land.Aug 22 2017, 9:28 PM
This revision was automatically updated to reflect the committed changes.