[commit: ghc] master: Mark system and internal symbols as private symbols in asm (64c54ff)
git at git.haskell.org
git at git.haskell.org
Fri Sep 14 14:09:22 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/64c54fff2d6534e1229359a8d357ec1dc6c21b73/ghc
>---------------------------------------------------------------
commit 64c54fff2d6534e1229359a8d357ec1dc6c21b73
Author: Sergei Azovskov <lastg at fb.com>
Date: Fri Sep 14 14:56:37 2018 +0100
Mark system and internal symbols as private symbols in asm
Summary:
This marks system and internal symbols as private in asm output so those
random generated sysmbols won't appear in .symtab
Reasoning:
* internal symbols don't help to debug because names are just random
* the symbols style breaks perf logic
* internal symbols can take ~75% of the .symtab. In the same time
.symtab can take about 20% of the binary file size
Notice:
This diff mostly makes sense on top of the D4713 (or similar)
Test Plan:
tests
Perf from D4713
```
7.97% FibbSlow FibbSlow [.] c3rM_info
6.75% FibbSlow FibbSlow [.] 0x000000000032cfa8
6.63% FibbSlow FibbSlow [.] cifA_info
4.98% FibbSlow FibbSlow [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
4.55% FibbSlow FibbSlow [.] chXn_info
4.52% FibbSlow FibbSlow [.] c3rH_info
4.45% FibbSlow FibbSlow [.] chZB_info
4.04% FibbSlow FibbSlow [.] Main_fibbzuslow_info
4.03% FibbSlow FibbSlow [.] stg_ap_0_fast
3.76% FibbSlow FibbSlow [.] chXA_info
3.67% FibbSlow FibbSlow [.] cifu_info
3.25% FibbSlow FibbSlow [.] ci4r_info
2.64% FibbSlow FibbSlow [.] s3rf_info
2.42% FibbSlow FibbSlow [.] s3rg_info
2.39% FibbSlow FibbSlow [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
2.25% FibbSlow FibbSlow [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
2.17% FibbSlow FibbSlow [.] ghczmprim_GHCziClasses_zeze_info
2.09% FibbSlow FibbSlow [.] cicc_info
2.03% FibbSlow FibbSlow [.] 0x0000000000331e15
2.02% FibbSlow FibbSlow [.] s3ri_info
1.91% FibbSlow FibbSlow [.] 0x0000000000331bb8
1.89% FibbSlow FibbSlow [.] ci4N_info
...
```
Perf from this patch:
```
15.37% FibbSlow FibbSlow [.] Main_fibbzuslow_info
15.33% FibbSlow FibbSlow [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
13.34% FibbSlow FibbSlow [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
9.24% FibbSlow FibbSlow [.] integerzmgmp_GHCziIntegerziType_plusInteger_info
9.08% FibbSlow FibbSlow [.] frame_dummy
8.25% FibbSlow FibbSlow [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
4.29% FibbSlow FibbSlow [.] 0x0000000000321ab0
3.84% FibbSlow FibbSlow [.] stg_ap_0_fast
3.07% FibbSlow FibbSlow [.] ghczmprim_GHCziClasses_zeze_info
2.39% FibbSlow FibbSlow [.] 0x0000000000321ab7
1.90% FibbSlow FibbSlow [.] 0x00000000003266b8
1.88% FibbSlow FibbSlow [.] base_GHCziNum_zm_info
1.83% FibbSlow FibbSlow [.] 0x0000000000326915
1.34% FibbSlow FibbSlow [.] 0x00000000003248cc
1.07% FibbSlow FibbSlow [.] base_GHCziNum_zp_info
0.98% FibbSlow FibbSlow [.] 0x00000000003247c8
0.80% FibbSlow FibbSlow [.] 0x0000000000121498
0.79% FibbSlow FibbSlow [.] stg_gc_noregs
0.75% FibbSlow FibbSlow [.] 0x0000000000321ad6
0.67% FibbSlow FibbSlow [.] 0x0000000000321aca
0.64% FibbSlow FibbSlow [.] 0x0000000000321b4a
0.61% FibbSlow FibbSlow [.] 0x00000000002ff633
```
Reviewers: simonmar, niteria, bgamari
Reviewed By: simonmar
Subscribers: lelf, angerman, olsner, rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4722
>---------------------------------------------------------------
64c54fff2d6534e1229359a8d357ec1dc6c21b73
compiler/cmm/CLabel.hs | 55 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 17 deletions(-)
diff --git a/compiler/cmm/CLabel.hs b/compiler/cmm/CLabel.hs
index 1a9bc73..1ba0d89 100644
--- a/compiler/cmm/CLabel.hs
+++ b/compiler/cmm/CLabel.hs
@@ -1135,20 +1135,12 @@ instance Outputable CLabel where
pprCLabel :: Platform -> CLabel -> SDoc
-pprCLabel platform (LocalBlockLabel u)
- = getPprStyle $ \ sty ->
- if asmStyle sty then
- ptext (asmTempLabelPrefix platform) <> pprUniqueAlways u
- else
- char '_' <> pprUniqueAlways u
+pprCLabel _ (LocalBlockLabel u)
+ = tempLabelPrefixOrUnderscore <> pprUniqueAlways u
pprCLabel platform (AsmTempLabel u)
| not (platformUnregisterised platform)
- = getPprStyle $ \ sty ->
- if asmStyle sty then
- ptext (asmTempLabelPrefix platform) <> pprUniqueAlways u
- else
- char '_' <> pprUniqueAlways u
+ = tempLabelPrefixOrUnderscore <> pprUniqueAlways u
pprCLabel platform (AsmTempDerivedLabel l suf)
| cGhcWithNativeCodeGen == "YES"
@@ -1168,7 +1160,15 @@ pprCLabel _ PicBaseLabel
pprCLabel platform (DeadStripPreventer lbl)
| cGhcWithNativeCodeGen == "YES"
- = pprCLabel platform lbl <> text "_dsp"
+ =
+ {-
+ `lbl` can be temp one but we need to ensure that dsp label will stay
+ in the final binary so we prepend non-temp prefix ("dsp_") and
+ optional `_` (underscore) because this is how you mark non-temp symbols
+ on some platforms (Darwin)
+ -}
+ maybe_underscore $ text "dsp_"
+ <> pprCLabel platform lbl <> text "_dsp"
pprCLabel _ (StringLitLabel u)
| cGhcWithNativeCodeGen == "YES"
@@ -1199,9 +1199,11 @@ pprCLbl (StringLitLabel u)
= pprUniqueAlways u <> text "_str"
pprCLbl (SRTLabel u)
- = pprUniqueAlways u <> pp_cSEP <> text "srt"
+ = tempLabelPrefixOrUnderscore <> pprUniqueAlways u <> pp_cSEP <> text "srt"
-pprCLbl (LargeBitmapLabel u) = text "b" <> pprUniqueAlways u <> pp_cSEP <> text "btm"
+pprCLbl (LargeBitmapLabel u) =
+ tempLabelPrefixOrUnderscore
+ <> char 'b' <> pprUniqueAlways u <> pp_cSEP <> text "btm"
-- Some bitsmaps for tuple constructors have a numeric tag (e.g. '7')
-- until that gets resolved we'll just force them to start
-- with a letter so the label will be legal assembly code.
@@ -1211,7 +1213,8 @@ pprCLbl (CmmLabel _ str CmmCode) = ftext str
pprCLbl (CmmLabel _ str CmmData) = ftext str
pprCLbl (CmmLabel _ str CmmPrimCall) = ftext str
-pprCLbl (LocalBlockLabel u) = text "blk_" <> pprUniqueAlways u
+pprCLbl (LocalBlockLabel u) =
+ tempLabelPrefixOrUnderscore <> text "blk_" <> pprUniqueAlways u
pprCLbl (RtsLabel (RtsApFast str)) = ftext str <> text "_fast"
@@ -1275,7 +1278,8 @@ pprCLbl (RtsLabel (RtsSlowFastTickyCtr pat))
pprCLbl (ForeignLabel str _ _ _)
= ftext str
-pprCLbl (IdLabel name _cafs flavor) = ppr name <> ppIdFlavor flavor
+pprCLbl (IdLabel name _cafs flavor) =
+ internalNamePrefix name <> ppr name <> ppIdFlavor flavor
pprCLbl (CC_Label cc) = ppr cc
pprCLbl (CCS_Label ccs) = ppr ccs
@@ -1318,6 +1322,24 @@ instance Outputable ForeignLabelSource where
ForeignLabelInThisPackage -> parens $ text "this package"
ForeignLabelInExternalPackage -> parens $ text "external package"
+internalNamePrefix :: Name -> SDoc
+internalNamePrefix name = getPprStyle $ \ sty ->
+ if codeStyle sty && isRandomGenerated then
+ sdocWithPlatform $ \platform ->
+ ptext (asmTempLabelPrefix platform)
+ else
+ empty
+ where
+ isRandomGenerated = not $ isExternalName name
+
+tempLabelPrefixOrUnderscore :: SDoc
+tempLabelPrefixOrUnderscore = sdocWithPlatform $ \platform ->
+ getPprStyle $ \ sty ->
+ if asmStyle sty then
+ ptext (asmTempLabelPrefix platform)
+ else
+ char '_'
+
-- -----------------------------------------------------------------------------
-- Machine-dependent knowledge about labels.
@@ -1390,4 +1412,3 @@ pprDynamicLinkerAsmLabel platform dllInfo lbl =
SymbolPtr -> text ".LC_" <> ppr lbl
GotSymbolPtr -> ppr lbl <> text "@got"
GotSymbolOffset -> ppr lbl <> text "@gotoff"
-
More information about the ghc-commits
mailing list