XRay: Add entry and exit sleds

Authored by dberris on Jul 13 2016, 9:06 PM.


XRay: Add entry and exit sleds

In this patch we implement the following parts of XRay:

  • Supporting a function attribute named 'function-instrument' which currently only supports 'xray-always'. We should be able to use this attribute for other instrumentation approaches.
  • Supporting a function attribute named 'xray-instruction-threshold' used to determine whether a function is instrumented with a minimum number of instructions (IR instruction counts).
  • X86-specific nop sleds as described in the white paper.
  • A machine function pass that adds the different instrumentation marker instructions at a very late stage.
  • A way of identifying which return opcode is considered "normal" for each architecture.

There are some caveats here:

  1. We don't handle PATCHABLE_RET in platforms other than x86_64 yet -- this means if IR used PATCHABLE_RET directly instead of a normal ret, instruction lowering for that platform might do the wrong thing. We think this should be handled at instruction selection time to by default be unpacked for platforms where XRay is not availble yet.
  1. The generated section for X86 is different from what is described from the white paper for the sole reason that LLVM allows us to do this neatly. We're taking the opportunity to deviate from the white paper from this perspective to allow us to get richer information from the runtime library.

Reviewers: sanjoy, eugenis, kcc, pcc, echristo, rnk

Subscribers: niravd, majnemer, atrick, rnk, emaste, bmakam, mcrosier, mehdi_amini, llvm-commits

Differential Revision: http://reviews.llvm.org/D19904

llvm-svn: 275367


dberrisJul 13 2016, 9:06 PM
Differential Revision
D19904: XRay: Add entry and exit sleds
rGed4d5ea82af5: [SCCP] Pass a Value * instead of templating this function. NFC.