[Git][ghc/ghc][wip/tsan/fixes-2] 5 commits: rts: Ensure that TSANUtils.h is included in Stg.h

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Mon Jun 26 15:49:49 UTC 2023



Ben Gamari pushed to branch wip/tsan/fixes-2 at Glasgow Haskell Compiler / GHC


Commits:
f96955a9 by Ben Gamari at 2023-06-26T10:09:33-04:00
rts: Ensure that TSANUtils.h is included in Stg.h

- - - - -
05074dd5 by Ben Gamari at 2023-06-26T10:09:53-04:00
rts/STM: Fix warning

- - - - -
b1c82826 by Ben Gamari at 2023-06-26T10:10:04-04:00
rts: Introduce NO_WARN macro

This allows fine-grained ignoring of warnings.

- - - - -
53cf83bd by Ben Gamari at 2023-06-26T10:10:42-04:00
rts: Fix unsupported fence warnings with TSAN

- - - - -
1b868666 by Ben Gamari at 2023-06-26T10:11:12-04:00
rts/RaiseAsync: Drop redundant release fence

- - - - -


6 changed files:

- rts/RaiseAsync.c
- rts/STM.c
- rts/include/Rts.h
- rts/include/Stg.h
- rts/include/rts/storage/ClosureMacros.h
- rts/include/stg/SMP.h


Changes:

=====================================
rts/RaiseAsync.c
=====================================
@@ -238,7 +238,6 @@ throwToMsg (Capability *cap, MessageThrowTo *msg)
     goto check_target;
 
 retry:
-    RELEASE_FENCE();
     debugTrace(DEBUG_sched, "throwTo: retrying...");
 
 check_target:


=====================================
rts/STM.c
=====================================
@@ -291,7 +291,7 @@ static StgClosure *lock_tvar(Capability *cap,
   StgClosure *result;
   TRACE("%p : lock_tvar(%p)", trec, s);
   do {
-    StgInfoTable *info;
+    const StgInfoTable *info;
     do {
       result = ACQUIRE_LOAD(&s->current_value);
       info = GET_INFO(UNTAG_CLOSURE(result));


=====================================
rts/include/Rts.h
=====================================
@@ -236,7 +236,6 @@ void _warnFail(const char *filename, unsigned int linenum);
 
 /* Parallel information */
 #include "rts/OSThreads.h"
-#include "rts/TSANUtils.h"
 #include "rts/SpinLock.h"
 
 #include "rts/Messages.h"


=====================================
rts/include/Stg.h
=====================================
@@ -284,6 +284,17 @@
 # define STG_RETURNS_NONNULL
 #endif
 
+/* -----------------------------------------------------------------------------
+   Suppressing C warnings
+   -------------------------------------------------------------------------- */
+
+#define DO_PRAGMA(x) _Pragma(#x)
+#define NO_WARN(warnoption, ...)                   \
+    DO_PRAGMA(GCC diagnostic push)                 \
+    DO_PRAGMA(GCC diagnostic ignored #warnoption)  \
+    __VA_ARGS__                                    \
+    DO_PRAGMA(GCC diagnostic pop)
+
 /* -----------------------------------------------------------------------------
    Global type definitions
    -------------------------------------------------------------------------- */
@@ -382,6 +393,7 @@ external prototype return neither of these types to workaround #11395.
 #include "stg/MachRegsForHost.h"
 #include "stg/Regs.h"
 #include "stg/Ticky.h"
+#include "rts/TSANUtils.h"
 
 #if IN_STG_CODE
 /*


=====================================
rts/include/rts/storage/ClosureMacros.h
=====================================
@@ -75,6 +75,7 @@ EXTERN_INLINE StgThunkInfoTable *itbl_to_thunk_itbl     (const StgInfoTable *i);
 EXTERN_INLINE StgConInfoTable   *itbl_to_con_itbl       (const StgInfoTable *i);
 
 #if defined(TABLES_NEXT_TO_CODE)
+NO_WARN(-Warray-bounds,
 EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgInfoTable *)info - 1;}
 EXTERN_INLINE StgRetInfoTable *RET_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgRetInfoTable *)info - 1;}
 EXTERN_INLINE StgFunInfoTable *FUN_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgFunInfoTable *)info - 1;}
@@ -84,6 +85,7 @@ EXTERN_INLINE StgFunInfoTable *itbl_to_fun_itbl(const StgInfoTable *i) {return (
 EXTERN_INLINE StgRetInfoTable *itbl_to_ret_itbl(const StgInfoTable *i) {return (StgRetInfoTable *)(i + 1) - 1;}
 EXTERN_INLINE StgThunkInfoTable *itbl_to_thunk_itbl(const StgInfoTable *i) {return (StgThunkInfoTable *)(i + 1) - 1;}
 EXTERN_INLINE StgConInfoTable *itbl_to_con_itbl(const StgInfoTable *i) {return (StgConInfoTable *)(i + 1) - 1;}
+)
 #else
 EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgInfoTable *)info;}
 EXTERN_INLINE StgRetInfoTable *RET_INFO_PTR_TO_STRUCT(const StgInfoTable *info) {return (StgRetInfoTable *)info;}


=====================================
rts/include/stg/SMP.h
=====================================
@@ -585,14 +585,12 @@ busy_wait_nop(void)
 
 #define ACQUIRE_FENCE() __atomic_thread_fence(__ATOMIC_ACQUIRE)
 #define RELEASE_FENCE() __atomic_thread_fence(__ATOMIC_RELEASE)
-#define SEQ_CST_FENCE() __atomic_thread_fence(__ATOMIC_SEQ_CST)
+#define SEQ_CST_FENCE() NO_WARN(-Wtsan, __atomic_thread_fence(__ATOMIC_SEQ_CST);)
 
 #if defined(TSAN_ENABLED)
-#define ACQUIRE_FENCE_ON(x) ACQUIRE_LOAD(x)
-#define RELEASE_FENCE_ON(x) RELEASE_STORE()
+#define ACQUIRE_FENCE_ON(x) (void)ACQUIRE_LOAD(x)
 #else
 #define ACQUIRE_FENCE_ON(x) __atomic_thread_fence(__ATOMIC_ACQUIRE)
-#define RELEASE_FENCE_ON(x) __atomic_thread_fence(__ATOMIC_RELEASE)
 #endif
 
 /* ---------------------------------------------------------------------- */



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/424e1e998021639fdea8ef5a238ebc7af6abf319...1b868666f1213f74badd3ebbb323ab126f3f44d3

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/424e1e998021639fdea8ef5a238ebc7af6abf319...1b868666f1213f74badd3ebbb323ab126f3f44d3
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230626/05cce4e1/attachment-0001.html>


More information about the ghc-commits mailing list