diff options
| author | Alessandro Arzilli <alessandro.arzilli@gmail.com> | 2017-07-04 08:32:02 +0200 |
|---|---|---|
| committer | Heschi Kreinick <heschi@google.com> | 2017-09-06 18:33:51 +0000 |
| commit | 31ddd8a39d802c073c2bcf4b1f4e74f851fa80c4 (patch) | |
| tree | 4ee24db0a679e6b3c33ed1446031b9a2e471d6a6 /src/cmd/internal/dwarf | |
| parent | 84188296e93dd4d26cb0a75a03a9096794e01e2f (diff) | |
| download | go-31ddd8a39d802c073c2bcf4b1f4e74f851fa80c4.tar.xz | |
cmd/compile: more compact DWARF location for locals and arguments
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>
Diffstat (limited to 'src/cmd/internal/dwarf')
| -rw-r--r-- | src/cmd/internal/dwarf/dwarf.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/cmd/internal/dwarf/dwarf.go b/src/cmd/internal/dwarf/dwarf.go index 4beb8c4c61..e963f99e51 100644 --- a/src/cmd/internal/dwarf/dwarf.go +++ b/src/cmd/internal/dwarf/dwarf.go @@ -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)) |
