@@ -1140,9 +1140,9 @@ void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args,
1140
1140
// ARM tools end.
1141
1141
1142
1142
// / getAArch64TargetCPU - Get the (LLVM) name of the AArch64 cpu we are
1143
- // / targeting.
1144
- static std::string getAArch64TargetCPU ( const ArgList &Args) {
1145
- Arg *A;
1143
+ // / targeting. Set \p A to the Arg corresponding to the -mcpu or -mtune
1144
+ // / arguments if they are provided, or to nullptr otherwise.
1145
+ static std::string getAArch64TargetCPU ( const ArgList &Args, Arg *&A) {
1146
1146
std::string CPU;
1147
1147
// If we have -mtune or -mcpu, use that.
1148
1148
if ((A = Args.getLastArg (options::OPT_mtune_EQ))) {
@@ -1919,13 +1919,15 @@ static StringRef getWebAssemblyTargetCPU(const ArgList &Args) {
1919
1919
1920
1920
static std::string getCPUName (const ArgList &Args, const llvm::Triple &T,
1921
1921
bool FromAs = false ) {
1922
+ Arg *A;
1923
+
1922
1924
switch (T.getArch ()) {
1923
1925
default :
1924
1926
return " " ;
1925
1927
1926
1928
case llvm::Triple::aarch64:
1927
1929
case llvm::Triple::aarch64_be:
1928
- return getAArch64TargetCPU (Args);
1930
+ return getAArch64TargetCPU (Args, A );
1929
1931
1930
1932
case llvm::Triple::arm:
1931
1933
case llvm::Triple::armeb:
@@ -2443,18 +2445,18 @@ static void getAArch64TargetFeatures(const Driver &D, const ArgList &Args,
2443
2445
else if ((A = Args.getLastArg (options::OPT_mcpu_EQ)))
2444
2446
success = getAArch64ArchFeaturesFromMcpu (D, A->getValue (), Args, Features);
2445
2447
else if (Args.hasArg (options::OPT_arch))
2446
- success = getAArch64ArchFeaturesFromMcpu (D, getAArch64TargetCPU (Args), Args ,
2447
- Features);
2448
+ success = getAArch64ArchFeaturesFromMcpu (D, getAArch64TargetCPU (Args, A) ,
2449
+ Args, Features);
2448
2450
2449
2451
if (success && (A = Args.getLastArg (options::OPT_mtune_EQ)))
2450
2452
success =
2451
2453
getAArch64MicroArchFeaturesFromMtune (D, A->getValue (), Args, Features);
2452
2454
else if (success && (A = Args.getLastArg (options::OPT_mcpu_EQ)))
2453
2455
success =
2454
2456
getAArch64MicroArchFeaturesFromMcpu (D, A->getValue (), Args, Features);
2455
- else if (Args.hasArg (options::OPT_arch))
2456
- success = getAArch64MicroArchFeaturesFromMcpu (D, getAArch64TargetCPU (Args),
2457
- Args, Features);
2457
+ else if (success && Args.hasArg (options::OPT_arch))
2458
+ success = getAArch64MicroArchFeaturesFromMcpu (
2459
+ D, getAArch64TargetCPU (Args, A), Args, Features);
2458
2460
2459
2461
if (!success)
2460
2462
D.Diag (diag::err_drv_clang_unsupported) << A->getAsString (Args);
0 commit comments