summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Mainland <gmainlan@microsoft.com>2013-06-12 14:31:49 +0100
committerGeoffrey Mainland <gmainlan@microsoft.com>2013-06-12 14:31:49 +0100
commitdb9b63105a541e4ad3f9c55e2cfadf716445ab87 (patch)
tree8b7af6cd3ef808052d0b48ff8f9f01a7b74bd4af
parent289be612b4e823ea705a00c45daa174549d38e4b (diff)
downloadhaskell-db9b63105a541e4ad3f9c55e2cfadf716445ab87.tar.gz
Avoid generating empty llvm.used definitions.
LLVM 3.3rc3 complains when the llvm.used global is an empty array, so don't define llvm.used at all when it would be empty.
-rw-r--r--compiler/llvmGen/LlvmCodeGen.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs
index a157a258fe..4f2bded6bb 100644
--- a/compiler/llvmGen/LlvmCodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen.hs
@@ -117,19 +117,19 @@ cmmProcLlvmGens :: DynFlags -> BufHandle -> UniqSupply -> LlvmEnv -> [RawCmmDecl
-> [[LlvmVar]] -- ^ info tables that need to be marked as 'used'
-> IO ()
-cmmProcLlvmGens _ _ _ _ [] _ []
- = return ()
-
cmmProcLlvmGens dflags h _ _ [] _ ivars
- = let ivars' = concat ivars
- cast x = LMBitc (LMStaticPointer (pVarLift x)) i8Ptr
- ty = (LMArray (length ivars') i8Ptr)
- usedArray = LMStaticArray (map cast ivars') ty
- lmUsed = (LMGlobalVar (fsLit "llvm.used") ty Appending
- (Just $ fsLit "llvm.metadata") Nothing False, Just usedArray)
- in Prt.bufLeftRender h $ {-# SCC "llvm_used_ppr" #-}
- withPprStyleDoc dflags (mkCodeStyle CStyle) $
- pprLlvmData ([lmUsed], [])
+ | null ivars' = return ()
+ | otherwise = Prt.bufLeftRender h $
+ {-# SCC "llvm_used_ppr" #-}
+ withPprStyleDoc dflags (mkCodeStyle CStyle) $
+ pprLlvmData ([lmUsed], [])
+ where
+ ivars' = concat ivars
+ cast x = LMBitc (LMStaticPointer (pVarLift x)) i8Ptr
+ ty = (LMArray (length ivars') i8Ptr)
+ usedArray = LMStaticArray (map cast ivars') ty
+ lmUsed = (LMGlobalVar (fsLit "llvm.used") ty Appending
+ (Just $ fsLit "llvm.metadata") Nothing False, Just usedArray)
cmmProcLlvmGens dflags h us env ((CmmData _ _) : cmms) count ivars
= cmmProcLlvmGens dflags h us env cmms count ivars