[Chapel Merge] Deinit module-scope variables in reverse init orde

Branch: refs/heads/master
Revision: 5c299b1
Author: mppf
Log Message:

Merge pull request #16430 from mppf/deinit-order-module-scope-vars

Deinit module-scope variables in reverse init order

Resolves #15570

This PR adjusts insertGlobalAutoDestroyCalls to consider the
initialization order of the module-scope variables being destroyed in the
module deinit function. It destroys these variables in reverse
initialization order rather than reverse declaration order.
(Initialization order will match declaration order unless split-init is
used).

Reviewed by @vasslitvinov - thanks!

  • [x] primers pass with valgrind+verify and do not leak
  • [x] full local futures testing

Modified Files:
A test/types/records/split-init/split-init-globals-deinit-order.chpl
A test/types/records/split-init/split-init-globals-deinit-order.good
A test/types/records/split-init/split-init-globals-reorder-cond-error.chpl
A test/types/records/split-init/split-init-globals-reorder-cond-error.good
M compiler/resolution/callDestructors.cpp

Compare: https://github.com/chapel-lang/chapel/compare/bd1c1a66e417...5c299b1ec6f5