Files
clang-p2996/llgo/test/irgen/select.go
Andrew Wilkins 75f34af99c [llgo] Elide alloca for unused received values in select
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.

Test Plan: lit test added

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6785

llvm-svn: 225033
2014-12-31 03:46:49 +00:00

19 lines
334 B
Go

// RUN: llgo -S -emit-llvm -o - %s | FileCheck %s
package foo
// CHECK-NOT: alloca [1024 x i8]
// CHECK-NOT: alloca [2048 x i8]
// CHECK: alloca [4096 x i8]
func F() {
ch1 := make(chan [1024]byte)
ch2 := make(chan [2048]byte)
ch3 := make(chan [4096]byte)
select {
case <-ch1:
case _ = <-ch2:
case x := <-ch3:
_ = x[0]
}
}