summaryrefslogtreecommitdiff
path: root/opt
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2012-06-11 18:01:14 -0400
committerOri Bernstein <orib@google.com>2012-06-11 18:01:14 -0400
commit9057331b1a5952440d7e48e29492a4f7cfd111a3 (patch)
tree4b3d2e9d3419bc927a66e6c1af5c57af8a81a135 /opt
parent357b2411f4cb3d37ff54e8a7a13ae36d387a1bb8 (diff)
downloadmc-9057331b1a5952440d7e48e29492a4f7cfd111a3.tar.gz
Integer correctness fixes.
We were mixing signed and unsigned comparisons. This can lead to weird edge cases that nobody should have to reason about. Don't do that.
Diffstat (limited to 'opt')
-rw-r--r--opt/cfg.c12
-rw-r--r--opt/opt.h2
2 files changed, 7 insertions, 7 deletions
diff --git a/opt/cfg.c b/opt/cfg.c
index 04ab335..92e3d50 100644
--- a/opt/cfg.c
+++ b/opt/cfg.c
@@ -50,12 +50,12 @@ int addnode(Cfg *cfg, Bb *bb, Node *n)
return 0;
}
-Cfg *mkcfg(Node **nl, int nn)
+Cfg *mkcfg(Node **nl, size_t nn)
{
Cfg *cfg;
Bb *bb, *targ;
Node *a, *b;
- int i;
+ size_t i;
cfg = zalloc(sizeof(Cfg));
cfg->lblmap = mkht(strhash, streq);
@@ -116,7 +116,7 @@ Cfg *mkcfg(Node **nl, int nn)
}
void dumpcfg(Cfg *cfg, FILE *fd)
{
- int i, j;
+ size_t i, j;
Bb *bb;
char *sep;
@@ -125,7 +125,7 @@ void dumpcfg(Cfg *cfg, FILE *fd)
fprintf(fd, "\n");
fprintf(fd, "Bb: %d labels=(", bb->id);
sep = "";
- for (i = 0; i < bb->nlbls; i++) {
+ for (i = 0; i < bb->nlbls; i++) {;
fprintf(fd, "%s%s", bb->lbls[i], sep);
sep = ",";
}
@@ -136,7 +136,7 @@ void dumpcfg(Cfg *cfg, FILE *fd)
sep = "";
for (i = 0; i < bsmax(bb->in); i++) {
if (bshas(bb->in, i)) {
- fprintf(fd, "%s%d", sep, i);
+ fprintf(fd, "%s%zd", sep, i);
sep = ",";
}
}
@@ -147,7 +147,7 @@ void dumpcfg(Cfg *cfg, FILE *fd)
sep = "";
for (i = 0; i < bsmax(bb->out); i++) {
if (bshas(bb->out, i)) {
- fprintf(fd, "%s%d", sep, i);
+ fprintf(fd, "%s%zd", sep, i);
sep = ",";
}
}
diff --git a/opt/opt.h b/opt/opt.h
index dbf7dce..d875dbd 100644
--- a/opt/opt.h
+++ b/opt/opt.h
@@ -24,6 +24,6 @@ struct Bb {
};
/* Takes a reduced block, and returns a flow graph. */
-Cfg *mkcfg(Node **nl, int nn);
+Cfg *mkcfg(Node **nl, size_t nn);
void dumpcfg(Cfg *c, FILE *fd);
void flow(Cfg *cfg);