[Chapel Merge] Support fixed sized arrays of tuples containing no

Branch: refs/heads/master
Revision: 1ae37e9
Author: dlongnecke-cray
Log Message:

Merge pull request #16802 from dlongnecke-cray/investigate-array-tuple-shared

Support fixed sized arrays of tuples containing non-nilable classes (#16802)

Add support for the last failing case in #15394, which is a fixed size
array of (shared C, shared C), a tuple containing non-nilable

class C { var x = 0; }
var arr = [new shared C(0), new shared C(1), new shared C(2)];

The above code will call chpl__buildArrayExpr() to create the array
literal that is used to initialize arr. The problem is that the
original code would default-initialize the array literal and then
assign the elements. The compiler would emit errors about default-
initializing non-nilable class tuple elements.

Adjust chpl__buildArrayExpr() to create an array with
initElts=false to avoid default-initializing array elements. Then
move the elements into place using a primitive. This sidesteps the
compiler errors.

The parser had to be adjusted to support a varargs formal with a
forward pragma list:

proc chpl__buildArrayExpr(pragma "no auto destroy" in elems ...?k);

The parser adjustment is good, but the way the flags are propagated
during expandVarArgs() is wonky. If others feel the inclination to
slap pragmas on varargs formals, the implementation will probably
have to be adjusted again.

Add code to move-initialize the varargs tuple when the varargs formal
has the in intent. The “no auto destroy” flag is propagated to
all of the formals inserted when the varargs is expanded, so they
can be moved into the tuple without worry.

This avoids an extra copy caused by chpl__init_tuple() that seems
to be otherwise unavoidable.

Adjust addLocalCopiesAndWritebacks() to not add the flag
FLAG_INSERT_AUTO_DESTROY to temporaries that have the NO_AUTO_DESTROY
flag. This is due to a quirk of how varargs formals are expanded.

Adjust chpl__buildArrayRuntimeType() to return an array initialized
with initElts=false. This was required to prevent warnings about
default-initialized (shared C, shared C) tuples, but does not affect
the behavior of array runtime types in any noticeable way.

Remove a compiler error embedded in ReplicatedDist that triggered
due to array literals being initialized with initElts=false. The
.good files of two tests using Replicated needed to be modified to
accept new output, but other than that all tests seem to pass.

Check the output of array-initialization-patterns-dists.chpl by
hand to make sure the behavior of Replicated seems correct. Modify
the test to have different .good files for Replicated depending on
if COMM=none or not.


  • [x] ALL on linux64 when COMM=none, LLVM=none
  • [x] ALL on linux64 when COMM=gasnet, LLVM=none

Reviewed by @mppf. Thanks!

Signed-off-by: David Longnecker dlongnecke-cray@users.noreply.github.com

Modified Files:
A test/arrays/ferguson/array-initialization-patterns/array-initialization-patterns-dists.replicated-comm.good
A test/arrays/ferguson/array-initialization-patterns/array-initialization-patterns-dists.replicated-no-comm.good
A test/arrays/types-fixed-array/testArrayTupleShared.chpl
A test/arrays/types-fixed-array/testArrayTupleShared.good
R test/arrays/ferguson/array-initialization-patterns/array-initialization-patterns-dists.replicated.good
R test/arrays/types-fixed-array/testTuple.bad
R test/arrays/types-fixed-array/testTuple.future
R test/arrays/types-fixed-array/testTuple.prediff
M compiler/include/bison-chapel.h
M compiler/include/flex-chapel.h
M compiler/parser/bison-chapel.cpp
M compiler/parser/chapel.ypp
M compiler/parser/flex-chapel.cpp
M compiler/resolution/expandVarArgs.cpp
M compiler/resolution/functionResolution.cpp
M compiler/resolution/resolveFunction.cpp
M modules/dists/ReplicatedDist.chpl
M modules/internal/ChapelArray.chpl
M modules/internal/DefaultRectangular.chpl
M test/arrays/ferguson/array-initialization-patterns/array-initialization-patterns-dists.compopts
M test/types/records/expiring/more-deinit-points.good
M test/types/records/split-init/split-init-array.chpl
M test/types/records/split-init/split-init-array.good

Compare: Comparing a7d436020f13...1ae37e983ac5 · chapel-lang/chapel · GitHub