LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 #include <u.h> | 5 #include <u.h> |
6 #include <libc.h> | 6 #include <libc.h> |
7 #include "gg.h" | 7 #include "gg.h" |
8 | 8 |
9 /* | 9 /* |
10 * generate: | 10 * generate: |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 if(debug['g']) { | 511 if(debug['g']) { |
512 dump("\nagen-res", res); | 512 dump("\nagen-res", res); |
513 dump("agen-r", n); | 513 dump("agen-r", n); |
514 } | 514 } |
515 if(n == N || n->type == T) | 515 if(n == N || n->type == T) |
516 return; | 516 return; |
517 | 517 |
518 while(n->op == OCONVNOP) | 518 while(n->op == OCONVNOP) |
519 n = n->left; | 519 n = n->left; |
520 | 520 |
| 521 if(isconst(n, CTNIL) && n->type->width > widthptr) { |
| 522 // Use of a nil interface or nil slice. |
| 523 // Create a temporary we can take the address of and read. |
| 524 // The generated code is just going to panic, so it need not |
| 525 // be terribly efficient. See issue 3670. |
| 526 tempname(&n1, n->type); |
| 527 clearfat(&n1); |
| 528 regalloc(&n2, types[tptr], res); |
| 529 gins(ALEAQ, &n1, &n2); |
| 530 gmove(&n2, res); |
| 531 regfree(&n2); |
| 532 goto ret; |
| 533 } |
| 534 ················ |
521 if(n->addable) { | 535 if(n->addable) { |
522 regalloc(&n1, types[tptr], res); | 536 regalloc(&n1, types[tptr], res); |
523 gins(ALEAQ, n, &n1); | 537 gins(ALEAQ, n, &n1); |
524 gmove(&n1, res); | 538 gmove(&n1, res); |
525 regfree(&n1); | 539 regfree(&n1); |
526 goto ret; | 540 goto ret; |
527 } | 541 } |
528 | 542 |
529 nl = n->left; | 543 nl = n->left; |
530 nr = n->right; | 544 nr = n->right; |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 regfree(&nodl); | 1425 regfree(&nodl); |
1412 return 0; | 1426 return 0; |
1413 | 1427 |
1414 yes: | 1428 yes: |
1415 if(freer) | 1429 if(freer) |
1416 regfree(&nodr); | 1430 regfree(&nodr); |
1417 if(freel) | 1431 if(freel) |
1418 regfree(&nodl); | 1432 regfree(&nodl); |
1419 return 1; | 1433 return 1; |
1420 } | 1434 } |
LEFT | RIGHT |