diff options
author | simonmar <unknown> | 2004-08-20 11:20:17 +0000 |
---|---|---|
committer | simonmar <unknown> | 2004-08-20 11:20:17 +0000 |
commit | fa93dff5b78e422d2d3abcc99f3918f6726a6719 (patch) | |
tree | 14da49cf1366d0dada454a9f8f64aaa669036cd7 | |
parent | 578d1788ceaae231a036d74777356b633c0368f6 (diff) | |
download | haskell-fa93dff5b78e422d2d3abcc99f3918f6726a6719.tar.gz |
[project @ 2004-08-20 11:20:16 by simonmar]
Give literal string labels a _str suffix, to make it less likely that
they'll clash with a symbol in scope in a C file.
-rw-r--r-- | ghc/compiler/cmm/CLabel.hs | 10 | ||||
-rw-r--r-- | ghc/compiler/codeGen/CgUtils.hs | 4 | ||||
-rw-r--r-- | ghc/driver/mangler/ghc-asm.lprl | 4 |
3 files changed, 14 insertions, 4 deletions
diff --git a/ghc/compiler/cmm/CLabel.hs b/ghc/compiler/cmm/CLabel.hs index ae470caa84..81f5ecac1d 100644 --- a/ghc/compiler/cmm/CLabel.hs +++ b/ghc/compiler/cmm/CLabel.hs @@ -28,6 +28,7 @@ module CLabel ( mkAltLabel, mkDefaultLabel, mkBitmapLabel, + mkStringLitLabel, mkClosureTblLabel, @@ -136,6 +137,9 @@ data CLabel | AsmTempLabel {-# UNPACK #-} !Unique + | StringLitLabel + {-# UNPACK #-} !Unique + | ModuleInitLabel Module -- the module name String -- its "way" @@ -249,6 +253,7 @@ mkReturnInfoLabel uniq = CaseLabel uniq CaseReturnInfo mkAltLabel uniq tag = CaseLabel uniq (CaseAlt tag) mkDefaultLabel uniq = CaseLabel uniq CaseDefault +mkStringLitLabel = StringLitLabel mkAsmTempLabel = AsmTempLabel mkModuleInitLabel = ModuleInitLabel @@ -351,6 +356,7 @@ needsCDecl (PlainModuleInitLabel _) = True needsCDecl ModuleRegdLabel = False needsCDecl (CaseLabel _ _) = False +needsCDecl (StringLitLabel _) = False needsCDecl (AsmTempLabel _) = False needsCDecl (RtsLabel _) = False needsCDecl (ForeignLabel _ _ _) = False @@ -372,6 +378,7 @@ isAsmTemp _ = False externallyVisibleCLabel :: CLabel -> Bool -- not C "static" externallyVisibleCLabel (CaseLabel _ _) = False +externallyVisibleCLabel (StringLitLabel _) = False externallyVisibleCLabel (AsmTempLabel _) = False externallyVisibleCLabel (ModuleInitLabel _ _)= True externallyVisibleCLabel (PlainModuleInitLabel _)= True @@ -536,6 +543,9 @@ pprAsmCLbl (ForeignLabel fs (Just sz) _) pprAsmCLbl lbl = pprCLbl lbl +pprCLbl (StringLitLabel u) + = pprUnique u <> ptext SLIT("_str") + pprCLbl (CaseLabel u CaseReturnPt) = hcat [pprUnique u, ptext SLIT("_ret")] pprCLbl (CaseLabel u CaseReturnInfo) diff --git a/ghc/compiler/codeGen/CgUtils.hs b/ghc/compiler/codeGen/CgUtils.hs index 9d789be942..ffd25eb908 100644 --- a/ghc/compiler/codeGen/CgUtils.hs +++ b/ghc/compiler/codeGen/CgUtils.hs @@ -48,7 +48,7 @@ import MachOp ( MachRep(..), wordRep, MachOp(..), MachHint(..), mo_wordULt, machRepByteWidth ) import ForeignCall ( CCallConv(..) ) import Literal ( Literal(..) ) -import CLabel ( CLabel, mkAsmTempLabel ) +import CLabel ( CLabel, mkStringLitLabel ) import Digraph ( SCC(..), stronglyConnComp ) import ListSetOps ( assocDefault ) import Util ( filterOut, sortLe ) @@ -302,7 +302,7 @@ mkStringCLit :: String -> FCode CmmLit -- and return its label mkStringCLit str = do { uniq <- newUnique - ; let lbl = mkAsmTempLabel uniq + ; let lbl = mkStringLitLabel uniq ; emitData ReadOnlyData [CmmDataLabel lbl, CmmString str] ; return (CmmLabel lbl) } diff --git a/ghc/driver/mangler/ghc-asm.lprl b/ghc/driver/mangler/ghc-asm.lprl index fbcd93441a..ec3fe5942e 100644 --- a/ghc/driver/mangler/ghc-asm.lprl +++ b/ghc/driver/mangler/ghc-asm.lprl @@ -494,8 +494,8 @@ sub mangle_asm { $chkcat[$i] = 'data'; $chksymb[$i] = ''; - # Labels beginning "_c": these are literal strings. - } elsif ( /^${T_US}_c.*$/ ) { + # Labels ending "_str": these are literal strings. + } elsif ( /^${T_US}([A-Za-z0-9_]+)_str${T_POST_LBL}$/ ) { $chk[++$i] = $_; $chkcat[$i] = 'rodata'; $chksymb[$i] = ''; |