[LLVMdev] ValueMapper question: no type mapping for GlobalValue?
Michael Muller
mmuller at enduden.com
Thu Jan 12 03:36:42 PST 2012
=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?= wrote:
> On 11/01/12 07:50 AM, Michael Muller wrote:
> >
> > Hi all, I was looking at the ValueMapper code this morning and I notice that
> > it doesn't do type mapping for GlobalValues. Is this correct?
> >
> > I ask because I am seeing a case where I'm failing type assertions from
> > ModuleLinker::linkGlobalInits() when an array initializer references an
> > external global. It looks like the external global is being mapped directly
> > and this causes an element type check to fail in ConstantArray::get().
> > Curiously, this only happens when that external global is also referenced from
> > within a function in the same module.
> >
>
> Do you have a testcase?
>
> I tried to reproduce this with
>
> -----------
> a = global i64 42, align 8
> -----------
>
> and
>
> ----------
> @a = external global i32
> @b = constant [1 x i32*] [i32* @a], align 8
>
> define i32 @f() nounwind uwtable readonly optsize {
> entry:
> %0 = load i32* @a, align 4
> ret i32 %0
> }
> ----------
>
> but llvm-link correctly produced
>
>
> @b = constant [1 x i32*] [i32* bitcast (i64* @a to i32*)], align 8
> @a = global i64 42, align 8
>
> define i32 @f() nounwind uwtable readonly optsize {
> entry:
> %0 = load i32* bitcast (i64* @a to i32*), align 4
> ret i32 %0
> }
I can reproduce this consistently, but only under an extremely large pile of
code :-) I haven't tried to strip it down to minimal a test case yet, but I
will. One salient difference with the code you've provided is that in my
code, @a is a struct type. However, changing the example to use a minimal
structure doesn't trigger the assertion failure.
But I'm still curious: why doesn't the value mapper do type mapping on global
variables?
>
>
> Cheers,
> Rafael
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
=============================================================================
michaelMuller = mmuller at enduden.com | http://www.mindhog.net/~mmuller
-----------------------------------------------------------------------------
The natural progress of things is for liberty to yield and government to
gain control. - Thomas Jefferson
=============================================================================
More information about the llvm-dev
mailing list