[LLVMbugs] bug in sequence 'load --> bswap --> bitcast --> fptoui'

Евгений Гришуль eugeny.grishul at gmail.com
Wed Sep 23 07:05:05 PDT 2009


Hi,

Currently I develop own compiler using LLVM ( and MS Phoenix framework =) )
and found that 'fptoui' instruction usage in following situation crashes
JIT:
;===========================================
@System.Test.ByteOrderTests.big2 = internal global i32 60994
@str = internal constant [18 x i8] c"Big endian: %lld\0A\00"
declare i32 @printf(i8* nocapture, ...) nounwind
declare i32 @llvm.bswap.i32(i32) nounwind readnone
define void @main() {
  %1 = load i32* @System.Test.ByteOrderTests.big2 ; <i32> [#uses=1]
  %2 = call i32 @llvm.bswap.i32(i32 %1)
  %3 = bitcast i32 %2 to float
  %4 = fptoui float %3 to i64
  %yo = call i32(i8* nocapture, ...)* @printf( i8* getelementptr ([18 x i8]*
@str, i32 0, i64 0), i64 %4 )
  ret void
}
;Writes:
;0.      Program arguments: lli test.bc
;00000000 (0x42EE0000 0x00000000 0x00D6FA60 0x01280E01) <unknown module>
;001D0023 (0x00C1F664 0x00C48F50 0x00C1F734 0x54AD8E88) <unknown module>
;0153245C (0x00C48F50 0x022941BC 0x00D61D18 0x54AD80F4),
llvm::ExecutionEngine::runFunctionAsMain()+0940 bytes(s),
e:\external\llvm\lib\executionengine\executionengine.cpp, line 387+0030
byte(s)
;01272C44 (0x00000002 0x00D680F8 0x00D61D18 0x54AD80A4), main()+2196
bytes(s), e:\external\llvm\tools\lli\lli.cpp, line 218+0064 byte(s)
;01C5FF78 (0x00C1F984 0x74DB3677 0x7EFDE000 0x00C1F9C4),
__tmainCRTStartup()+0424 bytes(s),
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, line 586+0025 byte(s)
;01C5FDBF (0x7EFDE000 0x00C1F9C4 0x77159D72 0x7EFDE000),
mainCRTStartup()+0015 bytes(s),
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c, line 403
;74DB3677 (0x7EFDE000 0x778EDA85 0x00000000 0x00000000),
BaseThreadInitThunk()+0018 bytes(s)
;77159D72 (0x01C5FDB0 0x7EFDE000 0x00000000 0x00000000),
RtlInitializeExceptionChain()+0099 bytes(s)
;77159D45 (0x01C5FDB0 0x7EFDE000 0x00000000 0x00000000),
RtlInitializeExceptionChain()+0054 bytes(s)
;===========================================
But if I change 'fptoui' to 'fptosi' everything is OK:

 @System.Test.ByteOrderTests.big2 = internal global i32 60994
@str = internal constant [18 x i8] c"Big endian: %lld\0A\00"
declare i32 @printf(i8* nocapture, ...) nounwind
declare i32 @llvm.bswap.i32(i32) nounwind readnone

define void @main() {
  %1 = load i32* @System.Test.ByteOrderTests.big2 ; <i32> [#uses=1]
  %2 = call i32 @llvm.bswap.i32(i32 %1)
  %3 = bitcast i32 %2 to float
  %4 = fptosi float %3 to i64
  %yo = call i32(i8* nocapture, ...)* @printf( i8* getelementptr ([18 x i8]*
@str, i32 0, i64 0), i64 %4 )
  ret void
}
;Writes: Big endian: 119
;===========================================
I'm using llvm from trunk (23 sept 2009) on Windows 7 ( build 7600 )
To run test I used:
  llvm-as test.ll
  lli test.bc

-- 
WBR,
Eugeny Grishul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20090923/2b4a8989/attachment.html>


More information about the llvm-bugs mailing list