[LLVMdev] noob IR builder question

Caldarale, Charles R Chuck.Caldarale at unisys.com
Tue Mar 10 15:43:28 PDT 2015

> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu]
> On Behalf Of Alan Nilsson
> Subject: [LLVMdev] noob IR builder question

> I've added the following snippets:
>	Value *c1 = ConstantFP::get(context, APFloat(1.0));
>	Value *c2 = ConstantFP::get(context, APFloat(3.0));
>	builder.CreateFAdd(c1, c2, "addtmp");
> expecting to see an add instruction in the dump, but nothing is added.

Because you don't use the result from the CreateFAdd(), it gets eliminated as dead code.  Try passing the result on a function call or as the return value for the function you're generating.

 - Chuck

More information about the llvm-dev mailing list