Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(75)

Side by Side Diff: src/cmd/gc/pgen.c

Issue 13334052: code review 13334052: cmd/gc: eliminate redundant &x.Field nil checks (Closed)
Patch Set: diff -r 2e735aa41d4a https://code.google.com/p/go/ Created 11 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/cmd/gc/gen.c ('k') | src/cmd/gc/popt.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // "Portable" code generation. 5 // "Portable" code generation.
6 // Compiled separately for 5g, 6g, and 8g, so allowed to use gg.h, opt.h. 6 // Compiled separately for 5g, 6g, and 8g, so allowed to use gg.h, opt.h.
7 // Must code to the intersection of the three back ends. 7 // Must code to the intersection of the three back ends.
8 8
9 #include <u.h> 9 #include <u.h>
10 #include <libc.h> 10 #include <libc.h>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 genlist(curfn->exit); 174 genlist(curfn->exit);
175 gclean(); 175 gclean();
176 if(nerrors != 0) 176 if(nerrors != 0)
177 goto ret; 177 goto ret;
178 178
179 pc->as = ARET; // overwrite AEND 179 pc->as = ARET; // overwrite AEND
180 pc->lineno = lineno; 180 pc->lineno = lineno;
181 181
182 if(!debug['N'] || debug['R'] || debug['P']) { 182 if(!debug['N'] || debug['R'] || debug['P']) {
183 regopt(ptxt); 183 regopt(ptxt);
184 nilopt(ptxt);
184 } 185 }
185 expandchecks(ptxt); 186 expandchecks(ptxt);
186 187
187 oldstksize = stksize; 188 oldstksize = stksize;
188 allocauto(ptxt); 189 allocauto(ptxt);
189 190
190 if(0) 191 if(0)
191 print("allocauto: %lld to %lld\n", oldstksize, (vlong)stksize); 192 print("allocauto: %lld to %lld\n", oldstksize, (vlong)stksize);
192 193
193 setlineno(curfn); 194 setlineno(curfn);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 531 }
531 } 532 }
532 533
533 void 534 void
534 cgen_checknil(Node *n) 535 cgen_checknil(Node *n)
535 { 536 {
536 Node reg; 537 Node reg;
537 538
538 if(disable_checknil) 539 if(disable_checknil)
539 return; 540 return;
540 » while(n->op == ODOT || (n->op == OINDEX && isfixedarray(n->left->type->t ype))) // NOTE: not ODOTPTR 541 » // Ideally we wouldn't see any TUINTPTR here, but we do.
541 » » n = n->left; 542 » if(n->type == T || (!isptr[n->type->etype] && n->type->etype != TUINTPTR && n->type->etype != TUNSAFEPTR)) {
543 » » dump("checknil", n);
544 » » fatal("bad checknil");
545 » }
542 if((thechar == '5' && n->op != OREGISTER) || !n->addable) { 546 if((thechar == '5' && n->op != OREGISTER) || !n->addable) {
543 regalloc(&reg, types[tptr], n); 547 regalloc(&reg, types[tptr], n);
544 cgen(n, &reg); 548 cgen(n, &reg);
545 gins(ACHECKNIL, &reg, N); 549 gins(ACHECKNIL, &reg, N);
546 regfree(&reg); 550 regfree(&reg);
547 return; 551 return;
548 } 552 }
549 gins(ACHECKNIL, n, N); 553 gins(ACHECKNIL, n, N);
550 } 554 }
OLDNEW
« no previous file with comments | « src/cmd/gc/gen.c ('k') | src/cmd/gc/popt.h » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b