Author: Phoebe Wang Date: 2021-12-10T10:31:09+08:00 New Revision: 925ec98d000a9df7749e93e8831282cbbb5839b2
URL: https://github.com/llvm/llvm-project/commit/925ec98d000a9df7749e93e8831282cbbb5839b2 DIFF: https://github.com/llvm/llvm-project/commit/925ec98d000a9df7749e93e8831282cbbb5839b2.diff LOG: Revert "[X86][clang] Emit diagnostic for float and double when we have features -x87 and -sse on 64-bits" This reverts commit 4a2c827b178f89d4cdeb56153d9440ad4ba786a3. Need to fix the problem when using `-mno-sse` together with "x86intrin.h" Added: Modified: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Basic/Targets/X86.cpp clang/lib/Sema/Sema.cpp clang/test/CodeGen/X86/x86_64-mno-sse.c clang/test/Sema/x86_64-no-x87.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 4e113e9afee24..0598be3a167f9 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10731,8 +10731,6 @@ def err_omp_wrong_dependency_iterator_type : Error< def err_target_unsupported_type : Error<"%0 requires %select{|%2 bit size}1 %3 %select{|return }4type support," " but target '%5' does not support it">; -def err_target_unsupported_type_without_sse : Error< - "SSE register return with SSE disabled">; def err_omp_lambda_capture_in_declare_target_not_to : Error< "variable captured in declare target region must appear in a to clause">; def err_omp_device_type_mismatch : Error< diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index bf5481a1e03d7..5c4bd364b06a3 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -387,9 +387,6 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features, if (!HasX87 && LongDoubleFormat == &llvm::APFloat::x87DoubleExtended()) HasLongDouble = false; - if (SSELevel < SSE1 && getTriple().getArch() == llvm::Triple::x86_64) - HasFPReturn = false; - return true; } diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 96f3d648dc7c7..734ed0f62ec65 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1957,7 +1957,15 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) { bool IsDouble = UnqualTy == Context.DoubleTy; bool IsFloat = UnqualTy == Context.FloatTy; if (IsRetTy && !TI.hasFPReturn() && (IsDouble || IsFloat)) { - if (Diag(Loc, diag::err_target_unsupported_type_without_sse)) { + PartialDiagnostic PD = PDiag(diag::err_target_unsupported_type); + if (D) + PD << D; + else + PD << "expression"; + + if (Diag(Loc, PD, FD) + << false /*show bit size*/ << 0 << Ty << true /*return*/ + << Context.getTargetInfo().getTriple().str()) { if (D) D->setInvalidDecl(); } diff --git a/clang/test/CodeGen/X86/x86_64-mno-sse.c b/clang/test/CodeGen/X86/x86_64-mno-sse.c index ec9995c929256..43a695ae3cd3d 100644 --- a/clang/test/CodeGen/X86/x86_64-mno-sse.c +++ b/clang/test/CodeGen/X86/x86_64-mno-sse.c @@ -1,16 +1,15 @@ // RUN: %clang_cc1 -triple x86_64-linux -target-feature -sse -target-feature -sse2 -S -o /dev/null -verify %s // REQUIRES: x86-registered-target -// expected-error@+2{{SSE register return with SSE disabled}} -// expected-note@+1{{'f1' defined here}} -double f1(void) { +double f1(void) { // expected-error {{SSE register return with SSE disabled}} return 1.4; } extern double g; -void f2(void) { +void f2(void) { // expected-error {{SSE register return with SSE disabled}} g = f1(); } void take_double(double); void pass_double(void) { - take_double(1.5); + // FIXME: Still asserts. + //take_double(1.5); } diff --git a/clang/test/Sema/x86_64-no-x87.cpp b/clang/test/Sema/x86_64-no-x87.cpp index a89c1ff7de93f..b47e69e4b350c 100644 --- a/clang/test/Sema/x86_64-no-x87.cpp +++ b/clang/test/Sema/x86_64-no-x87.cpp @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87 -target-feature -sse -DERROR_LONGDOUBLE -DERROR_NOSSE -// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87 -DERROR_LONGDOUBLE +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -DNOERROR #ifdef NOERROR @@ -19,45 +18,45 @@ long_double decl_ld_del(long_double) = delete; double decl_ld_del(double) = delete; float decl_ld_del(float) = delete; -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+4{{'def' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} // expected-note@+3{{'def' defined here}} // expected-note@+2{{'x' defined here}} #endif int def(long_double x) { -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+2{{'x' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} #endif return (int)x; } -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-note@+3{{'ld_args' defined here}} // expected-note@+2{{'ld_args' defined here}} #endif int ld_args(long_double x, long_double y); int call1(float x, float y) { -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+2 2{{'ld_args' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} #endif return ld_args(x, y); } -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-note@+2{{'ld_ret' defined here}} #endif long_double ld_ret(double x, double y); int call2(float x, float y) { -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+2{{'ld_ret' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} #endif return (int)ld_ret(x, y); } int binop(double x, double y) { -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+2 2{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} #endif double z = (long_double)x * (long_double)y; @@ -65,28 +64,28 @@ int binop(double x, double y) { } void assign1(long_double *ret, double x) { -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+2{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} #endif *ret = x; } struct st_long_double1 { -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-note@+2{{'ld' defined here}} #endif long_double ld; }; struct st_long_double2 { -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-note@+2{{'ld' defined here}} #endif long_double ld; }; struct st_long_double3 { -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-note@+2{{'ld' defined here}} #endif long_double ld; @@ -94,7 +93,7 @@ struct st_long_double3 { void assign2() { struct st_long_double1 st; -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} #endif @@ -103,7 +102,7 @@ void assign2() { void assign3() { struct st_long_double2 st; -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} #endif @@ -112,7 +111,7 @@ void assign3() { void assign4(double d) { struct st_long_double3 st; -#ifdef ERROR_LONGDOUBLE +#ifndef NOERROR // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}} #endif @@ -125,42 +124,22 @@ void assign5() { } // Double and Float return type on x86_64 do not use x87 registers -#ifdef ERROR_NOSSE - // expected-error@+3{{SSE register return with SSE disabled}} - // expected-note@+2{{'d_ret1' defined here}} -#endif double d_ret1(float x) { return 0.0; } -#ifdef ERROR_NOSSE - // expected-note@+2{{'d_ret2' defined here}} -#endif double d_ret2(float x); -#ifdef ERROR_NOSSE - // expected-error@+3{{SSE register return with SSE disabled}} -#endif int d_ret3(float x) { return (int)d_ret2(x); } -#ifdef ERROR_NOSSE - // expected-error@+3{{SSE register return with SSE disabled}} - // expected-note@+2{{'f_ret1' defined here}} -#endif float f_ret1(float x) { return 0.0f; } -#ifdef ERROR_NOSSE - // expected-note@+2{{'f_ret2' defined here}} -#endif float f_ret2(float x); -#ifdef ERROR_NOSSE - // expected-error@+3{{SSE register return with SSE disabled}} -#endif int f_ret3(float x) { return (int)f_ret2(x); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits