Bug Summary

File:src/optfoam.c
Warning:line 369, column 4
Value stored to 'newConsts' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name optfoam.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/kfp/aldor/aldor/aldor/src -fcoverage-compilation-dir=/home/kfp/aldor/aldor/aldor/src -resource-dir /usr/local/lib/clang/18 -D PACKAGE_NAME="aldor" -D PACKAGE_TARNAME="aldor" -D PACKAGE_VERSION="1.4.0" -D PACKAGE_STRING="aldor 1.4.0" -D PACKAGE_BUGREPORT="aldor@xinutec.org" -D PACKAGE_URL="" -D PACKAGE="aldor" -D VERSION="1.4.0" -D YYTEXT_POINTER=1 -D HAVE_STDIO_H=1 -D HAVE_STDLIB_H=1 -D HAVE_STRING_H=1 -D HAVE_INTTYPES_H=1 -D HAVE_STDINT_H=1 -D HAVE_STRINGS_H=1 -D HAVE_SYS_STAT_H=1 -D HAVE_SYS_TYPES_H=1 -D HAVE_UNISTD_H=1 -D STDC_HEADERS=1 -D HAVE_LIBREADLINE=1 -D HAVE_READLINE_READLINE_H=1 -D HAVE_READLINE_HISTORY=1 -D HAVE_READLINE_HISTORY_H=1 -D USE_GLOOP_SHELL=1 -D GENERATOR_COROUTINES=0 -D HAVE_DLFCN_H=1 -D LT_OBJDIR=".libs/" -I . -D VCSVERSION="2c53e759f1e00e345f8b172e7139debda72fda13" -internal-isystem /usr/local/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-empty-body -Wno-enum-compare -Wno-missing-field-initializers -Wno-unused -Wno-unused-parameter -Wno-error=format -Wno-error=type-limits -Wno-error=strict-aliasing -Wno-sign-compare -Wno-error=shift-negative-value -Wno-error=clobbered -std=c99 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2026-01-15-223856-845667-1 -x c optfoam.c
1/*****************************************************************************
2 *
3 * optfoam.c: Foam-to-foam optimizaion.
4 *
5 * Copyright (c) 1990-2007 Aldor Software Organization Ltd (Aldor.org).
6 *
7 ****************************************************************************/
8
9#include "axlobs.h"
10#include "debug.h"
11#include "flatten.h"
12#include "flog.h"
13#include "format.h"
14#include "inlutil.h"
15#include "loops.h"
16#include "of_argsub.h"
17#include "of_cfold.h"
18#include "of_comex.h"
19#include "of_cprop.h"
20#include "of_crinlin.h"
21#include "of_deada.h"
22#include "of_deadv.h"
23#include "of_emerg.h"
24#include "of_env.h"
25#include "of_hfold.h"
26#include "of_inlin.h"
27#include "of_jflow.h"
28#include "of_killp.h"
29#include "of_peep.h"
30#include "of_retyp.h"
31#include "of_rrfmt.h"
32#include "optfoam.h"
33#include "store.h"
34#include "strops.h"
35
36Bool optfDebug = false((int) 0);
37Bool optfShowDebug = false((int) 0);
38
39#define optfDEBUGif (!optfDebug) { } else afprintf DEBUG_IF(optf)if (!optfDebug) { } else afprintf
40#define optfShowDEBUGif (!optfShowDebug) { } else afprintf DEBUG_IF(optfShow)if (!optfShowDebug) { } else afprintf
41
42static int optInline;
43static int optInlineAll;
44static int optJFlowLimit;
45static int optInlineLimit;
46int optInlineRoof;
47static int optConstFold;
48static int optFloatFold;
49static int optHashFold;
50static int optDeadVar;
51static int optDeadAssign;
52static int optPeepHole;
53static int optCommExp;
54static int optEnvMerge;
55static int optEnvOpts;
56static int optCopyProp;
57static int optJumpFlow;
58static int optCast;
59static int optCC;
60static int optArgSub;
61static int optArgCrinlin;
62static int optCcFnonstd;
63static int optIgnoreAsserts;
64static int optKillPointers;
65static int optEmergeRRFmt;
66
67#define OPT_Negate"no-" "no-"
68#define OPT_All"all" "all"
69#define OPT_InlineAll"inline-all" "inline-all"
70
71#define OPT_MaxQLevel9 9
72#define OPT_MaxLevel4 4
73#define OPT_DefaultLevel1 1
74
75static int optLevel = OPT_DefaultLevel1;
76
77enum optNature {
78 OPT_FLAG,
79 OPT_FLOAT
80};
81
82struct optControl {
83 String name;
84 enum optNature nature;
85 int *pvar;
86 int value[OPT_MaxLevel4+1];
87};
88
89/******************************************************************************
90 *
91 * :: Local operations
92 *
93 *****************************************************************************/
94
95localstatic void optInitFormatters();
96
97localstatic void optSetAllTo (Bool);
98localstatic void optSetLevel (int);
99localstatic void optPrintOpts (FILE *fout);
100localstatic void optSetJFlowLimit (void);
101localstatic void optOptimizationsInit (void);
102
103
104/*
105 * Control Option processing: note that -Qinline-limit and -Qinline-size
106 * arguments supplied by the user are multiplied by 100.
107 */
108struct optControl optControl[] = {
109/* name nature pvar Q0 Q1 Q2 Q3 Q4. */
110{"inline", OPT_FLAG, &optInline, { 0, 0, 1, 1, 1}},
111{OPT_InlineAll"inline-all", OPT_FLAG, &optInlineAll, { 0, 0, 0, 1, 1}},
112{"inline-limit",OPT_FLOAT, &optInlineLimit, { 0, 0, 500, 600, 800}},
113{"inline-size", OPT_FLOAT, &optInlineRoof, { 0, 0, 1000, 2000, 4000}},
114{"cfold", OPT_FLAG, &optConstFold, { 0, 1, 1, 1, 1}},
115{"ffold", OPT_FLAG, &optFloatFold, { 0, 0, 1, 1, 1}},
116{"hfold", OPT_FLAG, &optHashFold, { 0, 1, 1, 1, 1}},
117{"deadvar", OPT_FLAG, &optDeadVar, { 0, 1, 1, 1, 1}},
118{"dassign", OPT_FLAG, &optDeadAssign, { 0, 0, 1, 1, 1}},
119{"peep", OPT_FLAG, &optPeepHole, { 0, 1, 1, 1, 1}},
120{"cprop", OPT_FLAG, &optCopyProp, { 0, 0, 1, 1, 1}},
121{"cse", OPT_FLAG, &optCommExp, { 0, 0, 1, 1, 1}},
122{"env", OPT_FLAG, &optEnvOpts, { 0, 0, 1, 1, 1}},
123{"emerge", OPT_FLAG, &optEnvMerge, { 0, 0, 1, 1, 1}},
124{"emerge-rr", OPT_FLAG, &optEmergeRRFmt, { 0, 0, 1, 1, 1}},
125{"flow", OPT_FLAG, &optJumpFlow, { 0, 0, 1, 1, 1}},
126{"cast", OPT_FLAG, &optCast, { 0, 0, 1, 1, 1}},
127{"cc", OPT_FLAG, &optCC, { 0, 0, 1, 1, 1}},
128{"del-assert", OPT_FLAG, &optIgnoreAsserts, { 0, 0, 1, 1, 1}},
129{"cc-fnonstd", OPT_FLAG, &optCcFnonstd, { 0, 0, 0, 0, 0}},
130/* The next three are experimental or future-work */
131{"killp", OPT_FLAG, &optKillPointers, { 0, 0, 0, 0, 0}},
132{"argsub", OPT_FLAG, &optArgSub, { 0, 0, 0, 0, 0}},
133{"crinlin", OPT_FLAG, &optArgCrinlin, { 0, 0, 1, 1, 1}},
134{ 0 }
135};
136
137/* optInlineLimit for Q5 Q6 Q7 Q8 Q9 */
138static int optQInlineLimit[] = {1000, 1400, 1800, 3000, -1};
139
140/*
141 * Set all flags to the given value.
142 */
143localstatic void
144optSetAllTo(Bool flag)
145{
146 int i;
147
148 for (i = 0; optControl[i].name; i++)
149 if (optControl[i].nature == OPT_FLAG)
150 *optControl[i].pvar = flag;
151}
152
153/*
154 * Set all flags and control variables to the values suitable for the
155 * given optimization level.
156 */
157localstatic void
158optSetLevel(int lev)
159{
160 int i, index;
161
162 optLevel = lev;
163#if OLD_SET_LEVEL
164 optInlineLimit = optQInlineLimit[lev - OPT_MaxLevel4 -1];
165 index = (lev > OPT_MaxLevel4 ? OPT_MaxLevel4 : lev);
166
167 for (i = 0; optControl[i].name; i++)
168 *optControl[i].pvar = optControl[i].value[index];
169#else
170 index = (lev > OPT_MaxLevel4 ? OPT_MaxLevel4 : lev);
171
172 for (i = 0; optControl[i].name; i++)
173 *optControl[i].pvar = optControl[i].value[index];
174
175 if (lev > OPT_MaxLevel4)
176 optInlineLimit = optQInlineLimit[lev - OPT_MaxLevel4 - 1];
177#endif
178}
179
180localstatic void
181optPrintOpts(FILE *fout)
182{
183 int i;
184 fprintf(fout, "Optimizations selected:\n");
185 for (i = 0; optControl[i].name; i++)
186 fprintf(fout, "%15s %d\n", optControl[i].name, *optControl[i].pvar);
187}
188
189void
190optInit(void)
191{
192 optSetLevel(OPT_DefaultLevel1);
193 optInitFormatters();
194}
195
196int
197optSetStdOptimization(void)
198{
199 return optSetOptimization("2");
200}
201
202void
203optSetLoopOption(void)
204{
205 inlSetGenerators();
206}
207
208int
209optSetOptimization(String opt)
210{
211 int i;
212 String s;
213 Bool isOn;
214
215 /* LEVELS: -Qn for n in 0..OPT_MaxLevel */
216 i = opt[0] - '0';
217 if (!opt[1] && 0 <= i && i <= OPT_MaxQLevel9) {
218 optSetLevel(i);
219 return 0;
220 }
221
222 /* INTEGERS: -Qxxx=nnn or -Qxxx:nnn */
223 for (i = 0; optControl[i].name; i++) {
224 if (optControl[i].nature != OPT_FLOAT) continue;
225 if ((s = strAIsPrefix(optControl[i].name, opt)) == 0) continue;
226 if (*s != '=' && *s != ':') continue;
227
228 s += 1;
229 *optControl[i].pvar = (int) (100 * atof(s));
230 return 0;
231 }
232
233 /* FLAGS: -Qxxx -Qno-xxx ... */
234 isOn = true1;
235 while (s = strAIsPrefix(OPT_Negate"no-", opt), s) {
236 isOn = !isOn;
237 opt = s;
238 }
239
240 if (strAEqual(opt, OPT_All"all")) {
241 optSetAllTo(isOn);
242 return 0;
243 }
244 if (strEqual(opt, OPT_InlineAll"inline-all")) {
245 optInlineAll = isOn;
246 if (isOn) optInline = isOn;
247 return 0;
248 }
249
250 for (i = 0; optControl[i].name; i++) {
251 if (!strEqual(opt, optControl[i].name)) continue;
252 if (optControl[i].nature != OPT_FLAG) continue;
253 *optControl[i].pvar = isOn;
254 return 0;
255 }
256
257 /* FAILED */
258 return -1;
259}
260
261Foam
262optimizeFoam(Foam foam)
263{
264 Bool newConsts = false((int) 0);
265 int i, iters;
266 if (DEBUG(optf)optfDebug){optPrintOpts(dbOut);}
267 if (DEBUG(optfShow)optfShowDebug) {
268 afprintf(dbOut, "optfoam - in:\n%pFoam\n", foam);
269 }
270 optOptimizationsInit();
271
272 if (optDeadVar) {
273 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting deadvar...\n");
274 dvElim(foam);
275 if (DEBUG(phase)phaseDebug){stoAudit();}
276 }
277 if (optInline) {
278 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting inline...\n");
279 inlineUnit(foam, optInlineAll, optInlineLimit, true1);
280 if (DEBUG(phase)phaseDebug){stoAudit();}
281 }
282 if (optInline) {
283 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting coroutine inline...\n");
284 crinUnit(foam);
285 inlineUnit(foam, optInlineAll, optInlineLimit, true1);
286 if (DEBUG(phase)phaseDebug){stoAudit();}
287 }
288 /* Maybe we ought to cprop before cfold? */
289 if (optConstFold || optFloatFold) {
290 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting cfold...\n");
291 newConsts = cfoldUnit(foam, optConstFold, optFloatFold);
292 if (DEBUG(phase)phaseDebug){stoAudit();}
293 }
294 while (newConsts && optInline) {
295 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting expr inline...\n");
296 /* If const folding made new constants, inline them. */
297 inlineUnit(foam, optInlineAll, optInlineLimit, false((int) 0));
298 newConsts = cfoldUnit(foam, optConstFold, optFloatFold);
299 if (DEBUG(phase)phaseDebug){stoAudit();}
300 }
301 if (newConsts && optInline) {
302 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting coroutine inline...\n");
303 crinUnit(foam);
304 if (DEBUG(phase)phaseDebug){stoAudit();}
305 }
306 if (optHashFold) {
307 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting hfold...\n");
308 hfoldUnit(foam);
309 cpropUnit(foam, false((int) 0));
310 cfoldUnit(foam, optConstFold, optFloatFold);
311 if (DEBUG(phase)phaseDebug){stoAudit();}
312 }
313 if (optEmergeRRFmt) {
314 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting emerge-rr...\n");
315 rrUnitEmerge(foam);
316 if (DEBUG(phase)phaseDebug){stoAudit();}
317 }
318 if (optEnvMerge) {
319 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting emerge...\n");
320 emMergeUnit(foam);
321 if (DEBUG(phase)phaseDebug){stoAudit();}
322 }
323 if (optDeadVar) {
324 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting deadvar...\n");
325 dvElim(foam);
326 if (DEBUG(phase)phaseDebug){stoAudit();}
327 }
328 if (optEnvOpts) {
329 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting env. opts...\n");
330 oeUnit(foam);
331 if (DEBUG(phase)phaseDebug){stoAudit();}
332 }
333 if (optCast) {
334 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting retype...\n");
335 retypeUnit(foam);
336 if (DEBUG(phase)phaseDebug){stoAudit();}
337 }
338
339 if (optLevel > 5)
340 iters = 5;
341 else if (optLevel == 0)
342 iters = 1;
343 else
344 iters = optLevel;
345
346 for (i=0; i<iters; i++) {
347 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "STARTING LOOP (%d)\n", i);
348
349 if (DEBUG(optf)optfDebug){foamWrSExpr(dbOut, foam, int0((int) 0));}
350#if 0
351 if (optInline) {
352 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting inline...\n");
353 inlineUnit(foam, optInlineAll, optInlineLimit, true1);
354 if (DEBUG(phase)phaseDebug){stoAudit();}
355 }
356#endif
357 if (optCopyProp) {
358 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting cprop...\n");
359 cpropUnit(foam, i == 0);
360 if (DEBUG(phase)phaseDebug){stoAudit();}
361 }
362 if (optPeepHole) {
363 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting peep...\n");
364 peepUnit(foam,optFloatFold);
365 if (DEBUG(phase)phaseDebug){stoAudit();}
366 }
367 if (optConstFold || optFloatFold) {
368 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting cfold...\n");
369 newConsts = cfoldUnit(foam, optConstFold,optFloatFold);
Value stored to 'newConsts' is never read
370 if (DEBUG(phase)phaseDebug){stoAudit();}
371 }
372 if (optCommExp) {
373 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting cse...\n");
374 cseUnit(foam);
375 if (DEBUG(phase)phaseDebug){stoAudit();}
376 }
377#if 0
378 while (newConsts && optInline) {
379 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting expr inline...\n");
380 /* If const folding made new constants, inline them. */
381 inlineUnit(foam, optInlineAll, optInlineLimit, false((int) 0));
382 newConsts = cfoldUnit(foam, optConstFold, optFloatFold);
383 if (DEBUG(phase)phaseDebug){stoAudit();}
384 }
385#endif
386#if 0
387 if (optArgSub) {
388 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting argsub...\n");
389 argsubUnit(foam);
390 if (DEBUG(phase)phaseDebug){stoAudit();}
391 }
392#endif
393 if (optJumpFlow) {
394 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting jflow...\n");
395 jflowUnit(foam, optJFlowLimit);
396 if (DEBUG(phase)phaseDebug){stoAudit();}
397 }
398 if (optDeadAssign) {
399 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting dead assign...\n");
400 deadAssign(foam);
401 if (DEBUG(phase)phaseDebug){stoAudit();}
402 }
403
404 if (optDeadVar) {
405 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting deadvar...\n");
406 dvElim(foam);
407 if (DEBUG(phase)phaseDebug){stoAudit();}
408 }
409#if 0
410 if (optEnvMerge) {
411 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting emerge...\n");
412 emMergeUnit(foam);
413 if (DEBUG(phase)phaseDebug){stoAudit();}
414 }
415#endif
416 }
417
418 if (optEnvOpts) {
419 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting env. opts...\n");
420 oeUnit(foam);
421 if (DEBUG(phase)phaseDebug){stoAudit();}
422 }
423
424 if (optPeepHole) {
425 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Starting peep...\n");
426 peepUnit(foam,optFloatFold);
427 if (DEBUG(phase)phaseDebug){stoAudit();}
428 }
429
430 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "(Starting patchUnit...)\n");
431
432 fpPatchUnit(foam);
433
434 /*
435 * inlSetAfterInline turns on checking for domainGetExport
436 * when using -W runtime.
437 */
438 inlSetAfterInline()(inl0AfterInline=1);
439
440 if (optInline) {
441 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "(Starting unitInfoRefresh...)\n");
442 inuUnitInfoRefresh(foam);
443 }
444
445 /* Remove any nested CCalls, etc */
446 /*flattenUnit(foam);*/
447
448 optfDEBUGif (!optfDebug) { } else afprintf(dbOut, "Optimizations finished.\n");
449
450 if (DEBUG(optfShow)optfShowDebug) {
451 afprintf(dbOut, "optfoam - out:\n%pFoam\n", foam);
452 }
453
454 foamAuditAll(foam, 0xffff);
455
456 assert(foamAudit(foam))do { if (!(foamAudit(foam))) _do_assert(("foamAudit(foam)"),"optfoam.c"
,456); } while (0)
;
457
458 return foam;
459}
460
461/* This seems reasonable. Note: assumes that with -Q3 limit=600 */
462localstatic void
463optSetJFlowLimit(void)
464{
465 if (optInlineLimit > -1)
466 optJFlowLimit = optInlineLimit / 20;
467 else
468 optJFlowLimit = 30000;
469}
470
471Bool
472optIsCcOptimizeWanted(void)
473{
474 return optCC;
475}
476
477Bool
478optIsCcFNonStdWanted(void)
479{
480 return optCcFnonstd;
481}
482
483Bool
484optIsFloatFoldWanted(void)
485{
486 return optFloatFold;
487}
488
489Bool
490optIsIgnoreAssertsWanted(void)
491{
492 return optIgnoreAsserts;
493}
494
495Bool
496optIsDeadVarWanted(void)
497{
498 return optDeadVar;
499}
500
501Bool
502optIsKillPointersWanted(void)
503{
504 return optKillPointers;
505}
506
507Bool
508optIsMaxLevel(void)
509{
510 return optLevel == OPT_MaxQLevel9;
511}
512
513/* Put here a every call needed to initialize an optimization. */
514localstatic void
515optOptimizationsInit()
516{
517 dvInit();
518 optSetJFlowLimit();
519}
520
521/*
522 * :: Formatters
523 */
524localstatic int flogFormatter(OStream stream, Pointer p);
525localstatic int loopFormatter(OStream stream, Pointer p);
526localstatic int bbFormatter(OStream stream, Pointer p);
527localstatic int bbufFormatter(OStream stream, Pointer p);
528localstatic int bbListFormatter(OStream stream, Pointer p);
529localstatic int loopListFormatter(OStream stream, Pointer p);
530
531localstatic void
532optInitFormatters()
533{
534 fmtRegisterFull("FlowGraph", flogFormatter, false((int) 0));
535
536 fmtRegisterFull("Loop", loopFormatter, false((int) 0));
537 fmtRegisterFull("LoopList", loopListFormatter, true1);
538
539 fmtRegisterFull("BBlock", bbFormatter, false((int) 0));
540 fmtRegisterFull("BBlockList", bbListFormatter, true1);
541
542 fmtRegisterFull("BlockBuf", bbufFormatter, false((int) 0));
543
544}
545
546localstatic int
547flogFormatter(OStream stream, Pointer p)
548{
549 FlowGraph flog = (FlowGraph) p;
550 int c=0;
551 int i;
552
553 c += ostreamPrintf(stream, "(Flog:");
554 for (i=0; i < flogBlockC(flog)((flog)->blocks->pos); i++) {
555 c += ostreamPrintf(stream, " %pBBlock", flogBlock(flog, i)bbufBlockFn((flog)->blocks,i));
556 }
557 c += ostreamPrintf(stream, ")");
558
559 return c;
560}
561
562localstatic int
563loopFormatter(OStream stream, Pointer p)
564{
565 Loop loop = (Loop) p;
566 int c;
567
568 c = ostreamPrintf(stream, "[L: %d %pBBlockList]", loop->header->label, loop->blockList);
569
570 return c;
571}
572
573localstatic int
574bbFormatter(OStream stream, Pointer p)
575{
576 BBlock bb = (BBlock) p;
577 int c;
578 c = ostreamPrintf(stream, "[B %s %d In: %pBlockBuf Out: %pBlockBuf]",
579 bb->kind < FOAM_LIMIT ? foamStr(bb->kind)((foamInfoTable [(int)(bb->kind)-(int)FOAM_START]).str) : "???",
580 bb->label, bb->entries, bb->exits);
581 return c;
582}
583
584localstatic int
585bbufFormatter(OStream stream, Pointer p)
586{
587 BlockBuf bf = (BlockBuf) p;
588 int c = 0;
589 int i;
590 char *sep = "";
591
592 ostreamWriteChar(stream, '(');
593 c++;
594 for (i=0; i < bbufCount(bf)((bf)->pos); i++) {
595 BBlock bb = bbufBlock(bf, i)bbufBlockFn(bf,i);
596 c += ostreamPrintf(stream, "%s%d", sep, bb->label);
597 sep = " ";
598 }
599 ostreamWriteChar(stream, ')');
600 c++;
601
602 return c;
603}
604
605localstatic int
606loopListFormatter(OStream ostream, Pointer p)
607{
608 LoopList list = (LoopList) p;
609 return listFormat(Loop)(Loop_listPointer->Format)(ostream, "Loop", list);
610}
611localstatic int
612bbListFormatter(OStream ostream, Pointer p)
613{
614 BBlockList list = (BBlockList) p;
615 return listFormat(BBlock)(BBlock_listPointer->Format)(ostream, "BBlock", list);
616}