[x86] Implement a tagged-globals backend feature.
authorMatt Morehouse <mascasa@google.com>
Mon, 18 Oct 2021 16:08:36 +0000 (09:08 -0700)
committerMatt Morehouse <mascasa@google.com>
Mon, 18 Oct 2021 20:31:10 +0000 (13:31 -0700)
commit431a5d8411952b4c9c2185303afd703123ef55cc
tree7cef84e001ce1936560980d64d3394ca9e27e4b4
parent04dc68710ad2b30a1d3b4a2ca33005af2c9460eb
[x86] Implement a tagged-globals backend feature.

The feature tells the backend to allow tags in the upper bits of global
variable addresses.  These tags will be ignored by upcoming CPUs with
the Intel LAM feature but may be used in instrumentation passes (e.g.,
HWASan).

This patch implements the feature by using @GOTPCREL relocations instead
of direct references to the locally defined global.  Thus the full
tagged address can be loaded by a single instruction:
  movq global@GOTPCREL(%rip), %rax

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D111343
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86Subtarget.cpp
llvm/lib/Target/X86/X86Subtarget.h
llvm/test/CodeGen/X86/tagged-globals-pic.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/tagged-globals-static.ll [new file with mode: 0644]