From ece881d5182873dd780b53387047fb8300cd5c7d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 27 Jan 2016 01:37:52 +0000 Subject: [PATCH] [WebAssembly] Add a test for the mem-intrinsic code in WebAssemblyPeephole.cpp llvm-svn: 258895 --- llvm/test/CodeGen/WebAssembly/mem-intrinsics.ll | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/llvm/test/CodeGen/WebAssembly/mem-intrinsics.ll b/llvm/test/CodeGen/WebAssembly/mem-intrinsics.ll index 669f6ec..4284e8e 100644 --- a/llvm/test/CodeGen/WebAssembly/mem-intrinsics.ll +++ b/llvm/test/CodeGen/WebAssembly/mem-intrinsics.ll @@ -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 +} -- 2.7.4