Skip to content

cmd/compile: simple functions in compress/flate, inlined in go1.10 no longer inlined #27621

Closed

Description

@laboger

Please answer these questions before submitting your issue. Thanks!

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

tip

Does this issue reproduce with the latest release?

yes

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

ppc64le Ubuntu 16.04

What did you do?

Inspecting code from compress/flate, noticed some simple functions that I would expect to be inlined that are not.

What did you expect to see?

Functions compress/flate.byLiteral.Len, compress/flate.byLiteral.Less, compress/flate.byLiteral.Swap, compress/flate.byFreq.Len, compress/flate.byFreq.Less, compress/flate.byFreq.Swap inlined as was done in go 1.10.

What did you see instead?

No inlining for these functions on the latest branch or in go 1.11.

I just built the test in compress/flate and looked at the code. Not sure if you need more information.
I did add the -m=2 option and the output said those functions should be inlined.

../../compress/flate/huffman_code.go:321:6: can inline byLiteral.Len as: method(byLiteral) func() int { return len(s) }
../../compress/flate/huffman_code.go:323:6: can inline byLiteral.Less as: method(byLiteral) func(int, int) bool { return s[i].literal < s[j].literal }
../../compress/flate/huffman_code.go:327:6: can inline byLiteral.Swap as: method(byLiteral) func(int, int) { s[i], s[j] = s[j], s[i] }
../../compress/flate/huffman_code.go:336:6: can inline byFreq.Len as: method(byFreq) func() int { return len(s) }
../../compress/flate/huffman_code.go:338:6: can inline byFreq.Less as: method(byFreq) func(int, int) bool { if s[i].freq == s[j].freq { return s[i].literal < s[j].literal }; return s[i].freq < s[j].freq }
../../compress/flate/huffman_code.go:345:6: can inline byFreq.Swap as: method(byFreq) func(int, int) { s[i], s[j] = s[j], s[i] }

Activity

  1. laboger commented on Sep 11, 2018

    @laboger
    ContributorAuthor

    Forgot to mention: they aren't being inlined in the corresponding functions like these:
    compress/flate.(*byLiteral).Len
    compress/flate.(*byLiteral).Less
    compress/flate.(*byLiteral).Swap
    compress.flate.(*byFreq).Len
    compress.flate.(*byFreq).Less
    compress.flate.(*byFreq).Swap

  2. TocarIP commented on Sep 11, 2018

    @TocarIP
    Contributor

    Looks like #25338

  3. gopherbot commented on Sep 17, 2018

    @gopherbot
    Contributor

    Change https://golang.org/cl/135697 mentions this issue: cmd/compile/internal/gc: inline autogenerated (*T).M wrappers

  4. andybons commented on Sep 26, 2018

    @andybons
    Member

    @laboger if you apply the above fix locally, is the issue resolved? If so, I'll close this as a dupe of #25338

  5. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Sep 26, 2018
  6. added this to the Unplanned milestone on Sep 26, 2018
  7. laboger commented on Sep 26, 2018

    @laboger
    ContributorAuthor

    I tried the fix above and the functions are now inlined.

  8. andybons commented on Sep 26, 2018

    @andybons
    Member

    @laboger thank you. Closing as a dupe of #25338.

  9. added a commit that references this issue on Oct 16, 2018
    fa913a3
  10. locked and limited conversation to collaborators on Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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