Error compiling simple loop, Casting.h used by Polly

clang: /home/ryan/llvm/llvm_core/llvm-3.0/include/llvm/Support/Casting.h:194: typename cast_retty<PHINode, ilist_iterator >::ret_type llvm::cast(const llvm::ilist_iteratorllvm::Instruction &): Assertion `isa(Val) && “cast() argument of incompatible type!”’ failed.
0 clang 0x0000000001b3618f
1 clang 0x0000000001b366a9
2 0x00007f5b07d3bc60
3 0x00007f5b07026d05 gsignal + 53
4 0x00007f5b0702aab6 abort + 390
5 0x00007f5b0701f7c5 __assert_fail + 245
6 0x00007f5b06dae9b8
7 clang 0x0000000001ad97cf llvm::FPPassManager::runOnFunction(llvm::Function&) + 351
8 clang 0x0000000001ad9059 llvm::FunctionPassManagerImpl::run(llvm::Function&) + 329
9 clang 0x0000000001ad8edb llvm::FunctionPassManager::run(llvm::Function&) + 139
10 clang 0x000000000076cd6c clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 5004
11 clang 0x000000000076ad83
12 clang 0x0000000000884700 clang::ParseAST(clang::Sema&, bool) + 448
13 clang 0x000000000076a1fb clang::CodeGenAction::ExecuteAction() + 859
14 clang 0x000000000062b63d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 957
15 clang 0x00000000006147d7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2247
16 clang 0x000000000060b81f cc1_main(char const**, char const**, char const*, void*) + 2991
17 clang 0x0000000000610c35 main + 757
18 0x00007f5b07011eff __libc_start_main + 255
19 clang 0x000000000060abad
Stack dump:
0. Program arguments: /usr/local/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -disable-free -main-file-name loop1.c -mrelocation-model static -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version -momit-leaf-frame-pointer -coverage-file loop1.c.ll -resource-dir /usr/local/bin/…/lib/clang/3.1 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/local/bin/…/lib/clang/3.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -fdebug-compilation-dir /home/ryan/llvm/llvm_core/llvm-3.0 -ferror-limit 19 -fmessage-length 100 -mstackrealign -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -load /home/ryan/llvm/llvm_core/llvm-3.0/tools/polly/Release+Asserts/lib/ -mllvm -polly -o loop1.c.ll -x c loop1.c

  1. parser at end of file
  2. Per-function optimization
  3. Running pass ‘Polly - Prepare code for polly’ on function ‘@func
    clang: error: unable to execute command: Aborted
    clang: error: clang frontend command failed due to signal (use -v to see invocation)
    clang: note: diagnostic msg: Please submit a bug report to and include command line arguments and all diagnostic information.
    clang: note: diagnostic msg: Preprocessed source(s) and associated run script(s) are located at:
    clang: note: diagnostic msg: /tmp/loop1-xX24bI.i
    clang: note: diagnostic msg: /tmp/

This code was running fine earlier today before I “up”'d the svn checkout for everything (polly, clang, llvm) and reinstalled updated cloog. I have attached a test case.

I am compiling with this:

clang -Xclang -load -Xclang ${PATH_TO_POLLY_LIB} $1 -mllvm -polly -O3 -S -emit-llvm

loop1.c (122 Bytes)

Hi Ryan,

Is there a PR about this? I've just hit the same assertion with

I am not sure if this is a general LLVM bug. It rather seems both Polly and AdressSanitizer try to generate an invalid cast. If you can reproduce this bug, it should be easy to understand. I would guess there is an IRBuilder somewhere in the backtrace, which is used to generate a cast. The types are probably incompatible. Unfortunately the backtrace from Ryan does not contain any debugging symbols and on the .c
file I cannot reproduce the problem.

Let me know if you found out what was the problem.