]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: more compact DWARF location for locals and arguments
authorAlessandro Arzilli <alessandro.arzilli@gmail.com>
Tue, 4 Jul 2017 06:32:02 +0000 (08:32 +0200)
committerHeschi Kreinick <heschi@google.com>
Wed, 6 Sep 2017 18:33:51 +0000 (18:33 +0000)
Now that all functions have a DW_AT_frame_base defined we can use
DW_OP_fbreg to specify the location of variables and formal parameters,
instead of the DW_OP_call_frame_cfa/DW_OP_consts/DW_OP_plus, saving 2
bytes for every variable and 2 bytes for every formal parameter after
the first one.

Change-Id: I2c7395b67e4a814a0131ab1520df11ca48ff9327
Reviewed-on: https://go-review.googlesource.com/60550
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/cmd/internal/dwarf/dwarf.go

index 4beb8c4c61c055dfce6f8934404c321814ee057c..e963f99e51eaf66961ec1463e813d82304e1df25 100644 (file)
@@ -804,12 +804,14 @@ func putvar(ctxt Context, info, loc Sym, v *Var, startPC Sym, encbuf []byte) {
                putattr(ctxt, info, v.Abbrev, DW_FORM_sec_offset, DW_CLS_PTR, int64(loc.Len()), loc)
                addLocList(ctxt, loc, startPC, v, encbuf)
        } else {
-               loc := append(encbuf[:0], DW_OP_call_frame_cfa)
-               if v.StackOffset != 0 {
-                       loc = append(loc, DW_OP_consts)
+               loc := encbuf[:0]
+               if v.StackOffset == 0 {
+                       loc = append(loc, DW_OP_call_frame_cfa)
+               } else {
+                       loc = append(loc, DW_OP_fbreg)
                        loc = AppendSleb128(loc, int64(v.StackOffset))
-                       loc = append(loc, DW_OP_plus)
                }
+
                putattr(ctxt, info, v.Abbrev, DW_FORM_block1, DW_CLS_BLOCK, int64(len(loc)), loc)
        }
        putattr(ctxt, info, v.Abbrev, DW_FORM_ref_addr, DW_CLS_REFERENCE, 0, v.Type)
@@ -826,8 +828,12 @@ func addLocList(ctxt Context, listSym, startPC Sym, v *Var, encbuf []byte) {
                for _, piece := range entry.Pieces {
                        if !piece.Missing {
                                if piece.OnStack {
-                                       locBuf = append(locBuf, DW_OP_fbreg)
-                                       locBuf = AppendSleb128(locBuf, int64(piece.StackOffset))
+                                       if piece.StackOffset == 0 {
+                                               locBuf = append(locBuf, DW_OP_call_frame_cfa)
+                                       } else {
+                                               locBuf = append(locBuf, DW_OP_fbreg)
+                                               locBuf = AppendSleb128(locBuf, int64(piece.StackOffset))
+                                       }
                                } else {
                                        if piece.RegNum < 32 {
                                                locBuf = append(locBuf, DW_OP_reg0+byte(piece.RegNum))