summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/cmm/CLabel.hs15
-rw-r--r--testsuite/tests/codeGen/should_compile/Makefile5
-rw-r--r--testsuite/tests/codeGen/should_compile/T15723.stderr2
-rw-r--r--testsuite/tests/codeGen/should_compile/T15723A.hs9
-rw-r--r--testsuite/tests/codeGen/should_compile/T15723B.hs6
-rw-r--r--testsuite/tests/codeGen/should_compile/all.T5
6 files changed, 38 insertions, 4 deletions
diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
index f07abebf50..dbb92e5f41 100644
--- a/compiler/cmm/CLabel.hs
+++ b/compiler/cmm/CLabel.hs
@@ -1019,7 +1019,7 @@ labelDynamic dflags this_mod lbl =
case lbl of
-- is the RTS in a DLL or not?
RtsLabel _ ->
- (gopt Opt_ExternalDynamicRefs dflags) && (this_pkg /= rtsUnitId)
+ externalDynamicRefs && (this_pkg /= rtsUnitId)
IdLabel n _ _ ->
isDllName dflags this_mod n
@@ -1028,7 +1028,7 @@ labelDynamic dflags this_mod lbl =
-- its own shared library.
CmmLabel pkg _ _
| os == OSMinGW32 ->
- (gopt Opt_ExternalDynamicRefs dflags) && (this_pkg /= pkg)
+ externalDynamicRefs && (this_pkg /= pkg)
| otherwise ->
gopt Opt_ExternalDynamicRefs dflags
@@ -1048,19 +1048,26 @@ labelDynamic dflags this_mod lbl =
-- When compiling in the "dyn" way, each package is to be
-- linked into its own DLL.
ForeignLabelInPackage pkgId ->
- (gopt Opt_ExternalDynamicRefs dflags) && (this_pkg /= pkgId)
+ externalDynamicRefs && (this_pkg /= pkgId)
else -- On Mac OS X and on ELF platforms, false positives are OK,
-- so we claim that all foreign imports come from dynamic
-- libraries
True
+ CC_Label cc ->
+ externalDynamicRefs && not (ccFromThisModule cc this_mod)
+
+ -- CCS_Label always contains a CostCentre defined in the current module
+ CCS_Label _ -> False
+
HpcTicksLabel m ->
- (gopt Opt_ExternalDynamicRefs dflags) && this_mod /= m
+ externalDynamicRefs && this_mod /= m
-- Note that DynamicLinkerLabels do NOT require dynamic linking themselves.
_ -> False
where
+ externalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags
os = platformOS (targetPlatform dflags)
this_pkg = moduleUnitId this_mod
diff --git a/testsuite/tests/codeGen/should_compile/Makefile b/testsuite/tests/codeGen/should_compile/Makefile
index a1fc58f89b..c0729443c9 100644
--- a/testsuite/tests/codeGen/should_compile/Makefile
+++ b/testsuite/tests/codeGen/should_compile/Makefile
@@ -38,3 +38,8 @@ T14999:
T15196:
'$(TEST_HC)' $(TEST_HC_OPTS) -c -O -ddump-asm T15196.hs | grep "jp " ; echo $$?
+
+T15723:
+ '$(TEST_HC)' $(TEST_HC_OPTS) -prof -fPIC -fexternal-dynamic-refs -fforce-recomp -O2 -c T15723A.hs -o T15723A.o
+ '$(TEST_HC)' $(TEST_HC_OPTS) -prof -fPIC -fexternal-dynamic-refs -fforce-recomp -O2 -c T15723B.hs -o T15723B.o
+ '$(TEST_HC)' $(TEST_HC_OPTS) -dynamic -shared T15723B.o -o T15723B.so
diff --git a/testsuite/tests/codeGen/should_compile/T15723.stderr b/testsuite/tests/codeGen/should_compile/T15723.stderr
new file mode 100644
index 0000000000..cd2812b10c
--- /dev/null
+++ b/testsuite/tests/codeGen/should_compile/T15723.stderr
@@ -0,0 +1,2 @@
+Warning: -rtsopts and -with-rtsopts have no effect with -shared.
+ Call hs_init_ghc() from your main() function to set these options.
diff --git a/testsuite/tests/codeGen/should_compile/T15723A.hs b/testsuite/tests/codeGen/should_compile/T15723A.hs
new file mode 100644
index 0000000000..aa47ece6ec
--- /dev/null
+++ b/testsuite/tests/codeGen/should_compile/T15723A.hs
@@ -0,0 +1,9 @@
+module T15723A where
+
+{-# INLINE foo #-}
+foo :: Int -> Int
+foo x = {-# SCC foo1 #-} bar x
+
+{-# NOINLINE bar #-}
+bar :: Int -> Int
+bar x = x
diff --git a/testsuite/tests/codeGen/should_compile/T15723B.hs b/testsuite/tests/codeGen/should_compile/T15723B.hs
new file mode 100644
index 0000000000..5b7b44d2f6
--- /dev/null
+++ b/testsuite/tests/codeGen/should_compile/T15723B.hs
@@ -0,0 +1,6 @@
+module T15723B where
+
+import T15723A
+
+test :: Int -> Int
+test x = {-# SCC test1 #-} foo $ foo x
diff --git a/testsuite/tests/codeGen/should_compile/all.T b/testsuite/tests/codeGen/should_compile/all.T
index a5d5a47034..f8e2fb0033 100644
--- a/testsuite/tests/codeGen/should_compile/all.T
+++ b/testsuite/tests/codeGen/should_compile/all.T
@@ -46,3 +46,8 @@ test('T15196',
[ unless(arch('x86_64'),skip),
only_ways('normal'),
], run_command, ['$MAKE -s --no-print-directory T15196'])
+
+test('T15723',
+ [ unless(have_profiling(), skip),
+ unless(have_dynamic(), skip),
+ ], run_command, ['$MAKE -s --no-print-directory T15723'])