Advice on Reducing LLVM Bitcode Programs


I have found a bitcode test program that triggers a miscompilation bug in an LLVM pass. However, when I use bugpoint to reduce the program, I encounter several problems. It would be great if someone can give me some advice.

(1) Ensure the validity of the reduced test program.

Is it necessary to add some checks in the interestingness script to ensure the validity of the reduced programs?

I tried to use various sanitizers to achieve this (asan, ubsan, msan). However, I always get the following error

==9070==ERROR: AddressSanitizer failed to allocate 0xdfff0001000 (15392894357504) bytes at address 2008fff7000 (errno: 12)
==9070==ReserveShadowMemoryRange failed while trying to map 0xdfff0001000 bytes. Perhaps you’re using ulimit -v

If I directly run these scripts, then the sanitizers can run smoothly.

(2) The minimality of the reduced test program.

Is the reduced test program by bugpoint minimal? I managed to reduce several programs (without using the sanitizers), however, the sizes are usually still big. I saw the test programs reduced by LLVM developers attached in bug reports, and they were usually very small, ~10 lines. Do you also use Delta to further minimize the test programs?

Thank you.


I managed to address the problem. It turns out that there is a flag -mlimit controlling the memory consumption of bugpoint. The default value is 400MB, and I set it to 0. Then the sanitizers run smoothly.

Now I am running delta and bugpoint together to minimize the bitcode. From what I see so far, the combination is not bad.

A remaining problem is the comments in the bitcode files (strings starting with ‘;’). It will be good if I can remove them too.