Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1075,11 +1075,11 @@ def mno_sha : Flag<["-"], "mno-sha">, Group; def munaligned_access : Flag<["-"], "munaligned-access">, Group, - HelpText<"Allow memory accesses to be unaligned (ARM only)">; + HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">; def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, Group, - HelpText<"Force all memory accesses to be aligned (ARM only)">; + HelpText<"Force all memory accesses to be aligned (AArch32/AArch64 only)">; def mstrict_align : Flag<["-"], "mstrict-align">, Alias, Flags<[CC1Option,HelpHidden]>, - HelpText<"Force all memory accesses to be aligned (ARM only, same as mno-unaligned-access)">; + HelpText<"Force all memory accesses to be aligned (AArch64 only, same as mno-unaligned-access)">; def mno_thumb : Flag<["-"], "mno-thumb">, Group; def mrestrict_it: Flag<["-"], "mrestrict-it">, Group, HelpText<"Disallow generation of deprecated IT blocks for ARMv8. It is on by default for ARMv8 Thumb mode.">; Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -3395,10 +3395,18 @@ options::OPT_munaligned_access)) { if (A->getOption().matches(options::OPT_mno_unaligned_access)) { CmdArgs.push_back("-backend-option"); - CmdArgs.push_back("-arm-strict-align"); + if (getToolChain().getTriple().getArch() == llvm::Triple::arm64 || + getToolChain().getTriple().getArch() == llvm::Triple::arm64_be) + CmdArgs.push_back("-arm64-strict-align"); + else + CmdArgs.push_back("-arm-strict-align"); } else { CmdArgs.push_back("-backend-option"); - CmdArgs.push_back("-arm-no-strict-align"); + if (getToolChain().getTriple().getArch() == llvm::Triple::arm64 || + getToolChain().getTriple().getArch() == llvm::Triple::arm64_be) + CmdArgs.push_back("-arm64-no-strict-align"); + else + CmdArgs.push_back("-arm-no-strict-align"); } } } Index: test/Driver/arm-alignment.c =================================================================== --- test/Driver/arm-alignment.c +++ test/Driver/arm-alignment.c @@ -1,25 +1,48 @@ // RUN: %clang -target arm-none-gnueabi -munaligned-access -### %s 2> %t -// RUN: FileCheck --check-prefix=CHECK-UNALIGNED < %t %s +// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s // RUN: %clang -target arm-none-gnueabi -mstrict-align -munaligned-access -### %s 2> %t -// RUN: FileCheck --check-prefix=CHECK-UNALIGNED < %t %s +// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s // RUN: %clang -target arm-none-gnueabi -mno-unaligned-access -munaligned-access -### %s 2> %t -// RUN: FileCheck --check-prefix=CHECK-UNALIGNED < %t %s +// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s -// CHECK-UNALIGNED: "-backend-option" "-arm-no-strict-align" +// RUN: %clang -target arm64-none-gnueabi -munaligned-access -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM64 < %t %s + +// RUN: %clang -target arm64-none-gnueabi -mstrict-align -munaligned-access -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM64 < %t %s + +// RUN: %clang -target arm64-none-gnueabi -mno-unaligned-access -munaligned-access -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM64 < %t %s + +// CHECK-UNALIGNED-ARM: "-backend-option" "-arm-no-strict-align" +// CHECK-UNALIGNED-ARM64: "-backend-option" "-arm64-no-strict-align" // RUN: %clang -target arm-none-gnueabi -mno-unaligned-access -### %s 2> %t -// RUN: FileCheck --check-prefix=CHECK-ALIGNED < %t %s +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s // RUN: %clang -target arm-none-gnueabi -mstrict-align -### %s 2> %t -// RUN: FileCheck --check-prefix=CHECK-ALIGNED < %t %s +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s // RUN: %clang -target arm-none-gnueabi -munaligned-access -mno-unaligned-access -### %s 2> %t -// RUN: FileCheck --check-prefix=CHECK-ALIGNED < %t %s +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s // RUN: %clang -target arm-none-gnueabi -munaligned-access -mstrict-align -### %s 2> %t -// RUN: FileCheck --check-prefix=CHECK-ALIGNED < %t %s +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s + +// RUN: %clang -target arm64-none-gnueabi -mno-unaligned-access -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM64 < %t %s + +// RUN: %clang -target arm64-none-gnueabi -mstrict-align -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM64 < %t %s + +// RUN: %clang -target arm64-none-gnueabi -munaligned-access -mno-unaligned-access -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM64 < %t %s + +// RUN: %clang -target arm64-none-gnueabi -munaligned-access -mstrict-align -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM64 < %t %s -// CHECK-ALIGNED: "-backend-option" "-arm-strict-align" +// CHECK-ALIGNED-ARM: "-backend-option" "-arm-strict-align" +// CHECK-ALIGNED-ARM64: "-backend-option" "-arm64-strict-align"