Skip to content

cmd/compile: duplicated panicslice calls in a single function #30437

@seebs

Description

@seebs

What version of Go are you using (go version)?

1.10/1.11 (on godbolt.org)

Does this issue reproduce with the latest release?

Not sure, godbolt doesn't have 1.12 yet.

What operating system and processor architecture are you using (go env)?

x86

What did you do?

Messed with some benchmarks, looked to see whether they were generating bounds checks.

What did you expect to see?

Less bounds checking.

What did you see instead?

This isn't actually about the amount of bounds checking generated. It's about the fact that identical blocks of code were generated several times consecutively.

https://godbolt.org/z/IfZOAD

Look in particular around lines 172-180 or so of the go1.11 output, or 134-150 of the go1.10 output. There's multiple instances of identical panic calls with distinct labels:

XorBytesUnrolled_pc198:
        pcdata  $2, $0
        pcdata  $0, $3
        call    runtime.panicslice(SB)
        undef
XorBytesUnrolled_pc205:
        call    runtime.panicslice(SB)
        undef
XorBytesUnrolled_pc212:
        call    runtime.panicslice(SB)
        undef
XorBytesUnrolled_pc219:
        call    runtime.panicslice(SB)
        undef

I wouldn't expect the compiler to realize that it could insert a label halfway through the _pc198 code, but I would expect it to be able to recognize that 205, 212, and 219 are all the same code.

(I was also hoping the bounds checker wouldn't need to generate those at all, but we can't have everything.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions