Commit Graph

17 Commits

Author SHA1 Message Date
Dean Michael Berris 71f88a955d [XRay][compiler-rt] Support sled versioning for custom event sleds
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.

Reviewers: kpw, pcc, dblaikie

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D36816

llvm-svn: 311524
2017-08-23 04:42:37 +00:00
Dean Michael Berris 29e16deb17 [XRay][compiler-rt] Runtime changes to support custom event logging
Summary:
This change implements support for the custom event logging sleds and
intrinsics at runtime. For now it only supports handling the sleds in
x86_64, with the implementations for other architectures stubbed out to
do nothing.

NOTE: Work in progress, uploaded for exposition/exploration purposes.

Depends on D27503, D30018, and D33032.

Reviewers: echristo, javed.absar, timshen

Subscribers: mehdi_amini, nemanjai, llvm-commits

Differential Revision: https://reviews.llvm.org/D30630

llvm-svn: 302857
2017-05-12 01:07:41 +00:00
Dean Michael Berris 5cc4632b5b [XRay][compiler-rt] Support patching/unpatching specific functions
Summary:
This change allows us to patch/unpatch specific functions using the
function ID. This is useful in cases where implementations might want to
do coverage-style, or more fine-grained control of which functions to
patch or un-patch at runtime.

Depends on D32693.

Reviewers: dblaikie, echristo, kpw

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32695

llvm-svn: 302112
2017-05-04 04:59:20 +00:00
Dean Michael Berris a814c94163 [XRay] [compiler-rt] Allow logging the first argument of a function call.
Summary:
Functions with the LOG_ARGS_ENTRY sled kind at their beginning will be handled
in a way to (optionally) pass their first call argument to your logging handler.

For practical and performance reasons, only the first argument is supported, and
only up to 64 bits.

Reviewers: javed.absar, dberris

Reviewed By: dberris

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D29703

llvm-svn: 297000
2017-03-06 07:25:41 +00:00
Tim Shen 7d0bffb537 [XRay] Refactor TSC related functions into a single header. NFC.
Summary:
The implementation, however, is in different arch-specific files, unless it's emulated.

Reviewers: dberris, pelikan, javed.absar

Subscribers: aemerson, llvm-commits

Differential Revision: https://reviews.llvm.org/D29796

llvm-svn: 294777
2017-02-10 20:30:43 +00:00
Diana Picus 6b88e325ea [XRay] [compiler-rt] Move machine-dependent code into machine-dependent files
Reapply r290077.

Authors: pelikan

Differential Revision: https://reviews.llvm.org/D27979

llvm-svn: 290330
2016-12-22 07:35:56 +00:00
Diana Picus c0eb996318 Revert "[XRay] [compiler-rt] Move machine-dependent code into machine-dependent files."
This reverts commit r290077, 78, 79 and 83.

llvm-svn: 290101
2016-12-19 12:43:08 +00:00
Dean Michael Berris 094173ba2c [XRay] [compiler-rt] Move machine-dependent code into machine-dependent files.
Summary: Include the necessary headers while there.

Reviewers: dberris

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D25360

llvm-svn: 290077
2016-12-19 03:21:26 +00:00
Dean Michael Berris 0d86810158 [XRay][x86_64] Define a tail exit trampoline.
Summary:
We define a new trampoline that's a hybrid between the exit and entry
trampolines with the following properties:

- Saves all of the callee-saved registers according to the x86_64
  calling conventions.
- Indicate to the log handler function being called that this is a
  function exit event.

This fixes a bug that is a result of not saving enough of the register
states, and that the log handler is clobbering registers that would be
used by the function being tail-exited into manifesting as runtime
errors.

Reviewers: rSerge, echristo, majnemer

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D26020

llvm-svn: 285787
2016-11-02 04:11:29 +00:00
Dean Michael Berris 1b09aae82a [compiler-rt][XRay] Support tail call sleds
Summary:
This change depends on D23986 which adds tail call-specific sleds. For
now we treat them first as normal exits, and in the future leave room
for implementing this as a different kind of log entry.

The reason for deferring the change is so that we can keep the naive
logging implementation more accurate without additional complexity for
reading the log. The accuracy is gained in effectively interpreting call
stacks like:

  A()
    B()
      C()

Which when tail-call merged will end up not having any exit entries for
A() nor B(), but effectively in turn can be reasoned about as:

  A()
  B()
  C()

Although we lose the fact that A() had called B() then had called C()
with the naive approach, a later iteration that adds the explicit tail
call entries would be a change in the log format and thus necessitate a
version change for the header. We can do this later to have a chance at
releasing some tools (in D21987) that are able to handle the naive log
format, then support higher version numbers of the log format too.

Reviewers: echristo, kcc, rSerge, majnemer

Subscribers: mehdi_amini, llvm-commits, dberris

Differential Revision: https://reviews.llvm.org/D23988

llvm-svn: 284178
2016-10-13 23:56:54 +00:00
Dean Michael Berris 4ef1a69b40 [compiler-rt][XRay][NFC] clang-format XRay sources
llvm-svn: 283421
2016-10-06 07:09:40 +00:00
Dean Michael Berris d1617cdc49 [XRay] ARM 32-bit no-Thumb support in compiler-rt
This is a port of XRay to ARM 32-bit, without Thumb support yet.
This is one of 3 commits to different repositories of XRay ARM port. The other 2 are:

https://reviews.llvm.org/D23931 (LLVM)
https://reviews.llvm.org/D23932 (Clang test)

Differential Revision: https://reviews.llvm.org/D23933

llvm-svn: 281971
2016-09-20 14:35:57 +00:00
Renato Golin 6f605133dd Revert "[XRay] ARM 32-bit no-Thumb support in compiler-rt"
This reverts commit r280890, as the related LLVM commit broke the thumb bots.

llvm-svn: 280969
2016-09-08 17:13:15 +00:00
Dean Michael Berris 5332645c6d [XRay] ARM 32-bit no-Thumb support in compiler-rt
This is a port of XRay to ARM 32-bit, without Thumb support yet.
This is one of 3 commits to different repositories of XRay ARM port. The
other 2 are:

1. https://reviews.llvm.org/D23931 (LLVM)
2. https://reviews.llvm.org/D23932 (Clang test)

Differential Revision: https://reviews.llvm.org/D23933

llvm-svn: 280890
2016-09-08 00:28:26 +00:00
Dean Michael Berris 938c5031ab [compiler-rt][XRay] re-submitting r276117, with fixes for build breakage due to extraneous and missing dependencies and attempts to build on unsupported OSes
Summary:
This is a fixed-up version of D21612, to address failure identified post-commit.

Original commit description:

This patch implements the initialisation and patching routines for the XRay runtime, along with the necessary trampolines for function entry/exit handling. For now we only define the basic hooks for allowing an implementation to define a handler that gets run on function entry/exit. We expose a minimal API for controlling the behaviour of the runtime (patching, cleanup, and setting the handler to invoke when instrumenting).

Fixes include:
- Gating XRay build to only Linux x86_64 and with the right dependencies in case it is the only library being built
- Including <cstddef> to fix std::size_t issue

Reviewers: kcc, rnk, echristo

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D22611

llvm-svn: 276251
2016-07-21 07:39:55 +00:00
Hans Wennborg ae4e6fe990 Revert r276117 "[XRay] Basic initialization and flag definition for XRay runtime"
and also the follow-up "[xray] Only build xray on Linux for now"

Two build errors were reported on the llvm-commits list:

	[ 88%] Building CXX object lib/xray/CMakeFiles/clang_rt.xray-x86_64.dir/xray_flags.cc.o
	/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/xray/xray_init.cc:23:10: fatal error: 'llvm/Support/ELF.h' file not found
  #include "llvm/Support/ELF.h"
					 ^

and

	In file included from /w/src/llvm.org/projects/compiler-rt/lib/xray/xray_interface.cc:16:
	/w/src/llvm.org/projects/compiler-rt/lib/xray/xray_interface_internal.h:36:8: error:
				no type named 'size_t' in namespace 'std'
		std::size_t Entries;
		~~~~~^

llvm-svn: 276186
2016-07-20 21:37:38 +00:00
Dean Michael Berris e1c81d10d7 [compiler-rt] [XRay] Basic initialization and flag definition for XRay runtime
Summary:
This patch implements the initialisation and patching routines for the XRay runtime, along with the necessary trampolines for function entry/exit handling. For now we only define the basic hooks for allowing an implementation to define a handler that gets run on function entry/exit. We expose a minimal API for controlling the behaviour of the runtime (patching, cleanup, and setting the handler to invoke when instrumenting).

Depends on D19904

Reviewers: echristo, kcc, rnk

Subscribers: rnk, mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D21612

llvm-svn: 276117
2016-07-20 14:14:50 +00:00