[clang] 5061eb6 - [Sparc] Don't define __sparcv9 and __sparcv9__ when targeting V8+
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 21 09:57:23 PST 2022
Author: John Paul Adrian Glaubitz
Date: 2022-01-21T09:57:17-08:00
New Revision: 5061eb6b0121af11a784d92e2dee5996858d04cd
URL: https://github.com/llvm/llvm-project/commit/5061eb6b0121af11a784d92e2dee5996858d04cd
DIFF: https://github.com/llvm/llvm-project/commit/5061eb6b0121af11a784d92e2dee5996858d04cd.diff
LOG: [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
Added:
Modified:
clang/lib/Basic/Targets/Sparc.cpp
clang/test/Preprocessor/predefined-arch-macros.c
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/Sparc.cpp b/clang/lib/Basic/Targets/Sparc.cpp
index 5eeb77406c342..9321024348014 100644
--- a/clang/lib/Basic/Targets/Sparc.cpp
+++ b/clang/lib/Basic/Targets/Sparc.cpp
@@ -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;
}
diff --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c
index 757008005ebaf..f0604de684fbe 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -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 \
More information about the cfe-commits
mailing list