v2-0003-Require-compiler-barrier-support.patch

text/x-patch

Filename: v2-0003-Require-compiler-barrier-support.patch
Type: text/x-patch
Part: 2
Message: Re: Remove last traces of HPPA support

Patch

Format: format-patch
Series: patch v2-0003
Subject: Require compiler barrier support.
File+
src/backend/port/atomics.c 0 8
src/include/port/atomics/fallback.h 0 15
src/include/port/atomics.h 3 0
From e0a1081846cb907a71adf13050605478c71a827c Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Tue, 30 Jul 2024 06:27:57 +1200
Subject: [PATCH v2 3/4] Require compiler barrier support.

Previously we had a fallback implementation of pg_compiler_barrier()
that called an empty function across a translation unit boundary so the
compiler couldn't see what it did.  That might not work with a link time
optimizer.  Since we now require knowledge of how to implement atomics,
there shouldn't be any cases where we don't also know how to implement
compiler barriers.

Discussion: https://postgr.es/m/721bf39a-ed8a-44b0-8b8e-be3bd81db748%40technowledgy.de
Discussion: https://postgr.es/m/3351991.1697728588%40sss.pgh.pa.us
---
 src/backend/port/atomics.c          |  8 --------
 src/include/port/atomics.h          |  3 +++
 src/include/port/atomics/fallback.h | 15 ---------------
 3 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/src/backend/port/atomics.c b/src/backend/port/atomics.c
index 6f1e014d0b..19a84a7849 100644
--- a/src/backend/port/atomics.c
+++ b/src/backend/port/atomics.c
@@ -40,14 +40,6 @@ pg_spinlock_barrier(void)
 }
 #endif
 
-#ifdef PG_HAVE_COMPILER_BARRIER_EMULATION
-void
-pg_extern_compiler_barrier(void)
-{
-	/* do nothing */
-}
-#endif
-
 
 #ifdef PG_HAVE_ATOMIC_U64_SIMULATION
 
diff --git a/src/include/port/atomics.h b/src/include/port/atomics.h
index c2ce10a718..edb0ae40dc 100644
--- a/src/include/port/atomics.h
+++ b/src/include/port/atomics.h
@@ -98,6 +98,9 @@
 #if !defined(PG_HAVE_ATOMIC_U32_SUPPORT)
 #error "could not find an implementation of pg_atomic_uint32"
 #endif
+#if !defined(pg_compiler_barrier_impl)
+#error "could not find an implementation of pg_compiler_barrier"
+#endif
 
 /*
  * Provide a spinlock-based implementation of the 64 bit variants, if
diff --git a/src/include/port/atomics/fallback.h b/src/include/port/atomics/fallback.h
index 8ffd1a8fd3..9f83827d83 100644
--- a/src/include/port/atomics/fallback.h
+++ b/src/include/port/atomics/fallback.h
@@ -33,21 +33,6 @@ extern void pg_spinlock_barrier(void);
 #define pg_memory_barrier_impl pg_spinlock_barrier
 #endif
 
-#ifndef pg_compiler_barrier_impl
-/*
- * If the compiler/arch combination does not provide compiler barriers,
- * provide a fallback.  The fallback simply consists of a function call into
- * an externally defined function.  That should guarantee compiler barrier
- * semantics except for compilers that do inter translation unit/global
- * optimization - those better provide an actual compiler barrier.
- *
- * A native compiler barrier for sure is a lot faster than this...
- */
-#define PG_HAVE_COMPILER_BARRIER_EMULATION
-extern void pg_extern_compiler_barrier(void);
-#define pg_compiler_barrier_impl pg_extern_compiler_barrier
-#endif
-
 
 #if !defined(PG_HAVE_ATOMIC_U64_SUPPORT)
 
-- 
2.39.2