[PATCH] D112427: [ARM] Implement setjmp BTI placement for PACBTI-M
David Spickett via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 10 09:10:52 PST 2022
DavidSpickett added inline comments.
================
Comment at: llvm/lib/Target/ARM/ARMInstrThumb2.td:5745
+ IIC_Br, [(ARMt2CallBTI tglobaladdr:$func)]>,
+ Requires<[IsThumb2]>, Sched<[WriteBrL]>;
----------------
chill wrote:
> DavidSpickett wrote:
> > Should this require `IsMClass` instead/also? Though I wasn't able to get anything weird to happen when using an A profile triple so maybe I'm missing a check elsewhere that means you'd never get to this point with A profile Arm.
> >
> > For example this A profile triple:
> > ```
> > $ ./bin/clang --target=thumbv8-arm-none-eabi /tmp/test.c -o /tmp/test.o -o - -S -mbranch-protection=bti -mthumb
> > ```
> >
> > Doesn't put anything after a call to `setjmp`, nop or otherwise, but I can't place where that decision is made.
> The decision is made in ARMMachineFunctionInfo
>
> https://github.com/llvm/llvm-project/blob/a02af37560ff5aa22dcef5735ef25eaf58eaaf64/llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp#L18
Never mind, I figured it out as per usual just after leaving the comment.
```
static bool GetBranchTargetEnforcement(MachineFunction &MF) {
const auto &Subtarget = MF.getSubtarget<ARMSubtarget>();
if (!Subtarget.isMClass() || !Subtarget.hasV7Ops())
return false;
```
This returns false for the A profile which means that GuardWithBTI is false so we don't add a BTI. Maybe one could craft some IR example that got around that but doesn't seem a likely issue.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112427/new/
https://reviews.llvm.org/D112427
More information about the llvm-commits
mailing list