Hi, I am debugging a case when compiling a dll library (this is on Windows) with optimizations makes it crash, but works fine without optimizations. I want bugpoint to produce the dll, then run my custom script to execute (which will launch the main program that uses the dll). I'm trying to use "bugpoint bitcode.bc -run-custom -safe-run-custom -exec-command my_script.cmd ", but that seems to override the compilation step and not the final execution step... Is there a command line switch that does what I want? Vadim -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140126/eb04e478/attachment.html>
Pekka Jääskeläinen
2014-Jan-27 08:14 UTC
[LLVMdev] How to use a custom execute step with bugpoint?
Hi, On 01/26/2014 11:22 PM, Vadim wrote:> I'm trying to use "bugpoint bitcode.bc -run-custom -safe-run-custom > -exec-command my_script.cmd ", but that seems to override the compilation step > and not the final execution step... > Is there a command line switch that does what I want?The -exec-command is supposed to execute the bitcode. Thus, it includes the code generation for your target too. Here's how we use it in TCE to track bugs. tce-exec-bc here generates the code and runs the resulting binary in our simulator (thus allows tracking LLVM-related bugs in a cross-compilation scenario). 1) Generate a bytecode that works correctly with -O0, but not with -O3: tcecc src/board_test.c -O0 -o adpcm.bc 2) Create a script for executing the bytecode and to produce validation output: cat > run_bytecode #!/bin/sh tce-exec-bc -e "run; puts [x /u h /n 32 _Input]; quit;" \ 1_bus_full_connectivity.adf $1 ^D chmod +x run_bytecode The script given with '-e' is fed to ttasim and executed after it has loaded the machine and the scheduled tpef. It is used to produce output for verification. Do not forget to add the interpreter line (the first one) as it doesn't seem to work without. I could have used also printf() in the C code to print out verification output, but it slows down compilation quite a lot so I decided to generate the verification data using ttasim instead. If you have verification data printed out to STDOUT and you can run the simulation to completion, the following run_bytecode script content suffices: #!/bin/sh tce-exec-bc machine.adf $1 3) Generate reference output from a valid run of the unoptimized program: ./run_bytecode adpcm.bc > reference.txt 4) Start Bugpoint. bugpoint adpcm.bc -run-custom -exec-command=$PWD/run_bytecode -output=reference.txt -O3 This instructs Bugpoint to do a binary search on the optimization passes to find the pass the produces the broken end result, hopefully reducing the list of passes to a single one. -- Pekka