Sebastian Pop
2011-Nov-09 21:07 UTC
[LLVMdev] Help to debug the miscompilation of a loop into an infinite loop
Hi, I found out that dumping the IR to disk and taking it back makes a miscompile disappear. I would appreciate your help on how to narrow down such a bug. Here are more details: when I compile one of the SPEC benchmarks with clang at -O3, the code is miscompiled producing an infinite loop. If I split the compilation using -emit-llvm and then finish the compilation from the .ll file with llc (I verified that the same passes are enabled) I cannot reproduce the bug exposing the infinite loop. My guess is that one of the target independent passes is invalidating the results of an analysis without marking it for re-computation. When the IR is dumped to disk and read back, the analysis results are forced to be recomputed, and that makes the bug disappear. Is there a systematic way to reduce such bugs? I would like, for example, to invalidate the results of analyses at the end of a set of passes. Otherwise, is there a way to enable/disable each optimization pass from clang without the help of -emit-llvm and opt/llc? Thanks, Sebastian -- Qualcomm Innovation Center, Inc is a member of Code Aurora Forum
Eli Friedman
2011-Nov-09 21:33 UTC
[LLVMdev] Help to debug the miscompilation of a loop into an infinite loop
On Wed, Nov 9, 2011 at 1:07 PM, Sebastian Pop <spop at codeaurora.org> wrote:> Hi, > > I found out that dumping the IR to disk and taking it back makes > a miscompile disappear. I would appreciate your help on how > to narrow down such a bug. > > Here are more details: when I compile one of the SPEC benchmarks > with clang at -O3, the code is miscompiled producing an infinite loop. > If I split the compilation using -emit-llvm and then finish the compilation > from the .ll file with llc (I verified that the same passes are enabled) > I cannot reproduce the bug exposing the infinite loop.First, make sure llc is actually doing the same thing as clang (-O3, the same relocation model, frame pointer elimination, etc.) clang can handle .ll files directly; that may be useful in some cases. Also, the "-mllvm -disable-llvm-optzns" command-line argument to clang can be useful; it turns off the mid-level optimizers. -Eli
Reasonably Related Threads
- Miscompilation bugs in GVN.cpp and PromoteMemoryToRegister.cpp?
- Miscompilation bugs in GVN.cpp and PromoteMemoryToRegister.cpp?
- Miscompilation bugs in GVN.cpp and PromoteMemoryToRegister.cpp?
- [LLVMdev] Infinite loop in llc on ARMv7 (LLVM HEAD from June 17)
- [LLVMdev] Using non-system compiler to build llvm and llvm-gcc front end