diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-02-11 19:19:42 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-02-11 19:19:59 -0500 |
commit | 7fac7cdce975620e04eccfc2751190063cf715a8 (patch) | |
tree | a1fe1c14ad47981de574a3eaf779c63fe90ca5c0 /compiler/nativeGen | |
parent | 594123f57779464c9b7c0f51445639e15b8bd55c (diff) | |
download | haskell-7fac7cdce975620e04eccfc2751190063cf715a8.tar.gz |
Dwarf.Types: Use DW_CFA_same_value encoding when possible
This is a bit smaller than the alternative, DW_CFA_val_expression. Also
a bit of refactoring.
Test Plan: Validate
Reviewers: scpmw, simonmar, austin
Reviewed By: simonmar
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2745
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r-- | compiler/nativeGen/Dwarf/Types.hs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs index b5348db843..d4d8e2429e 100644 --- a/compiler/nativeGen/Dwarf/Types.hs +++ b/compiler/nativeGen/Dwarf/Types.hs @@ -436,10 +436,10 @@ pprSetUnwind _ Sp (Just (UwReg s _), Just (UwReg s' o')) | s == s' pprSetUnwind plat Sp (_, Just (UwReg s' o')) = if o' >= 0 then pprByte dW_CFA_def_cfa $$ - pprLEBWord (fromIntegral $ dwarfGlobalRegNo plat s') $$ + pprLEBRegNo plat s' $$ pprLEBWord (fromIntegral o') else pprByte dW_CFA_def_cfa_sf $$ - pprLEBWord (fromIntegral $ dwarfGlobalRegNo plat s') $$ + pprLEBRegNo plat s' $$ pprLEBInt o' pprSetUnwind _ Sp (_, Just uw) = pprByte dW_CFA_def_cfa_expression $$ pprUnwindExpr False uw @@ -449,17 +449,26 @@ pprSetUnwind plat g (_, Just (UwDeref (UwReg Sp o))) pprLEBWord (fromIntegral ((-o) `div` platformWordSize plat)) | otherwise = pprByte dW_CFA_offset_extended_sf $$ - pprLEBWord (fromIntegral (dwarfGlobalRegNo plat g)) $$ + pprLEBRegNo plat g $$ pprLEBInt o pprSetUnwind plat g (_, Just (UwDeref uw)) = pprByte dW_CFA_expression $$ - pprLEBWord (fromIntegral (dwarfGlobalRegNo plat g)) $$ + pprLEBRegNo plat g $$ pprUnwindExpr True uw +pprSetUnwind plat g (_, Just (UwReg g' 0)) + | g == g' + = pprByte dW_CFA_same_value $$ + pprLEBRegNo plat g pprSetUnwind plat g (_, Just uw) = pprByte dW_CFA_val_expression $$ - pprLEBWord (fromIntegral (dwarfGlobalRegNo plat g)) $$ + pprLEBRegNo plat g $$ pprUnwindExpr True uw +-- | Print the register number of the given 'GlobalReg' as an unsigned LEB128 +-- encoded number. +pprLEBRegNo :: Platform -> GlobalReg -> SDoc +pprLEBRegNo plat = pprLEBWord . fromIntegral . dwarfGlobalRegNo plat + -- | Generates a DWARF expression for the given unwind expression. If -- @spIsCFA@ is true, we see @Sp@ as the frame base CFA where it gets -- mentioned. @@ -488,7 +497,7 @@ pprUnwindExpr spIsCFA expr -- register to @undefined@ pprUndefUnwind :: Platform -> GlobalReg -> SDoc pprUndefUnwind plat g = pprByte dW_CFA_undefined $$ - pprLEBWord (fromIntegral $ dwarfGlobalRegNo plat g) + pprLEBRegNo plat g -- | Align assembly at (machine) word boundary |