[Sparc] Don't define __sparcv9 and __sparcv9__ when targeting V8+

Currently, clang defines the three macros __sparcv9, __sparcv9__
and __sparc_v9__ when targeting the V8+ baseline, i.e. using the
V9 instruction set on a 32-bit target.

Since neither gcc nor SolarisStudio define __sparcv9 and __sparcv9__
when targeting V8+, some existing code such as the glibc breaks when
defining either of these two macros on a 32-bit target as they are
used to detect a 64-bit target. Update the tests accordingly.

Fixes PR49562.

Reviewed By: jrtc27, MaskRay, hvdijk

Differential Revision: https://reviews.llvm.org/D98574
This commit is contained in:
John Paul Adrian Glaubitz 2022-01-21 09:57:17 -08:00 committed by Fangrui Song
parent 10e5c513b5
commit 5061eb6b01
2 changed files with 2 additions and 4 deletions

View File

@ -156,8 +156,6 @@ void SparcV8TargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__sparcv8__");
break;
case CG_V9:
Builder.defineMacro("__sparcv9");
Builder.defineMacro("__sparcv9__");
Builder.defineMacro("__sparc_v9__");
break;
}

View File

@ -3479,8 +3479,8 @@
// CHECK_SPARC-V9-NOT: #define __sparcv8 1
// CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
// CHECK_SPARC-V9: #define __sparc_v9__ 1
// CHECK_SPARC-V9: #define __sparcv9 1
// CHECK_SPARC-V9: #define __sparcv9__ 1
// CHECK_SPARC-V9-NOT: #define __sparcv9 1
// CHECK_SPARC-V9-NOT: #define __sparcv9__ 1
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target sparc-sun-solaris \