diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp --- a/clang/lib/Basic/Targets/ARM.cpp +++ b/clang/lib/Basic/Targets/ARM.cpp @@ -369,7 +369,7 @@ bool ARMTargetInfo::isBranchProtectionSupportedArch(StringRef Arch) const { if (Arch.empty()) - return true; + return false; llvm::ARM::ArchKind ArchKind = llvm::ARM::parseCPUArch(Arch); if (ArchKind != llvm::ARM::ArchKind::ARMV8_1MMainline && @@ -388,7 +388,7 @@ if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err)) return false; - if (!isBranchProtectionSupportedArch(Arch)) + if (!Arch.empty() && !isBranchProtectionSupportedArch(Arch)) return false; BPI.SignReturnAddr = diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -6403,7 +6403,8 @@ // If the Branch Protection attribute is missing, validate the target // Architecture attribute against Branch Protection command line // settings. - if (!CGM.getTarget().isBranchProtectionSupportedArch(Attr.Architecture)) + if (!Attr.Architecture.empty() && + !CGM.getTarget().isBranchProtectionSupportedArch(Attr.Architecture)) CGM.getDiags().Report( D->getLocation(), diag::warn_target_unsupported_branch_protection_attribute)