Measuring memory usage of opt passes.

Hi,

I need to measure the memory usage of opt passes and have some questions in this regard.

First off, this does not really do anything; is it a bug?

$ clang -mllvm -time-passes -mllvm -track-memory -c -O3 ./p0.c

So, instead, I do:

$ clang -emit-llvm -O3 -c ./p0.c

$ opt -time-passes -track-memory ./p0.bc -O3 -o p0.O3.bc 2> p0.O3.txt

Which gets me the report I am looking for, however, I do not understand why there are negative numbers in the Mem column.

Hi,

I need to measure the memory usage of opt passes and have some questions in
this regard.

First off, this does not really do anything; is it a bug?

$ clang -mllvm -time-passes -mllvm -track-memory -c -O3 ./p0.c

You should use -ftime-report here. I'm not sure why this happens, but
it could be related to the fact that clang doesn't call global
destuctors on exit() (there's an option to override the behaviour,
IIRC).

So, instead, I do:

$ clang -emit-llvm -O3 -c ./p0.c

$ opt -time-passes -track-memory ./p0.bc -O3 -o p0.O3.bc 2> p0.O3.txt

Which gets me the report I am looking for, however, I do not understand why
there are negative numbers in the Mem column.

Presumably a bug.

===-------------------------------------------------------------------------===

                      ... Pass execution timing report ...

===-------------------------------------------------------------------------===

---User Time--- --User+System-- ---Wall Time--- ---Mem--- --- Name ---

0.0010 ( 33.3%) 0.0010 ( 33.3%) 0.0012 ( 41.2%) 324576 Simplify the
CFG

0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.4%) -7184 Scalar
Evolution Analysis

Also, what are the units for the numbers in the Mem column?

I think those are Mb.

I found the -ftime-report option to clang; is there a similar way to request
memory usage tracking of opt passes from clang?

I'm not aware of any. Probably one could be added if not available already.

Thanks,