summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2018-03-25 15:34:27 -0400
committerBen Gamari <ben@smart-cactus.org>2018-03-25 15:34:34 -0400
commit0cbb13b3dfd70b4c9665109cd6c4a150cb7b99df (patch)
tree5b3bb844993ca9d77199f7d96dfda175ccb62db1
parent20f14b4fd4eaf2c3ab375b8fc6d40ee9e6db94fd (diff)
downloadhaskell-0cbb13b3dfd70b4c9665109cd6c4a150cb7b99df.tar.gz
Don't refer to blocks in debug info when -g1
-g1 removes block information, but it turns out that procs can refer to block information through parents. Note [Splitting DebugBlocks] explains the parentage relationship. Test Plan: * ./validate * added a new test Reviewers: bgamari, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14894 Differential Revision: https://phabricator.haskell.org/D4496
-rw-r--r--compiler/nativeGen/Dwarf.hs11
-rw-r--r--testsuite/tests/simplCore/should_run/T14894.hs9
-rw-r--r--testsuite/tests/simplCore/should_run/T14894.stdout1
-rw-r--r--testsuite/tests/simplCore/should_run/all.T1
4 files changed, 20 insertions, 2 deletions
diff --git a/compiler/nativeGen/Dwarf.hs b/compiler/nativeGen/Dwarf.hs
index db1695864d..0e645a2a56 100644
--- a/compiler/nativeGen/Dwarf.hs
+++ b/compiler/nativeGen/Dwarf.hs
@@ -182,10 +182,17 @@ procToDwarf df prc
_otherwise -> showSDocDump df $ ppr $ dblLabel prc
, dwLabel = dblCLabel prc
, dwParent = fmap mkAsmTempDieLabel
- $ mfilter (/= dblCLabel prc)
+ $ mfilter goodParent
$ fmap dblCLabel (dblParent prc)
- -- Omit parent if it would be self-referential
}
+ where
+ goodParent a | a == dblCLabel prc = False
+ -- Omit parent if it would be self-referential
+ goodParent a | not (externallyVisibleCLabel a)
+ , debugLevel df < 2 = False
+ -- We strip block information when running -g0 or -g1, don't
+ -- refer to blocks in that case. Fixes #14894.
+ goodParent _ = True
-- | Generate DWARF info for a block
blockToDwarf :: DynFlags -> DebugBlock -> DwarfInfo
diff --git a/testsuite/tests/simplCore/should_run/T14894.hs b/testsuite/tests/simplCore/should_run/T14894.hs
new file mode 100644
index 0000000000..420b85e466
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T14894.hs
@@ -0,0 +1,9 @@
+{-# OPTIONS_GHC -g1 -O #-}
+import System.Environment
+summap :: (Int -> Int) -> (Int -> Int)
+summap f n = f 10
+{-# NOINLINE summap #-}
+
+main = do
+ n <- length `fmap` getArgs
+ print $ summap (+ n) n
diff --git a/testsuite/tests/simplCore/should_run/T14894.stdout b/testsuite/tests/simplCore/should_run/T14894.stdout
new file mode 100644
index 0000000000..f599e28b8a
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T14894.stdout
@@ -0,0 +1 @@
+10
diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T
index d1ea496af3..d697605754 100644
--- a/testsuite/tests/simplCore/should_run/all.T
+++ b/testsuite/tests/simplCore/should_run/all.T
@@ -82,3 +82,4 @@ test('T14768', reqlib('vector'), compile_and_run, [''])
test('T14868',
[when((arch('powerpc64') or arch('powerpc64le')), expect_broken(11261))],
compile_and_run, [''])
+test('T14894', normal, compile_and_run, [''])