From 462be93d0eb03e48b92e41a3e653c955f639bb0b Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 30 Jan 2017 08:44:30 +0100 Subject: Fix functions with no arguments --- codegen.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codegen.hs b/codegen.hs index b7af7a1..23db784 100644 --- a/codegen.hs +++ b/codegen.hs @@ -284,7 +284,9 @@ genFunctionBlock bl args = do bodybb <- genBlock bl termbb changeBlock firstbb setTerminator $ A.Br (A.Name bodybb) [] - return firstbb + if length args > 0 + then return firstbb + else return bodybb genBlock :: Block -> LLName -- name of BasicBlock following this Block @@ -562,9 +564,7 @@ commonTypeM t1 t2 = maybe err return $ commonType t1 t2 cleanupTrampolines :: CGMonad () cleanupTrampolines = do - st <- get - let newblocks = go (allBlocks st) - put $ st {allBlocks = newblocks} + state $ \s -> ((), s {allBlocks = go (allBlocks s)}) where go :: Map.Map LLName A.BasicBlock -> Map.Map LLName A.BasicBlock go bbs = folder bbs (Map.toList bbs) -- cgit v1.2.3-70-g09d2