diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-02-07 22:58:48 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-02-08 10:26:00 -0500 |
commit | 5279b08ba3f01e4b7e28d12b2751413d789d9fbe (patch) | |
tree | 05151c492ab9c12ab6a30a2505cea3d641a897ad | |
parent | 3328ddb88b6eb11cb1f6e844f883e7e9d2b8f21b (diff) | |
download | haskell-5279b08ba3f01e4b7e28d12b2751413d789d9fbe.tar.gz |
CmmLayoutStack: Correctly annotate Sp adjustments with unwinding information
Test Plan: Validate
Reviewers: austin, simonmar
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3104
-rw-r--r-- | compiler/cmm/CmmLayoutStack.hs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/compiler/cmm/CmmLayoutStack.hs b/compiler/cmm/CmmLayoutStack.hs index f59daad64d..9051845e08 100644 --- a/compiler/cmm/CmmLayoutStack.hs +++ b/compiler/cmm/CmmLayoutStack.hs @@ -802,18 +802,29 @@ manifestSp dflags stackmaps stack0 sp0 sp_high adj_pre_sp = mapExpDeep (areaToSp dflags sp0 sp_high area_off) adj_post_sp = mapExpDeep (areaToSp dflags (sp0 - sp_off) sp_high area_off) - -- Add unwind pseudo-instructions at the beginning of each block to + -- Add unwind pseudo-instruction at the beginning of each block to -- document Sp level for debugging - add_unwind_info block + add_initial_unwind block | debugLevel dflags > 0 - = CmmUnwind [(Sp, Just sp_unwind)] : block + = CmmUnwind [(Sp, Just sp_unwind)] `blockCons` block | otherwise = block - sp_unwind = CmmRegOff (CmmGlobal Sp) (sp0 - wORD_SIZE dflags) + where sp_unwind = CmmRegOff spReg (sp0 - wORD_SIZE dflags) + + -- Add unwind pseudo-instruction right before the Sp adjustment + -- if there is one. + add_adj_unwind block + | debugLevel dflags > 0 + , sp_off /= 0 + = block `blockSnoc` CmmUnwind [(Sp, Just sp_unwind)] + | otherwise + = block + where sp_unwind = CmmRegOff spReg (sp0 - wORD_SIZE dflags - sp_off) final_middle = maybeAddSpAdj dflags sp_off + . add_adj_unwind + . add_initial_unwind . blockFromList - . add_unwind_info . map adj_pre_sp . elimStackStores stack0 stackmaps area_off $ middle_pre |