[PATCH] D157688: [LowerTypeTests,ARM] Support Armv8-M BTI in jump tables.
Simon Tatham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 11 01:49:33 PDT 2023
simon_tatham created this revision.
simon_tatham added reviewers: MaskRay, danielkiss, ostannard, eugenis, tamas.petz, chill.
Herald added subscribers: hoy, ormris, hiraditya, kristof.beyls.
Herald added a project: All.
simon_tatham requested review of this revision.
Herald added subscribers: llvm-commits, wangpc.
Herald added a project: LLVM.
This adds support for the branch target enforcement system available
in 32-bit Armv8-M, following the pattern of the implementation that
already exists for the analogous AArch64 feature. If we're generating
a Thumb jump table, and branch target enforcement is enabled in the
module being processed, then we must put a BTI instruction at the
start of each jump table entry, to make it a valid target for an
indirect branch.
Also, we clear the branch-target-enforcement flag on the naked
function that contains the jump table asm statement, to ensure a spare
BTI doesn't accidentally appear at the start of that. (Again, this is
how AArch64 already does it.) This is done unconditionally, on the
theory that clearing those flags should be harmless in any existing
situation.
To avoid too much tedious code duplication, I've factored out
AArch64's check for branch target enforcement into a helper method of
LowerTypeTestsModule, so that it can be called more conveniently from
lots of places. While I was doing that, I also made it cache its
result, so it no longer calls M.getModuleFlag with the same string key
for every single jump table entry it generates.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157688
Files:
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/test/Transforms/LowerTypeTests/function-arm-thumb.ll
llvm/test/Transforms/LowerTypeTests/function-thumb-bti.ll
llvm/test/Transforms/LowerTypeTests/function.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157688.549289.patch
Type: text/x-patch
Size: 7819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230811/461269f8/attachment.bin>
More information about the llvm-commits
mailing list