[commit: ghc] master: Dwarf.Types: Use DW_CFA_same_value encoding when possible (7fac7cd)

git at git.haskell.org git at git.haskell.org
Sun Feb 12 01:08:37 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7fac7cdce975620e04eccfc2751190063cf715a8/ghc

>---------------------------------------------------------------

commit 7fac7cdce975620e04eccfc2751190063cf715a8
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Sat Feb 11 19:19:42 2017 -0500

    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


>---------------------------------------------------------------

7fac7cdce975620e04eccfc2751190063cf715a8
 compiler/nativeGen/Dwarf/Types.hs | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/compiler/nativeGen/Dwarf/Types.hs b/compiler/nativeGen/Dwarf/Types.hs
index b5348db..d4d8e24 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



More information about the ghc-commits mailing list