This is an archive of the discontinued LLVM Phabricator instance.

Remove optnone/opt-bisect check from StackColoring
ClosedPublic

Authored by andrew.w.kaylor on May 19 2016, 3:55 PM.

Details

Summary

This removes the skipFunction() call in the StackColoring pass that allows the pass to be skipped for opt-bisect and "optnone" function attribute handling.

This pass was calling skipOptnoneFunction() before I made the opt-bisect changes, but if a function reaches this pass with lifetime.start/lifetime.end intrinsics in place and the pass is skipped code generation will fail. This pass is not called at opt-level zero, but the lifetime intrinsics are never translated to machine instructions at opt-level zero.

It would be possible to have the pass simply remove the intrinsics and do nothing else if the skipFunction() call returns 'true' but I don't like the idea of having a pass that changes the IR in a different way when it is told not to change the IR. We could always re-visit that later if the need arises.

Diff Detail

Repository
rL LLVM

Event Timeline

andrew.w.kaylor retitled this revision from to Remove optnone/opt-bisect check from StackColoring.
andrew.w.kaylor updated this object.
andrew.w.kaylor added a reviewer: probinson.
andrew.w.kaylor set the repository for this revision to rL LLVM.
andrew.w.kaylor added a subscriber: llvm-commits.
probinson edited edge metadata.May 26 2016, 12:02 PM

Hmmm. In the optnone case, presumably we're not running that pass that inserts the lifetime markers; if there are no markers, and this pass runs, naively it looks like this would be a no-op pass. So, from the optnone perspective, this change would not be a problem.

But if you're bisecting, there might be markers, and if the bisection point is between the insertion and this pass, then later on codegen will fail. This change means, if the bisection point is between the insertion and this pass, then this pass runs anyway.

In effect this becomes an always-run pass, and whether it does anything depends on whether the marker-insertion pass runs. Makes the bisection less ideal, but I guess we can live with that.

test/Other/opt-bisect-legacy-pass-manager.ll
157 ↗(On Diff #57871)

This wants some commentary, as each hunk of this test is doing something particular and this new hunk isn't doing the same thing as the previous hunk.

Hmmm. In the optnone case, presumably we're not running that pass that inserts the lifetime markers; if there are no markers, and this pass runs, naively it looks like this would be a no-op pass. So, from the optnone perspective, this change would not be a problem.

But if you're bisecting, there might be markers, and if the bisection point is between the insertion and this pass, then later on codegen will fail. This change means, if the bisection point is between the insertion and this pass, then this pass runs anyway.

In effect this becomes an always-run pass, and whether it does anything depends on whether the marker-insertion pass runs. Makes the bisection less ideal, but I guess we can live with that.

The lifetime start call can be inserted by AtomicExpand, which isn't skipped by optnone or opt-bisect, or by SROA, which is run very early, or by the function inliner, which can't be skipped for the AlwaysInline pass.

thanm edited edge metadata.May 26 2016, 3:56 PM

Hi Andy,
I think I agree with probinson about the need for removing the markers in the opt-none case. I think the most expedient thing to do would be to make the skipFunction() check at the same point in the code where "DisableColoring" is checked (line 1008), this way the "removeAllMarkers()" helper will be called on the way out. This has the minor compile-time drawback that there is some analysis done to get to this point, but that seems like a minor concern for bisections purposes.
Thanks, Than

Hi Andy,
I think I agree with probinson about the need for removing the markers in the opt-none case. I think the most expedient thing to do would be to make the skipFunction() check at the same point in the code where "DisableColoring" is checked (line 1008), this way the "removeAllMarkers()" helper will be called on the way out. This has the minor compile-time drawback that there is some analysis done to get to this point, but that seems like a minor concern for bisections purposes.
Thanks, Than

I like Than's idea. For either bisection or optnone, the compile-time "drawback" is pretty irrelevant.

Sounds good to me. I'll upload changes for final review as soon as my local testing finishes. It looks like I still need to take that line out of the optnone-llc test because the pass aborts for other reasons before calling skipFunction. Otherwise, this looks like a very clean solution.

andrew.w.kaylor edited edge metadata.

Implemented suggested revisions.

This revision was automatically updated to reflect the committed changes.