summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Shao <astrohavoc@gmail.com>2022-10-27 13:44:50 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-11 00:26:55 -0500
commit8104f6f5524d324e56fe903d07aab4cad16ceaf5 (patch)
tree83af880dcd8457886e6a9122d84c21e6d58dce46
parent2e6ab4537ff5a2d496de44a0475efb274867317a (diff)
downloadhaskell-8104f6f5524d324e56fe903d07aab4cad16ceaf5.tar.gz
Fix Cmm symbol kind
-rw-r--r--compiler/GHC/Cmm/CLabel.hs9
-rw-r--r--rts/Apply.cmm34
-rw-r--r--rts/Compact.cmm4
-rw-r--r--rts/ContinuationOps.cmm17
-rw-r--r--rts/Exception.cmm25
-rw-r--r--rts/HeapStackCheck.cmm22
-rw-r--r--rts/PrimOps.cmm54
-rw-r--r--rts/RtsSymbols.c16
-rw-r--r--rts/StgMiscClosures.cmm22
-rw-r--r--rts/StgStartup.cmm5
-rw-r--r--rts/StgStdThunks.cmm10
-rw-r--r--rts/Updates.cmm7
-rw-r--r--utils/genapply/Main.hs26
13 files changed, 237 insertions, 14 deletions
diff --git a/compiler/GHC/Cmm/CLabel.hs b/compiler/GHC/Cmm/CLabel.hs
index 22c1c9ef05..83555e9227 100644
--- a/compiler/GHC/Cmm/CLabel.hs
+++ b/compiler/GHC/Cmm/CLabel.hs
@@ -1204,12 +1204,15 @@ labelType (CmmLabel _ _ _ CmmPrimCall) = CodeLabel
labelType (CmmLabel _ _ _ CmmRetInfo) = DataLabel
labelType (CmmLabel _ _ _ CmmRet) = CodeLabel
labelType (RtsLabel (RtsSelectorInfoTable _ _)) = DataLabel
+labelType (RtsLabel (RtsSelectorEntry _ _)) = CodeLabel
labelType (RtsLabel (RtsApInfoTable _ _)) = DataLabel
+labelType (RtsLabel (RtsApEntry _ _)) = CodeLabel
labelType (RtsLabel (RtsApFast _)) = CodeLabel
-labelType (RtsLabel RtsUnpackCStringInfoTable) = CodeLabel
+labelType (RtsLabel RtsUnpackCStringInfoTable) = DataLabel
labelType (RtsLabel RtsUnpackCStringUtf8InfoTable)
- = CodeLabel
-labelType (RtsLabel _) = DataLabel
+ = DataLabel
+labelType (RtsLabel (RtsPrimOp _)) = CodeLabel
+labelType (RtsLabel (RtsSlowFastTickyCtr _)) = DataLabel
labelType (LocalBlockLabel _) = CodeLabel
labelType (SRTLabel _) = DataLabel
labelType (ForeignLabel _ _ _ IsFunction) = CodeLabel
diff --git a/rts/Apply.cmm b/rts/Apply.cmm
index 78a0256d3a..e91418ab14 100644
--- a/rts/Apply.cmm
+++ b/rts/Apply.cmm
@@ -12,6 +12,40 @@
#include "Cmm.h"
+/*
+Note [import CLOSURE annotations]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+When the Cmm syntax refers to an undefined symbol without a corresponding import
+statement, the parser always creates a CLabel with function kind, even if it
+refers to data instead (e.g. info tables or static closures). This is a huge
+trouble for backends which have zero tolerance in CLabel kind error. The issue
+has been tracked at #22368, and for the time being, we need to add explicit
+"import CLOSURE" statements for all undefined data symbols used in hand-written
+Cmm files.
+
+We also need the !defined(UnregisterisedCompiler) CPP guard, since otherwise it
+causes trouble for the unregisterised backend: they conflict with existing
+declarations in MiscClosures.h, and gcc will start to throw errors like "error:
+conflicting types for ‘__stg_EAGER_BLACKHOLE_info’; have ‘StgWordArray’ {aka
+‘long unsigned int[]’}".
+*/
+
+#if !defined(UnregisterisedCompiler)
+import CLOSURE CCS_OVERHEAD;
+import CLOSURE ENT_AP_ctr;
+import CLOSURE ENT_PAP_ctr;
+import CLOSURE ENT_VIA_NODE_ctr;
+import CLOSURE RtsFlags;
+import CLOSURE STK_CHK_ctr;
+import CLOSURE __stg_EAGER_BLACKHOLE_info;
+import CLOSURE stg_AP_STACK_info;
+import CLOSURE stg_PAP_info;
+import CLOSURE stg_WHITEHOLE_info;
+import CLOSURE stg_ap_0_ret_str;
+import CLOSURE stg_restore_cccs_eval_info;
+#endif
+
/* ----------------------------------------------------------------------------
* Evaluate a closure and return it.
*
diff --git a/rts/Compact.cmm b/rts/Compact.cmm
index cfa8bba0f1..1a5b2162e2 100644
--- a/rts/Compact.cmm
+++ b/rts/Compact.cmm
@@ -13,6 +13,10 @@
import CLOSURE base_GHCziIOziException_cannotCompactFunction_closure;
import CLOSURE base_GHCziIOziException_cannotCompactMutable_closure;
import CLOSURE base_GHCziIOziException_cannotCompactPinned_closure;
+#if !defined(UnregisterisedCompiler)
+import CLOSURE g0;
+import CLOSURE large_alloc_lim;
+#endif
//
// Allocate space for a new object in the compact region. We first try
diff --git a/rts/ContinuationOps.cmm b/rts/ContinuationOps.cmm
index f7437a6f73..2282dd9425 100644
--- a/rts/ContinuationOps.cmm
+++ b/rts/ContinuationOps.cmm
@@ -13,6 +13,23 @@
#include "Cmm.h"
import CLOSURE base_ControlziExceptionziBase_noMatchingContinuationPrompt_closure;
+#if !defined(UnregisterisedCompiler)
+import CLOSURE ALLOC_RTS_ctr;
+import CLOSURE ALLOC_RTS_tot;
+import CLOSURE ENT_CONTINUATION_ctr;
+import CLOSURE HEAP_CHK_ctr;
+import CLOSURE RtsFlags;
+import CLOSURE SLOW_CALL_fast_pv_ctr;
+import CLOSURE SLOW_CALL_fast_v_ctr;
+import CLOSURE STK_CHK_ctr;
+import CLOSURE UNKNOWN_CALL_ctr;import CLOSURE stg_PROMPT_TAG_info;
+import CLOSURE stg_ap_pv_info;
+import CLOSURE stg_ap_v_info;
+import CLOSURE stg_maskAsyncExceptionszh_ret_info;
+import CLOSURE stg_maskUninterruptiblezh_ret_info;
+import CLOSURE stg_prompt_frame_info;
+import CLOSURE stg_unmaskAsyncExceptionszh_ret_info;
+#endif
/* --------------------------------------------------------------------------
Prompts and prompt tags
diff --git a/rts/Exception.cmm b/rts/Exception.cmm
index f246d60a1e..6d040b37cd 100644
--- a/rts/Exception.cmm
+++ b/rts/Exception.cmm
@@ -17,6 +17,31 @@ import CLOSURE ghczmprim_GHCziTypes_True_closure;
import CLOSURE base_GHCziExceptionziType_divZZeroException_closure;
import CLOSURE base_GHCziExceptionziType_underflowException_closure;
import CLOSURE base_GHCziExceptionziType_overflowException_closure;
+#if !defined(UnregisterisedCompiler)
+import CLOSURE CATCHF_PUSHED_ctr;
+import CLOSURE RtsFlags;
+import CLOSURE SLOW_CALL_fast_pv_ctr;
+import CLOSURE SLOW_CALL_fast_v_ctr;
+import CLOSURE STK_CHK_ctr;
+import CLOSURE UNKNOWN_CALL_ctr;
+import CLOSURE g0;
+import CLOSURE large_alloc_lim;
+import CLOSURE no_break_on_exception;
+import CLOSURE rts_breakpoint_io_action;
+import CLOSURE rts_stop_on_exception;
+import CLOSURE stg_END_TSO_QUEUE_closure;
+import CLOSURE stg_NO_TREC_closure;
+import CLOSURE stg_ap_n_info;
+import CLOSURE stg_ap_ppv_info;
+import CLOSURE stg_ap_v_info;
+import CLOSURE stg_catch_frame_info;
+import CLOSURE stg_enter_info;
+import CLOSURE stg_maskAsyncExceptionszh_ret_info;
+import CLOSURE stg_maskUninterruptiblezh_ret_info;
+import CLOSURE stg_raise_ret_info;
+import CLOSURE stg_ret_p_info;
+import CLOSURE stg_unmaskAsyncExceptionszh_ret_info;
+#endif
/* -----------------------------------------------------------------------------
Exception Primitives
diff --git a/rts/HeapStackCheck.cmm b/rts/HeapStackCheck.cmm
index 8ab8356550..49abbe934b 100644
--- a/rts/HeapStackCheck.cmm
+++ b/rts/HeapStackCheck.cmm
@@ -20,6 +20,28 @@ import pthread_mutex_unlock;
import AcquireSRWLockExclusive;
import ReleaseSRWLockExclusives;
+#if !defined(UnregisterisedCompiler)
+import CLOSURE g0;
+import CLOSURE large_alloc_lim;
+import CLOSURE stg_MSG_THROWTO_info;
+import CLOSURE stg_MVAR_DIRTY_info;
+import CLOSURE stg_WHITEHOLE_info;
+import CLOSURE stg_arg_bitmaps;
+import CLOSURE stg_block_putmvar_info;
+import CLOSURE stg_block_readmvar_info;
+import CLOSURE stg_block_takemvar_info;
+import CLOSURE stg_block_throwto_info;
+import CLOSURE stg_enter_info;
+import CLOSURE stg_gc_fun_info;
+import CLOSURE stg_gc_prim_p_ll_info;
+import CLOSURE stg_gc_prim_pp_ll_info;
+import CLOSURE stg_ret_d_info;
+import CLOSURE stg_ret_f_info;
+import CLOSURE stg_ret_l_info;
+import CLOSURE stg_ret_n_info;
+import CLOSURE stg_ret_p_info;
+#endif
+
/* Stack/Heap Check Failure
* ------------------------
*
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index db4d53ea5f..fe74b3fa81 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -40,6 +40,60 @@ import CLOSURE ghczmprim_GHCziTypes_False_closure;
import CLOSURE CCS_MAIN;
#endif
+#if !defined(UnregisterisedCompiler)
+import CLOSURE ALLOC_RTS_ctr;
+import CLOSURE ALLOC_RTS_tot;
+import CLOSURE CCS_SYSTEM;
+import CLOSURE HEAP_CHK_ctr;
+import CLOSURE RtsFlags;
+import CLOSURE STK_CHK_ctr;
+import CLOSURE blocked_queue_hd;
+import CLOSURE blocked_queue_tl;
+import CLOSURE g0;
+import CLOSURE large_alloc_lim;
+import CLOSURE n_capabilities;
+import CLOSURE sleeping_queue;
+import CLOSURE stable_name_table;
+import CLOSURE stable_ptr_table;
+import CLOSURE stg_AP_STACK_info;
+import CLOSURE stg_AP_info;
+import CLOSURE stg_ARR_WORDS_info;
+import CLOSURE stg_BCO_info;
+import CLOSURE stg_C_FINALIZER_LIST_info;
+import CLOSURE stg_DEAD_WEAK_info;
+import CLOSURE stg_END_STM_WATCH_QUEUE_closure;
+import CLOSURE stg_END_TSO_QUEUE_closure;
+import CLOSURE stg_IND_info;
+import CLOSURE stg_MSG_NULL_info;
+import CLOSURE stg_MUT_ARR_PTRS_DIRTY_info;
+import CLOSURE stg_MUT_ARR_PTRS_FROZEN_CLEAN_info;
+import CLOSURE stg_MUT_ARR_PTRS_FROZEN_DIRTY_info;
+import CLOSURE stg_MUT_VAR_CLEAN_info;
+import CLOSURE stg_MUT_VAR_DIRTY_info;
+import CLOSURE stg_MVAR_CLEAN_info;
+import CLOSURE stg_MVAR_DIRTY_info;
+import CLOSURE stg_MVAR_TSO_QUEUE_info;
+import CLOSURE stg_NO_FINALIZER_closure;
+import CLOSURE stg_NO_TREC_closure;
+import CLOSURE stg_SMALL_MUT_ARR_PTRS_DIRTY_info;
+import CLOSURE stg_SMALL_MUT_ARR_PTRS_FROZEN_CLEAN_info;
+import CLOSURE stg_SMALL_MUT_ARR_PTRS_FROZEN_DIRTY_info;
+import CLOSURE stg_STABLE_NAME_info;
+import CLOSURE stg_TREC_HEADER_info;
+import CLOSURE stg_TVAR_DIRTY_info;
+import CLOSURE stg_WEAK_info;
+import CLOSURE stg_WHITEHOLE_info;
+import CLOSURE stg_ap_2_upd_info;
+import CLOSURE stg_atomically_frame_info;
+import CLOSURE stg_atomically_waiting_frame_info;
+import CLOSURE stg_catch_retry_frame_info;
+import CLOSURE stg_catch_stm_frame_info;
+import CLOSURE stg_keepAlive_frame_info;
+import CLOSURE stg_noDuplicate_info;
+import CLOSURE stg_ret_p_info;
+import CLOSURE stg_sel_0_upd_info;
+#endif
+
#if defined(DEBUG)
#define ASSERT_IN_BOUNDS(ind, sz) \
if (ind >= sz) { ccall rtsOutOfBoundsAccess(); }
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 097b8a1df4..64545d2e09 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -995,14 +995,14 @@ extern char **environ;
SymI_HasDataProto(stg_waitWritezh) \
SymI_HasDataProto(stg_writeTVarzh) \
SymI_HasDataProto(stg_yieldzh) \
- SymI_NeedsDataProto(stg_badAlignment_entry) \
- SymI_NeedsDataProto(stg_interp_constr1_entry) \
- SymI_NeedsDataProto(stg_interp_constr2_entry) \
- SymI_NeedsDataProto(stg_interp_constr3_entry) \
- SymI_NeedsDataProto(stg_interp_constr4_entry) \
- SymI_NeedsDataProto(stg_interp_constr5_entry) \
- SymI_NeedsDataProto(stg_interp_constr6_entry) \
- SymI_NeedsDataProto(stg_interp_constr7_entry) \
+ SymI_NeedsProto(stg_badAlignment_entry) \
+ SymI_NeedsProto(stg_interp_constr1_entry) \
+ SymI_NeedsProto(stg_interp_constr2_entry) \
+ SymI_NeedsProto(stg_interp_constr3_entry) \
+ SymI_NeedsProto(stg_interp_constr4_entry) \
+ SymI_NeedsProto(stg_interp_constr5_entry) \
+ SymI_NeedsProto(stg_interp_constr6_entry) \
+ SymI_NeedsProto(stg_interp_constr7_entry) \
SymI_HasDataProto(stg_arg_bitmaps) \
SymI_HasProto(large_alloc_lim) \
SymI_HasProto(g0) \
diff --git a/rts/StgMiscClosures.cmm b/rts/StgMiscClosures.cmm
index ff0ec062f8..20dc531a80 100644
--- a/rts/StgMiscClosures.cmm
+++ b/rts/StgMiscClosures.cmm
@@ -23,6 +23,28 @@ import whitehole_lockClosure_spin;
import whitehole_lockClosure_yield;
#endif
+#if !defined(UnregisterisedCompiler)
+import CLOSURE CCS_SYSTEM;
+import CLOSURE ENT_DYN_IND_ctr;
+import CLOSURE ENT_STATIC_IND_ctr;
+import CLOSURE ENT_VIA_NODE_ctr;
+import CLOSURE RtsFlags;
+import CLOSURE stg_BLOCKING_QUEUE_CLEAN_info;
+import CLOSURE stg_BLOCKING_QUEUE_DIRTY_info;
+import CLOSURE stg_IND_info;
+import CLOSURE stg_MSG_BLACKHOLE_info;
+import CLOSURE stg_TSO_info;
+import CLOSURE stg_apply_interp_info;
+import CLOSURE stg_enter_info;
+import CLOSURE stg_ret_d_info;
+import CLOSURE stg_ret_f_info;
+import CLOSURE stg_ret_l_info;
+import CLOSURE stg_ret_n_info;
+import CLOSURE stg_ret_p_info;
+import CLOSURE stg_ret_t_info;
+import CLOSURE stg_ret_v_info;
+#endif
+
/* ----------------------------------------------------------------------------
Stack underflow
------------------------------------------------------------------------- */
diff --git a/rts/StgStartup.cmm b/rts/StgStartup.cmm
index 388e27965e..cbdff480d9 100644
--- a/rts/StgStartup.cmm
+++ b/rts/StgStartup.cmm
@@ -12,6 +12,11 @@
#include "Cmm.h"
+#if !defined(UnregisterisedCompiler)
+import CLOSURE CCS_SYSTEM;
+import CLOSURE stg_dead_thread_info;
+#endif
+
/*
* This module contains the two entry points and the final exit point
* to/from the Haskell world. We can enter either by:
diff --git a/rts/StgStdThunks.cmm b/rts/StgStdThunks.cmm
index c4f5d25881..a4dc07d235 100644
--- a/rts/StgStdThunks.cmm
+++ b/rts/StgStdThunks.cmm
@@ -13,8 +13,13 @@
#include "Cmm.h"
#include "Updates.h"
-import ghczmprim_GHCziCString_unpackCStringzh_info;
-import ghczmprim_GHCziCString_unpackCStringUtf8zh_info;
+import CLOSURE ghczmprim_GHCziCString_unpackCStringzh_info;
+import CLOSURE ghczmprim_GHCziCString_unpackCStringUtf8zh_info;
+#if !defined(UnregisterisedCompiler)
+import CLOSURE STK_CHK_ctr;
+import CLOSURE stg_bh_upd_frame_info;
+import CLOSURE stg_upd_frame_info;
+#endif
/* -----------------------------------------------------------------------------
The code for a thunk that simply extracts a field from a
@@ -385,4 +390,3 @@ INFO_TABLE(stg_unpack_cstring_utf8, 0, 0, THUNK_STATIC, "stg_unpack_cstring_utf8
jump stg_do_unpack_cstring_utf8(node, newCAF_ret);
}
}
-
diff --git a/rts/Updates.cmm b/rts/Updates.cmm
index 57839216c4..c1de06c5e4 100644
--- a/rts/Updates.cmm
+++ b/rts/Updates.cmm
@@ -16,6 +16,13 @@
#include "Updates.h"
+#if !defined(UnregisterisedCompiler)
+import CLOSURE UPD_CON_IN_NEW_ctr;
+import CLOSURE UPD_OLD_IND_ctr;
+import CLOSURE UPD_NEW_IND_ctr;
+import CLOSURE stg_BLACKHOLE_info;
+#endif
+
/*
* The update code is PERFORMANCE CRITICAL, if you make any changes
* here make sure you eyeball the assembly and check that the fast
diff --git a/utils/genapply/Main.hs b/utils/genapply/Main.hs
index 34d793236f..f3b4c174dd 100644
--- a/utils/genapply/Main.hs
+++ b/utils/genapply/Main.hs
@@ -958,6 +958,32 @@ main = do
text "",
text "#include \"Cmm.h\"",
text "#include \"AutoApply.h\"",
+ text "#if !defined(UnregisterisedCompiler)",
+ text "import CLOSURE ALLOC_RTS_ctr;",
+ text "import CLOSURE ALLOC_RTS_tot;",
+ text "import CLOSURE HEAP_CHK_ctr;",
+ text "import CLOSURE RtsFlags;",
+ text "import CLOSURE stg_PAP_info;",
+ text "import CLOSURE stg_ap_d_info;",
+ text "import CLOSURE stg_ap_f_info;",
+ text "import CLOSURE stg_ap_l_info;",
+ text "import CLOSURE stg_ap_n_info;",
+ text "import CLOSURE stg_ap_p_info;",
+ text "import CLOSURE stg_ap_pp_info;",
+ text "import CLOSURE stg_ap_ppp_info;",
+ text "import CLOSURE stg_ap_pppp_info;",
+ text "import CLOSURE stg_ap_ppppp_info;",
+ text "import CLOSURE stg_ap_pppppp_info;",
+ text "import CLOSURE stg_ap_pppv_info;",
+ text "import CLOSURE stg_ap_ppv_info;",
+ text "import CLOSURE stg_ap_pv_info;",
+ text "import CLOSURE stg_ap_v16_info;",
+ text "import CLOSURE stg_ap_v32_info;",
+ text "import CLOSURE stg_ap_v64_info;",
+ text "import CLOSURE stg_ap_v_info;",
+ text "import CLOSURE stg_gc_fun_info;",
+ text "import CLOSURE stg_restore_cccs_info;",
+ text "#endif",
text "",
vcat (intersperse (text "") $