[commit: ghc] master: Fix rare undefined asm temp end label error in x86 (3c452d0)

git at git.haskell.org git at git.haskell.org
Sun Oct 28 17:41:06 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/3c452d0dce33cb06ef739f4e44549a499277e11b/ghc

>---------------------------------------------------------------

commit 3c452d0dce33cb06ef739f4e44549a499277e11b
Author: Zejun Wu <watashi at fb.com>
Date:   Sun Oct 28 12:22:25 2018 -0400

    Fix rare undefined asm temp end label error in x86
    
    Summary:
    Encountered assembly error due to undefined label `.LcaDcU_info_end` for
    following code generated by `pprFrameProc`:
    
    ```
    .Lsat_sa8fp{v}_info_fde_end:
      .long .Lblock{v caDcU}_info_fde_end-.Lblock{v caDcU}_info_fde
    .Lblock{v caDcU}_info_fde:
      .long _nbHlD-.Lsection_frame
      .quad block{v caDcU}_info-1
      .quad .Lblock{v caDcU}_info_end-block{v caDcU}_info+1
      .byte 1
    ```
    
    This diff fixed the error.
    
    Test Plan:
      ./validate
    
    Also the case where we used to have assembly error is now fixed.
    Unfortunately, I have limited insight here and cannot get a small enough repro
    or test case for this.
    
    Ben says:
    
    > I think I see: Previously we only produced end symbols for the info
    > tables of top-level procedures. However, blocks within a procedure may
    > also have info tables, we will dutifully generate debug information for
    > and consequently we get undefined symbols.
    
    Reviewers: simonmar, scpmw, last_g, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, carter
    
    Differential Revision: https://phabricator.haskell.org/D5246


>---------------------------------------------------------------

3c452d0dce33cb06ef739f4e44549a499277e11b
 compiler/nativeGen/X86/Ppr.hs | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs
index 03d4fce..808d22a 100644
--- a/compiler/nativeGen/X86/Ppr.hs
+++ b/compiler/nativeGen/X86/Ppr.hs
@@ -115,8 +115,6 @@ pprNatCmmDecl proc@(CmmProc top_info lbl _ (ListGraph blocks)) =
             <+> char '-'
             <+> ppr (mkDeadStripPreventer info_lbl)
        else empty) $$
-      (if debugLevel dflags > 0
-       then ppr (mkAsmTempEndLabel info_lbl) <> char ':' else empty) $$
       pprSizeDecl info_lbl
 
 -- | Output the ELF .size directive.
@@ -130,20 +128,23 @@ pprSizeDecl lbl
 pprBasicBlock :: LabelMap CmmStatics -> NatBasicBlock Instr -> SDoc
 pprBasicBlock info_env (BasicBlock blockid instrs)
   = sdocWithDynFlags $ \dflags ->
-    maybe_infotable $$
+    maybe_infotable dflags $
     pprLabel asmLbl $$
     vcat (map pprInstr instrs) $$
     (if debugLevel dflags > 0
      then ppr (mkAsmTempEndLabel asmLbl) <> char ':' else empty)
   where
     asmLbl = blockLbl blockid
-    maybe_infotable = case mapLookup blockid info_env of
-       Nothing   -> empty
-       Just (Statics info_lbl info) ->
+    maybe_infotable dflags c = case mapLookup blockid info_env of
+       Nothing -> c
+       Just (Statics infoLbl info) ->
            pprAlignForSection Text $$
            infoTableLoc $$
            vcat (map pprData info) $$
-           pprLabel info_lbl
+           pprLabel infoLbl $$
+           c $$
+           (if debugLevel dflags > 0
+            then ppr (mkAsmTempEndLabel infoLbl) <> char ':' else empty)
     -- Make sure the info table has the right .loc for the block
     -- coming right after it. See [Note: Info Offset]
     infoTableLoc = case instrs of



More information about the ghc-commits mailing list