Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track register allocations #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

klauspost
Copy link
Contributor

@klauspost klauspost commented Jan 2, 2020

To help debugging keep track of where registers are allocated.

After a bit back and forth I ended up with this, which shows sorted physical id and where the virtual register is allocated in the calling code:

failed to allocate registers. 56 virtual:                                                                                             
00: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:81 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                      
00:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:97 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)        
01: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:83 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                      
02: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
02:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:109 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
02:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:111 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
03: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
03:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:109 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
05: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
05:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:110 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
06: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:115 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
06:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:118 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
06:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:136 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
06:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:159 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
06:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:265 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
06:  - As8() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:116 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr8)         
07: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:134 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
07:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:135 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
07:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:136 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
07:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:137 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
08: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:160 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
08:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:163 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
09: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:176 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
09:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:183 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
10: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:176 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
10:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:180 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
10:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:183 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
11: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:176 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)                     
11:  - As32() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:177 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)       
11:  - As64() e:/gopath/src/github.com/klauspost/compress/s2/gen.go:193 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr64)       
[...]

When #100 is fixed this will allow easier tracking of what avo considers allocated.

If nothing else, it could also help debugging #100.

Using the package path is the most reasonable approach I could find to determine what to store.

To help debugging keep track of where registers are allocated.

After a bit back and forth I ended up with this, which shows sorted physical id and where the virtual register is allocated in the calling code:

```
failed to allocate registers. 38 virtual:
00: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:81 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
00: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:81 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
01: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:83 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
02: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
02: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
03: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
03: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
05: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
05: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:102 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
06: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:115 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
06: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:115 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
06: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:115 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr8)
07: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:134 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
07: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:134 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
08: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:160 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
08: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:160 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
09: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:176 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
09: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:176 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
10: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:176 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
10: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:176 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
10: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:176 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr64)
11: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:186 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
11: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:186 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr16)
11: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:186 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
11: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:186 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr64)
11: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:186 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr8)
12: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:191 main.genEncodeBlockAsm() (type:reg.gpv, kind:gpr64)
12: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:191 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr64)
13: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:381 main.emitLiteral() (type:reg.gpv, kind:gpr64)
13: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:381 main.emitLiteral() (type:reg.virtual, kind:gpr16)
13: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:381 main.emitLiteral() (type:reg.virtual, kind:gpr32)
13: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:381 main.emitLiteral() (type:reg.virtual, kind:gpr8)
14: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:382 main.emitLiteral() (type:reg.gpv, kind:gpr64)
14: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:382 main.emitLiteral() (type:reg.virtual, kind:gpr32)
14: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:382 main.emitLiteral() (type:reg.virtual, kind:gpr8)
15: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:247 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr16)
15: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:247 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr32)
15: e:/gopath/src/github.com/klauspost/compress/s2/gen.go:247 main.genEncodeBlockAsm() (type:reg.virtual, kind:gpr8)
```

When mmcloughlin#100 is fixed this will allow easier tracking of what avo considers allocated.

If nothing else, it could also help debugging mmcloughlin#100.

Using the package path is the most reasonable approach I could find to determine what to store.
@codecov-io
Copy link

codecov-io commented Jan 2, 2020

Codecov Report

Merging #105 into master will decrease coverage by 0.04%.
The diff coverage is 51.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
- Coverage   76.18%   76.13%   -0.05%     
==========================================
  Files          52       53       +1     
  Lines       31325    31378      +53     
==========================================
+ Hits        23865    23891      +26     
- Misses       7355     7380      +25     
- Partials      105      107       +2
Flag Coverage Δ
#integration 6.45% <51.72%> (+0.07%) ⬆️
#unittests 74.09% <34.48%> (-0.08%) ⬇️
Impacted Files Coverage Δ
pass/alloc.go 83.33% <0%> (-6.67%) ⬇️
reg/x86.go 70.21% <36.36%> (-29.79%) ⬇️
reg/func.go 78.57% <78.57%> (ø)
reg/types.go 89.47% <84.61%> (-1.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfc6eca...fe08d14. Read the comment docs.

@@ -136,6 +148,8 @@ func (v virtual) as(s Spec) Register {
kind: v.kind,
Width: Width(s.Size()),
mask: s.Mask(),
// Non-breaking space for sorting.
allocAt: fmt.Sprintf("\u00A0- As%v() %s", s.String(), getFnNameFile(2)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks allocation, hinting that an == is used on this type somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect the possible map[reg.Virtual][]reg.Physical is the problem here or with type Allocation map[Register]Physical

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants