1 ; RUN: llc < %s -asm-verbose=false | FileCheck %s 2 3 ; Test that the "returned" attribute is optimized effectively. 4 5 target datalayout = "e-p:32:32-i64:64-n32:64-S128" 6 target triple = "wasm32-unknown-unknown" 7 8 ; CHECK-LABEL: _Z3foov: 9 ; CHECK-NEXT: .result i32{{$}} 10 ; CHECK-NEXT: i32.const $push0=, 1{{$}} 11 ; CHECK-NEXT: {{^}} i32.call $push1=, _Znwm, $pop0{{$}} 12 ; CHECK-NEXT: {{^}} i32.call $push2=, _ZN5AppleC1Ev, $pop1{{$}} 13 ; CHECK-NEXT: return $pop2{{$}} 14 %class.Apple = type { i8 } 15 declare noalias i8* @_Znwm(i32) 16 declare %class.Apple* @_ZN5AppleC1Ev(%class.Apple* returned) 17 define %class.Apple* @_Z3foov() { 18 entry: 19 %call = tail call noalias i8* @_Znwm(i32 1) 20 %0 = bitcast i8* %call to %class.Apple* 21 %call1 = tail call %class.Apple* @_ZN5AppleC1Ev(%class.Apple* %0) 22 ret %class.Apple* %0 23 } 24 25 ; CHECK-LABEL: _Z3barPvS_l: 26 ; CHECK-NEXT: .param i32, i32, i32{{$}} 27 ; CHECK-NEXT: .result i32{{$}} 28 ; CHECK-NEXT: {{^}} i32.call $push0=, memcpy, $0, $1, $2{{$}} 29 ; CHECK-NEXT: return $pop0{{$}} 30 declare i8* @memcpy(i8* returned, i8*, i32) 31 define i8* @_Z3barPvS_l(i8* %p, i8* %s, i32 %n) { 32 entry: 33 %call = tail call i8* @memcpy(i8* %p, i8* %s, i32 %n) 34 ret i8* %p 35 } 36 37 ; Test that the optimization isn't performed on constant arguments. 38 39 ; CHECK-LABEL: test_constant_arg: 40 ; CHECK-NEXT: i32.const $push0=, global{{$}} 41 ; CHECK-NEXT: {{^}} i32.call $discard=, returns_arg, $pop0{{$}} 42 ; CHECK-NEXT: return{{$}} 43 @global = external global i32 44 @addr = global i32* @global 45 define void @test_constant_arg() { 46 %call = call i32* @returns_arg(i32* @global) 47 ret void 48 } 49 declare i32* @returns_arg(i32* returned) 50