[commit: ghc] master: Use full contents size for arrays (fa6cbdf)

David Terei davidterei at gmail.com
Fri Jun 28 03:56:42 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/fa6cbdfb6e5d572dc74622d1c12e259c208321ab

>---------------------------------------------------------------

commit fa6cbdfb6e5d572dc74622d1c12e259c208321ab
Author: Peter Wortmann <scpmw at leeds.ac.uk>
Date:   Wed May 29 17:55:12 2013 +0100

    Use full contents size for arrays
    
    I am not quite sure at what point it makes sense to look at arrays as
    pointers, but I ran into at least one use case that strongly suggested
    doing it this way (calculating the actual size of structures, to be exact).

>---------------------------------------------------------------

 compiler/llvmGen/Llvm/Types.hs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler/llvmGen/Llvm/Types.hs b/compiler/llvmGen/Llvm/Types.hs
index 3ccdfec..c93147f 100644
--- a/compiler/llvmGen/Llvm/Types.hs
+++ b/compiler/llvmGen/Llvm/Types.hs
@@ -317,8 +317,10 @@ llvmWidthInBits _      (LMFloat80)     = 80
 llvmWidthInBits _      (LMFloat128)    = 128
 -- Could return either a pointer width here or the width of what
 -- it points to. We will go with the former for now.
+-- PMW: At least judging by the way LLVM outputs constants, pointers
+--      should use the former, but arrays the latter.
 llvmWidthInBits dflags (LMPointer _)   = llvmWidthInBits dflags (llvmWord dflags)
-llvmWidthInBits dflags (LMArray _ _)   = llvmWidthInBits dflags (llvmWord dflags)
+llvmWidthInBits dflags (LMArray n t)   = n * llvmWidthInBits dflags t
 llvmWidthInBits dflags (LMVector n ty) = n * llvmWidthInBits dflags ty
 llvmWidthInBits _      LMLabel         = 0
 llvmWidthInBits _      LMVoid          = 0





More information about the ghc-commits mailing list