[commit: ghc] wip/kavon-nosplit-llvm: adding linux support for table inserter (79dd250)
git at git.haskell.org
git at git.haskell.org
Wed Sep 6 13:47:15 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/kavon-nosplit-llvm
Link : http://ghc.haskell.org/trac/ghc/changeset/79dd250fb3dcb6e220f32a5fb2d8e59e562860d3/ghc
>---------------------------------------------------------------
commit 79dd250fb3dcb6e220f32a5fb2d8e59e562860d3
Author: Kavon Farvardin <kavon at farvard.in>
Date: Wed Sep 6 14:46:47 2017 +0100
adding linux support for table inserter
>---------------------------------------------------------------
79dd250fb3dcb6e220f32a5fb2d8e59e562860d3
compiler/llvmGen/LlvmMangler.hs | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/compiler/llvmGen/LlvmMangler.hs b/compiler/llvmGen/LlvmMangler.hs
index a21b135..25c46dc 100644
--- a/compiler/llvmGen/LlvmMangler.hs
+++ b/compiler/llvmGen/LlvmMangler.hs
@@ -12,9 +12,9 @@
module LlvmMangler ( llvmFixupAsm, ManglerInfo, ManglerStr ) where
import DynFlags ( DynFlags, targetPlatform )
-import Platform ( platformArch, Arch(..) )
+import Platform ( platformArch, Arch(..), platformOS, OS(..) )
import ErrUtils ( withTiming )
-import Outputable ( text )
+import Outputable ( text, panic )
import Control.Exception
import qualified Data.ByteString.Char8 as B
@@ -80,15 +80,22 @@ type LabRewrite = State -> Rewrite
-- | This rewrite looks for return points of a llvm.cpscall and adds GC info
-- above that label.
addInfoTable :: LabelMap ManglerStr -> LabRewrite
-addInfoTable info FirstLabel _ line = do
+addInfoTable info FirstLabel dflags line = do
retPt <- B.stripPrefix labPrefix line
(i, _) <- B.readInt retPt
statics <- mapLookup (toKey i) info
fullName <- B.stripSuffix colon line
return $ B.concat $ (map (\f -> f fullName) statics) ++ [line]
where
- -- TODO(kavon): check if prefix changes on different platforms.
- labPrefix = B.pack "L"
+
+ -- At a minimum, Mac and Linux assembly output from LLVM use different prefixes
+ -- basic block labels. It may be the case that one of the prefixes is very common,
+ -- but I have not looked into it (kavon)
+ labPrefix = case platformOS (targetPlatform dflags) of
+ OSDarwin -> B.pack "L"
+ OSLinux -> B.pack ".L"
+ otherwise -> panic "Please update LLVM Mangler for this OS."
+
colon = B.pack ":"
toKey = uniqueToLbl . intToUnique
More information about the ghc-commits
mailing list