This is an archive of the discontinued LLVM Phabricator instance.

[x86/SLH] Significantly optimize the interprocedural hardening strategy.
Changes PlannedPublic

Authored by chandlerc on Jul 25 2018, 5:02 AM.

Details

Summary

Previously, SLH would pedantically thread the predicate state in and out
of the stack pointer around every single call. This is unnecessary, and
there are vague indications it is fairly expensive.

Instead, observe a few things:

  1. We can be lazy about restoring the predicate state from the stack pointer until we need it to do some hardening.
  2. Once we have put the predicate state for a basic block into the stack pointer, that predicate state never changes due to code *in* that basic block. All subsequent updates within the basic block's execution occur inside of called functions and are communicated back to the block *in the stack pointer*. So once we first merge our predicate state into the stack pointer in a basic block, the most current state remains in the stack pointer for the rest of the block. We can completely skip subsequent merges into the stack pointer.
  3. If we already have the predicate state in the stack pointer when we see a return, that may be sufficient to harden the return. This is still being checked, so is currently disabled by a flag.

I'm hopeful this will somewhat help with the instruction density
overhead of SLH, and significantly help benchmarks and applications
where there are tight long chains of calls. I haven't yet gotten
performance data with this optimization in place, but once I do I will
update all of the documentation.

Diff Detail

Event Timeline

chandlerc created this revision.Jul 25 2018, 5:02 AM

Before anyone gets too excited about the performance improvements here, I should mention that I am working on implementing another component of the high level SLH design that I'm worried will completely defeat all of these improvements. Maybe even hold off reviewing, as this whole thing may not be relevant. =/ Sorry for the noise.

chandlerc planned changes to this revision.Jul 25 2018, 5:14 AM