Index: clang/lib/Driver/ToolChain.cpp =================================================================== --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -894,7 +894,11 @@ SanitizerMask ToolChain::getSupportedSanitizers() const { // Return sanitizers which don't require runtime support and are not // platform dependent. - + const auto Arch = getTriple().getArch(); + const bool IsAArch64 = Arch == llvm::Triple::aarch64 || + Arch == llvm::Triple::aarch64_be; + const bool IsArmArch = Arch == llvm::Triple::arm || + Arch == llvm::Triple::armeb; SanitizerMask Res = (SanitizerKind::Undefined & ~SanitizerKind::Vptr & ~SanitizerKind::Function) | (SanitizerKind::CFI & ~SanitizerKind::CFIICall) | @@ -903,16 +907,15 @@ SanitizerKind::UnsignedIntegerOverflow | SanitizerKind::ImplicitConversion | SanitizerKind::Nullability | SanitizerKind::LocalBounds; - if (getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64 || - getTriple().getArch() == llvm::Triple::arm || - getTriple().getArch() == llvm::Triple::aarch64 || - getTriple().getArch() == llvm::Triple::wasm32 || - getTriple().getArch() == llvm::Triple::wasm64) + if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64 || + IsAArch64 || IsArmArch || + Arch == llvm::Triple::wasm32 || Arch == llvm::Triple::wasm64) Res |= SanitizerKind::CFIICall; - if (getTriple().getArch() == llvm::Triple::x86_64 || - getTriple().getArch() == llvm::Triple::aarch64) + if (Arch == llvm::Triple::x86_64 || IsAArch64) Res |= SanitizerKind::ShadowCallStack; + if (IsAArch64) + Res |= SanitizerKind::MemTag; + return Res; } Index: clang/lib/Driver/ToolChains/Linux.cpp =================================================================== --- clang/lib/Driver/ToolChains/Linux.cpp +++ clang/lib/Driver/ToolChains/Linux.cpp @@ -1026,8 +1026,6 @@ Res |= SanitizerKind::HWAddress; Res |= SanitizerKind::KernelHWAddress; } - if (IsAArch64) - Res |= SanitizerKind::MemTag; return Res; }