Fail to optimize .ll file

Hi,

I generated .ll file, say “out.ll”.

Works fine ( and produced executable that generates correct result ) when compiling as following

clang -c out.ll

but crashes when optimization is attempted, e.g.

clang -c -O1 out.ll

What are the tools that might help me to determine the reason for a crash?

See clang bug for the source of “out.ll”.

Thank you,

David Livshin

www.dalsoft.com

In general, bugs/crashes should be reported to our GitHub issue tracker Issues · llvm/llvm-project with the traceback and source.

You can narrow down whether the crash is from an IR optimization by using the opt tool to compile out.ll; if that doesn’t crash, try llc which is the codegen/backend tool. Assuming this is an assertion, it should report the source location where the assertion failed, and you can poke around in the source to see what assumption wasn’t satisfied.

You could also try using bugpoint to reduce the test case.

Can you post the out.ll file?
Also, please clarify, what crashes.

  1. The compiler
  2. The program that has been compiled.
    If the answer is (2), then what might be happening is that the program has some undefined outcomes, that the compiler optimizes out, thus causing the crash in the program. I.e. there might be a bug in the program that only shows itself when compiled with optimization turned on.

.ll can be found in the posted link:

Thank you. Looks promising - will try the tools you suggested.

Thanks to pogo59 - bugpoint is the tool I was looking for. In no time the problem ( in my code generator ) was determined and fixed.

Being on the subject, wondering why clang, when encounting this case, crashed and not reported the error in the code ( like bugpoint did )?.

Looks like the x.ll is not well formed.

llvm-as-15 x.ll -o x.bc
llvm-as-15: assembly parsed, but does not verify as correct!
Instruction does not dominate all uses!
%17 = getelementptr inbounds double, double* %0, i64 %16
%92 = ptrtoint double* %17 to i64
Instruction does not dominate all uses!
%22 = getelementptr inbounds double, double* %2, i64 %16
%143 = ptrtoint double* %22 to i64

Thank you.
Exactly the same errors were reported by bugpoint.