[PATCH] D49378: [x86/SLH] Completely rework how we sink post-load hardening past data invariant instructions to be both more correct and much more powerful.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 07:43:55 PDT 2018


chandlerc created this revision.
chandlerc added a reviewer: bkramer.
Herald added subscribers: hiraditya, mcrosier, sanjoy.

While testing, I continued to find issues with sinking post-load
hardening. Unfortunately, it was amazingly hard to create any useful
tests of this because we were mostly sinking across copies and other
loading instructions. The fact that we couldn't sink past normal
arithmetic was really a big oversight.

So first, I've ported roughly the same set of instructions from the data
invariant loads to also have their non-loading varieties understood to
be data invariant. I've also added a few instructions that came up so
often it again made testing complicated: inc, dec, and lea.

With this, I was able to shake out a few nasty bugs in the validity
checking. We need to restrict to hardening single-def instructions with
defined registers that match a particular form: GPRs that don't have
a NOREX constraint directly attached to their register class.

The (tiny!) test case included catches all of the issues I was seeing
(once we can sink the hardening at all) except for the NOREX issue. The
only test I have there is horrible. It is large, inexplicable, and
doesn't even produce an error unless you try to emit encodings. I can
keep looking for a way to test it, but I'm out of ideas really.

I'm asking Ben to take a quick look at this for sanity and then I'll land it.
I'll follow up with Craig to get a more thorough review, but without this we're
getting crashes everywhere.


Repository:
  rL LLVM

https://reviews.llvm.org/D49378

Files:
  llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp
  llvm/test/CodeGen/X86/speculative-load-hardening.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49378.155679.patch
Type: text/x-patch
Size: 14132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180716/dad1399c/attachment.bin>


More information about the llvm-commits mailing list