[LLVMdev] ValueMapper question: no type mapping for GlobalValue?
Rafael Ávila de Espíndola
rafael.espindola at gmail.com
Wed Jan 11 21:02:28 PST 2012
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
}
Cheers,
Rafael
More information about the llvm-dev
mailing list