Skip to content

Commit 69ea62f

Browse files
committed
Revert "cmd/compile/internal/abi: fix ComputePadding"
This reverts CL 656736. Reason for revert: breaks many builders (all flavors of linux-amd64 builders). Change-Id: Ie7190d4078fada227391804c5cf10b9ce9cc9115 Reviewed-on: https://go-review.googlesource.com/c/go/+/659955 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
1 parent c386ed1 commit 69ea62f

File tree

4 files changed

+5
-117
lines changed

4 files changed

+5
-117
lines changed

‎src/cmd/compile/internal/abi/abiutils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,10 @@ func (pa *ABIParamAssignment) ComputePadding(storage []uint64) []uint64 {
673673
panic("internal error")
674674
}
675675
offsets, _ := appendParamOffsets([]int64{}, 0, pa.Type)
676+
off := int64(0)
676677
for idx, t := range types {
677678
ts := t.Size()
678-
off := offsets[idx] + ts
679+
off += int64(ts)
679680
if idx < len(types)-1 {
680681
noff := offsets[idx+1]
681682
if noff != off {

‎src/cmd/compile/internal/ssa/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ func PopulateABIInRegArgOps(f *Func) {
557557
f.Entry.Values = append(newValues, f.Entry.Values...)
558558
}
559559

560-
// BuildFuncDebug builds debug information for f, placing the results
560+
// BuildFuncDebug debug information for f, placing the results
561561
// in "rval". f must be fully processed, so that each Value is where it
562562
// will be when machine code is emitted.
563563
func BuildFuncDebug(ctxt *obj.Link, f *Func, loggingLevel int, stackOffset func(LocalSlot) int32, rval *FuncDebug) {

‎src/cmd/compile/internal/test/abiutils_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ func TestABIUtilsComputePadding(t *testing.T) {
390390
padding := make([]uint64, 32)
391391
parm := regRes.InParams()[1]
392392
padding = parm.ComputePadding(padding)
393-
want := "[1 0 0 0]"
393+
want := "[1 1 1 0]"
394394
got := fmt.Sprintf("%+v", padding)
395395
if got != want {
396-
t.Errorf("padding mismatch: wanted %q got %q\n", want, got)
396+
t.Errorf("padding mismatch: wanted %q got %q\n", got, want)
397397
}
398398
}

‎src/cmd/link/internal/ld/dwarf_test.go

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
package ld
66

77
import (
8-
"bytes"
98
"debug/dwarf"
10-
"debug/elf"
119
"debug/pe"
1210
"fmt"
1311
"internal/platform"
@@ -2044,114 +2042,3 @@ func TestConsistentGoKindAndRuntimeType(t *testing.T) {
20442042
t.Logf("%d types checked\n", typesChecked)
20452043
}
20462044
}
2047-
2048-
func TestIssue72053(t *testing.T) {
2049-
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
2050-
t.Skip("skipping test: requires ELF binary and amd64 arch")
2051-
}
2052-
2053-
testenv.MustHaveGoBuild(t)
2054-
2055-
mustHaveDWARF(t)
2056-
2057-
t.Parallel()
2058-
2059-
dir := t.TempDir()
2060-
2061-
const prog = `package main
2062-
2063-
import (
2064-
"fmt"
2065-
"strings"
2066-
)
2067-
2068-
func main() {
2069-
u := Address{Addr: "127.0.0.1"}
2070-
fmt.Println(u) // line 10
2071-
}
2072-
2073-
type Address struct {
2074-
TLS bool
2075-
Addr string
2076-
}
2077-
2078-
func (a Address) String() string {
2079-
sb := new(strings.Builder)
2080-
sb.WriteString(a.Addr)
2081-
return sb.String()
2082-
}
2083-
`
2084-
2085-
bf := gobuild(t, dir, prog, NoOpt)
2086-
2087-
defer bf.Close()
2088-
2089-
f, err := elf.Open(bf.path)
2090-
if err != nil {
2091-
t.Fatal(err)
2092-
}
2093-
2094-
dwrf, err := f.DWARF()
2095-
if err != nil {
2096-
t.Fatal(err)
2097-
}
2098-
2099-
rdr := dwrf.Reader()
2100-
2101-
found := false
2102-
for {
2103-
e, err := rdr.Next()
2104-
if err != nil {
2105-
t.Fatal(err)
2106-
}
2107-
if e == nil {
2108-
break
2109-
}
2110-
2111-
name, _ := e.Val(dwarf.AttrName).(string)
2112-
2113-
if e.Tag == dwarf.TagSubprogram && name == "main.Address.String" {
2114-
found = true
2115-
continue
2116-
}
2117-
2118-
if found && name == "a" {
2119-
loc := e.AttrField(dwarf.AttrLocation)
2120-
if loc != nil {
2121-
switch loc.Class {
2122-
case dwarf.ClassLocListPtr:
2123-
offset := loc.Val.(int64)
2124-
buf := make([]byte, 32)
2125-
s := f.Section(".debug_loc")
2126-
if s == nil {
2127-
t.Fatal("could not find debug_loc section")
2128-
}
2129-
d := s.Open()
2130-
// Seek past the first 16 bytes which establishes the base address and
2131-
// can be brittle and unreliable in the test due to compiler changes or DWARF
2132-
// version used.
2133-
d.Seek(offset+16, io.SeekStart)
2134-
d.Read(buf)
2135-
2136-
// DW_OP_reg0 DW_OP_piece 0x1 DW_OP_piece 0x7 DW_OP_reg3 DW_OP_piece 0x8 DW_OP_reg2 DW_OP_piece 0x8
2137-
expected := []byte{
2138-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2139-
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2140-
0x0b, 0x00, 0x50, 0x93, 0x01, 0x93, 0x07, 0x53,
2141-
0x93, 0x08, 0x52, 0x93, 0x08, 0x1f, 0x00, 0x00,
2142-
}
2143-
2144-
if !bytes.Equal(buf, expected) {
2145-
t.Fatalf("unexpected DWARF sequence found, expected:\n%#v\nfound:\n%#v\n", expected, buf)
2146-
}
2147-
}
2148-
} else {
2149-
t.Fatal("unable to find expected DWARF location list")
2150-
}
2151-
break
2152-
}
2153-
}
2154-
if !found {
2155-
t.Fatal("unable to find expected DWARF location list")
2156-
}
2157-
}

0 commit comments

Comments
 (0)