[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [csmith-dev] How to generate fixed size program using Csmith

Hi Shijun, if you really want to eliminate dead code, you have to decide if you are going after statically or dynamically dead code.

If statically, then you need some sort of source-to-source transformer for C code that uses static analysis to eliminate dead code. We used to use CIL for such jobs but now probably this would be a Clang hack.

If dynamically, you need to instrument the code, run it, see which parts actually execute, and then rewrite the code to not contain the dead stuff.

Either way, this isn't much fun.


On 11/6/18 6:11 PM, shijun zhao wrote:
Hi John,

Your reply is exactly what I'm worrying. My goal is not to find bugs,
but to evaluate the performance of my system, and I want to test the
performance difference when the running applications are in different
size. Do you have any advice on eliminating dead code? Or is there any
other tools that meet my requirement? Thanks a lot.

Best Regards,
John Regehr <regehr@cs.utah.edu> 于2018年11月7日周三 上午1:25写道:

Eric's answer is excellent and I'll just add that since Csmith programs
often contain quite a bit of dead code, you may (depending on your
goals) prefer to generate programs that contain a specified amount of
live code.


On 11/6/18 8:30 AM, Eric Eide wrote:
shijun zhao <zqyzsj@gmail.com> writes:

Is there any way for Csmith to generate programs whose size (or the
lines of code) can be specified? Thanks.

Hi!  No, there is no option that sets the exact size of the generated program.

There are options that influence the possible (maximum) size of the generated
programs.  These include:


If you set these values higher, the generated programs can be bigger.

The easiest way to generate programs in a particular size range is simply to
generate a lot of programs and discard the ones that don't fall into the size
range you want.

Warning: If you have a very narrow range, you might have to run Csmith many,
many times to get the total number of programs that you want!  My advice is to
not make your ranges too narrow.  "Exactly 100K" is bad; "between 90K and 110K"
is better.

Happy hacking! ---