summaryrefslogtreecommitdiffstats
path: root/tools/ghc/ghc-llvmCodeGen-empty-array.patch
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ghc/ghc-llvmCodeGen-empty-array.patch')
-rw-r--r--tools/ghc/ghc-llvmCodeGen-empty-array.patch44
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/ghc/ghc-llvmCodeGen-empty-array.patch b/tools/ghc/ghc-llvmCodeGen-empty-array.patch
new file mode 100644
index 0000000..2129e52
--- /dev/null
+++ b/tools/ghc/ghc-llvmCodeGen-empty-array.patch
@@ -0,0 +1,44 @@
+commit db9b63105a541e4ad3f9c55e2cfadf716445ab87
+Author: Geoffrey Mainland <gmainlan@microsoft.com>
+Date: Wed Jun 12 14:31:49 2013 +0100
+
+ 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.
+
+ Modified compiler/llvmGen/LlvmCodeGen.hs
+diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs
+index a157a25..4f2bded 100644
+--- a/compiler/llvmGen/LlvmCodeGen.hs
++++ b/compiler/llvmGen/LlvmCodeGen.hs
+@@ -117,18 +117,18 @@ cmmProcLlvmGens :: DynFlags -> BufHandle -> UniqSupply -> LlvmEnv -> [RawCmmDecl
+ -> [[LlvmVar]] -- ^ info tables that need to be marked as 'used'
+ -> IO ()
+
+-cmmProcLlvmGens _ _ _ _ [] _ []
+- = return ()
+-
+ cmmProcLlvmGens _ 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" #-}
+- pprLlvmData ([lmUsed], [])
++ | null ivars' = return ()
++ | otherwise = Prt.bufLeftRender h $
++ {-# SCC "llvm_used_ppr" #-}
++ 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