LTO regression test Bug 17623

Hello,

I have a fix for Bug17623 (http://llvm.org/bugs/show_bug.cgi?id=17623) but I am not sure how best to install a regression test. The commands I use to run the test are (approximately)

$LLVM/clang -flto -O2 -o BUG.o -c BUG.c
$LLVM/llvm-lto -exported-symbol=main -o lto.o BUG.o
$LLVM/clang -o bug lto.o
./bug

Where the failing behavior is to seg fault and corrected behavior is to run to completion.
The use of llvm-lto avoids a dependence on the native loader having appropriate plugin support.

The reliance on running clang and code suggests a test belongs in the llvm-test-suite. Could someone give me a pointer on how to configure a test using commands like the above? Are there any other tests with a similar structure?

Thanks
david

Hello,

I have a fix for Bug17623 (http://llvm.org/bugs/show_bug.cgi?id=17623) but I am not sure how best to install a regression test. The commands I use to run the test are (approximately)

$LLVM/clang -flto -O2 -o BUG.o -c BUG.c
$LLVM/llvm-lto -exported-symbol=main -o lto.o BUG.o
$LLVM/clang -o bug lto.o
./bug

Where the failing behavior is to seg fault and corrected behavior is to run to completion.
The use of llvm-lto avoids a dependence on the native loader having appropriate plugin support.

The reliance on running clang and code suggests a test belongs in the llvm-test-suite.

Not necessarily. It depends where the bug is. If clang is producing wrong IR and needs to be changed, we just test clang and verify that the desired IR doesn’t have the erroneous feature that wr removed.

Alternatively, if clang is doing the right thing and the llvm IR linker is mangling the result, or the llvm optimizations misunderstand - we should just be able to construct the minimal IR that demonstrates the poor behavior and verify llvm gets the right answer.

So where is the bug?

Thanks for the reply.

The bug is in the alias analysis (lib/Analysis/IPA/GlobalsModRef.cpp) where a variable is not correctly seen as address-taken due to a static initializer. This leads to an invalid loop invariant code motion and a subsequent use of a bad pointer.

So clang is correct but lto introduces a problem. I tried but was unable to reproduce the problem with opt.
The bug can be reproduced with a .ll file but I don’t know how to verify the fix other than running the output of LTO and so would welcome any suggestions.

david

Thanks for the reply.

The bug is in the alias analysis (lib/Analysis/IPA/GlobalsModRef.cpp)
where a variable is not correctly seen as address-taken due to a static
initializer. This leads to an invalid loop invariant code motion and a
subsequent use of a bad pointer.

Are there other tests for GlobalsModRef? You could check in test/Analysis
for them (or look at the blame history of GlobalsModRef.cpp and see how
other changes were tested) to get an idea of how to test changes to that
Analysis.