This is an archive of the discontinued LLVM Phabricator instance.

[llgo] Elide alloca for unused received values in select
ClosedPublic

Authored by axw on Dec 26 2014, 7:35 PM.

Details

Summary

If a receive case in a select statement is not assigned to a named variable, then we can eliminate the alloca and copy at runtime.

Diff Detail

Event Timeline

axw updated this revision to Diff 17643.Dec 26 2014, 7:35 PM
axw retitled this revision from to [llgo] Elide alloca for unused received values in select.
axw updated this object.
axw edited the test plan for this revision. (Show Details)
axw added a reviewer: pcc.
axw added a subscriber: Unknown Object (MLST).
pcc added inline comments.Dec 28 2014, 7:03 AM
irgen/channels.go
64

It looks like we don't need this struct definition any more.

71

Was there any particular reason to make this a top-level function rather than a method?

136

There could in principle be multiple extract referrers. With this code you end up checking only the first one.

axw updated this revision to Diff 17702.Dec 29 2014, 5:25 PM
axw added inline comments.
irgen/channels.go
64

Thanks, removed.

71

It feels a little odd for frame to own methods; the frame is the subject here, so it feels more natural to have it as a top-level function operating on a frame. I'll change it back for now, for consistency's sake.

136

The loop and index check should take care of multiple extract instructions. I don't think there would ever be multiple extract referrers with the same index, would there?

axw updated this revision to Diff 17703.Dec 29 2014, 5:27 PM
pcc accepted this revision.Dec 30 2014, 3:41 PM
pcc edited edge metadata.

LGTM. Comment is mostly nitpicking, this is fine as is.

irgen/channels.go
71

Right, if we decide this is worth changing we should do it globally rather than be inconsistent.

136

Yes, I meant multiple extract referrers with the same index. I agree that we probably won't ever see this, but it wouldn't hurt to check for them.

This revision is now accepted and ready to land.Dec 30 2014, 3:41 PM
axw updated this revision to Diff 17737.Dec 30 2014, 6:07 PM
axw edited edge metadata.

Check all Extract referrers with a matching index, not just the first one.

irgen/channels.go
136

Okay, done.

axw updated this revision to Diff 17738.Dec 30 2014, 6:12 PM

Add missing test file.

axw updated this revision to Diff 17739.Dec 30 2014, 7:19 PM

Merge.

axw closed this revision.Dec 30 2014, 7:47 PM