[llvm] [llvm][ARM][AArch64] Add attributes to synthetic functions. (PR #83153)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 1 15:48:45 PST 2024
================
@@ -378,6 +380,40 @@ Function *Function::createWithDefaultAttr(FunctionType *Ty,
}
if (M->getModuleFlag("function_return_thunk_extern"))
B.addAttribute(Attribute::FnRetThunkExtern);
+
+ Triple T(M->getTargetTriple());
+
+ auto Profile = llvm::ARM::parseArchProfile(T.getArchName());
+ if ((T.isArmT32() && Profile == llvm::ARM::ProfileKind::M) || T.isAArch64()) {
+ // Check if the module attribute is present and not zero.
+ auto isModuleAttributeSet = [&](const StringRef &ModAttr) -> bool {
+ const auto *Attr =
+ mdconst::extract_or_null<ConstantInt>(M->getModuleFlag(ModAttr));
+ return Attr && Attr->getZExtValue();
+ };
+
+ auto AddAttributeIfSet = [&](const StringRef &ModAttr) {
+ if (isModuleAttributeSet(ModAttr))
+ B.addAttribute(ModAttr, "true");
+ };
+
+ StringRef SignType = "none";
+ if (isModuleAttributeSet("sign-return-address"))
+ SignType = "non-leaf";
+ if (isModuleAttributeSet("sign-return-address-all"))
+ SignType = "all";
----------------
DanielKristofKiss wrote:
#83635 is about the verification.
https://github.com/llvm/llvm-project/pull/83153
More information about the llvm-commits
mailing list