[Chapel Merge] Fix a leak in driverEdgeBtw.chpl

Branch: refs/heads/master
Revision: a50a209
Author: mppf
Log Message:

Merge pull request #17374 from mppf/fix-leak-895

Fix a leak in driverEdgeBtw.chpl

Resolves https://github.com/Cray/chapel-private/issues/895

This commit fixes a leak in the test

test/studies/dijkstra/driverEdgeBtw.chpl

The leak seems to come up for functions that return an array by value but
also use the out or inout intent (with any type).

The issue was that ReturnByRef::transformMove checks only the next
statement for an initCopy to remove when returning a function by value.
But, it needs to skip past certain other kinds of statements added by the
compiler. It was already skipping error handling statements.

After PR #14917, we also add out/inout intent writebacks at the call
site. These interfering with the ability of ReturnByRef::transformMove to
identify a copy that should be removed. This PR adjusts wrappers.cpp to
mark the relevant temporaries with a flag and then adjusts
ReturnByRef::transformMove to skip these.

  • [x] full local testing
  • [x] release/examples/primers pass with valgrind+verify and do not leak
  • [x] full gasnet testing
  • [x] no new memory leaks with gasnet testing as compared to without this PR

Reviewed by @e-kayrakli - thanks!

Modified Files:
A test/users/ferguson/issue-895-reproducer.chpl

A test/users/ferguson/issue-895-reproducer.execopts
A test/users/ferguson/issue-895-reproducer.good
M compiler/include/flags_list.h
M compiler/resolution/callDestructors.cpp
M compiler/resolution/wrappers.cpp

Compare: https://github.com/chapel-lang/chapel/compare/76e0d6d0cd56...a50a209d9e44