Skip to content

Commit 6184708

Browse files
[Clang][Driver] Fix target parsing for -fveclib=libmvec option.
There are various places where the -fveclib option is parsed to determine whether its value is correct for the target. Unfortunately these places assume case-insensitivity and subsequently use "LIBMVEC" where the driver mandates "libmvec", thus rendering the diagnosistic useless. This PR corrects the naming along with similar incorrect uses within the test files. NOTE: The reason the tests don't report the incorrect usage is because the option's validation does not occur when using -###.
1 parent 001cc34 commit 6184708

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5843,7 +5843,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
58435843
Triple.getArch() != llvm::Triple::x86_64)
58445844
D.Diag(diag::err_drv_unsupported_opt_for_target)
58455845
<< Name << Triple.getArchName();
5846-
} else if (Name == "LIBMVEC-X86") {
5846+
} else if (Name == "libmvec") {
58475847
if (Triple.getArch() != llvm::Triple::x86 &&
58485848
Triple.getArch() != llvm::Triple::x86_64)
58495849
D.Diag(diag::err_drv_unsupported_opt_for_target)

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
934934
std::optional<StringRef> OptVal =
935935
llvm::StringSwitch<std::optional<StringRef>>(ArgVecLib->getValue())
936936
.Case("Accelerate", "Accelerate")
937-
.Case("LIBMVEC", "LIBMVEC-X86")
937+
.Case("libmvec", "LIBMVEC-X86")
938938
.Case("MASSV", "MASSV")
939939
.Case("SVML", "SVML")
940940
.Case("SLEEF", "sleefgnuabi")

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ void Flang::addTargetOptions(const ArgList &Args,
483483
Triple.getArch() != llvm::Triple::x86_64)
484484
D.Diag(diag::err_drv_unsupported_opt_for_target)
485485
<< Name << Triple.getArchName();
486-
} else if (Name == "LIBMVEC-X86") {
486+
} else if (Name == "libmvec") {
487487
if (Triple.getArch() != llvm::Triple::x86 &&
488488
Triple.getArch() != llvm::Triple::x86_64)
489489
D.Diag(diag::err_drv_unsupported_opt_for_target)

clang/test/Driver/fveclib.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang -### -c -fveclib=none %s 2>&1 | FileCheck --check-prefix=CHECK-NOLIB %s
22
// RUN: %clang -### -c -fveclib=Accelerate %s 2>&1 | FileCheck --check-prefix=CHECK-ACCELERATE %s
3-
// RUN: %clang -### -c -fveclib=libmvec %s 2>&1 | FileCheck --check-prefix=CHECK-libmvec %s
3+
// RUN: %clang -### -c --target=x86_64-unknown-linux-gnu -fveclib=libmvec %s 2>&1 | FileCheck --check-prefix=CHECK-libmvec %s
44
// RUN: %clang -### -c -fveclib=MASSV %s 2>&1 | FileCheck --check-prefix=CHECK-MASSV %s
55
// RUN: %clang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck --check-prefix=CHECK-DARWIN_LIBSYSTEM_M %s
66
// RUN: %clang -### -c --target=aarch64 -fveclib=SLEEF %s 2>&1 | FileCheck --check-prefix=CHECK-SLEEF %s
@@ -21,7 +21,7 @@
2121

2222
// RUN: not %clang --target=x86 -c -fveclib=SLEEF %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
2323
// RUN: not %clang --target=x86 -c -fveclib=ArmPL %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
24-
// RUN: not %clang --target=aarch64 -c -fveclib=LIBMVEC-X86 %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
24+
// RUN: not %clang --target=aarch64 -c -fveclib=libmvec %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
2525
// RUN: not %clang --target=aarch64 -c -fveclib=SVML %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
2626
// CHECK-ERROR: unsupported option {{.*}} for target
2727

@@ -37,7 +37,7 @@
3737

3838
/* Verify that the correct vector library is passed to LTO flags. */
3939

40-
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=LIBMVEC -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBMVEC %s
40+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=libmvec -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBMVEC %s
4141
// CHECK-LTO-LIBMVEC: "-plugin-opt=-vector-library=LIBMVEC-X86"
4242

4343
// RUN: %clang -### --target=powerpc64-unknown-linux-gnu -fveclib=MASSV -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-MASSV %s
@@ -58,8 +58,8 @@
5858

5959
/* Verify that -fmath-errno is set correctly for the vector library. */
6060

61-
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=LIBMVEC %s 2>&1 | FileCheck --check-prefix=CHECK-ERRNO-LIBMVEC %s
62-
// CHECK-ERRNO-LIBMVEC: "-fveclib=LIBMVEC"
61+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=libmvec %s 2>&1 | FileCheck --check-prefix=CHECK-ERRNO-LIBMVEC %s
62+
// CHECK-ERRNO-LIBMVEC: "-fveclib=libmvec"
6363
// CHECK-ERRNO-LIBMVEC-SAME: "-fmath-errno"
6464

6565
// RUN: %clang -### --target=powerpc64-unknown-linux-gnu -fveclib=MASSV %s 2>&1 | FileCheck --check-prefix=CHECK-ERRNO-MASSV %s
@@ -110,7 +110,7 @@
110110
// CHECK-ENABLED-LAST: math errno enabled by '-ffp-model=strict' after it was implicitly disabled by '-fveclib=ArmPL', this may limit the utilization of the vector library [-Wmath-errno-enabled-with-veclib]
111111

112112
/* Verify no warning when math-errno is re-enabled for a different veclib (that does not imply -fno-math-errno). */
113-
// RUN: %clang -### --target=aarch64-linux-gnu -fveclib=ArmPL -fmath-errno -fveclib=LIBMVEC %s 2>&1 | FileCheck --check-prefix=CHECK-REPEAT-VECLIB %s
113+
// RUN: %clang -### --target=aarch64-linux-gnu -fveclib=ArmPL -fmath-errno -fveclib=Accelerate %s 2>&1 | FileCheck --check-prefix=CHECK-REPEAT-VECLIB %s
114114
// CHECK-REPEAT-VECLIB-NOT: math errno enabled
115115

116116
/// Verify that vectorized routines library is being linked in.

0 commit comments

Comments
 (0)