[LLVMdev] Global variable initializer type does not match global variable type
whitequark at whitequark.org
Wed Jan 9 07:59:06 PST 2013
I've managed to create a bitcode file (attached; also available at )
a series of identical errors when verified:
| Global variable initializer type does not match global variable type!
| %i.NilClass* @nil
When ran through llvm-dis and recompiled, through, it verifies
successfully. If I
disassemble it one more time, the result is identical to the first
recompiled bitcode file is slightly smaller.
I suspect that the problem is with aggregate type uniqueing. I use
LLVM 3.2 to generate the file; the following code demonstrates what I
deem the incorrect
# llvm_ty is an LLVM struct type with 2 elements.
a, b = llvm_ty.element_types
# Here, I decompose the type and verify that the types of elements
# match my expectations:
p a == @types[Monotype.of(VI::Class)] # true
p b == emit_class_body_type(klass) # true
# I attempt to reconstruct the type using the elements
# and check if it's still the same.
p llvm_ty == LLVM::Type.struct([
], false) # false. Why?
Ruby-LLVM bindings compare underlying LLVM pointers when the Type
objects are compared
The problem manifests itself when the following code contains the
datum = @llvm.globals.add llvm_ty, name
datum.initializer = LLVM::ConstantStruct.const([
LLVM::ConstantStruct.const eventually calls the LLVMConstStruct method
appropriate arguments; LLVM::Constant.null corresponds to
Any hints are greatly appreciated.
WBR, Peter Zotov.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 752 bytes
Desc: not available
More information about the llvm-dev