-
Notifications
You must be signed in to change notification settings - Fork 91
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
Track register allocations #105
Conversation
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 Report
@@ 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
Continue to review full report at Codecov.
|
@@ -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)), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
# Conflicts: # pass/alloc.go # reg/types.go # reg/x86.go
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:
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.