From e16a342d70b92fc8480793d3ec911853f0c31e44 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 21 Nov 2014 21:05:25 +0100 Subject: 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 --- compiler/llvmGen/LlvmCodeGen.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'compiler/llvmGen/LlvmCodeGen.hs') diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs index dd16e52868..6120a72d3a 100644 --- a/compiler/llvmGen/LlvmCodeGen.hs +++ b/compiler/llvmGen/LlvmCodeGen.hs @@ -81,7 +81,7 @@ llvmCodeGen' cmm_stream _ <- Stream.collect llvmStream -- Declare aliases for forward references - renderLlvm . pprLlvmData =<< generateAliases + renderLlvm . pprLlvmData =<< generateExternDecls -- Postamble cmmUsedLlvmGens @@ -120,8 +120,9 @@ cmmDataLlvmGens statics = funInsert l ty regGlobal _ = return () mapM_ regGlobal (concat gss) + gss' <- mapM aliasify $ concat gss - renderLlvm $ pprLlvmData (concat gss, concat tss) + renderLlvm $ pprLlvmData (concat gss', concat tss) -- | Complete LLVM code generation phase for a single top-level chunk of Cmm. cmmLlvmGen ::RawCmmDecl -> LlvmM () -- cgit v1.2.1