[LLVMdev] "Value has wrong type!" on Bool:4 bitfield

Jay Foad jay.foad at gmail.com
Thu Jan 7 06:30:45 PST 2010


I've built a debug build of llvm 2.6, and llvm-gcc 2.6 for arm-elf
with --enable-checking=yes.

On the attached test case (which is g++.dg/expr/bitfield4.C from the
GCC 4.2 testsuite) I get:

$ cc1plus bitfield4.ii -emit-llvm-bc -o bitfield4.o -quiet

cc1plus: /home/foad/svn/antix/toolchain/branches/w/foad/2757llvm26/toolchain/llvm/llvm-gcc/gcc/llvm-convert.cpp:999:
llvm::Value* TreeToLLVM::Emit(tree_node*, const MemRef*): Assertion
`(Result == 0 || (((enum tree_code)
(((exp)->common.type))->common.code) == VOID_TYPE) ||
isa<VectorType>(ConvertType(((exp)->common.type))) ||
Result->getType() == ConvertType(((exp)->common.type))) && "Value has
wrong type!"' failed.

At this point Result is "i8 1". ConvertType(TREE_TYPE(exp)) is i4. And
the code generated for the basic block so far is:

entry:
  %retval = alloca i32                            ; <i32*> [#uses=0]
  %0 = alloca i4                                  ; <i4*> [#uses=1]
  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
  %1 = load i8* getelementptr inbounds (%struct.S* @s, i32 0, i32 0),
align 1 ; <i8> [#uses=1]
  %2 = shl i8 %1, 4                               ; <i8> [#uses=1]
  %3 = lshr i8 %2, 4                              ; <i8> [#uses=1]
  %4 = trunc i8 %3 to i4                          ; <i4> [#uses=1]
  store i4 %4, i4* %0, align 1
  %5 = load i8* getelementptr inbounds (%struct.S* @s, i32 0, i32 0),
align 1 ; <i8> [#uses=1]
  %6 = and i8 %5, -16                             ; <i8> [#uses=1]
  %7 = or i8 %6, 1                                ; <i8> [#uses=1]
  store i8 %7, i8* getelementptr inbounds (%struct.S* @s, i32 0, i32 0), align 1

Any idea what's going wrong?

Thanks,
Jay.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bitfield4.ii
Type: application/octet-stream
Size: 285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100107/c8c2a60d/attachment.obj>


More information about the llvm-dev mailing list