[LLVMdev] Size of structs & arrays

Fraser Cormack frasercrmck at gmail.com
Wed Feb 22 15:54:49 PST 2012



Eli Friedman-2 wrote:
> 
> 
> Try llvm::Constant::getNullValue().
> 
> 

I'm trying this:

llvm::Constant* one =
llvm::Constant::getNullValue(llvm::IntegerType::get(mod->getContext(), 64));
llvm::ConstantInt* two = llvm::ConstantInt::get(mod->getContext(),
llvm::APInt(32, llvm::StringRef("1"), 10));

std::vector<llvm::Value*> indices;	
indices.push_back(one);  indices.push_back(two);
	
llvm::Value* size = builder->CreateGEP(struct_ptr, indices);
llvm::Value* size_int = builder->CreatePtrToInt(size,
llvm::IntegerType::get(mod->getContext(), 64))

And I'm getting the assertion error "Invalid GetElementPtrInst indices for
type!"'. 'struct_ptr' is a pointer to the struct I'm trying to size. I've
also tried using getNullValue on the struct's own type.

Sorry to ask so directly, but I'd quite like to get this sorted.

-- 
View this message in context: http://old.nabble.com/Size-of-structs---arrays-tp33341964p33374460.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.




More information about the llvm-dev mailing list