[HWASan] [GlobalISel] Add +tagged-globals backend feature for GlobalISel
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Mon, 3 Aug 2020 20:55:27 +0000 (13:55 -0700)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Mon, 3 Aug 2020 21:28:44 +0000 (14:28 -0700)
commit9a05fa10bd05525adedb6117351333699a3d4ae2
tree54b69a3a97a082226ee67de326cc4c10cd3d1ec6
parent22916481c11e1d46132752086290a668e62fc9ce
[HWASan] [GlobalISel] Add +tagged-globals backend feature for GlobalISel

GlobalISel is the default ISel for aarch64 at -O0. Prior to D78465, GlobalISel
didn't have support for dealing with address-of-global lowerings, so it fell
back to SelectionDAGISel.

HWASan Globals require special handling, as they contain the pointer tag in the
top 16-bits, and are thus outside the code model. We need to generate a `movk`
in the instruction sequence with a G3 relocation to ensure the bits are
relocated properly. This is implemented in SelectionDAGISel, this patch does
the same for GlobalISel.

GlobalISel and SelectionDAGISel differ in their lowering sequence, so there are
differences in the final instruction sequence, explained in
`tagged-globals.ll`. Both of these implementations are correct, but GlobalISel
is slightly larger code size / slightly slower (by a couple of arithmetic
instructions). I don't see this as a problem for now as GlobalISel is only on
by default at `-O0`.

Reviewed By: aemerson, arsenm

Differential Revision: https://reviews.llvm.org/D82615
compiler-rt/test/hwasan/TestCases/exported-tagged-global.c [new file with mode: 0644]
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
llvm/test/CodeGen/AArch64/tagged-globals.ll