@@ -161,6 +161,7 @@ initDefs tgt =
161 -- , exfun "llvm.llvm.memcpy.p0i8.p0i8.i32" VoidType [ptrI8, ptrI8, IntegerType 32, IntegerType 32, IntegerType 1] False
161 -- , exfun "llvm.llvm.memcpy.p0i8.p0i8.i32" VoidType [ptrI8, ptrI8, IntegerType 32, IntegerType 32, IntegerType 1] False
162 -- , exfun "llvm.llvm.memcpy.p0i8.p0i8.i64" VoidType [ptrI8, ptrI8, IntegerType 64, IntegerType 32, IntegerType 1] False
162 -- , exfun "llvm.llvm.memcpy.p0i8.p0i8.i64" VoidType [ptrI8, ptrI8, IntegerType 64, IntegerType 32, IntegerType 1] False
163 , exfun "memcpy" ptrI8 [ptrI8, ptrI8, intPtr] False
163 , exfun "memcpy" ptrI8 [ptrI8, ptrI8, intPtr] False
164+ , exfun "llvm.invariant.start" (PointerType (StructureType False []) (AddrSpace 0)) [IntegerType 64, ptrI8] False
164 , exfun "snprintf" (IntegerType 32) [ptrI8, intPtr, ptrI8] True
165 , exfun "snprintf" (IntegerType 32) [ptrI8, intPtr, ptrI8] True
165 , exfun "strcmp" (IntegerType 32) [ptrI8, ptrI8] False
166 , exfun "strcmp" (IntegerType 32) [ptrI8, ptrI8] False
166 , exfun "strlen" intPtr [ptrI8] False
167 , exfun "strlen" intPtr [ptrI8] False
@@ -423,7 +424,8 @@ cgExpr (SCon tag name args) = do
423 case sequence argSlots of
424 case sequence argSlots of
424 Nothing -> return Nothing
425 Nothing -> return Nothing
425 Just argVals -> do
426 Just argVals -> do
426− con <- alloc . conType . fromIntegral . length $ argVals
427+ let ty = conType . fromIntegral . length $ argVals
427 tagPtr <- inst $ GetElementPtr True con [ConstantOperand (C.Int 32 0), ConstantOperand (C.Int 32 0)] []
429 tagPtr <- inst $ GetElementPtr True con [ConstantOperand (C.Int 32 0), ConstantOperand (C.Int 32 0)] []
428 inst' $ Store False tagPtr (ConstantOperand (C.Int 32 (fromIntegral tag))) Nothing 0 []
430 inst' $ Store False tagPtr (ConstantOperand (C.Int 32 (fromIntegral tag))) Nothing 0 []
429 forM_ (zip argVals [0..]) $ \(arg, i) -> do
431 forM_ (zip argVals [0..]) $ \(arg, i) -> do
@@ -431,6 +433,8 @@ cgExpr (SCon tag name args) = do
431 , ConstantOperand (C.Int 32 1)
433 , ConstantOperand (C.Int 32 1)
432 , ConstantOperand (C.Int 32 i)] []
434 , ConstantOperand (C.Int 32 i)] []
433 inst' $ Store False ptr arg Nothing 0 []
435 inst' $ Store False ptr arg Nothing 0 []
436+ ptrI8 <- inst $ BitCast con (PointerType (IntegerType 8) (AddrSpace 0)) []
437+ inst' $ simpleCall "llvm.invariant.start" [ConstantOperand $ C.Int 64 (-1), ptrI8]
434 Just <$> inst (BitCast con (PointerType valueType (AddrSpace 0)) [])
438 Just <$> inst (BitCast con (PointerType valueType (AddrSpace 0)) [])
435cgExpr (SCase inspect alts) = do
439cgExpr (SCase inspect alts) = do
436 val <- var inspect
440 val <- var inspect
@@ -690,11 +694,14 @@ nameAlt _ (SConstCase const _) = getName (show const)
690box :: FType -> Operand -> Codegen Operand
694box :: FType -> Operand -> Codegen Operand
691box FUnit _ = return $ ConstantOperand nullValue
695box FUnit _ = return $ ConstantOperand nullValue
692box fty fval = do
696box fty fval = do
697+ let ty = primTy (ftyToTy fty)
693− val <- alloc (primTy (ftyToTy fty))
698+ val <- alloc ty
694 tagptr <- inst $ GetElementPtr True val [ConstantOperand (C.Int 32 0), ConstantOperand (C.Int 32 0)] []
699 tagptr <- inst $ GetElementPtr True val [ConstantOperand (C.Int 32 0), ConstantOperand (C.Int 32 0)] []
695 valptr <- inst $ GetElementPtr True val [ConstantOperand (C.Int 32 0), ConstantOperand (C.Int 32 1)] []
700 valptr <- inst $ GetElementPtr True val [ConstantOperand (C.Int 32 0), ConstantOperand (C.Int 32 1)] []
696 inst' $ Store False tagptr (ConstantOperand (C.Int 32 (-1))) Nothing 0 []
701 inst' $ Store False tagptr (ConstantOperand (C.Int 32 (-1))) Nothing 0 []
697 inst' $ Store False valptr fval Nothing 0 []
702 inst' $ Store False valptr fval Nothing 0 []
703+ ptrI8 <- inst $ BitCast val (PointerType (IntegerType 8) (AddrSpace 0)) []
704+ inst' $ simpleCall "llvm.invariant.start" [ConstantOperand $ C.Int 64 (-1), ptrI8]
698 inst $ BitCast val (PointerType valueType (AddrSpace 0)) []
705 inst $ BitCast val (PointerType valueType (AddrSpace 0)) []
700unbox :: FType -> Operand -> Codegen Operand
707unbox :: FType -> Operand -> Codegen Operand