[PATCH] D35928: [XRay][X86] Use a valid instruction for the synthetic reference.

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 22:03:08 PDT 2017


dberris created this revision.

Before this change, we unconditionally write out a synthetic reference
to the XRay function index label in the text section. This makes it so
that we're writing valid instructions in the text section instead of
garbage.

With this change we're aiming to help the CPU's decoder to decode a
valid instruction instead of potentially stalling because of almost
quite literally garbage data in the text section. To do this, we're
introducing a protected virtual function in the AsmPrinter class, which
is specifically an extension point for emitting the XRay synthetic
reference.

The instruction we're using is an absolute move from a label to a
scratch register. We use %r10d because XRay already uses this register
for the function id, and since this code is never meant to execute (it
falls outside of the function after the last return) we can be positive
in using this specific scratch register.


https://reviews.llvm.org/D35928

Files:
  include/llvm/CodeGen/AsmPrinter.h
  lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  lib/Target/X86/X86AsmPrinter.cpp
  lib/Target/X86/X86AsmPrinter.h
  test/CodeGen/X86/xray-attribute-instrumentation.ll
  test/CodeGen/X86/xray-tail-call-sled.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35928.108414.patch
Type: text/x-patch
Size: 5025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170727/bb554a69/attachment.bin>


More information about the llvm-commits mailing list