summaryrefslogtreecommitdiff
path: root/compiler/llvmGen/LlvmCodeGen/Data.hs
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2014-11-21 21:05:25 +0100
committerHerbert Valerio Riedel <hvr@gnu.org>2014-11-21 22:32:16 +0100
commite16a342d70b92fc8480793d3ec911853f0c31e44 (patch)
treea566c89ae63c6953a68ecf0292c27c9f781b0e59 /compiler/llvmGen/LlvmCodeGen/Data.hs
parent2a523ebf091478aea39deef28073320bed628434 (diff)
downloadhaskell-e16a342d70b92fc8480793d3ec911853f0c31e44.tar.gz
llvmGen: Compatibility with LLVM 3.5 (re #9142)
Due to changes in LLVM 3.5 aliases now may only refer to definitions. Previously to handle symbols defined outside of the current commpilation unit GHC would emit both an `external` declaration, as well as an alias pointing to it, e.g., @stg_BCO_info = external global i8 @stg_BCO_info$alias = alias private i8* @stg_BCO_info Where references to `stg_BCO_info` will use the alias `stg_BCO_info$alias`. This is not permitted under the new alias behavior, resulting in errors resembling, Alias must point to a definition i8* @"stg_BCO_info$alias" To fix this, we invert the naming relationship between aliases and definitions. That is, now the symbol definition takes the name `@stg_BCO_info$def` and references use the actual name, `@stg_BCO_info`. This means the external symbols can be handled by simply emitting an `external` declaration, @stg_BCO_info = external global i8 Whereas in the case of a forward declaration we emit, @stg_BCO_info = alias private i8* @stg_BCO_info$def Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D155
Diffstat (limited to 'compiler/llvmGen/LlvmCodeGen/Data.hs')
-rw-r--r--compiler/llvmGen/LlvmCodeGen/Data.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen/Data.hs b/compiler/llvmGen/LlvmCodeGen/Data.hs
index 1dbfb4b527..90ce44367a 100644
--- a/compiler/llvmGen/LlvmCodeGen/Data.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Data.hs
@@ -39,15 +39,16 @@ genLlvmData (sec, Statics lbl xs) = do
let types = map getStatType static
strucTy = LMStruct types
- alias = LMAlias ((label `appendFS` structStr), strucTy)
+ tyAlias = LMAlias ((label `appendFS` structStr), strucTy)
- struct = Just $ LMStaticStruc static alias
+ struct = Just $ LMStaticStruc static tyAlias
link = if (externallyVisibleCLabel lbl)
then ExternallyVisible else Internal
const = if isSecConstant sec then Constant else Global
- glob = LMGlobalVar label alias link Nothing Nothing const
+ varDef = LMGlobalVar label tyAlias link Nothing Nothing const
+ globDef = LMGlobal varDef struct
- return ([LMGlobal glob struct], [alias])
+ return ([globDef], [tyAlias])
-- | Should a data in this section be considered constant
isSecConstant :: Section -> Bool
@@ -134,4 +135,3 @@ genStaticLit (CmmHighStackMark)
-- | Error Function
panic :: String -> a
panic s = Outputable.panic $ "LlvmCodeGen.Data." ++ s
-