The following code works on 2.7, but causes an assertion on recent snapshots. Has something changed regarding bitcasts that makes this illegal?
The code is:
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32"
target triple = "x86-unknown-unknown"
@aa = global [32 x i8] zeroinitializer, align 1
@bb = global [16 x i8] zeroinitializer, align 1
define void @x() nounwind {
L.0:
%0 = getelementptr [32 x i8]* @aa, i32 0, i32 4
%1 = bitcast i8* %0 to [16 x i8]*
%2 = bitcast [16 x i8]* %1 to [0 x i8]*
%3 = getelementptr [16 x i8]* @bb
%4 = bitcast [16 x i8]* %3 to [0 x i8]*
call void @llvm.memcpy.i32([0 x i8]* %2, [0 x i8]* %4, i32 16, i32 1)
br label %return
return:
ret void
}
declare void @llvm.memcpy.i32([0 x i8]*, [0 x i8]*, i32, i32) nounwind
The assertion is:
Unknown type!
UNREACHABLE executed at ValueTypes.cpp:190!
0 opt 0x000000000081cf8f
1 opt 0x000000000081effa
2 libpthread.so.0 0x0000003961a0f0f0
3 libc.so.6 0x0000003960e326d5 gsignal + 53
4 libc.so.6 0x0000003960e33eb5 abort + 373
5 opt 0x0000000000800e14 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 356
6 opt 0x00000000007c8733 llvm::EVT::getEVT(llvm::Type const*, bool) + 979
7 opt 0x00000000007ccff1
8 opt 0x00000000007cd446
9 opt 0x00000000007d56b7
10 opt 0x00000000007d6826
11 opt 0x00000000007b223d llvm::FPPassManager::runOnFunction(llvm::Function&) + 637
12 opt 0x00000000007b233b llvm::FPPassManager::runOnModule(llvm::Module&) + 75
13 opt 0x00000000007b1d41 llvm::MPPassManager::runOnModule(llvm::Module&) + 497
14 opt 0x00000000007b1eb7 llvm::PassManagerImpl::run(llvm::Module&) + 167
15 opt 0x00000000004a1a02 main + 2642
16 libc.so.6 0x0000003960e1eb1d __libc_start_main + 253
17 opt 0x0000000000497639
Stack dump:
0. Program arguments: /home/bgl/work/llvm-work/Release/bin/opt -std-compile-opts -o - t322.ll
1. Running pass 'Function Pass Manager' on module 't322.ll'.
2. Running pass 'Module Verifier' on function '@x'
Any ideas?
Thanks.