summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-30 08:44:30 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-30 08:44:30 +0100
commit462be93d0eb03e48b92e41a3e653c955f639bb0b (patch)
treed57d00183a101849ac3edd6de35e6c63ea68eeb7
parent8f444b0c2a6d468a596949926eccf1edf932d4df (diff)
Fix functions with no arguments
-rw-r--r--codegen.hs8
1 files 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)