regression? Or did I do something wrong again?

I don't know if the toy program in chapter 4 of the tutorial
implementing Kaleidoscope in llvm with C++ is part of your
regression suite, but with the version of llvm I installed
last weekend, it does not compile:

hendrik@lovesong:~/dv/llvm/tut$ g++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy
toy.cpp: In member function ‘virtual llvm::Value* NumberExprAST::Codegen()’:
toy.cpp:359: error: no matching function for call to ‘llvm::ConstantFP::get(const llvm::Type*&, llvm::APFloat)’
/usr/local/llvm/include/llvm/Constants.h:237: note: candidates are: static llvm::ConstantFP* llvm::ConstantFP::get(const llvm::APFloat&)
/usr/local/llvm/include/llvm/Constants.h:242: note: static llvm::ConstantFP* llvm::ConstantFP::get(const llvm::Type*, double)
hendrik@lovesong:~/dv/llvm/tut$

I cut-and-pasted the sourse from http://llvm.org/docs/tutorial/LangImpl4.html

-- hendrik

I don't know if the toy program in chapter 4 of the tutorial
implementing Kaleidoscope in llvm with C++ is part of your
regression suite, but with the version of llvm I installed
last weekend, it does not compile:

Does it work with the 2.3 release? The web-page docs refer
to what's in svn (which is basically the same as 2.3 right
now).

Ciao,

Duncan.

I don't know if the toy program in chapter 4 of the tutorial
implementing Kaleidoscope in llvm with C++ is part of your
regression suite

It isn't (although that might be a good idea).

but with the version of llvm I installed
last weekend, it does not compile:

hendrik@lovesong:~/dv/llvm/tut$ g++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy
toy.cpp: In member function 'virtual llvm::Value* NumberExprAST::Codegen()':
toy.cpp:359: error: no matching function for call to 'llvm::ConstantFP::get(const llvm::Type*&, llvm::APFloat)'
/usr/local/llvm/include/llvm/Constants.h:237: note: candidates are: static llvm::ConstantFP* llvm::ConstantFP::get(const llvm::APFloat&)
/usr/local/llvm/include/llvm/Constants.h:242: note: static llvm::ConstantFP* llvm::ConstantFP::get(const llvm::Type*, double)
hendrik@lovesong:~/dv/llvm/tut$

I cut-and-pasted the sourse from http://llvm.org/docs/tutorial/LangImpl4.html

That should be easy to fix; from the LLVM 2.3 release notes: "The
ConstantFP::get method that uses APFloat now takes one argument
instead of two. The type argument has been removed, and the type is
now inferred from the size of the given APFloat value." So to make it
compile, "ConstantFP::get(Type::DoubleTy, APFloat(Val));" needs to be
changed to "ConstantFP::get(APFloat(Val));".

-Eli

Hi Hendrik,

hendrik@lovesong:~/dv/llvm/tut$ g++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3 -o toy
toy.cpp: In member function ‘virtual llvm::Value* NumberExprAST::Codegen()’:
toy.cpp:359: error: no matching function for call to ‘llvm::ConstantFP::get(const llvm::Type*&, llvm::APFloat)’
/usr/local/llvm/include/llvm/Constants.h:237: note: candidates are: static llvm::ConstantFP* llvm::ConstantFP::get(const llvm::APFloat&)
/usr/local/llvm/include/llvm/Constants.h:242: note: static llvm::ConstantFP* llvm::ConstantFP::get(const llvm::Type*, double)
hendrik@lovesong:~/dv/llvm/tut$

It seems the ConstantFP method get might have been modified to take a
reference-to-APFloat, meaning you can't pass in APFloat(Value) anonymously.
You should either put it in a local variable, like
  APFloat F(Val);
  return ConstantFP::get(Type::DoubleTy, F);
which I _think_ is the right way to use the first get() function. Easier is to
use the alternative get() function, which simply takes a double directly.
i.e.,
  return ConstantFP::get(Type::DoubleTy, Val);

Could you please test both and report the results?

Gr.

Matthijs

It was the version from svn that I installed. If the tutorial is to be
released with llvm (and it probably should be), you'd better update the
code in it before the release. Otherwise you'll make a lot of new
users as confused as me.

-- hendrik

And removing the first argument in toy.cpp program does indeed make it
work.

-- hendrik

Eli Friedman tells me that the specs for ConstantFP have changed. In the
release notes it now tells us that the first argument has been dropped
entirely.

Given the change of spec, there isn't much point in doing your tests; but
removing the first argument from the offending call works wonders.
Someone with write access should correct the tutorial!

-- hendrik

> Hi Hendrik,

> It seems the ConstantFP method get might have been modified to take a
> reference-to-APFloat, meaning you can't pass in APFloat(Value) anonymously.
> You should either put it in a local variable, like
> APFloat F(Val);
> return ConstantFP::get(Type::DoubleTy, F);
> which I _think_ is the right way to use the first get() function. Easier is to
> use the alternative get() function, which simply takes a double directly.
> i.e.,
> return ConstantFP::get(Type::DoubleTy, Val);

> Could you please test both and report the results?

Eli Friedman tells me that the specs for ConstantFP have changed. In the
release notes it now tells us that the first argument has been dropped
entirely.

Given the change of spec, there isn't much point in doing your tests; but
removing the first argument from the offending call works wonders.
Someone with write access should correct the tutorial!

Done: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080609/063539.html

Cheers,

    Gabor