[LLVMdev] Incrementing a pointer to array element?

Paul J. Lucas paul at lucasmail.org
Wed Oct 17 17:19:21 PDT 2012


Using the LLVM C++ API, if I want to create an array via an Alloca instruction like:

	Value *a = ir_builder.CreateAlloca( my_type, my_size );

and then I want to initialize each element of the array with values computed elsewhere like:

	for ( vector<Value*>::const_iterator i = v.begin(); i != v.end(); ++i ) {
	  builder.CreateStore( *i, a );
	  // How do I increment 'a' to point to the next element?
	}

how do I increment 'a' to point to the next element (taking the size of my_type into account) so that each store instruction stores in successive elements?

- Paul





More information about the llvm-dev mailing list