Add a few bytes of stack to every function.
This also makes sure that every function gets a stack size constant. There are some functions which don't do any stack adjustment -- where GCC's smart enough to just compile them to a "ret" (because it knows it needs a function pointer, but also that the function does nothing). CCSP doesn't like it when you ask for a stack size of 0; I haven't yet investigated why, but this is likely to change anyway once Carl's changes go into CCSP trunk.
This commit is contained in:
parent
10b0b556d2
commit
bd44a1c748
|
@ -134,7 +134,9 @@ collectInfo ais = collectInfo' ais "" Map.empty
|
|||
collectInfo' [] _ fmap = fmap
|
||||
collectInfo' (ai:ais) func fmap
|
||||
= case ai of
|
||||
AsmFunction newFunc -> collectInfo' ais newFunc fmap
|
||||
AsmFunction newFunc ->
|
||||
let fi = Map.findWithDefault emptyFI func fmap
|
||||
in collectInfo' ais newFunc (Map.insert func fi fmap)
|
||||
AsmStackInc v ->
|
||||
let ofi = Map.findWithDefault emptyFI func fmap
|
||||
-- This overestimates: it adds together all the stack
|
||||
|
@ -152,6 +154,10 @@ collectInfo ais = collectInfo' ais "" Map.empty
|
|||
unknownSize :: Int
|
||||
unknownSize = 512
|
||||
|
||||
-- | Additional stack size to give to all functions.
|
||||
baseStackSize :: Int
|
||||
baseStackSize = 16
|
||||
|
||||
-- | Add the stack sizes for called functions to their callers.
|
||||
addCalls :: FuncMap -> PassM FuncMap
|
||||
addCalls fmap
|
||||
|
@ -174,7 +180,7 @@ addCalls fmap
|
|||
knownStack :: String -> PassM Int
|
||||
knownStack func
|
||||
= do let fi = fmap Map.! func
|
||||
let localStack = fiStack fi
|
||||
let localStack = fiStack fi + baseStackSize
|
||||
calledStacks <- mapM totalStack $ Set.toList $ fiCalls fi
|
||||
return $ localStack + maximum (0 : calledStacks)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user