Branch: refs/heads/master
Revision: b7463e2
Author: e-kayrakli
Log Message:
Merge pull request #16509 from e-kayrakli/generic-in-domain-formal
Fix some issues with constant domain optimization
Resolves https://github.com/chapel-lang/chapel/issues/16398
Resolves two leaks:
test/arrays/shapes/field-defaults.chpl
test/classes/initializers/compilerGenerated/array-field-not-in-call2.chpl
Supersedes https://github.com/chapel-lang/chapel/pull/16461
While passing a domain literal to an in
formal, we adjust the related initCopy
to take care of the definedConst
field of the domain. However, we don’t have
that initCopy for fully generic formals. This causes two issues:
- We don’t set the constness correctly for
in
formals (#16398) - Consider:
record R {
var d;
var a: [d] int;
}
var r = new R({1..3});
we move the literal to d
in the default initializer and adjust its constness
in the initializer body, however, we create the default array argument at the
call site where the domain still has definedConst=true
.
To fix this issue, this PR:
-
Add
isFormalTmpConst
to check forin
formals in default initializers -
When we are moving a domain for an
in
intent formal without any coercion,
set the constness of that domain based on the constness of the formal (i.e.
const in
vsin
) [except when calling a default initializer] -
When we are eliding a domain copy, sets the constness of the symbol after
PRIM_ASSIGN_ELIDED_COPY
-
Makes
setDefinedConstForDomainSymbol
a non static function and simplifies
its interface. -
Removes the workaround in a test, that was added to avoid #16398
-
Adds bunch of testing
[Reviewed by @mppf]
Test:
- [x] standard
- [x] gasnet
- [x] valgrind examples
- [x] memleaks examples
Modified Files:
A test/optimizations/constDomain/domainArgsConcrete.chpl
A test/optimizations/constDomain/domainArgsConcrete.good
A test/optimizations/constDomain/domainField2.chpl
A test/optimizations/constDomain/domainField2.good
A test/optimizations/constDomain/literalIntoVar.chpl
A test/optimizations/constDomain/literalIntoVar.good
M compiler/include/optimizations.h
M compiler/optimizations/propagateDomainConstness.cpp
M compiler/passes/splitInit.cpp
M compiler/resolution/wrappers.cpp
M test/optimizations/constDomain/domainArgs.chpl
Compare: https://github.com/chapel-lang/chapel/compare/c724ff7000a6...b7463e290e6b