From 92e5673018a42efee75f7f5ada84b8149f80e925 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Dec 2023 15:35:15 -0500 Subject: [PATCH 01/14] Bring in a version from Brad's earlier effort --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 72 +++++++++++++++++++++- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index cc82558e4f1c..4cf7c7f3a452 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -183,7 +183,7 @@ static Expr* foldTryCond(Expr* expr); static void unmarkDefaultedGenerics(); static void resolveUsesAndModule(ModuleSymbol* mod, const char* path); static void resolveSupportForModuleDeinits(); -static void resolveExports(); +static void resolveExportsEtc(); static void resolveEnumTypes(); static void populateRuntimeTypeMap(); static void resolveAutoCopies(); @@ -11436,7 +11436,7 @@ void resolve() { finishInterfaceChecking(); // should happen before resolveAutoCopies - resolveExports(); + resolveExportsEtc(); resolveEnumTypes(); @@ -11623,9 +11623,23 @@ static void resolveSupportForModuleDeinits() { * * ************************************** | *************************************/ -static void resolveExports() { +static bool hasVariableArgs(FnSymbol* fn) { + for_formals(formal, fn) { + if (formal->variableExpr) { + return true; + } + } + + return false; +} + +static void resolveExportsEtc() { std::vector exps; + // try to resolve concrete functions when using --dyno-gen-lib + bool alsoConcrete = !gDynoGenLibOutput.empty() && + !fMinimalModules; + // We need to resolve any additional functions that will be exported. forv_expanding_Vec(FnSymbol, fn, gFnSymbols) { if (fn == initStringLiterals) { @@ -11642,6 +11656,58 @@ static void resolveExports() { if (fn->hasFlag(FLAG_EXPORT)) exps.push_back(fn); + } else if (alsoConcrete) { + // gather the receiver type if there is one + AggregateType* at = NULL; + if (fn->_this) { + at = toAggregateType(fn->_this->type); + } + + if (!fn->hasFlag(FLAG_GENERIC) && + !hasVariableArgs(fn) && + !fn->hasFlag(FLAG_RESOLVED) && + !fn->hasFlag(FLAG_INVISIBLE_FN) && + !fn->hasFlag(FLAG_INLINE) && + !fn->hasFlag(FLAG_EXTERN) && + !fn->hasFlag(FLAG_ON) && + !fn->hasFlag(FLAG_COBEGIN_OR_COFORALL) && + // !fn->hasFlag(FLAG_COMPILER_NESTED_FUNCTION) + !fn->hasFlag(FLAG_COMPILER_GENERATED) && + // either this is not a method, or at least it's not a method + // on a generic type + (fn->_this == NULL || !at || !at->isGeneric()) && + // TODO: What chpl_ functions are not marked compiler-generated? + (strncmp(fn->name, "chpl_", 5) != 0) && + fn->defPoint && + // Nested functions are tricky because their resolution may depend + // on the resolution of the outer function in which they are located; + // i.e., they may be generic w.r.t. outer-scoped variables, yet not + // marked with FLAG_GENERIC. How to distinguish simple nested + // concrete functions which could be resolved from those that can't? + !isFnSymbol(fn->defPoint->parentSymbol) && // fn is not nested + fn->defPoint->getModule() && + fn->defPoint->getModule()->modTag == MOD_USER) { + SET_LINENO(fn); + + if (developer) { + printf("---\n"); + printf("%s (%s:%d)\n", fn->name, fn->astloc.filename(), fn->astloc.lineno()); + printf("---\n"); + viewFlags(fn->id); + printf("---\n\n"); + } + + // disable resolveExprMaybeIssueError + //squashCompilerMessages = true; + if (evaluateWhereClause(fn)) { + resolveSignatureAndFunction(fn); + /* + fn->removeFlag(FLAG_RESOLVED); // though we resolved it, pretend we + // didn't so it'll be dead-code eliminated + */ + } + //squashCompilerMessages = false; + } } } From 44e72a30329ed2298231782cf04ae7d6f0c1238f Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Dec 2023 16:42:00 -0500 Subject: [PATCH 02/14] Remove deprecated CHPL_AUX_FILESYS --- Signed-off-by: Michael Ferguson --- modules/standard/ChplConfig.chpl | 8 -------- test/deprecated/chplAuxFilesys.chpl | 4 ---- test/deprecated/chplAuxFilesys.good | 2 -- 3 files changed, 14 deletions(-) delete mode 100644 test/deprecated/chplAuxFilesys.chpl delete mode 100644 test/deprecated/chplAuxFilesys.good diff --git a/modules/standard/ChplConfig.chpl b/modules/standard/ChplConfig.chpl index 0803e298d844..4b0a39d57e69 100644 --- a/modules/standard/ChplConfig.chpl +++ b/modules/standard/ChplConfig.chpl @@ -39,14 +39,6 @@ module ChplConfig { param CHPL_HOME:string; CHPL_HOME = __primitive("get compiler variable", "CHPL_HOME"); - /* Deprecated */ - @deprecated(notes="CHPL_AUX_FILESYS is deprecated, please let us know if this is a problem") - proc CHPL_AUX_FILESYS param :string { - // use a proc here because the split initialization caused an - // additional deprecation warning - return __primitive("get compiler variable", "CHPL_AUX_FILESYS"); - } - /* See :ref:`readme-chplenv.CHPL_TARGET_PLATFORM` for more information. */ @unstable("'ChplConfig.CHPL_TARGET_PLATFORM' is unstable and may be replaced with a different way to access this information in the future"); param CHPL_TARGET_PLATFORM:string; diff --git a/test/deprecated/chplAuxFilesys.chpl b/test/deprecated/chplAuxFilesys.chpl deleted file mode 100644 index c0a96a8fb944..000000000000 --- a/test/deprecated/chplAuxFilesys.chpl +++ /dev/null @@ -1,4 +0,0 @@ -{ - use ChplConfig; - writeln(CHPL_AUX_FILESYS=="goober"); -} diff --git a/test/deprecated/chplAuxFilesys.good b/test/deprecated/chplAuxFilesys.good deleted file mode 100644 index d6313ade9f8a..000000000000 --- a/test/deprecated/chplAuxFilesys.good +++ /dev/null @@ -1,2 +0,0 @@ -chplAuxFilesys.chpl:3: warning: CHPL_AUX_FILESYS is deprecated, please let us know if this is a problem -false From 2185410919e8c0944c21ee469bfcb50f20fcc7d0 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Dec 2023 16:42:46 -0500 Subject: [PATCH 03/14] Improve resolving concrete & add a flag for it --- Signed-off-by: Michael Ferguson --- compiler/include/driver.h | 2 ++ compiler/main/driver.cpp | 3 +++ compiler/resolution/functionResolution.cpp | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/compiler/include/driver.h b/compiler/include/driver.h index 293173f65a6d..3553e1e411d1 100644 --- a/compiler/include/driver.h +++ b/compiler/include/driver.h @@ -313,6 +313,8 @@ extern bool fDynoVerifySerialization; extern size_t fDynoBreakOnHash; +extern bool fResolveConcreteFns; + extern bool fNoIOGenSerialization; extern bool fNoIOSerializeWriteThis; extern bool fNoIODeserializeReadThis; diff --git a/compiler/main/driver.cpp b/compiler/main/driver.cpp index e5d5bdf3b661..bf5f8ca8967c 100644 --- a/compiler/main/driver.cpp +++ b/compiler/main/driver.cpp @@ -363,6 +363,8 @@ bool fDynoDebugTrace = false; bool fDynoVerifySerialization = false; size_t fDynoBreakOnHash = 0; +bool fResolveConcreteFns = false; + bool fNoIOGenSerialization = false; bool fNoIOSerializeWriteThis = false; bool fNoIODeserializeReadThis = false; @@ -1488,6 +1490,7 @@ static ArgumentDescription arg_desc[] = { {"dyno-break-on-hash", ' ' , NULL, "Break when query with given hash value is executed when using dyno compiler library", "X", &fDynoBreakOnHash, "CHPL_DYNO_BREAK_ON_HASH", NULL}, {"dyno-gen-lib", ' ', "", "Specify files named on the command line should be saved into a .dyno library", "P", NULL, NULL, addDynoGenLib}, {"dyno-verify-serialization", ' ', NULL, "Enable [disable] verification of serialization", "N", &fDynoVerifySerialization, NULL, NULL}, + {"resolve-concrete-fns", ' ', NULL, "Enable [disable] resolving concrete functions", "N", &fResolveConcreteFns, NULL, NULL}, {"foreach-intents", ' ', NULL, "Enable [disable] (current, experimental, support for) foreach intents.", "N", &fForeachIntents, "CHPL_FOREACH_INTENTS", NULL}, {"io-gen-serialization", ' ', NULL, "Enable [disable] generation of IO serialization methods", "n", &fNoIOGenSerialization, "CHPL_IO_GEN_SERIALIZATION", NULL}, diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 4cf7c7f3a452..4816e53993fb 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -11633,11 +11633,18 @@ static bool hasVariableArgs(FnSymbol* fn) { return false; } +static bool isGenericFn(FnSymbol* fn) { + if (!fn->isGenericIsValid()) { + fn->tagIfGeneric(); + } + return fn->isGeneric(); +} + static void resolveExportsEtc() { std::vector exps; // try to resolve concrete functions when using --dyno-gen-lib - bool alsoConcrete = !gDynoGenLibOutput.empty() && + bool alsoConcrete = (fResolveConcreteFns || !gDynoGenLibOutput.empty()) && !fMinimalModules; // We need to resolve any additional functions that will be exported. @@ -11664,6 +11671,7 @@ static void resolveExportsEtc() { } if (!fn->hasFlag(FLAG_GENERIC) && + !fn->hasFlag(FLAG_LAST_RESORT) && !hasVariableArgs(fn) && !fn->hasFlag(FLAG_RESOLVED) && !fn->hasFlag(FLAG_INVISIBLE_FN) && @@ -11686,16 +11694,18 @@ static void resolveExportsEtc() { // concrete functions which could be resolved from those that can't? !isFnSymbol(fn->defPoint->parentSymbol) && // fn is not nested fn->defPoint->getModule() && - fn->defPoint->getModule()->modTag == MOD_USER) { + !isGenericFn(fn) + /* && fn->defPoint->getModule()->modTag == MOD_USER*/ + ) { SET_LINENO(fn); - if (developer) { + /*if (developer) { printf("---\n"); printf("%s (%s:%d)\n", fn->name, fn->astloc.filename(), fn->astloc.lineno()); printf("---\n"); viewFlags(fn->id); printf("---\n\n"); - } + }*/ // disable resolveExprMaybeIssueError //squashCompilerMessages = true; From 92e05480787ed29f4edca59c82905c668d7fd213 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Dec 2023 16:43:02 -0500 Subject: [PATCH 04/14] Resolve declared return types first To resolve a problem with the Locale class heirarchy with _getChild --- Signed-off-by: Michael Ferguson --- compiler/resolution/resolveFunction.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/resolution/resolveFunction.cpp b/compiler/resolution/resolveFunction.cpp index 0e2920c8674c..f9592457e4a7 100644 --- a/compiler/resolution/resolveFunction.cpp +++ b/compiler/resolution/resolveFunction.cpp @@ -571,6 +571,10 @@ void resolveFunction(FnSymbol* fn, CallExpr* forCall) { insertUnrefForArrayOrTupleReturn(fn); + if (fn->retExprType) { + resolveSpecifiedReturnType(fn); + } + Type* yieldedType = NULL; resolveReturnTypeAndYieldedType(fn, &yieldedType); From af26d0045cf62c449b22dc9f16e5551c7d808b6b Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 6 Dec 2023 16:46:01 -0500 Subject: [PATCH 05/14] Address module errors with --resolve-concrete-fns --- Signed-off-by: Michael Ferguson --- modules/internal/Atomics.chpl | 1 + modules/internal/BytesStringCommon.chpl | 2 +- modules/internal/ChapelBase.chpl | 2 ++ modules/internal/ChapelLocale.chpl | 4 ++-- modules/internal/DefaultRectangular.chpl | 2 +- modules/internal/LocaleModelHelpSetup.chpl | 6 ++++++ modules/internal/NetworkAtomics.chpl | 1 + modules/standard/IO.chpl | 6 ++++-- modules/standard/Regex.chpl | 1 + modules/standard/Time.chpl | 13 ++++++++----- 10 files changed, 27 insertions(+), 11 deletions(-) diff --git a/modules/internal/Atomics.chpl b/modules/internal/Atomics.chpl index 799b9174bdc1..73f8124985af 100644 --- a/modules/internal/Atomics.chpl +++ b/modules/internal/Atomics.chpl @@ -423,6 +423,7 @@ module Atomics { } // TODO: should this be an operator method AtomicBool.: ? + pragma "last resort" @chpldoc.nodoc operator :(rhs: bool, type t:AtomicBool) { var lhs: AtomicBool = rhs; // use init= diff --git a/modules/internal/BytesStringCommon.chpl b/modules/internal/BytesStringCommon.chpl index 590007100a73..8687343bbe46 100644 --- a/modules/internal/BytesStringCommon.chpl +++ b/modules/internal/BytesStringCommon.chpl @@ -999,7 +999,7 @@ module BytesStringCommon { if curMargin == '':t { // An unindented non-empty line means no margin exists, return early - margin = ''; + margin = '':t; break; } else if margin == '':t { // Initialize margin diff --git a/modules/internal/ChapelBase.chpl b/modules/internal/ChapelBase.chpl index 345e3175ffa7..4e1b13ecdd77 100644 --- a/modules/internal/ChapelBase.chpl +++ b/modules/internal/ChapelBase.chpl @@ -45,11 +45,13 @@ module ChapelBase { inline operator c_fn_ptr.=(ref a:c_fn_ptr, b:c_fn_ptr) { __primitive("=", a, b); } + pragma "last resort" @chpldoc.nodoc @unstable proc c_fn_ptr.this() { compilerError("Can't call a C function pointer within Chapel"); } + pragma "last resort" @chpldoc.nodoc @unstable proc c_fn_ptr.this(args...) { diff --git a/modules/internal/ChapelLocale.chpl b/modules/internal/ChapelLocale.chpl index 1085fb3f7927..e828dede5560 100644 --- a/modules/internal/ChapelLocale.chpl +++ b/modules/internal/ChapelLocale.chpl @@ -558,12 +558,12 @@ module ChapelLocale { // LocaleSpace -- an array of locales and its corresponding domain // which are used as the default set of targetLocales in many // distributions. - proc getDefaultLocaleSpace() const ref { + proc getDefaultLocaleSpace() const ref : chpl_emptyLocaleSpace.type { HaltWrappers.pureVirtualMethodHalt(); return chpl_emptyLocaleSpace; } - proc getDefaultLocaleArray() const ref { + proc getDefaultLocaleArray() const ref : chpl_emptyLocales.type { HaltWrappers.pureVirtualMethodHalt(); return chpl_emptyLocales; } diff --git a/modules/internal/DefaultRectangular.chpl b/modules/internal/DefaultRectangular.chpl index 129cc0f43819..3d73791d8bb2 100644 --- a/modules/internal/DefaultRectangular.chpl +++ b/modules/internal/DefaultRectangular.chpl @@ -126,7 +126,7 @@ module DefaultRectangular { proc dsiEqualDMaps(d:unmanaged DefaultDist) param do return true; proc dsiEqualDMaps(d) param do return false; - proc trackDomains() param do return false; + override proc trackDomains() param do return false; override proc dsiTrackDomains() do return false; override proc singleton() param do return true; diff --git a/modules/internal/LocaleModelHelpSetup.chpl b/modules/internal/LocaleModelHelpSetup.chpl index cc4a1324929d..f51de7f54bca 100644 --- a/modules/internal/LocaleModelHelpSetup.chpl +++ b/modules/internal/LocaleModelHelpSetup.chpl @@ -92,6 +92,8 @@ module LocaleModelHelpSetup { } proc helpSetupRootLocaleNUMA(dst:borrowed RootLocale) { + extern proc chpl_task_setSubloc(subloc: int(32)); + var root_accum:chpl_root_locale_accum; forall locIdx in dst.chpl_initOnLocales() with (ref root_accum) { @@ -105,6 +107,8 @@ module LocaleModelHelpSetup { } proc helpSetupRootLocaleAPU(dst:borrowed RootLocale) { + extern proc chpl_task_setSubloc(subloc: int(32)); + var root_accum:chpl_root_locale_accum; forall locIdx in dst.chpl_initOnLocales() with (ref root_accum) { @@ -119,6 +123,8 @@ module LocaleModelHelpSetup { } proc helpSetupRootLocaleGPU(dst:borrowed RootLocale) { + extern proc chpl_task_setSubloc(subloc: int(32)); + var root_accum:chpl_root_locale_accum; forall locIdx in dst.chpl_initOnLocales() with (ref root_accum) { diff --git a/modules/internal/NetworkAtomics.chpl b/modules/internal/NetworkAtomics.chpl index a998830e440b..c330b8751a5f 100644 --- a/modules/internal/NetworkAtomics.chpl +++ b/modules/internal/NetworkAtomics.chpl @@ -142,6 +142,7 @@ module NetworkAtomics { } + pragma "last resort" operator :(rhs: bool, type t:RAtomicBool) { var lhs: RAtomicBool = rhs; // use init= return lhs; diff --git a/modules/standard/IO.chpl b/modules/standard/IO.chpl index ae5d971c1b0b..ceb64c2dd97b 100644 --- a/modules/standard/IO.chpl +++ b/modules/standard/IO.chpl @@ -2051,8 +2051,9 @@ proc file.unlock() { */ @chpldoc.nodoc -proc file.filePlugin() : QioPluginFile? { - return qio_file_get_plugin(this._channel_internal); +proc file.filePlugin() : borrowed QioPluginFile? { + var vptr = qio_file_get_plugin(this._file_internal); + return vptr:borrowed QioPluginFile?; } // File style cannot be modified after the file is created; @@ -9948,6 +9949,7 @@ proc file.fstype():int throws { :returns: a set of locales that are best for working with this region :rtype: domain(locale) */ +pragma "last resort" @deprecated(notes="file.localesForRegion is deprecated") proc file.localesForRegion(start:int(64), end:int(64)) { diff --git a/modules/standard/Regex.chpl b/modules/standard/Regex.chpl index f3bb660d047f..9da94dd70b48 100644 --- a/modules/standard/Regex.chpl +++ b/modules/standard/Regex.chpl @@ -439,6 +439,7 @@ record regexMatch { var numBytes:int; } +pragma "last resort" @chpldoc.nodoc proc reMatch type { diff --git a/modules/standard/Time.chpl b/modules/standard/Time.chpl index 5f3d9746e020..2193f0672832 100644 --- a/modules/standard/Time.chpl +++ b/modules/standard/Time.chpl @@ -148,6 +148,7 @@ module Time { /* Specifies the day of the week */ @deprecated(notes="enum 'day' is deprecated. Please use :enum:`dayOfWeek` instead") enum day { sunday=0, monday, tuesday, wednesday, thursday, friday, saturday } + pragma "last resort" @chpldoc.nodoc proc DayOfWeek { compilerError("'DayOfWeek' was renamed. Please use 'dayOfWeek' instead"); @@ -163,6 +164,7 @@ module Time { Saturday = 6, Sunday = 7 } + pragma "last resort" @chpldoc.nodoc proc ISODayOfWeek { compilerError("'ISODayOfWeek was renamed. Please use 'isoDayOfWeek' instead"); @@ -2105,7 +2107,7 @@ module Time { } @chpldoc.nodoc - operator timeDelta.>(lhs: timeDelta, rhs: timeDelta) : timeDelta { + operator timeDelta.>(lhs: timeDelta, rhs: timeDelta) : bool { const ls = (lhs.days*(24*60*60) + lhs.seconds); const rs = (rhs.days*(24*60*60) + rhs.seconds); if ls > rs then return true; @@ -2152,6 +2154,7 @@ module Time { @chpldoc.nodoc operator :(t: timeDelta, type s:string) : string { + import Math; var str: string; if t.days != 0 { str = t.days: string + " day"; @@ -2167,13 +2170,13 @@ module Time { str += hours: string + ":"; if minutes < 10 then str += "0"; - str += minutes + ":"; + str += minutes:string + ":"; if seconds < 10 then str += "0"; - str += seconds; + str += seconds:string; if microseconds != 0 { str += "."; - const usLog10 = log10(microseconds): int; + const usLog10 = Math.log10(microseconds): int; for i in 1..(5-usLog10) { str += "0"; } @@ -2425,7 +2428,7 @@ record Timer { Clears the elapsed time. If the timer is running then it is restarted otherwise it remains in the stopped state. */ - proc clear() : void { + proc ref clear() : void { accumulated = 0.0; if running { From 8977f516c525107d5fb27ba087753aceaadfb164 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 7 Dec 2023 10:34:22 -0500 Subject: [PATCH 06/14] Use a new pragma instead of adding "last resort" "last resort" changes function overload behavior and I don't want to get in to that in this PR, so instead add a new pragma that is more focused. --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 3 ++- frontend/include/chpl/uast/PragmaList.h | 1 + modules/internal/Atomics.chpl | 2 +- modules/internal/ChapelBase.chpl | 4 ++-- modules/internal/NetworkAtomics.chpl | 2 +- modules/standard/Regex.chpl | 2 +- modules/standard/Time.chpl | 4 ++-- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 4816e53993fb..6907a6b6f54a 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -11671,7 +11671,8 @@ static void resolveExportsEtc() { } if (!fn->hasFlag(FLAG_GENERIC) && - !fn->hasFlag(FLAG_LAST_RESORT) && + !fn->hasFlag(FLAG_LAST_RESORT) /* often a compilerError overload*/ && + !fn->hasFlag(FLAG_DO_NOT_RESOLVE_UNLESS_CALLED) && !hasVariableArgs(fn) && !fn->hasFlag(FLAG_RESOLVED) && !fn->hasFlag(FLAG_INVISIBLE_FN) && diff --git a/frontend/include/chpl/uast/PragmaList.h b/frontend/include/chpl/uast/PragmaList.h index 415ae2e7b17e..366563d1bb1b 100644 --- a/frontend/include/chpl/uast/PragmaList.h +++ b/frontend/include/chpl/uast/PragmaList.h @@ -634,6 +634,7 @@ PRAGMA(EXEMPT_INSTANTIATION_LIMIT, ypr, "fn exempt instantiation limit", "compil PRAGMA(COMPUTE_UNIFIED_TYPE_HELP, ypr, "compute unified type helper", "identify the internal chpl_computeUnifiedTypeHelp() routine") +PRAGMA(DO_NOT_RESOLVE_UNLESS_CALLED, npr, "do not resolve unless called", "do not resolve this function unless it is called (e.g. if it contains only compilerError)") #undef ypr #undef npr #undef ncm diff --git a/modules/internal/Atomics.chpl b/modules/internal/Atomics.chpl index 73f8124985af..07b0af97c120 100644 --- a/modules/internal/Atomics.chpl +++ b/modules/internal/Atomics.chpl @@ -423,7 +423,7 @@ module Atomics { } // TODO: should this be an operator method AtomicBool.: ? - pragma "last resort" + pragma "do not resolve unless called" @chpldoc.nodoc operator :(rhs: bool, type t:AtomicBool) { var lhs: AtomicBool = rhs; // use init= diff --git a/modules/internal/ChapelBase.chpl b/modules/internal/ChapelBase.chpl index 4e1b13ecdd77..23b732ab89f2 100644 --- a/modules/internal/ChapelBase.chpl +++ b/modules/internal/ChapelBase.chpl @@ -45,13 +45,13 @@ module ChapelBase { inline operator c_fn_ptr.=(ref a:c_fn_ptr, b:c_fn_ptr) { __primitive("=", a, b); } - pragma "last resort" + pragma "do not resolve unless called" @chpldoc.nodoc @unstable proc c_fn_ptr.this() { compilerError("Can't call a C function pointer within Chapel"); } - pragma "last resort" + pragma "do not resolve unless called" @chpldoc.nodoc @unstable proc c_fn_ptr.this(args...) { diff --git a/modules/internal/NetworkAtomics.chpl b/modules/internal/NetworkAtomics.chpl index c330b8751a5f..1efeba21ee2e 100644 --- a/modules/internal/NetworkAtomics.chpl +++ b/modules/internal/NetworkAtomics.chpl @@ -142,7 +142,7 @@ module NetworkAtomics { } - pragma "last resort" + pragma "do not resolve unless called" operator :(rhs: bool, type t:RAtomicBool) { var lhs: RAtomicBool = rhs; // use init= return lhs; diff --git a/modules/standard/Regex.chpl b/modules/standard/Regex.chpl index 9da94dd70b48..8c621ae23ebf 100644 --- a/modules/standard/Regex.chpl +++ b/modules/standard/Regex.chpl @@ -439,7 +439,7 @@ record regexMatch { var numBytes:int; } -pragma "last resort" +pragma "do not resolve unless called" @chpldoc.nodoc proc reMatch type { diff --git a/modules/standard/Time.chpl b/modules/standard/Time.chpl index 2193f0672832..a0bdb583f3a2 100644 --- a/modules/standard/Time.chpl +++ b/modules/standard/Time.chpl @@ -148,7 +148,7 @@ module Time { /* Specifies the day of the week */ @deprecated(notes="enum 'day' is deprecated. Please use :enum:`dayOfWeek` instead") enum day { sunday=0, monday, tuesday, wednesday, thursday, friday, saturday } - pragma "last resort" + pragma "do not resolve unless called" @chpldoc.nodoc proc DayOfWeek { compilerError("'DayOfWeek' was renamed. Please use 'dayOfWeek' instead"); @@ -164,7 +164,7 @@ module Time { Saturday = 6, Sunday = 7 } - pragma "last resort" + pragma "do not resolve unless called" @chpldoc.nodoc proc ISODayOfWeek { compilerError("'ISODayOfWeek was renamed. Please use 'isoDayOfWeek' instead"); From 2c3d0d24014c0a5df5c0620e2f115425794dc865 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 7 Dec 2023 10:35:27 -0500 Subject: [PATCH 07/14] Remove deprecated localesForRegion function --- Signed-off-by: Michael Ferguson --- modules/standard/IO.chpl | 52 --------------------- test/deprecated/IO/localesForRegion.chpl | 7 --- test/deprecated/IO/localesForRegion.good | 10 ---- test/deprecated/IO/localesForRegion.prediff | 19 -------- test/deprecated/IO/localesForRegion.skipif | 1 - 5 files changed, 89 deletions(-) delete mode 100644 test/deprecated/IO/localesForRegion.chpl delete mode 100644 test/deprecated/IO/localesForRegion.good delete mode 100755 test/deprecated/IO/localesForRegion.prediff delete mode 100644 test/deprecated/IO/localesForRegion.skipif diff --git a/modules/standard/IO.chpl b/modules/standard/IO.chpl index ceb64c2dd97b..49efa8eddf0a 100644 --- a/modules/standard/IO.chpl +++ b/modules/standard/IO.chpl @@ -9936,58 +9936,6 @@ proc file.fstype():int throws { return t:int; } -/* - Returns the 'best' locale to run something working with the region - of the file in start..end-1. - - This *must* return the same result when called from different locales. - Returns a domain of locales that are "best" for the given region. If no - locales are "best" we return a domain containing all locales. - - :arg start: the file offset (starting from 0) where the region begins - :arg end: the file offset just after the region - :returns: a set of locales that are best for working with this region - :rtype: domain(locale) - */ -pragma "last resort" -@deprecated(notes="file.localesForRegion is deprecated") -proc file.localesForRegion(start:int(64), end:int(64)) { - - proc findloc(loc:string, locs:c_ptr(c_ptrConst(c_char)), end:int) { - for i in 0..end-1 { - if (loc == locs[i]) then - return true; - } - return false; - } - - var ret: domain(locale); - on this._home { - var err:errorCode; - var locs: c_ptr(c_ptrConst(c_char)); - var num_hosts:c_int; - err = qio_locales_for_region(this._file_internal, start, end, c_ptrTo(locs), num_hosts); - // looping over Locales enforces the ordering constraint on the locales. - for loc in Locales { - if (findloc(loc.name, locs, num_hosts:int)) then - ret += loc; - } - - // We allocated memory in the runtime for this, so free it now - if num_hosts != 0 { - for i in 0..num_hosts-1 do - deallocate(locs[i]); - deallocate(locs); - } - - // We found no "good" locales. So any locale is just as good as the next - if ret.size == 0 then - for loc in Locales do - ret += loc; - } - return ret; -} - /* diff --git a/test/deprecated/IO/localesForRegion.chpl b/test/deprecated/IO/localesForRegion.chpl deleted file mode 100644 index 3875c83a876c..000000000000 --- a/test/deprecated/IO/localesForRegion.chpl +++ /dev/null @@ -1,7 +0,0 @@ -use IO; - -const f = open("test.txt", ioMode.r); - -const locales = f.localesForRegion(0, 10); - -f.close(); diff --git a/test/deprecated/IO/localesForRegion.good b/test/deprecated/IO/localesForRegion.good deleted file mode 100644 index 8e3dacb5f8ee..000000000000 --- a/test/deprecated/IO/localesForRegion.good +++ /dev/null @@ -1,10 +0,0 @@ -localesForRegion.chpl:5: warning: file.localesForRegion is deprecated -$CHPL_HOME/modules/standard/IO.chpl:nnnn: In method 'localesForRegion': -$CHPL_HOME/modules/standard/IO.chpl:nnnn: error: unresolved call '==(string, c_ptrConst(int(8)))' -$CHPL_HOME/modules/standard/CTypes.chpl:nnnn: note: this candidate did not match: ==(a: c_ptr(void), b: c_ptr(void)) -$CHPL_HOME/modules/standard/IO.chpl:nnnn: note: because actual argument #1 with type 'string' -$CHPL_HOME/modules/standard/CTypes.chpl:nnnn: note: is passed to formal 'a: c_ptr(void)' -$CHPL_HOME/modules/standard/IO.chpl:nnnn: note: other candidates are: -$CHPL_HOME/modules/standard/CTypes.chpl:nnnn: note: ==(a: c_ptr, b: _nilType) -$CHPL_HOME/modules/standard/CTypes.chpl:nnnn: note: ==(a: _nilType, b: c_ptr) -note: and xxx other candidates, use --print-all-candidates to see them diff --git a/test/deprecated/IO/localesForRegion.prediff b/test/deprecated/IO/localesForRegion.prediff deleted file mode 100755 index cbabc7c4edea..000000000000 --- a/test/deprecated/IO/localesForRegion.prediff +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# -# Remove test sensitivity to line numbers in module files, and number of -# candidate procedures for resolution. - -tmpfile=$2 - -tmptmp=`mktemp "tmp.XXXXXX"` - -# line numbers in module files -regex='\|CHPL_HOME/modules|s/:[0-9:]*:/:nnnn:/' -sed -e "$regex" $tmpfile > $tmptmp -mv $tmptmp $tmpfile - -# number of candidates -regex='s/and [0-9][0-9]* other candidates/and xxx other candidates/' -sed -e "$regex" $tmpfile > $tmptmp - -mv $tmptmp $tmpfile diff --git a/test/deprecated/IO/localesForRegion.skipif b/test/deprecated/IO/localesForRegion.skipif deleted file mode 100644 index 9efb75227841..000000000000 --- a/test/deprecated/IO/localesForRegion.skipif +++ /dev/null @@ -1 +0,0 @@ -CHPL_TARGET_ARCH == aarch64 From bee6e45a912438165d331756754468672230f6d7 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Thu, 7 Dec 2023 11:12:32 -0500 Subject: [PATCH 08/14] Add flag to chpl-completion.bash --- Signed-off-by: Michael Ferguson --- util/chpl-completion.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/chpl-completion.bash b/util/chpl-completion.bash index c8b6c753ad44..f1b8c0303436 100644 --- a/util/chpl-completion.bash +++ b/util/chpl-completion.bash @@ -271,6 +271,7 @@ _chpl () --no-report-auto-aggregation \ --no-report-auto-local-access \ --no-report-blocking \ +--no-resolve-concrete-fns \ --no-scalar-replacement \ --no-specialize \ --no-split-initialization \ @@ -352,6 +353,7 @@ _chpl () --report-promotion \ --report-scalar-replace \ --report-vectorized-loops \ +--resolve-concrete-fns \ --savec \ --scalar-replace-limit \ --scalar-replacement \ From 3ba330571851534500e6c453932dd590eee5a5d3 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 11 Dec 2023 14:51:26 -0500 Subject: [PATCH 09/14] Clean up comments --- Signed-off-by: Michael Ferguson --- compiler/resolution/functionResolution.cpp | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/compiler/resolution/functionResolution.cpp b/compiler/resolution/functionResolution.cpp index 6907a6b6f54a..d943784a7c4f 100644 --- a/compiler/resolution/functionResolution.cpp +++ b/compiler/resolution/functionResolution.cpp @@ -11680,44 +11680,26 @@ static void resolveExportsEtc() { !fn->hasFlag(FLAG_EXTERN) && !fn->hasFlag(FLAG_ON) && !fn->hasFlag(FLAG_COBEGIN_OR_COFORALL) && - // !fn->hasFlag(FLAG_COMPILER_NESTED_FUNCTION) !fn->hasFlag(FLAG_COMPILER_GENERATED) && // either this is not a method, or at least it's not a method // on a generic type (fn->_this == NULL || !at || !at->isGeneric()) && - // TODO: What chpl_ functions are not marked compiler-generated? + // for now, ignore chpl_ functions (strncmp(fn->name, "chpl_", 5) != 0) && fn->defPoint && // Nested functions are tricky because their resolution may depend // on the resolution of the outer function in which they are located; // i.e., they may be generic w.r.t. outer-scoped variables, yet not - // marked with FLAG_GENERIC. How to distinguish simple nested - // concrete functions which could be resolved from those that can't? + // marked with FLAG_GENERIC. For now, rule out all nested functions. !isFnSymbol(fn->defPoint->parentSymbol) && // fn is not nested fn->defPoint->getModule() && !isGenericFn(fn) - /* && fn->defPoint->getModule()->modTag == MOD_USER*/ ) { SET_LINENO(fn); - /*if (developer) { - printf("---\n"); - printf("%s (%s:%d)\n", fn->name, fn->astloc.filename(), fn->astloc.lineno()); - printf("---\n"); - viewFlags(fn->id); - printf("---\n\n"); - }*/ - - // disable resolveExprMaybeIssueError - //squashCompilerMessages = true; if (evaluateWhereClause(fn)) { resolveSignatureAndFunction(fn); - /* - fn->removeFlag(FLAG_RESOLVED); // though we resolved it, pretend we - // didn't so it'll be dead-code eliminated - */ } - //squashCompilerMessages = false; } } } From fed886ac711b02e7238decd487e725883a5becff Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Mon, 11 Dec 2023 15:56:12 -0500 Subject: [PATCH 10/14] Add a test of --resolve-concrete-fns --- Signed-off-by: Michael Ferguson --- test/compflags/ferguson/resolve-concrete-fns.chpl | 4 ++++ test/compflags/ferguson/resolve-concrete-fns.compopts | 1 + test/compflags/ferguson/resolve-concrete-fns.good | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 test/compflags/ferguson/resolve-concrete-fns.chpl create mode 100644 test/compflags/ferguson/resolve-concrete-fns.compopts create mode 100644 test/compflags/ferguson/resolve-concrete-fns.good diff --git a/test/compflags/ferguson/resolve-concrete-fns.chpl b/test/compflags/ferguson/resolve-concrete-fns.chpl new file mode 100644 index 000000000000..afbdc2ec4e58 --- /dev/null +++ b/test/compflags/ferguson/resolve-concrete-fns.chpl @@ -0,0 +1,4 @@ +proc foo() { + var x: int = "hello"; + return 1; +} diff --git a/test/compflags/ferguson/resolve-concrete-fns.compopts b/test/compflags/ferguson/resolve-concrete-fns.compopts new file mode 100644 index 000000000000..5521c93df3bb --- /dev/null +++ b/test/compflags/ferguson/resolve-concrete-fns.compopts @@ -0,0 +1 @@ +--resolve-concrete-fns diff --git a/test/compflags/ferguson/resolve-concrete-fns.good b/test/compflags/ferguson/resolve-concrete-fns.good new file mode 100644 index 000000000000..23036279bb12 --- /dev/null +++ b/test/compflags/ferguson/resolve-concrete-fns.good @@ -0,0 +1,2 @@ +resolve-concrete-fns.chpl:1: In function 'foo': +resolve-concrete-fns.chpl:2: error: cannot initialize 'x' of type 'int(64)' from '"hello"' From fe8fec377fc68ad12a35954831f59320abb900cf Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 12 Dec 2023 10:14:24 -0500 Subject: [PATCH 11/14] Add a test of timeDelta comparison functions --- Signed-off-by: Michael Ferguson --- .../standard/Time/dateTime/timeDeltaOps.chpl | 42 +++++++++++++++++++ .../standard/Time/dateTime/timeDeltaOps.good | 1 + 2 files changed, 43 insertions(+) create mode 100644 test/library/standard/Time/dateTime/timeDeltaOps.chpl create mode 100644 test/library/standard/Time/dateTime/timeDeltaOps.good diff --git a/test/library/standard/Time/dateTime/timeDeltaOps.chpl b/test/library/standard/Time/dateTime/timeDeltaOps.chpl new file mode 100644 index 000000000000..b9ef9a38bf7a --- /dev/null +++ b/test/library/standard/Time/dateTime/timeDeltaOps.chpl @@ -0,0 +1,42 @@ +use Time; + +{ + // check all the comparison operators + var x = new timeDelta(seconds=30); + var y = new timeDelta(seconds=40); + + assert(x < y); + assert(x <= y); + assert(!(x == y)); + assert(x != y); + assert(!(x >= y)); + assert(!(x > y)); + + assert(!(x < x)); + assert(x <= x); + assert(x == x); + assert(!(x != x)); + assert(x >= x); + assert(!(x > x)); + + assert(!(y < x)); + assert(!(y <= x)); + assert(!(y == x)); + assert(y != x); + assert(y >= x); + assert(y > x); +} + +{ + // also check comparison involving multiple units + var a = new timeDelta(days=3, seconds=4, microseconds=5); + var b = new timeDelta(days=2, seconds=20, microseconds=200); + assert(a > b); + assert(b < a); +} + +{ + // also try cast to string + var z = new timeDelta(days=400, seconds=8000, microseconds=30000); + writeln(z:string); +} diff --git a/test/library/standard/Time/dateTime/timeDeltaOps.good b/test/library/standard/Time/dateTime/timeDeltaOps.good new file mode 100644 index 000000000000..3d5d670fec89 --- /dev/null +++ b/test/library/standard/Time/dateTime/timeDeltaOps.good @@ -0,0 +1 @@ +400 days, 2:13:20.030000 From d8853944eeb723d735e0d8f4b88ee4d2bb80c469 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 12 Dec 2023 10:21:35 -0500 Subject: [PATCH 12/14] Also test .clear in Timer deprecation test --- Signed-off-by: Michael Ferguson --- test/deprecated/Time/useTimer.chpl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/deprecated/Time/useTimer.chpl b/test/deprecated/Time/useTimer.chpl index 2e678047826c..2723000fc59f 100644 --- a/test/deprecated/Time/useTimer.chpl +++ b/test/deprecated/Time/useTimer.chpl @@ -4,3 +4,4 @@ var t: Timer; t.start(); t.stop(); +t.clear(); From 402e6f20d27683bb3f7df632ed306a1521d99ade Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 12 Dec 2023 10:27:50 -0500 Subject: [PATCH 13/14] Test that file.filePlugin compiles --- Signed-off-by: Michael Ferguson --- test/io/ferguson/filePlugin.chpl | 6 ++++++ test/io/ferguson/filePlugin.good | 0 2 files changed, 6 insertions(+) create mode 100644 test/io/ferguson/filePlugin.chpl create mode 100644 test/io/ferguson/filePlugin.good diff --git a/test/io/ferguson/filePlugin.chpl b/test/io/ferguson/filePlugin.chpl new file mode 100644 index 000000000000..0db138661f35 --- /dev/null +++ b/test/io/ferguson/filePlugin.chpl @@ -0,0 +1,6 @@ +// Just make sure that file.filePlugin compiles +proc main() { + use IO; + var f = openTempFile(); + var x = f.filePlugin(); +} diff --git a/test/io/ferguson/filePlugin.good b/test/io/ferguson/filePlugin.good new file mode 100644 index 000000000000..e69de29bb2d1 From 5040e43f19d492dbe566b142d598068431ca28f3 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Tue, 12 Dec 2023 10:34:50 -0500 Subject: [PATCH 14/14] Add test of bytes.dedent --- Signed-off-by: Michael Ferguson --- test/types/bytes/dedent.chpl | 8 ++++++++ test/types/bytes/dedent.good | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 test/types/bytes/dedent.chpl create mode 100644 test/types/bytes/dedent.good diff --git a/test/types/bytes/dedent.chpl b/test/types/bytes/dedent.chpl new file mode 100644 index 000000000000..94eee762450f --- /dev/null +++ b/test/types/bytes/dedent.chpl @@ -0,0 +1,8 @@ +// mainly, just check that bytes.dedent compiles + +var x:bytes = b""" + hello + there + """; +var y = x.dedent(ignoreFirst=true); +writeln(y.decode()); diff --git a/test/types/bytes/dedent.good b/test/types/bytes/dedent.good new file mode 100644 index 000000000000..d487197000ff --- /dev/null +++ b/test/types/bytes/dedent.good @@ -0,0 +1,4 @@ + +hello +there +