]> granicus.if.org Git - llvm/commit
[XRay] Create an Index of sleds per function
authorDean Michael Berris <dberris@google.com>
Thu, 4 May 2017 03:37:57 +0000 (03:37 +0000)
committerDean Michael Berris <dberris@google.com>
Thu, 4 May 2017 03:37:57 +0000 (03:37 +0000)
commitacf912e5baa5b84f7a3eb99ec594e40016bc1875
tree0e53e5189112efc7c62929b6ccdd86158dcebb4b
parentdf2206086cc06c13f1462f2b3eb9d4199bf22b70
[XRay] Create an Index of sleds per function

Summary:
This change adds a new section to the xray-instrumented binary that
stores an index into ranges of the instrumentation map, where sleds
associated with the same function can be accessed as an array. At
runtime, we can get access to this index by function ID offset allowing
for selective patching and unpatching by function ID.

Each entry in this new section (xray_fn_idx) will include two pointers
indicating the start and one past the end of the sleds associated with
the same function. These entries will be 16 bytes long on x86 and
aarch64. On arm, we align to 16 bytes anyway so the runtime has to take
that into consideration.

__{start,stop}_xray_fn_idx will be the symbols that the runtime will
look for when we implement the selective patching/unpatching by function
id APIs. Because XRay synthesizes the function id's in a monotonically
increasing manner at runtime now, implementations (and users) can use
this table to look up the sleds associated with a specific function.
This is useful in implementations that want to do things like:

  - Implement coverage mode for functions by patching everything
    pre-main, then as functions are encountered, the installed handler
    can unpatch the function that's been encountered after recording
    that it's been called.
  - Do "learning mode", so that the implementation can figure out some
    statistical information about function calls by function id for a
    time being, and then determine which functions are worth
    uninstrumenting at runtime.
  - Do "selective instrumentation" where an implementation can
    specifically instrument only certain function id's at runtime
    (either based on some external data, or through some other
    heuristics) instead of patching all the instrumented functions at
    runtime.

Reviewers: dblaikie, echristo, chandlerc, javed.absar

Subscribers: pelikan, aemerson, kpw, llvm-commits, rengolin

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302109 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
test/CodeGen/AArch64/xray-attribute-instrumentation.ll
test/CodeGen/AArch64/xray-tail-call-sled.ll
test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
test/CodeGen/X86/xray-attribute-instrumentation.ll
test/CodeGen/X86/xray-tail-call-sled.ll