[clang] [llvm] [llvm][AArch64] Do not inline a function with different signing scheme. (PR #80642)
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 09:48:23 PST 2024
================
@@ -5167,6 +5199,41 @@ void llvm::UpgradeFunctionAttributes(Function &F) {
F.removeRetAttrs(AttributeFuncs::typeIncompatible(F.getReturnType()));
for (auto &Arg : F.args())
Arg.removeAttrs(AttributeFuncs::typeIncompatible(Arg.getType()));
+
+ if (!ModuleMetadataIsMaterialized)
+ return;
+ if (F.isDeclaration())
+ return;
+ Module *M = F.getParent();
+ if (!M)
+ return;
+
+ Triple T(M->getTargetTriple());
+ // Convert module level attributes to function level attributes because
+ // after merging modules the attributes might change and would have different
+ // effect on the functions as the original module would have.
+ if (T.isThumb() || T.isARM() || T.isAArch64()) {
+ if (!F.hasFnAttribute("sign-return-address")) {
+ StringRef SignType = "none";
+ if (const auto *Sign = mdconst::extract_or_null<ConstantInt>(
+ M->getModuleFlag("sign-return-address")))
+ if (Sign->getZExtValue())
+ SignType = "non-leaf";
+
+ if (const auto *SignAll = mdconst::extract_or_null<ConstantInt>(
+ M->getModuleFlag("sign-return-address-all")))
+ if (SignAll->getZExtValue())
----------------
nickdesaulniers wrote:
This pattern appears a lot; consider using a small static helper function.
https://github.com/llvm/llvm-project/pull/80642
More information about the llvm-commits
mailing list