llvm.org GIT mirror llvm / fee2961
[WebAssembly] Fix WebAssemblyOptimizeReturned after r300367 Summary: Refactoring changed paramHasAttr(1 + i) to paramHasAttr(0), fix that to paramHasAttr(i). Add more tests to WebAssemblyOptimizeReturned that catch that regression. Reviewers: dschuff Subscribers: jfb, sbc100, llvm-commits Differential Revision: https://reviews.llvm.org/D32136 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300502 91177308-0d34-0410-b5e6-96231b3b80d8 Jacob Gravelle 3 years ago
2 changed file(s) with 32 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
5353
5454 void OptimizeReturned::visitCallSite(CallSite CS) {
5555 for (unsigned i = 0, e = CS.getNumArgOperands(); i < e; ++i)
56 if (CS.paramHasAttr(0, Attribute::Returned)) {
56 if (CS.paramHasAttr(i, Attribute::Returned)) {
5757 Instruction *Inst = CS.getInstruction();
5858 Value *Arg = CS.getArgOperand(i);
5959 // Ignore constants, globals, undef, etc.
4646 ret void
4747 }
4848 declare i32* @returns_arg(i32* returned)
49
50 ; Test that the optimization isn't performed on arguments without the
51 ; "returned" attribute.
52
53 ; CHECK-LABEL: test_other_skipped:
54 ; CHECK-NEXT: .param i32, i32, f64{{$}}
55 ; CHECK-NEXT: {{^}} i32.call $drop=, do_something@FUNCTION, $0, $1, $2{{$}}
56 ; CHECK-NEXT: {{^}} call do_something_with_i32@FUNCTION, $1{{$}}
57 ; CHECK-NEXT: {{^}} call do_something_with_double@FUNCTION, $2{{$}}
58 declare i32 @do_something(i32 returned, i32, double)
59 declare void @do_something_with_i32(i32)
60 declare void @do_something_with_double(double)
61 define void @test_other_skipped(i32 %a, i32 %b, double %c) {
62 %call = call i32 @do_something(i32 %a, i32 %b, double %c)
63 call void @do_something_with_i32(i32 %b)
64 call void @do_something_with_double(double %c)
65 ret void
66 }
67
68 ; Test that the optimization is performed on arguments other than the first.
69
70 ; CHECK-LABEL: test_second_arg:
71 ; CHECK-NEXT: .param i32, i32{{$}}
72 ; CHECK-NEXT: .result i32{{$}}
73 ; CHECK-NEXT: {{^}} i32.call $push0=, do_something_else@FUNCTION, $0, $1{{$}}
74 ; CHECK-NEXT: return $pop0{{$}}
75 declare i32 @do_something_else(i32, i32 returned)
76 define i32 @test_second_arg(i32 %a, i32 %b) {
77 %call = call i32 @do_something_else(i32 %a, i32 %b)
78 ret i32 %b
79 }