[LLVMdev] Forward references of globals in .ll files

Dmitry N. Mikushin maemarcus at gmail.com
Fri Nov 9 17:11:21 PST 2012


Does not work and same error even on old r157485 build.

- D.

2012/11/10 Eli Friedman <eli.friedman at gmail.com>:
> On Fri, Nov 9, 2012 at 5:01 PM, Justin Holewinski
> <justin.holewinski at gmail.com> wrote:
>> 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.
>
> Looks like it should work.
>
> -Eli
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list