OLD | NEW |
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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 if(debug['g']) { | 547 if(debug['g']) { |
548 dump("\nagen-res", res); | 548 dump("\nagen-res", res); |
549 dump("agen-r", n); | 549 dump("agen-r", n); |
550 } | 550 } |
551 if(n == N || n->type == T || res == N || res->type == T) | 551 if(n == N || n->type == T || res == N || res->type == T) |
552 fatal("agen"); | 552 fatal("agen"); |
553 | 553 |
554 while(n->op == OCONVNOP) | 554 while(n->op == OCONVNOP) |
555 n = n->left; | 555 n = n->left; |
556 | 556 |
| 557 if(isconst(n, CTNIL) && n->type->width > widthptr) { |
| 558 // Use of a nil interface or nil slice. |
| 559 // Create a temporary we can take the address of and read. |
| 560 // The generated code is just going to panic, so it need not |
| 561 // be terribly efficient. See issue 3670. |
| 562 tempname(&n1, n->type); |
| 563 clearfat(&n1); |
| 564 regalloc(&n2, types[tptr], res); |
| 565 gins(ALEAQ, &n1, &n2); |
| 566 gmove(&n2, res); |
| 567 regfree(&n2); |
| 568 goto ret; |
| 569 } |
| 570 ················ |
| 571 |
557 if(n->addable) { | 572 if(n->addable) { |
558 memset(&n1, 0, sizeof n1); | 573 memset(&n1, 0, sizeof n1); |
559 n1.op = OADDR; | 574 n1.op = OADDR; |
560 n1.left = n; | 575 n1.left = n; |
561 regalloc(&n2, types[tptr], res); | 576 regalloc(&n2, types[tptr], res); |
562 gins(AMOVW, &n1, &n2); | 577 gins(AMOVW, &n1, &n2); |
563 gmove(&n2, res); | 578 gmove(&n2, res); |
564 regfree(&n2); | 579 regfree(&n2); |
565 goto ret; | 580 goto ret; |
566 } | 581 } |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 p->to.type = D_OREG; | 1406 p->to.type = D_OREG; |
1392 p->to.offset = dir; | 1407 p->to.offset = dir; |
1393 p->scond |= C_PBIT; | 1408 p->scond |= C_PBIT; |
1394 } | 1409 } |
1395 } | 1410 } |
1396 | 1411 |
1397 regfree(&dst); | 1412 regfree(&dst); |
1398 regfree(&src); | 1413 regfree(&src); |
1399 regfree(&tmp); | 1414 regfree(&tmp); |
1400 } | 1415 } |
OLD | NEW |