Completing GCC Go escape analysis in GSoC 2014

2014-03-12 Thread Ray Li
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() {
}


Re: Completing GCC Go escape analysis in GSoC 2014

2014-03-16 Thread Ray Li
Hi Ian

I have spend these 3 days to read lots of documents about Go and
gccgo. And scan many papers about escape analysis.

I plan to use about next 2 days to read more source code of gccgo.

In order to dig more and come to a more detailed and efficient
proposal. I need your suggestion:

-Which codes must I read firstly, and which are the most
important to read very carefully?

-Do you have suggestions on where should I start? What small
implementations can I firstly accomplish?

-What would be the background knowledge needed? As there would
be more requirements regarding this specific idea not now obvious.

-Are there some documentations or papers should I read now?

I really appreciate your help =D

Ray




On Fri, Mar 14, 2014 at 6:11 AM, Ian Lance Taylor  wrote:
> On Wed, Mar 12, 2014 at 8:31 PM, Ray Li  wrote:
>>
>> 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.
>
> Thanks for your interest.  Yes, all of your examples look correct to
> me.
>
> There is a larger escape analysis test in libgo/go/fmt/fmt_test.go.
> That file is copied from the master repository, but in mallocTest the
> numbers are changed.  Instead of 7 5's and a 20, it should be 0, 1, 1,
> 2, 1, 2, 0, 1.
>
> Ian


[GSoC 2014]Is this proposal suitable?

2014-03-16 Thread Ray Li
I have made a proposal and wonder if it is clearly and realistic?

Thanks for every correction.

Ray
GCC Go escape analysis


The Project

The Project aims to accomplish escape analysis for gccgo.


Goal:

escape analysis

(optimization) converting heap allocation to stack allocation

Schedule:

21 April - 25 May 
Preparation:communicate with mentor, read gccgo source code, get 
familiar with tools, coding and documenting style, try submit some small 
patches.

26 May - 8 June
Coding to implement escape analysis.

9 June - 15 June
Do some tests and improvements.

16 June - 29 June
Do optimization work.(converting heap allocation to stack 
allocation)

30 June - 11 August
(if permits)More optimization implementation.
Detailed Testing.



Re: [GSoC 2014]Is this proposal suitable?

2014-03-16 Thread Ray Li
Thank you. I will made it a little more specific.

And now I've made it a little bit slower ...

And divide my first stage work into 2 parts for the present.

I'll look for more information to accomplish it.

On Mon, Mar 17, 2014 at 3:26 AM, Joel Sherrill
 wrote:
>
> On Mar 16, 2014 2:15 PM, Ray Li  wrote:
>>
>> I have made a proposal and wonder if it is clearly and realistic?
>
> I am not a GCC mentor but have mentored for another project for 8 years. I
> would like to see more detail. For example, what exactly will you deliver by
> midterm? At the end?
>
> Break the effort into smaller steps so progress is easier to see and
> measure.
>
> A Go developer would have to answer this but I like to see something that
> shows a student is in a good place to start. Can you build GCC and Go and
> publish test results? Can you provide a small test case showing what is
> missing (assuming this is possible)?
>
> Will you need to do any copyright assignment paperwork? Ian will have to
> answer this.
>
> Break the project down, show you will hit the ground running, and show us
> how to measure your progress.
>
> --joel
> RTEMS and GCC
>
>>
>> Thanks for every correction.
>>
>> Ray
GCC Go escape analysis


The Project

The Project aims to accomplish escape analysis for gccgo.


Goal:

escape analysis

(optimization) converting heap allocation to stack allocation

Schedule:

21 April - 25 May 
Preparation:communicate with mentor, read gccgo source code, get 
familiar with tools, coding and documenting style, try submit some small 
patches.

26 May - 8 June
Coding to implement GlobalEscape analysis.

9 June - 22 June
Coding to implement ArgEscape analysis

23 June - 29 June
finish mid-term evaluations
Do some tests and improvements.
30 June - 13 July
Some implementation work.(optimization: convert heap allocation 
to stack allocation)

14 July - 11 August
(if permits)More optimization implementation.
Detailed Testing.

Details:

Mid-term: The basis implementation of escape analysis.(enable to 
determine the 3 status of escape (GlobalEscape, ArgEscape and NoEscape))
Final results: Use escape analysis to do optimizations.(I have list 
one, but I will try as fast to do more...)