[llvm] [llvm][ARM][AArch64] Don't use module attr as function attr. (PR #83154)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 20:42:31 PST 2024
================
@@ -93,24 +79,16 @@ AArch64FunctionInfo::AArch64FunctionInfo(const Function &F,
// TODO: skip functions that have no instrumented allocas for optimization
IsMTETagged = F.hasFnAttribute(Attribute::SanitizeMemTag);
- // BTI/PAuthLR may be set either on the function or the module. Set Bool from
- // either the function attribute or module attribute, depending on what is
- // set.
- // Note: the module attributed is numeric (0 or 1) but the function attribute
- // is stringy ("true" or "false").
- auto TryFnThenModule = [&](StringRef AttrName, bool &Bool) {
- if (F.hasFnAttribute(AttrName)) {
- const StringRef V = F.getFnAttribute(AttrName).getValueAsString();
- assert(V.equals_insensitive("true") || V.equals_insensitive("false"));
- Bool = V.equals_insensitive("true");
- } else if (const auto *ModVal = mdconst::extract_or_null<ConstantInt>(
- F.getParent()->getModuleFlag(AttrName))) {
- Bool = ModVal->getZExtValue();
- }
+ // BTI/PAuthLR are set on the function attribute.
+ auto TryFnAttr = [&](StringRef AttrName) -> bool {
+ if (F.hasFnAttribute(AttrName))
+ return F.getFnAttribute(AttrName).getValueAsBool();
+ else
+ return false;
};
- TryFnThenModule("branch-target-enforcement", BranchTargetEnforcement);
- TryFnThenModule("branch-protection-pauth-lr", BranchProtectionPAuthLR);
+ BranchTargetEnforcement = TryFnAttr("branch-target-enforcement");
+ BranchProtectionPAuthLR = TryFnAttr("branch-protection-pauth-lr");
----------------
arsenm wrote:
you could also do `if (Attr = F.getFnAttribute(...)) Attr.getValueAsBool()` if not
https://github.com/llvm/llvm-project/pull/83154
More information about the llvm-commits
mailing list