[PATCH] D144733: [ARM] Add Thumb Attributes for thumb thunks created in SLSHarding
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 24 07:06:19 PST 2023
dmgreen created this revision.
dmgreen added reviewers: kristof.beyls, DavidSpickett, ostannard, chill.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dmgreen requested review of this revision.
Herald added a project: LLVM.
Without this the function will be use an Arm subtarget, meaning the instructions in it will be invalid for the current subtarget.
https://reviews.llvm.org/D144733
Files:
llvm/include/llvm/CodeGen/IndirectThunks.h
llvm/lib/Target/ARM/ARMSLSHardening.cpp
Index: llvm/lib/Target/ARM/ARMSLSHardening.cpp
===================================================================
--- llvm/lib/Target/ARM/ARMSLSHardening.cpp
+++ llvm/lib/Target/ARM/ARMSLSHardening.cpp
@@ -202,7 +202,8 @@
const ARMSubtarget *ST = &MF.getSubtarget<ARMSubtarget>();
for (auto T : SLSBLRThunks)
if (ST->isThumb() == T.isThumb)
- createThunkFunction(MMI, T.Name, ComdatThunks);
+ createThunkFunction(MMI, T.Name, ComdatThunks,
+ T.isThumb ? "+thumb-mode" : "");
return ST->isThumb() ? ThumbThunk : ArmThunk;
}
Index: llvm/include/llvm/CodeGen/IndirectThunks.h
===================================================================
--- llvm/include/llvm/CodeGen/IndirectThunks.h
+++ llvm/include/llvm/CodeGen/IndirectThunks.h
@@ -33,7 +33,7 @@
InsertedThunksTy InsertedThunks;
void doInitialization(Module &M) {}
void createThunkFunction(MachineModuleInfo &MMI, StringRef Name,
- bool Comdat = true);
+ bool Comdat = true, StringRef TargetAttrs = "");
public:
void init(Module &M) {
@@ -46,7 +46,8 @@
template <typename Derived, typename InsertedThunksTy>
void ThunkInserter<Derived, InsertedThunksTy>::createThunkFunction(
- MachineModuleInfo &MMI, StringRef Name, bool Comdat) {
+ MachineModuleInfo &MMI, StringRef Name, bool Comdat,
+ StringRef TargetAttrs) {
assert(Name.startswith(getDerived().getThunkPrefix()) &&
"Created a thunk with an unexpected prefix!");
@@ -67,6 +68,8 @@
AttrBuilder B(Ctx);
B.addAttribute(llvm::Attribute::NoUnwind);
B.addAttribute(llvm::Attribute::Naked);
+ if (TargetAttrs != "")
+ B.addAttribute("target-features", TargetAttrs);
F->addFnAttrs(B);
// Populate our function a bit so that we can verify.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144733.500192.patch
Type: text/x-patch
Size: 1813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230224/64301f7c/attachment.bin>
More information about the llvm-commits
mailing list