Skip to content

Commit cb9683f

Browse files
[Clang][Flang][Driver] Fix target parsing for -fveclib=libmvec option. (llvm#138288)
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.
1 parent dad3162 commit cb9683f

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
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
@@ -484,7 +484,7 @@ void Flang::addTargetOptions(const ArgList &Args,
484484
Triple.getArch() != llvm::Triple::x86_64)
485485
D.Diag(diag::err_drv_unsupported_opt_for_target)
486486
<< Name << Triple.getArchName();
487-
} else if (Name == "LIBMVEC-X86") {
487+
} else if (Name == "libmvec") {
488488
if (Triple.getArch() != llvm::Triple::x86 &&
489489
Triple.getArch() != llvm::Triple::x86_64)
490490
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.

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static bool parseVectorLibArg(Fortran::frontend::CodeGenOptions &opts,
195195
std::optional<VectorLibrary> val =
196196
llvm::StringSwitch<std::optional<VectorLibrary>>(arg->getValue())
197197
.Case("Accelerate", VectorLibrary::Accelerate)
198-
.Case("LIBMVEC", VectorLibrary::LIBMVEC)
198+
.Case("libmvec", VectorLibrary::LIBMVEC)
199199
.Case("MASSV", VectorLibrary::MASSV)
200200
.Case("SVML", VectorLibrary::SVML)
201201
.Case("SLEEF", VectorLibrary::SLEEF)

flang/test/Driver/fveclib-codegen.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! test that -fveclib= is passed to the backend
2-
! RUN: %if aarch64-registered-target %{ %flang -S -Ofast -target aarch64-unknown-linux-gnu -fveclib=LIBMVEC -o - %s | FileCheck %s %}
3-
! RUN: %if x86-registered-target %{ %flang -S -Ofast -target x86_64-unknown-linux-gnu -fveclib=LIBMVEC -o - %s | FileCheck %s %}
2+
! RUN: %if aarch64-registered-target %{ %flang -S -Ofast -target aarch64-unknown-linux-gnu -fveclib=SLEEF -o - %s | FileCheck %s --check-prefix=SLEEF %}
3+
! RUN: %if x86-registered-target %{ %flang -S -Ofast -target x86_64-unknown-linux-gnu -fveclib=libmvec -o - %s | FileCheck %s %}
44
! RUN: %flang -S -Ofast -fveclib=NoLibrary -o - %s | FileCheck %s --check-prefix=NOLIB
55

66
subroutine sb(a, b)
@@ -9,6 +9,7 @@ subroutine sb(a, b)
99
do i=1,100
1010
! check that we used a vectorized call to powf()
1111
! CHECK: _ZGVbN4vv_powf
12+
! SLEEF: _ZGVnN4vv_powf
1213
! NOLIB: powf
1314
a(i) = a(i) ** b(i)
1415
end do

flang/test/Driver/fveclib.f90

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

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

0 commit comments

Comments
 (0)