Kaleidoscope Debug Assertion

When running Kaleidoscope[1-7] from svn head (105926) in Debug mode I receive the following assertion.

Assertion failed: (C1->getType()->isIntOrIntVectorTy() && “Tried to create an integer operation on a non-integer type!”), function get, file Constants.cpp, line 1460.

Program received signal SIGABRT, Aborted.
0x93e33e42 in __kill ()
(gdb) where
#0 0x93e33e42 in __kill ()
#1 0x93e33e34 in kill$UNIX2003 ()
#2 0x93ea623a in raise ()
#3 0x93eb2679 in abort ()
#4 0x93ea73db in __assert_rtn ()
#5 0x005422da in llvm::ConstantExpr::get (Opcode=8, C1=0x150d7e0, C2=0x150d810, Flags=0) at Constants.cpp:1459
#6 0x00542ade in llvm::ConstantExpr::getAdd (C1=0x150d7e0, C2=0x150d810) at Constants.cpp:1859
#7 0x00004ca8 in llvm::ConstantFolder::CreateAdd (this=0x72082c, LHS=0x150d7e0, RHS=0x150d810) at Support/ConstantFolder.h:37
#8 0x000091dd in llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter >::CreateAdd (this=0x720818, LHS=0x150d7e0, RHS=0x150d810, Name=@0xbffff54c) at Support/IRBuilder.h:324
#9 0x0000470b in BinaryExprAST::Codegen (this=0x150d2d0) at toy.cpp:670
#10 0x00004596 in BinaryExprAST::Codegen (this=0x150d320) at toy.cpp:665
#11 0x000036c7 in FunctionAST::Codegen (this=0x150d330) at toy.cpp:977
#12 0x00003796 in HandleDefinition () at toy.cpp:1006
#13 0x000038eb in MainLoop () at toy.cpp:1053
#14 0x00003bb8 in main () at toy.cpp:1131

I believe the issue is that an integer add/sub/mult/div IR instruction is being emitted when an fadd/fsub/fmul should be. I have attached a patch which fixes the assertion.

Kaleidoscope.diff (2.93 KB)

I believe the issue is that an integer add/sub/mult/div IR instruction is being emitted when an fadd/fsub/fmul should be. I have attached a patch which fixes the assertion.

Thanks! Committed in:

[issola:~/sources/llvm] echristo% svn ci examples
Sending examples/Kaleidoscope/Chapter4/toy.cpp
Sending examples/Kaleidoscope/Chapter5/toy.cpp
Sending examples/Kaleidoscope/Chapter6/toy.cpp
Sending examples/Kaleidoscope/Chapter7/toy.cpp
Transmitting file data ....
Committed revision 105932.

-eric

Might want to check to Ocaml version of Kaleidoscope too, to be on the
safe side, documentation as well?

Did this finally. It appears that the ocaml example doesn't work? It appears to
just exit on startup for me.

-eric