[LLVMdev] Problem with llvm-c

James Courtier-Dutton james.dutton at gmail.com
Mon May 13 01:44:46 PDT 2013

On 13 May 2013 09:03, Duncan Sands <baldrick at free.fr> wrote:
> Hi James,
> On 13/05/13 00:25, James Courtier-Dutton wrote:
>> I.e. With the "add" in there.
>> llvm appears to be doing some optimization on it, to remove the add.
> if you used LLVMConstAdd to create the add, then don't, use LLVMBuildAdd
> instead.  If you were using LLVMBuildAdd, then use a builder than doesn't
> do automatic constant folding.
> Ciao, Duncan.

I have looked into this a bit further.
The LLVM C++ API allows to select a builder without constant folding.
The LLVM C API does not seem to have an option for a builder without
constant folding.
It only has:
LLVMBuilderRef builder = LLVMCreateBuilderInContext(context);   <-
Uses a constant folding builder it appears, when it probably should

The C API does not have a
LLVMFoldingBuilderRef builder = LLVMCreateBuilderInContext(context);
LLVMBuilderRef builder = LLVMCreateFoldingBuilderInContext(context);

Is this a limitation of the LLVM C API ?

More information about the llvm-dev mailing list