[llvm] [llvm][AArch64] Autoupgrade function attributes from Module attributes. (PR #80640)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 21 11:43:25 PST 2024
================
@@ -5155,7 +5155,51 @@ struct StrictFPUpgradeVisitor : public InstVisitor<StrictFPUpgradeVisitor> {
};
} // namespace
-void llvm::UpgradeFunctionAttributes(Function &F) {
+// Check if the module attribute is present and not zero.
+static bool isModuleAttributeSet(const Module *M, const StringRef &ModAttr) {
+ if (const auto *Attr =
+ mdconst::extract_or_null<ConstantInt>(M->getModuleFlag(ModAttr)))
+ if (Attr->getZExtValue())
+ return true;
+ return false;
+}
+
+// Copy an attribute from module to the function if exists.
+// First value of the pair is used when the module attribute is not zero
+// the second otherwise.
+static void
+CopyModuleAttributeToFunction(Function &F, StringRef FnAttrName,
+ StringRef ModAttrName,
+ std::pair<StringRef, StringRef> Values) {
+ Module *M = F.getParent();
+ assert(M && "Missing module");
+ if (F.hasFnAttribute(FnAttrName))
+ return;
+ if (isModuleAttributeSet(M, ModAttrName))
----------------
DanielKristofKiss wrote:
This only used now when the module is materialised for sure, no need for it.
https://github.com/llvm/llvm-project/pull/80640
More information about the llvm-commits
mailing list