[commit: ghc] master: x86 codegen: don't generate location comments (e272ab9)

git at git.haskell.org git at git.haskell.org
Thu Oct 29 23:04:34 UTC 2015


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

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

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

commit e272ab99f60884e5c510c9597fbdb1a570eedcaa
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date:   Thu Oct 29 23:03:42 2015 +0000

    x86 codegen: don't generate location comments
    
    The following source snippet 'module A where x */* y = 42'
    when being compiled with '-g' option emits syntactically
    invalid comment for GNU as:
    
        .text
            .align 8
            .loc 1 3 1 /* */* */
    
    Fixed by not emitting comments at all. We already suppress
    all asm comments in 'X86/Ppr.hs'.
    
    Signed-off-by: Sergei Trofimovich <siarheit at google.com>
    
    Test Plan: added test and check it works
    
    Reviewers: scpmw, simonmar, austin, bgamari
    
    Reviewed By: simonmar
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1386
    
    GHC Trac Issues: #10667


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

e272ab99f60884e5c510c9597fbdb1a570eedcaa
 compiler/nativeGen/X86/Ppr.hs                    | 5 ++---
 testsuite/tests/codeGen/should_compile/T10667.hs | 6 ++++++
 testsuite/tests/codeGen/should_compile/all.T     | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs
index ce63cae..0c9507a 100644
--- a/compiler/nativeGen/X86/Ppr.hs
+++ b/compiler/nativeGen/X86/Ppr.hs
@@ -506,9 +506,8 @@ pprInstr (COMMENT _) = empty -- nuke 'em
 pprInstr (COMMENT s) = ptext (sLit "# ") <> ftext s
 -}
 
-pprInstr (LOCATION file line col name)
-   = ptext (sLit "\t.loc ") <> ppr file <+> ppr line <+> ppr col <>
-     ptext (sLit " /* ") <> text name <> ptext (sLit " */")
+pprInstr (LOCATION file line col _name)
+   = ptext (sLit "\t.loc ") <> ppr file <+> ppr line <+> ppr col
 
 pprInstr (DELTA d)
    = pprInstr (COMMENT (mkFastString ("\tdelta = " ++ show d)))
diff --git a/testsuite/tests/codeGen/should_compile/T10667.hs b/testsuite/tests/codeGen/should_compile/T10667.hs
new file mode 100644
index 0000000..665c764
--- /dev/null
+++ b/testsuite/tests/codeGen/should_compile/T10667.hs
@@ -0,0 +1,6 @@
+module A where
+
+-- when used with '-g' debug generation option
+-- '*/*' leaked into a /* comment */ and broke
+-- GNU as.
+x */* y = 42
diff --git a/testsuite/tests/codeGen/should_compile/all.T b/testsuite/tests/codeGen/should_compile/all.T
index d4e12fc..a8ca738 100644
--- a/testsuite/tests/codeGen/should_compile/all.T
+++ b/testsuite/tests/codeGen/should_compile/all.T
@@ -31,3 +31,4 @@ test('debug', extra_clean(['debug.cmm']),
      ['$MAKE -s --no-print-directory debug'])
 test('T9964', normal, compile, ['-O'])
 test('T10518', [cmm_src], compile, [''])
+test('T10667', normal, compile, ['-g'])



More information about the ghc-commits mailing list