18306cb57SDan Gohman; RUN: llc -verify-machineinstrs -mtriple=wasm32-unknown-unknown < %s | FileCheck -check-prefix=WASM32 %s
28306cb57SDan Gohman
38306cb57SDan Gohman@"\01LC" = internal constant [11 x i8] c"buf == %s\0A\00"		; <[11 x i8]*> [#uses=1]
48306cb57SDan Gohman
5*86cc731fSAlex Bradbury; WASM32-LABEL: test:
67e6793aaSHeejin Ahn; WASM32:      i32.load        28
77e6793aaSHeejin Ahn; WASM32:      br_if           0
87e6793aaSHeejin Ahn; WASM32:      call __stack_chk_fail
97e6793aaSHeejin Ahn; WASM32-NEXT: unreachable
107e6793aaSHeejin Ahn
118306cb57SDan Gohmandefine void @test(i8* %a) nounwind ssp {
128306cb57SDan Gohmanentry:
138306cb57SDan Gohman	%a_addr = alloca i8*		; <i8**> [#uses=2]
148306cb57SDan Gohman	%buf = alloca [8 x i8]		; <[8 x i8]*> [#uses=2]
158306cb57SDan Gohman  %"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0]
168306cb57SDan Gohman	store i8* %a, i8** %a_addr
178306cb57SDan Gohman	%buf1 = bitcast [8 x i8]* %buf to i8*		; <i8*> [#uses=1]
188306cb57SDan Gohman	%0 = load i8*, i8** %a_addr, align 4		; <i8*> [#uses=1]
198306cb57SDan Gohman	%1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind		; <i8*> [#uses=0]
208306cb57SDan Gohman  %buf2 = bitcast [8 x i8]* %buf to i8*		; <i8*> [#uses=1]
218306cb57SDan Gohman	%2 = call i32 (i8*, ...) @printf(i8* getelementptr ([11 x i8], [11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind		; <i32> [#uses=0]
228306cb57SDan Gohman	br label %return
238306cb57SDan Gohman
248306cb57SDan Gohmanreturn:		; preds = %entry
258306cb57SDan Gohman	ret void
268306cb57SDan Gohman}
278306cb57SDan Gohman
28*86cc731fSAlex Bradbury; WASM32-LABEL: test_return_i32:
297e6793aaSHeejin Ahn; WASM32:      call __stack_chk_fail
307e6793aaSHeejin Ahn; WASM32-NEXT: unreachable
317e6793aaSHeejin Ahn
327e6793aaSHeejin Ahndefine i32 @test_return_i32(i8* %a) nounwind ssp {
337e6793aaSHeejin Ahnentry:
347e6793aaSHeejin Ahn  %a_addr = alloca i8*    ; <i8**> [#uses=2]
357e6793aaSHeejin Ahn  %buf = alloca [8 x i8]    ; <[8 x i8]*> [#uses=2]
367e6793aaSHeejin Ahn  %"alloca point" = bitcast i32 0 to i32    ; <i32> [#uses=0]
377e6793aaSHeejin Ahn  store i8* %a, i8** %a_addr
387e6793aaSHeejin Ahn  %buf1 = bitcast [8 x i8]* %buf to i8*    ; <i8*> [#uses=1]
397e6793aaSHeejin Ahn  %0 = load i8*, i8** %a_addr, align 4    ; <i8*> [#uses=1]
407e6793aaSHeejin Ahn  %1 = call i8* @strcpy(i8* %buf1, i8* %0) nounwind    ; <i8*> [#uses=0]
417e6793aaSHeejin Ahn  %buf2 = bitcast [8 x i8]* %buf to i8*    ; <i8*> [#uses=1]
427e6793aaSHeejin Ahn  %2 = call i32 (i8*, ...) @printf(i8* getelementptr ([11 x i8], [11 x i8]* @"\01LC", i32 0, i32 0), i8* %buf2) nounwind    ; <i32> [#uses=0]
437e6793aaSHeejin Ahn  br label %return
447e6793aaSHeejin Ahn
457e6793aaSHeejin Ahnreturn:    ; preds = %entry
467e6793aaSHeejin Ahn  ret i32 0
477e6793aaSHeejin Ahn}
487e6793aaSHeejin Ahn
498306cb57SDan Gohmandeclare i8* @strcpy(i8*, i8*) nounwind
508306cb57SDan Gohman
518306cb57SDan Gohmandeclare i32 @printf(i8*, ...) nounwind
52