Please sign in to comment.
[Fix] Misc reference handling buglets exposed by enabling inlining
Summary: - in f($x, $x &= $y), where f takes its first param by reference, we would pass a reference to $x after the assignment, rather than before it (this happened independent of inlining). - in f(g(x)) if g returned by reference, and f did not take its param by reference, f could end up with a reference to the result of g anyway, due to copy constructor elision (again, independent of inlining) - there was a similar problem when a return-by-reference function got inlined. The return value could be destroyed before it was used (resulting in a crash in one of the added test cases), or it could just end up refering to the wrong thing. - in $a = &f(), if f returned by value, and got inlined, $a could end up bound to the result of f() (rather than bound to a copy of the result of f()) In order to expose the return-by-reference issue, I had to increase the inliner's agressiveness. So Ive changed it from a bool, to an int and used it as the max "cost" for a function. To minimize extra temps, I added the return value's refness to the FunctionInfo. Test Plan: fast_tests, slow_tests and slow_tests with AutoInline=5 (there are still some failures, with the latter - will address separately). Reviewers: qigao, myang Reviewed By: myang CC: ps, mwilliams, myang Differential Revision: 348039 Task ID: 630786
- Loading branch information...
Showing with 234 additions and 50 deletions.
- +3 −3 src/compiler/analysis/alias_manager.cpp
- +24 −2 src/compiler/analysis/function_scope.cpp
- +6 −1 src/compiler/analysis/function_scope.h
- +1 −0 src/compiler/analysis/type.cpp
- +3 −0 src/compiler/expression/constant_expression.h
- +13 −3 src/compiler/expression/expression.cpp
- +37 −5 src/compiler/expression/expression_list.cpp
- +6 −1 src/compiler/expression/function_call.cpp
- +51 −22 src/compiler/expression/simple_variable.cpp
- +2 −2 src/compiler/option.cpp
- +1 −1 src/compiler/option.h
- +87 −10 src/test/test_code_run.cpp
Oops, something went wrong.