Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
67de53a6
by Cheng Shao at 2025-09-23T14:37:31-04:00
10 changed files:
- libraries/ghc-internal/cbits/atomic.c
- libraries/ghc-internal/cbits/ctz.c
- rts/RtsStartup.c
- rts/RtsSymbols.c
- rts/include/Rts.h
- rts/include/Stg.h
- rts/include/rts/Types.h
- rts/sm/BlockAlloc.c
- rts/sm/Evac.h
- rts/sm/Storage.c
Changes:
| ... | ... | @@ -163,7 +163,7 @@ hs_atomic_and64(StgWord x, StgWord64 val) |
| 163 | 163 | #pragma GCC diagnostic push
|
| 164 | 164 | #if defined(__clang__)
|
| 165 | 165 | #pragma GCC diagnostic ignored "-Wsync-fetch-and-nand-semantics-changed"
|
| 166 | -#elif defined(__GNUC__)
|
|
| 166 | +#else
|
|
| 167 | 167 | #pragma GCC diagnostic ignored "-Wsync-nand"
|
| 168 | 168 | #endif
|
| 169 | 169 |
| ... | ... | @@ -31,7 +31,7 @@ hs_ctz32(StgWord x) |
| 31 | 31 | StgWord
|
| 32 | 32 | hs_ctz64(StgWord64 x)
|
| 33 | 33 | {
|
| 34 | -#if defined(__GNUC__) && (defined(i386_HOST_ARCH) || defined(powerpc_HOST_ARCH))
|
|
| 34 | +#if defined(i386_HOST_ARCH) || defined(powerpc_HOST_ARCH)
|
|
| 35 | 35 | /* On Linux/i386, the 64bit `__builtin_ctzll()` intrinsic doesn't
|
| 36 | 36 | get inlined by GCC but rather a short `__ctzdi2` runtime function
|
| 37 | 37 | is inserted when needed into compiled object files.
|
| ... | ... | @@ -125,13 +125,7 @@ void _fpreset(void) |
| 125 | 125 | x86_init_fpu();
|
| 126 | 126 | }
|
| 127 | 127 | |
| 128 | -#if defined(__GNUC__)
|
|
| 129 | 128 | void __attribute__((alias("_fpreset"))) fpreset(void);
|
| 130 | -#else
|
|
| 131 | -void fpreset(void) {
|
|
| 132 | - _fpreset();
|
|
| 133 | -}
|
|
| 134 | -#endif
|
|
| 135 | 129 | |
| 136 | 130 | /* Set the console's CodePage to UTF-8 if using the new I/O manager and the CP
|
| 137 | 131 | is still the default one. */
|
| ... | ... | @@ -963,7 +963,7 @@ extern char **environ; |
| 963 | 963 | RTS_INTCHAR_SYMBOLS
|
| 964 | 964 | |
| 965 | 965 | // 64-bit support functions in libgcc.a
|
| 966 | -#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
|
|
| 966 | +#if SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
|
|
| 967 | 967 | #define RTS_LIBGCC_SYMBOLS \
|
| 968 | 968 | SymI_NeedsProto(__divdi3) \
|
| 969 | 969 | SymI_NeedsProto(__udivdi3) \
|
| ... | ... | @@ -974,7 +974,7 @@ extern char **environ; |
| 974 | 974 | SymI_NeedsProto(__ashrdi3) \
|
| 975 | 975 | SymI_NeedsProto(__lshrdi3) \
|
| 976 | 976 | SymI_NeedsProto(__fixunsdfdi)
|
| 977 | -#elif defined(__GNUC__) && SIZEOF_VOID_P == 8
|
|
| 977 | +#elif SIZEOF_VOID_P == 8
|
|
| 978 | 978 | #define RTS_LIBGCC_SYMBOLS \
|
| 979 | 979 | SymI_NeedsProto(__udivti3) \
|
| 980 | 980 | SymI_NeedsProto(__umodti3)
|
| ... | ... | @@ -54,35 +54,19 @@ extern "C" { |
| 54 | 54 | #include "rts/Types.h"
|
| 55 | 55 | #include "rts/Time.h"
|
| 56 | 56 | |
| 57 | -#if __GNUC__ >= 3
|
|
| 58 | 57 | #define ATTRIBUTE_ALIGNED(n) __attribute__((aligned(n)))
|
| 59 | -#else
|
|
| 60 | -#define ATTRIBUTE_ALIGNED(n) /*nothing*/
|
|
| 61 | -#endif
|
|
| 62 | 58 | |
| 63 | 59 | // Symbols that are extern, but private to the RTS, are declared
|
| 64 | 60 | // with visibility "hidden" to hide them outside the RTS shared
|
| 65 | 61 | // library.
|
| 66 | 62 | #define RTS_PRIVATE GNUC3_ATTRIBUTE(visibility("hidden"))
|
| 67 | 63 | |
| 68 | -#if __GNUC__ >= 4
|
|
| 69 | 64 | #define RTS_UNLIKELY(p) __builtin_expect((p),0)
|
| 70 | -#else
|
|
| 71 | -#define RTS_UNLIKELY(p) (p)
|
|
| 72 | -#endif
|
|
| 73 | 65 | |
| 74 | -#if __GNUC__ >= 4
|
|
| 75 | 66 | #define RTS_LIKELY(p) __builtin_expect(!!(p), 1)
|
| 76 | -#else
|
|
| 77 | -#define RTS_LIKELY(p) (p)
|
|
| 78 | -#endif
|
|
| 79 | 67 | |
| 80 | 68 | /* __builtin_unreachable is supported since GNU C 4.5 */
|
| 81 | -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
|
|
| 82 | 69 | #define RTS_UNREACHABLE __builtin_unreachable()
|
| 83 | -#else
|
|
| 84 | -#define RTS_UNREACHABLE abort()
|
|
| 85 | -#endif
|
|
| 86 | 70 | |
| 87 | 71 | /* Prefetch primitives */
|
| 88 | 72 | #define prefetchForRead(ptr) __builtin_prefetch(ptr, 0)
|
| ... | ... | @@ -374,17 +358,8 @@ TICK_VAR(2) |
| 374 | 358 | Useful macros and inline functions
|
| 375 | 359 | -------------------------------------------------------------------------- */
|
| 376 | 360 | |
| 377 | -#if defined(__GNUC__)
|
|
| 378 | -#define SUPPORTS_TYPEOF
|
|
| 379 | -#endif
|
|
| 380 | - |
|
| 381 | -#if defined(SUPPORTS_TYPEOF)
|
|
| 382 | 361 | #define stg_min(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _a : _b; })
|
| 383 | 362 | #define stg_max(a,b) ({typeof(a) _a = (a), _b = (b); _a <= _b ? _b : _a; })
|
| 384 | -#else
|
|
| 385 | -#define stg_min(a,b) ((a) <= (b) ? (a) : (b))
|
|
| 386 | -#define stg_max(a,b) ((a) <= (b) ? (b) : (a))
|
|
| 387 | -#endif
|
|
| 388 | 363 | |
| 389 | 364 | /* -------------------------------------------------------------------------- */
|
| 390 | 365 |
| ... | ... | @@ -131,20 +131,12 @@ |
| 131 | 131 | /*
|
| 132 | 132 | * GCC attributes
|
| 133 | 133 | */
|
| 134 | -#if defined(__GNUC__)
|
|
| 135 | 134 | #define GNU_ATTRIBUTE(at) __attribute__((at))
|
| 136 | -#else
|
|
| 137 | -#define GNU_ATTRIBUTE(at)
|
|
| 138 | -#endif
|
|
| 139 | 135 | |
| 140 | -#if __GNUC__ >= 3
|
|
| 141 | 136 | #define GNUC3_ATTRIBUTE(at) __attribute__((at))
|
| 142 | -#else
|
|
| 143 | -#define GNUC3_ATTRIBUTE(at)
|
|
| 144 | -#endif
|
|
| 145 | 137 | |
| 146 | 138 | /* Used to mark a switch case that falls-through */
|
| 147 | -#if (defined(__GNUC__) && __GNUC__ >= 7)
|
|
| 139 | +#if __GNUC__ >= 7
|
|
| 148 | 140 | // N.B. Don't enable fallthrough annotations when compiling with Clang.
|
| 149 | 141 | // Apparently clang doesn't enable implicitly fallthrough warnings by default
|
| 150 | 142 | // http://llvm.org/viewvc/llvm-project?revision=167655&view=revision
|
| ... | ... | @@ -154,7 +146,7 @@ |
| 154 | 146 | #define FALLTHROUGH ((void)0)
|
| 155 | 147 | #endif /* __GNUC__ >= 7 */
|
| 156 | 148 | |
| 157 | -#if !defined(DEBUG) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
|
|
| 149 | +#if !defined(DEBUG)
|
|
| 158 | 150 | #define GNUC_ATTR_HOT __attribute__((hot))
|
| 159 | 151 | #else
|
| 160 | 152 | #define GNUC_ATTR_HOT /* nothing */
|
| ... | ... | @@ -168,21 +160,13 @@ |
| 168 | 160 | See Note [Windows Stack allocations] */
|
| 169 | 161 | #if defined(__clang__)
|
| 170 | 162 | #define STG_NO_OPTIMIZE __attribute__((optnone))
|
| 171 | -#elif defined(__GNUC__) || defined(__GNUG__)
|
|
| 172 | -#define STG_NO_OPTIMIZE __attribute__((optimize("O0")))
|
|
| 173 | 163 | #else
|
| 174 | -#define STG_NO_OPTIMIZE /* nothing */
|
|
| 164 | +#define STG_NO_OPTIMIZE __attribute__((optimize("O0")))
|
|
| 175 | 165 | #endif
|
| 176 | 166 | |
| 177 | 167 | // Mark a function as accepting a printf-like format string.
|
| 178 | -#if !defined(__GNUC__) && defined(mingw32_HOST_OS)
|
|
| 179 | -/* On Win64, if we say "printf" then gcc thinks we are going to use
|
|
| 180 | - MS format specifiers like %I64d rather than %llu */
|
|
| 181 | -#define STG_PRINTF_ATTR(fmt_arg, rest) GNUC3_ATTRIBUTE(format(gnu_printf, fmt_arg, rest))
|
|
| 182 | -#else
|
|
| 183 | 168 | /* However, on OS X, "gnu_printf" isn't recognised */
|
| 184 | 169 | #define STG_PRINTF_ATTR(fmt_arg, rest) GNUC3_ATTRIBUTE(format(printf, fmt_arg, rest))
|
| 185 | -#endif
|
|
| 186 | 170 | |
| 187 | 171 | #define STG_RESTRICT __restrict__
|
| 188 | 172 | |
| ... | ... | @@ -204,13 +188,9 @@ |
| 204 | 188 | # define stg__has_attribute(attr) (0)
|
| 205 | 189 | #endif
|
| 206 | 190 | |
| 207 | -#ifdef __GNUC__
|
|
| 208 | -# define STG_GNUC_GUARD_VERSION(major, minor) \
|
|
| 191 | +#define STG_GNUC_GUARD_VERSION(major, minor) \
|
|
| 209 | 192 | ((__GNUC__ > (major)) || \
|
| 210 | 193 | ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor))))
|
| 211 | -#else
|
|
| 212 | -# define STG_GNUC_GUARD_VERSION(major, minor) (0)
|
|
| 213 | -#endif
|
|
| 214 | 194 | |
| 215 | 195 | /*
|
| 216 | 196 | * The versions of the `__malloc__` attribute which take arguments are only
|
| ... | ... | @@ -16,16 +16,6 @@ |
| 16 | 16 | #include <stddef.h>
|
| 17 | 17 | #include <stdbool.h>
|
| 18 | 18 | |
| 19 | -// Deprecated, use uint32_t instead.
|
|
| 20 | -typedef unsigned int nat __attribute__((deprecated)); /* uint32_t */
|
|
| 21 | - |
|
| 22 | -/* ullong (64|128-bit) type: only include if needed (not ANSI) */
|
|
| 23 | -#if defined(__GNUC__)
|
|
| 24 | -#define LL(x) (x##LL)
|
|
| 25 | -#else
|
|
| 26 | -#define LL(x) (x##L)
|
|
| 27 | -#endif
|
|
| 28 | - |
|
| 29 | 19 | typedef struct StgClosure_ StgClosure;
|
| 30 | 20 | typedef struct StgInfoTable_ StgInfoTable;
|
| 31 | 21 | typedef struct StgTSO_ StgTSO; |
| ... | ... | @@ -274,19 +274,9 @@ STATIC_INLINE uint32_t |
| 274 | 274 | log_2(W_ n)
|
| 275 | 275 | {
|
| 276 | 276 | ASSERT(n > 0 && n < (1<<NUM_FREE_LISTS));
|
| 277 | -#if defined(__GNUC__)
|
|
| 278 | 277 | return CLZW(n) ^ (sizeof(StgWord)*8 - 1);
|
| 279 | 278 | // generates good code on x86. __builtin_clz() compiles to bsr+xor, but
|
| 280 | 279 | // we want just bsr, so the xor here cancels out gcc's xor.
|
| 281 | -#else
|
|
| 282 | - W_ i, x;
|
|
| 283 | - x = n;
|
|
| 284 | - for (i=0; i < NUM_FREE_LISTS; i++) {
|
|
| 285 | - x = x >> 1;
|
|
| 286 | - if (x == 0) return i;
|
|
| 287 | - }
|
|
| 288 | - return NUM_FREE_LISTS;
|
|
| 289 | -#endif
|
|
| 290 | 280 | }
|
| 291 | 281 | |
| 292 | 282 | // log base 2 (ceiling), needs to support up to (2^NUM_FREE_LISTS)-1
|
| ... | ... | @@ -294,18 +284,8 @@ STATIC_INLINE uint32_t |
| 294 | 284 | log_2_ceil(W_ n)
|
| 295 | 285 | {
|
| 296 | 286 | ASSERT(n > 0 && n < (1<<NUM_FREE_LISTS));
|
| 297 | -#if defined(__GNUC__)
|
|
| 298 | 287 | uint32_t r = log_2(n);
|
| 299 | 288 | return (n & (n-1)) ? r+1 : r;
|
| 300 | -#else
|
|
| 301 | - W_ i, x;
|
|
| 302 | - x = 1;
|
|
| 303 | - for (i=0; i < MAX_FREE_LIST; i++) {
|
|
| 304 | - if (x >= n) return i;
|
|
| 305 | - x = x << 1;
|
|
| 306 | - }
|
|
| 307 | - return MAX_FREE_LIST;
|
|
| 308 | -#endif
|
|
| 309 | 289 | }
|
| 310 | 290 | |
| 311 | 291 | STATIC_INLINE void
|
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | // registers EAX, EDX, and ECX instead of on the stack. Functions that
|
| 26 | 26 | // take a variable number of arguments will continue to be passed all of
|
| 27 | 27 | // their arguments on the stack.
|
| 28 | -#if __GNUC__ >= 2 && (defined(x86_64_HOST_ARCH) || defined(i386_HOST_ARCH))
|
|
| 28 | +#if defined(x86_64_HOST_ARCH) || defined(i386_HOST_ARCH)
|
|
| 29 | 29 | #define REGPARM1 __attribute__((regparm(1)))
|
| 30 | 30 | #else
|
| 31 | 31 | #define REGPARM1
|
| ... | ... | @@ -1818,25 +1818,6 @@ StgWord calcTotalCompactW (void) |
| 1818 | 1818 | #include <libkern/OSCacheControl.h>
|
| 1819 | 1819 | #endif
|
| 1820 | 1820 | |
| 1821 | -/* __builtin___clear_cache is supported since GNU C 4.3.6.
|
|
| 1822 | - * We pick 4.4 to simplify condition a bit.
|
|
| 1823 | - */
|
|
| 1824 | -#define GCC_HAS_BUILTIN_CLEAR_CACHE (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
|
| 1825 | - |
|
| 1826 | -#if defined(__clang__)
|
|
| 1827 | -/* clang defines __clear_cache as a builtin on some platforms.
|
|
| 1828 | - * For example on armv7-linux-androideabi. The type slightly
|
|
| 1829 | - * differs from gcc.
|
|
| 1830 | - */
|
|
| 1831 | -extern void __clear_cache(void * begin, void * end);
|
|
| 1832 | -#elif defined(__GNUC__) && !GCC_HAS_BUILTIN_CLEAR_CACHE
|
|
| 1833 | -/* __clear_cache is a libgcc function.
|
|
| 1834 | - * It existed before __builtin___clear_cache was introduced.
|
|
| 1835 | - * See #8562.
|
|
| 1836 | - */
|
|
| 1837 | -extern void __clear_cache(char * begin, char * end);
|
|
| 1838 | -#endif /* __GNUC__ */
|
|
| 1839 | - |
|
| 1840 | 1821 | /* On ARM and other platforms, we need to flush the cache after
|
| 1841 | 1822 | writing code into memory, so the processor reliably sees it. */
|
| 1842 | 1823 | void flushExec (W_ len, AdjustorExecutable exec_addr)
|
| ... | ... | @@ -1849,26 +1830,11 @@ void flushExec (W_ len, AdjustorExecutable exec_addr) |
| 1849 | 1830 | /* On iOS we need to use the special 'sys_icache_invalidate' call. */
|
| 1850 | 1831 | sys_icache_invalidate(exec_addr, len);
|
| 1851 | 1832 | #elif defined(wasm32_HOST_ARCH)
|
| 1852 | -#elif defined(__clang__)
|
|
| 1853 | - unsigned char* begin = (unsigned char*)exec_addr;
|
|
| 1854 | - unsigned char* end = begin + len;
|
|
| 1855 | -# if __has_builtin(__builtin___clear_cache)
|
|
| 1856 | - __builtin___clear_cache((void*)begin, (void*)end);
|
|
| 1857 | -# else
|
|
| 1858 | - __clear_cache((void*)begin, (void*)end);
|
|
| 1859 | -# endif
|
|
| 1860 | -#elif defined(__GNUC__)
|
|
| 1861 | - /* For all other platforms, fall back to a libgcc builtin. */
|
|
| 1833 | +#else
|
|
| 1834 | + /* For all other platforms, fall back to __builtin___clear_cache. */
|
|
| 1862 | 1835 | unsigned char* begin = (unsigned char*)exec_addr;
|
| 1863 | 1836 | unsigned char* end = begin + len;
|
| 1864 | -# if GCC_HAS_BUILTIN_CLEAR_CACHE
|
|
| 1865 | 1837 | __builtin___clear_cache((void*)begin, (void*)end);
|
| 1866 | -# else
|
|
| 1867 | - /* For all other platforms, fall back to a libgcc builtin. */
|
|
| 1868 | - __clear_cache((void*)begin, (void*)end);
|
|
| 1869 | -# endif
|
|
| 1870 | -#else
|
|
| 1871 | -#error Missing support to flush the instruction cache
|
|
| 1872 | 1838 | #endif
|
| 1873 | 1839 | }
|
| 1874 | 1840 |