This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Completing GCC Go escape analysis in GSoC 2014


Hi, I'm a student interested in working on GCC and want to make a
proposal of GSoC 2014 on GCC Go escape analysis.

I 've read code under /gcc/testsuit/go.* the some source code of
gofrontend, and realization of escape analysis and furthermore
optimization is needed.

Right now I have come up with a small patch of escape test at the
beginning. My patch aims at test for whether escape analysis is
working. Then I want to start some small part of performance function
and write more tests for optimization. Am i on the right direction?
Thanks a lot if anyone can give me some advice.

Ray Li
package main

import(

)

var glob_var = 0

//escape;
func global1(p bool) {
	if p == true {
		glob_var = 987654321
	}
}

//tests for escape as return
//variable v returned as the result of the current function
func escape1() int {
	v := 123
	return v
}
func escape1b() (int, int) {
	x, y := 123, 456
	return x, y				//both p and q escaped
}
func escape2(p *int) int {
	return *p
}

func escape2a(p, q *int) (*int, *int) {
	return p, q				//escaped
}
func escape2b(p, q *int) (*int, *int) {
	return escape2a(p, q)	//escaped
}
func escape3(p *int) *int {
	q := p
	if *p > 0 {
		return q			//p escaped
	} else {
		return nil
	}
}


//tests for no escape
func noesc1(ptr *int) int {
	return *ptr				//not escape
}
func noesc2() {
	var p int
	q := noesc1(&p)			//not escape
	t := q
	_ = t
}
func noesc3() {
	var p int
	q := escape2(&p)		//not escape
	_ = q
}
func noesc4() {
	var p int
	q := escape2(&p)		//escape
	glob_var = q
}


type T struct {
	a, b int
}

func (t *T) foo(x int) (*T, bool) {
	t.a = x
	t.b = t.a + x
	return t, true			//escape as return
}
func f() *T {
	p, _ := new(T).foo(123)
	return p
}

//escape recursively
func escrecursive(p, q int) int {
	if p + q > 0 {
		return escrecursive(p-1, q-1)
	} else {
		return p * q		//escape as return and also this function become recursively escape
	}
}

func main() {
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]