Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td (revision 226573) +++ include/clang/Driver/Options.td (working copy) @@ -1214,6 +1214,8 @@ def mfix_cortex_a53_835769 : Flag<["-"], "mfix-cor def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">, Group, HelpText<"Don't workaround Cortex-A53 erratum 835769 (AArch64 only)">; +def ffixed_x18 : Flag<["-"], "ffixed-x18">, Group, + HelpText<"Reserve the x18 register (AArch64 only)">; def mvsx : Flag<["-"], "mvsx">, Group; def mno_vsx : Flag<["-"], "mno-vsx">, Group; Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp (revision 226573) +++ lib/Driver/Tools.cpp (working copy) @@ -958,6 +958,11 @@ void Clang::AddAArch64TargetArgs(const ArgList &Ar if (A->getOption().matches(options::OPT_mno_global_merge)) CmdArgs.push_back("-mno-global-merge"); } + + if (Args.hasArg(options::OPT_ffixed_x18)) { + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-aarch64-reserve-x18"); + } } // Get CPU and ABI names. They are not independent Index: test/Driver/aarch64-fixed-x18.c =================================================================== --- test/Driver/aarch64-fixed-x18.c (revision 0) +++ test/Driver/aarch64-fixed-x18.c (working copy) @@ -0,0 +1,4 @@ +// RUN: %clang -target aarch64-none-gnu -ffixed-x18 -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-FIXED-X18 < %t %s + +// CHECK-FIXED-X18: "-backend-option" "-aarch64-reserve-x18"