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

Andrew Wilkins axwalk at gmail.com
Mon Dec 29 17:26:12 PST 2014


================
Comment at: irgen/channels.go:64
@@ -62,3 +63,3 @@
 
 // selectState is equivalent to ssa.SelectState
 type selectState struct {
----------------
pcc wrote:
> It looks like we don't need this struct definition any more.
Thanks, removed.

================
Comment at: irgen/channels.go:71
@@ -69,4 +70,3 @@
 
-func (fr *frame) chanSelect(states []selectState, blocking bool) (index, recvOk *govalue, recvElems []*govalue) {
-	n := uint64(len(states))
-	if !blocking {
+func chanSelect(fr *frame, sel *ssa.Select) (index, recvOk *govalue, recvElems []*govalue) {
+	n := uint64(len(sel.States))
----------------
pcc wrote:
> Was there any particular reason to make this a top-level function rather than a method?
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.

================
Comment at: irgen/channels.go:136
@@ +135,3 @@
+		}
+		return len(*extract.Referrers()) > 0
+	}
----------------
pcc wrote:
> There could in principle be multiple `extract` referrers. With this code you end up checking only the first one.
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?

http://reviews.llvm.org/D6785

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list