[cfi-verify] Support AArch64.
authorJoel Galenson <jgalenson@google.com>
Fri, 13 Jul 2018 15:19:33 +0000 (15:19 +0000)
committerJoel Galenson <jgalenson@google.com>
Fri, 13 Jul 2018 15:19:33 +0000 (15:19 +0000)
commit06e7e5798fa4efdcbc9598427fb8ccb6942d6cb0
tree28217e428500e88e450e60f95ae2051a756e9f83
parent02695fa8a7f2337bc4524dc877f618e0e2045e16
[cfi-verify] Support AArch64.

This patch adds support for AArch64 to cfi-verify.

This required three changes to cfi-verify.  First, it generalizes checking if an instruction is a trap by adding a new isTrap flag to TableGen (and defining it for x86 and AArch64).  Second, the code that ensures that the operand register is not clobbered between the CFI check and the indirect call needs to allow a single dereference (in x86 this happens as part of the jump instruction).  Third, we needed to ensure that return instructions are not counted as indirect branches.  Technically, returns are indirect branches and can be covered by CFI, but LLVM's forward-edge CFI does not protect them, and x86 does not consider them, so we keep that behavior.

In addition, we had to improve AArch64's code to evaluate the branch target of a MCInst to handle calls where the destination is not the first operand (which it often is not).

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

llvm-svn: 337007
14 files changed:
llvm/include/llvm/MC/MCInstrDesc.h
llvm/include/llvm/Target/Target.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
llvm/lib/Target/X86/X86InstrSystem.td
llvm/test/tools/llvm-cfi-verify/AArch64/protected-lineinfo.s [new file with mode: 0644]
llvm/test/tools/llvm-cfi-verify/AArch64/unprotected-lineinfo.s [new file with mode: 0644]
llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
llvm/unittests/tools/llvm-cfi-verify/FileAnalysis.cpp
llvm/utils/TableGen/CodeGenInstruction.cpp
llvm/utils/TableGen/CodeGenInstruction.h
llvm/utils/TableGen/InstrDocsEmitter.cpp
llvm/utils/TableGen/InstrInfoEmitter.cpp