Justin Holewinski
2012-Nov-10 01:01 UTC
[LLVMdev] Forward references of globals in .ll files
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>
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
Dmitry N. Mikushin
2012-Nov-10 01:11 UTC
[LLVMdev] Forward references of globals in .ll files
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
Maybe Matching Threads
- [LLVMdev] Forward references of globals in .ll files
- [LLVMdev] Forward references of globals in .ll files
- [LLVMdev] Forward references of globals in .ll files
- [LLVMdev] [NVPTX] Backend failure in LegalizeDAG due to unimplemented expand in target lowering
- [LLVMdev] [NVPTX] Backend failure in LegalizeDAG due to unimplemented expand in target lowering