Skip to content

cmd/compile: remove instruction reordering by obj package #15837

Closed
@randall77

Description

@randall77

It's confusing, especially to assembly writers, when obj package reorders their instructions from under them. It also interferes with any instruction layout done earlier in the compiler, e.g. SSA scheduling.

It may be as simple as removing the Follow pass from cmd/internal/obj/plist.go (and all the associated code for each arch).

The follow pass does the following optimization: for unconditional branches, copy a few instructions from the destination instead of jumping to the copy.

For typical loops, SSA currently generates:

loop:
   CMP ...
   JGE exit
   ..loop body..
   jmp loop
exit:

The follow pass rewrites this to:

   CMP ...
   JGE exit
loop:
   ..loop body..
   CMP ...
   JLT loop
exit:

We probably want to do this loop head peeling some other way (in SSA?).

@rsc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions