[Git][ghc/ghc][master] TNTC: set CmmProc entry_label properly (#25565)

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sat Dec 14 09:31:31 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
62a2b25f by Sylvain Henry at 2024-12-14T04:31:09-05:00
TNTC: set CmmProc entry_label properly (#25565)

Before this patch we were renaming the entry label of a CmmProc late in
the CmmToAsm pass. It led to inconsistencies and to some labels being
used in info tables but not being emitted (#25565).
Now we set the CmmProc entry label earlier in the StgToCmm monad and we
don't renamed it afterwards.

- - - - -


2 changed files:

- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/StgToCmm/Monad.hs


Changes:

=====================================
compiler/GHC/CmmToAsm/X86/Ppr.hs
=====================================
@@ -76,14 +76,11 @@ pprNatCmmDecl config proc@(CmmProc top_info entry_lbl _ (ListGraph blocks)) =
   let platform = ncgPlatform config
       top_info_table = topInfoTable proc
       -- we need a label to delimit the proc code (e.g. in debug builds). When
-      -- we have an info table, we reuse the info table label. Otherwise we make
-      -- a fresh "entry" label from the label of the entry block. We can't reuse
-      -- the entry block label as-is, otherwise we get redundant labels:
-      -- delimiters for the entry block and for the whole proc are the same (see
-      -- #22792).
+      -- we have an info table, we reuse the info table label. Otherwise we use
+      -- the entry label.
       proc_lbl = case top_info_table of
         Just (CmmStaticsRaw info_lbl _) -> info_lbl
-        Nothing                         -> toProcDelimiterLbl entry_lbl
+        Nothing                         -> entry_lbl
 
       -- handle subsections_via_symbols when enabled and when we have an
       -- info-table to link to. See Note [Subsections Via Symbols]


=====================================
compiler/GHC/StgToCmm/Monad.hs
=====================================
@@ -798,7 +798,17 @@ emitProc mb_info lbl live blocks offset do_layout
               tinfo = TopInfo { info_tbls = DWrap infos
                               , stack_info=sinfo}
 
-              proc_block = CmmProc tinfo lbl live blks
+              -- we must be careful to:
+              -- 1. not emit a proc label twice (#22792)
+              -- 2. emit it at least once! (#25565)
+              --
+              -- (2) happened because the entry label was the label of a basic
+              -- block that got dropped (empty basic block...), hence we never
+              -- generated a label for it after we fixed (1) where we were
+              -- always emitting entry label.
+              proc_lbl = toProcDelimiterLbl lbl
+
+              proc_block = CmmProc tinfo proc_lbl live blks
 
         ; state <- getState
         ; setState $ state { cgs_tops = cgs_tops state `snocOL` proc_block } }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62a2b25f6cd1947c85a7d847a8f88bb0de5d80fd

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/62a2b25f6cd1947c85a7d847a8f88bb0de5d80fd
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/20241214/7b182e02/attachment-0001.html>


More information about the ghc-commits mailing list