LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 // | 4 // |
5 // The inlining facility makes 2 passes: first caninl determines which | 5 // The inlining facility makes 2 passes: first caninl determines which |
6 // functions are suitable for inlining, and for those that are it | 6 // functions are suitable for inlining, and for those that are it |
7 // saves a copy of the body. Then inlcalls walks each function body to | 7 // saves a copy of the body. Then inlcalls walks each function body to |
8 // expand calls to inlinable functions. | 8 // expand calls to inlinable functions. |
9 // | 9 // |
10 // The debug['l'] flag controls the agressiveness. Note that main() swaps level
0 and 1, | 10 // The debug['l'] flag controls the agressiveness. Note that main() swaps level
0 and 1, |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 dcl = fn->defn->dcl; | 549 dcl = fn->defn->dcl; |
550 else // imported function | 550 else // imported function |
551 dcl = fn->dcl; | 551 dcl = fn->dcl; |
552 | 552 |
553 inlretvars = nil; | 553 inlretvars = nil; |
554 i = 0; | 554 i = 0; |
555 // Make temp names to use instead of the originals | 555 // Make temp names to use instead of the originals |
556 for(ll = dcl; ll; ll=ll->next) | 556 for(ll = dcl; ll; ll=ll->next) |
557 if(ll->n->op == ONAME) { | 557 if(ll->n->op == ONAME) { |
558 ll->n->inlvar = inlvar(ll->n); | 558 ll->n->inlvar = inlvar(ll->n); |
| 559 // Typecheck because inlvar is not necessarily a functio
n parameter. |
| 560 typecheck(&ll->n->inlvar, Erv); |
559 ninit = list(ninit, nod(ODCL, ll->n->inlvar, N)); // ot
herwise gen won't emit the allocations for heapallocs | 561 ninit = list(ninit, nod(ODCL, ll->n->inlvar, N)); // ot
herwise gen won't emit the allocations for heapallocs |
560 if (ll->n->class == PPARAMOUT) // we rely on the order
being correct here | 562 if (ll->n->class == PPARAMOUT) // we rely on the order
being correct here |
561 inlretvars = list(inlretvars, ll->n->inlvar); | 563 inlretvars = list(inlretvars, ll->n->inlvar); |
562 } | 564 } |
563 | 565 |
564 // anonymous return values, synthesize names for use in assignment that
replaces return | 566 // anonymous return values, synthesize names for use in assignment that
replaces return |
565 if(inlretvars == nil && fn->type->outtuple > 0) | 567 if(inlretvars == nil && fn->type->outtuple > 0) |
566 for(t = getoutargx(fn->type)->type; t; t = t->down) { | 568 for(t = getoutargx(fn->type)->type; t; t = t->down) { |
567 m = retvar(t, i++); | 569 m = retvar(t, i++); |
568 ninit = list(ninit, nod(ODCL, m, N)); | 570 ninit = list(ninit, nod(ODCL, m, N)); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 setlno(n->left, lno); | 823 setlno(n->left, lno); |
822 setlno(n->right, lno); | 824 setlno(n->right, lno); |
823 setlnolist(n->list, lno); | 825 setlnolist(n->list, lno); |
824 setlnolist(n->rlist, lno); | 826 setlnolist(n->rlist, lno); |
825 setlnolist(n->ninit, lno); | 827 setlnolist(n->ninit, lno); |
826 setlno(n->ntest, lno); | 828 setlno(n->ntest, lno); |
827 setlno(n->nincr, lno); | 829 setlno(n->nincr, lno); |
828 setlnolist(n->nbody, lno); | 830 setlnolist(n->nbody, lno); |
829 setlnolist(n->nelse, lno); | 831 setlnolist(n->nelse, lno); |
830 } | 832 } |
LEFT | RIGHT |