ref: c87d318d74c70aa998b7188564a22f687dae99b9
parent: 6a4159ecf7e47dbbe155f887ed755a6346ad6eb3
author: Ori Bernstein <[email protected]>
date: Tue Oct 7 13:33:49 EDT 2014
Set the line number when generating labels. We want to know where errors come from.
--- a/opt/cfg.c
+++ b/opt/cfg.c
@@ -92,12 +92,12 @@
return 1;
}
-static Bb *addlabel(Cfg *cfg, Bb *bb, Node **nl, size_t i)
+static Bb *addlabel(Cfg *cfg, Bb *bb, Node **nl, size_t i, int line)
{
/* if the current block assumes fall-through, insert an explicit jump */
if (i > 0 && nl[i - 1]->type == Nexpr) {
if (exprop(nl[i - 1]) != Ocjmp && exprop(nl[i - 1]) != Ojmp)
- addnode(cfg, bb, mkexpr(-1, Ojmp, mklbl(-1, lblstr(nl[i])), NULL));
+ addnode(cfg, bb, mkexpr(line, Ojmp, mklbl(line, lblstr(nl[i])), NULL));
}
if (bb->nnl)
bb = mkbb(cfg);
@@ -137,6 +137,11 @@
case Oret:
bb->nnl = i + 1;
return;
+ case Ocall:
+ if (!isnonretcall(bb->nl[i]->expr.args[0]))
+ break;
+ bb->nnl = i + 1;
+ return;
default:
/* nothing */
break;
@@ -198,7 +203,7 @@
switch (nl[i]->type) {
case Nexpr:
if (islabel(nl[i]))
- bb = addlabel(cfg, bb, nl, i);
+ bb = addlabel(cfg, bb, nl, i, nl[i]->line);
else if (addnode(cfg, bb, nl[i]))
bb = mkbb(cfg);
break;