[X86] Fix for ballooning compile times due to Load Value Injection (LVI) mitigations
authorScott Constable <scott.d.constable@intel.com>
Fri, 31 Jul 2020 00:21:48 +0000 (17:21 -0700)
committerCraig Topper <craig.topper@intel.com>
Fri, 31 Jul 2020 00:22:33 +0000 (17:22 -0700)
commitec1445c5afda7f145a414f11c9103c87a4c1823f
tree82532851db0b6acbc2422e3e41618c31bb5205ec
parent3ad09fd03c51823aeb0bcbd7898aada33e9228d6
[X86] Fix for ballooning compile times due to Load Value Injection (LVI) mitigations

Fix for the issue raised in https://github.com/rust-lang/rust/issues/74632.

The current heuristic for inserting LFENCEs uses a quadratic-time algorithm. This can apparently cause substantial compilation slowdowns for building Rust projects, where functions > 5000 LoC are apparently common.

The updated heuristic in this patch implements a linear-time algorithm. On a set of benchmarks, the slowdown factor for the generated code was comparable (2.55x geo mean for the quadratic-time heuristic, vs. 2.58x for the linear-time heuristic). Both heuristics offer the same security properties, namely, mitigating LVI.

This patch also includes some formatting fixes.

Differential Revision: https://reviews.llvm.org/D84471
llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp