[x86/SLH] Add a real Clang flag and LLVM IR attribute for Speculative
commit8f620bdbb9cc7a55e7c3a980502a6e5a89792f46
authorChandler Carruth <chandlerc@gmail.com>
Tue, 4 Sep 2018 12:38:00 +0000 (4 12:38 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 4 Sep 2018 12:38:00 +0000 (4 12:38 +0000)
tree0554d161968823ca1fc206896322f4d0ad5ee80d
parenta5b0e8f5675fa24af08bfd9745571e5d04de60b5
[x86/SLH] Add a real Clang flag and LLVM IR attribute for Speculative
Load Hardening.

Wires up the existing pass to work with a proper IR attribute rather
than just a hidden/internal flag. The internal flag continues to work
for now, but I'll likely remove it soon.

Most of the churn here is adding the IR attribute. I talked about this
Kristof Beyls and he seemed at least initially OK with this direction.
The idea of using a full attribute here is that we *do* expect at least
some forms of this for other architectures. There isn't anything
*inherently* x86-specific about this technique, just that we only have
an implementation for x86 at the moment.

While we could potentially expose this as a Clang-level attribute as
well, that seems like a good question to defer for the moment as it
isn't 100% clear whether that or some other programmer interface (or
both?) would be best. We'll defer the programmer interface side of this
for now, but at least get to the point where the feature can be enabled
without relying on implementation details.

This also allows us to do something that was really hard before: we can
enable *just* the indirect call retpolines when using SLH. For x86, we
don't have any other way to mitigate indirect calls. Other architectures
may take a different approach of course, and none of this is surfaced to
user-level flags.

Differential Revision: https://reviews.llvm.org/D51157

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341363 91177308-0d34-0410-b5e6-96231b3b80d8
19 files changed:
docs/LangRef.rst
include/llvm/Bitcode/LLVMBitCodes.h
include/llvm/IR/Attributes.td
lib/AsmParser/LLLexer.cpp
lib/AsmParser/LLParser.cpp
lib/AsmParser/LLToken.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/IR/Attributes.cpp
lib/IR/Verifier.cpp
lib/Target/X86/X86SpeculativeLoadHardening.cpp
lib/Target/X86/X86TargetMachine.cpp
lib/Transforms/IPO/ForceFunctionAttrs.cpp
lib/Transforms/Utils/CodeExtractor.cpp
test/CodeGen/X86/O0-pipeline.ll
test/CodeGen/X86/O3-pipeline.ll
test/CodeGen/X86/speculative-load-hardening-gather.ll
test/CodeGen/X86/speculative-load-hardening.ll
test/Transforms/Inline/attributes.ll