Transferring value* in LLVM

Hello
I want to transfer value (Value* src) of the type FloatTyID to DoubleTyID(I need all floats to be saved as 8 bytes).I have tried:

builder.CreateCast(llvm::Instruction::FPExt, src, llvm::Type::getDoubleTy(llvmContext),””)

I don`t know if I use CreateCast correctly and if this approach is correct at all.

Thank you.

Yakov

Hi Yakov, that looks correct to me. You can also use CreateFPExt which is
slightly simpler.

Ciao, Duncan.

It doesnt work it fails with assertation that cast is invalid .What
could be done?

It doesnt work it fails with assertation that cast is invalid .What
could be done?

Maybe src doesn't have Float type?

Ciao, Duncan.

I sure that is.What could be other reasons for such error?
Yakov

I sure that is.

Did you test it? Can you do: src->getType()->isFloatTy()

What could be other reasons for such error?

The only other possibility I can think of is that src was created
using a different context.

Ciao, Duncan.

yes - i checked that the src->getType()->isFloatTy() is true
Yakov

You’ll probably need to dump both the source and the dest and show the code that’s being generated. A lot of guessing here that’s not getting us very far very fast.

-eric

Here is the error that I get:
Assertion failed: (i >= FTy->getNumParams() || FTy->getParamType(i) == Params[i]->getType()) && “Calling a function with a bad signature!”
Yakov

Here is the error that I get:
Assertion failed: (i >= FTy->getNumParams() || FTy->getParamType(i) ==
Params[i]->getType()) && "Calling a function with a bad signature!"

That's not being generated by the CreateCast, so it looks like your description
of the problem was quite misleading.

Ciao, Duncan.

So what do you think the problem is?
Thank you.
Yakov

It means that you aren’t calling the function you think you are.

Again. Dump the arguments, show the code. Anything else isn’t going to be helpful and I’m done guessing.

-eric