[LLVMdev] Forward references of globals in .ll files

Justin Holewinski justin.holewinski at gmail.com
Fri Nov 9 17:01:56 PST 2012


I'm experiencing a weird issue during .ll file parsing, and I'm not sure if
it's a bug in the .ll parser, or if I'm just not understanding the IR.

Take the following IR:

@a = addrspace(1) global i8 0
@a2 = global i8 addrspace(1)* @a

This parses fine.  But if I rearrange the statements to:

@a2 = global i8 addrspace(1)* @a
@a = addrspace(1) global i8 0

then I get an ugly assertion failure:

Assertion failed: (InitVal->getType() == getType()->getElementType() &&
"Initializer type must match GlobalVariable type"), function
setInitializer, file
/Users/jholewinski/projects/llvm/src/llvm/lib/VMCore/Globals.cpp, line 168.

Looking at the debugger, I see that InitVal (the initializer for @a2) has
type i8*, which looks incorrect as it drops the addrspace from the
definition of @a.

Before I go too far into this, should this IR work?  It looks like the
parser is failing to properly process the forward declaration of @a, but I
just want to be sure.

-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121109/eda6c257/attachment.html>


More information about the llvm-dev mailing list