[LLVMdev] Invalid bitcode signature

Fraser Cormack frasercrmck at gmail.com
Sat Feb 11 12:59:17 PST 2012


Ah, updating to LLVM 3.0 has worked, thanks!

Once again, this is sorta off topic (I don't want to unnecessarily start a
new thread), but I've noticed that my program segmentation faults when I try
and use a GEP on a struct that is opaque in a module, but will be resolved
when linked to another module later, like this:

if (reg_pt_st->isOpaque())
  std::cout << "opaque" << std::endl;

ConstantInt* index = ConstantInt::get(mod->getContext(), APInt(32,
StringRef("0"), 10));
std::vector<llvm::Value*> indices;
indices.push_back(index);	indices.push_back(index);
				
Value* gep_ptr = builder->CreateGEP(reg, indices);

Here, 'reg' is a pointer to a struct, and so 'reg_pt_st' is the cast from
'reg' to pointer to struct.

Is this possible? What am I supposed to do here? Would using a different
LLVMContext (for instance the one that defines the struct) solve it? That
just came to me now.

Cheers,
Fraser


Chris Lattner-2 wrote:
> 
> 
> On Feb 7, 2012, at 1:29 AM, Fraser Cormack wrote:
> 
>> 
>> Sorry, I was being an idiot and was trying to link the wrong file type.
>> Sigh.
>> 
>> Now I have a problem where I merge two modules each containing the same
>> struct, one opaque and one defined, and it's not merging the two
>> consistently. I have two, let's say
>> 
>> %"StructA" = type opaque
>> %"StructB" = type opaque
>> 
>> in one module, and in the other:
>> 
>> %"StructA" = type { i8 }
>> %"StructB" = type  { [0 x i8] }
>> 
>> and when I link the two modules, only one is correctly defined:
>> 
>> %"StructA" = { i8 }
>> %"StructB" = type opaque
>> %"StructB.0" =  { [0 x i8] }
>> 
>> I know it's not technically 'on-topic' for this thread, but just in case
>> you
>> had any ideas as to why this is happening.
> 
> Are you using mainline or LLVM 3.0?  The behavior in this area has changed
> since 3.0 was released (and it should now do what you want).
> 
> -Chris
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> 
> 

-- 
View this message in context: http://old.nabble.com/Invalid-bitcode-signature-tp33259763p33307774.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.




More information about the llvm-dev mailing list