Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Driver] Report invalid target triple versions for all environment types. #78655

Merged
merged 20 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f440f44
Make clang report invalid target versions for all environment.
ZijunZhaoCCK Jan 19, 2024
4d0c8f6
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Jan 19, 2024
1f0a2ee
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Jan 19, 2024
b5daff2
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Jan 19, 2024
a2e1335
Make clang report invalid target versions for all environment.
ZijunZhaoCCK Jan 19, 2024
a5052ba
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Jan 24, 2024
036ea34
Make clang report invalid target versions for all environment.
ZijunZhaoCCK Jan 19, 2024
c756121
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Jan 24, 2024
2ab3f7b
Make clang report invalid target versions for all environment.
ZijunZhaoCCK Jan 19, 2024
30be503
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Jan 26, 2024
f32525a
Make clang report invalid target versions for all environment.
ZijunZhaoCCK Jan 19, 2024
c60ea16
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Feb 1, 2024
d657b7f
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Feb 1, 2024
6173010
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Feb 1, 2024
c016d09
Make clang report invalid target versions for all environment.
ZijunZhaoCCK Jan 19, 2024
3d25a65
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Feb 2, 2024
4458696
Make clang report invalid target versions for all environment.
ZijunZhaoCCK Jan 19, 2024
ee0355c
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Feb 2, 2024
a2976a8
Merge branch 'llvm:main' into check-version
ZijunZhaoCCK Feb 2, 2024
6f41d09
Make clang report invalid target versions for all environment.
ZijunZhaoCCK Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,15 +1430,16 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
const ToolChain &TC = getToolChain(
*UArgs, computeTargetTriple(*this, TargetTriple, *UArgs));

if (TC.getTriple().isAndroid()) {
llvm::Triple Triple = TC.getTriple();
StringRef TripleVersionName = Triple.getEnvironmentVersionString();

if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "") {
Diags.Report(diag::err_drv_triple_version_invalid)
<< TripleVersionName << TC.getTripleString();
ContainsError = true;
}
// Check if the environment version is valid.
llvm::Triple Triple = TC.getTriple();
StringRef TripleVersionName = Triple.getEnvironmentVersionString();
StringRef TripleObjectFormat = Triple.getObjectFormatTypeName(Triple.getObjectFormat());

if (Triple.getEnvironmentVersion().empty() && TripleVersionName != ""
&& TripleVersionName != TripleObjectFormat) {
Diags.Report(diag::err_drv_triple_version_invalid)
<< TripleVersionName << TC.getTripleString();
ContainsError = true;
}

// Report warning when arm64EC option is overridden by specified target
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/fp128_complex.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang -target aarch64-linux-gnuabi %s -S -emit-llvm -o - | FileCheck %s
// RUN: %clang -target aarch64-linux-gnueabi %s -S -emit-llvm -o - | FileCheck %s

_Complex long double a, b, c, d;
void test_fp128_compound_assign(void) {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Driver/mips-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,12 @@
// LONG-CALLS-DEF-NOT: "long-calls"
//
// -mbranch-likely
// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \
// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \
// RUN: | FileCheck --check-prefix=BRANCH-LIKELY %s
// BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely'
//
// -mno-branch-likely
// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \
// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \
// RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s
// NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely'

Expand Down
4 changes: 2 additions & 2 deletions clang/test/Frontend/fixed_point_bit_widths.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - %s | FileCheck %s
// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-ubuntu-fast %s | FileCheck %s
// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4 %s | FileCheck %s
// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=ppc64 %s | FileCheck %s
// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-windows10pro-fast %s | FileCheck %s
// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4 %s | FileCheck %s

/* Primary signed _Accum */

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/TargetParser/Triple.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class Triple {
Callable,
Mesh,
Amplification,

OpenCL,
OpenHOS,

LastEnvironmentType = OpenHOS
Expand Down
14 changes: 14 additions & 0 deletions llvm/lib/TargetParser/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
case Callable: return "callable";
case Mesh: return "mesh";
case Amplification: return "amplification";
case OpenCL: return "opencl";
case OpenHOS: return "ohos";
}

Expand Down Expand Up @@ -692,6 +693,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
.StartsWith("callable", Triple::Callable)
.StartsWith("mesh", Triple::Mesh)
.StartsWith("amplification", Triple::Amplification)
.StartsWith("opencl", Triple::OpenCL)
.StartsWith("ohos", Triple::OpenHOS)
.Default(Triple::UnknownEnvironment);
}
Expand Down Expand Up @@ -1217,8 +1219,20 @@ VersionTuple Triple::getEnvironmentVersion() const {

StringRef Triple::getEnvironmentVersionString() const {
StringRef EnvironmentName = getEnvironmentName();

// none is a valid environment type - it basically amounts to a freestanding environment.
if (EnvironmentName == "none")
return "";

StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
EnvironmentName.consume_front(EnvironmentTypeName);

if (EnvironmentName.starts_with("-")) {
// arch-vendor-os-env-obj is correct
StringRef ObjectFormatType = getObjectFormatTypeName(getObjectFormat());
if (ObjectFormatType == StringRef(EnvironmentName).split('-').second)
return "";
}
return EnvironmentName;
}

Expand Down
Loading