[WebAssembly] Add a test for the mem-intrinsic code in WebAssemblyPeephole.cpp

llvm-svn: 258895
This commit is contained in:
Dan Gohman 2016-01-27 01:37:52 +00:00
parent a3518ad0b7
commit ece881d518
1 changed files with 31 additions and 0 deletions

View File

@ -74,3 +74,34 @@ entry:
call void @llvm.memset.p0i8.i32(i8* %1, i8 256, i32 1024, i32 16, i1 false)
ret void
}
; If the result value of memset doesn't get stackified, it should be marked
; $discard.
; CHECK-LABEL: discard_result:
; CHECK: i32.call $discard=, memset@FUNCTION, $0, $1, $2
declare i8* @def()
define i8* @discard_result(i8* %arg, i8 %arg1, i32 %arg2, i32 %arg3, i32 %arg4) {
bb:
%tmp = icmp eq i32 %arg3, 0
br i1 %tmp, label %bb5, label %bb9
bb5:
%tmp6 = icmp eq i32 %arg4, 0
br i1 %tmp6, label %bb7, label %bb8
bb7:
call void @llvm.memset.p0i8.i32(i8* %arg, i8 %arg1, i32 %arg2, i32 1, i1 false)
br label %bb11
bb8:
br label %bb11
bb9:
%tmp10 = call i8* @def()
br label %bb11
bb11:
%tmp12 = phi i8* [ %arg, %bb7 ], [ %arg, %bb8 ], [ %tmp10, %bb9 ]
ret i8* %tmp12
}