Successfully identified regression in *llvm* in CI configuration tcwg_bmk_llvm_apm/llvm-master-aarch64-spec2k6-Oz_LTO. So far, this commit has regressed CI configurations: - tcwg_bmk_llvm_apm/llvm-master-aarch64-spec2k6-Oz_LTO
Culprit: <cut> commit 131b4620ee7847102479f399ce3e35a3c1cb5461 Author: Corentin Jabot corentin.jabot@gmail.com Date: Fri Aug 6 10:29:28 2021 -0400
Implement P1937 consteval in unevaluated contexts
In an unevaluated contexts, consteval functions should not be immediately evaluated. </cut>
Results regressed to (for first_bad == 131b4620ee7847102479f399ce3e35a3c1cb5461) # reset_artifacts: -10 # build_abe binutils: -9 # build_abe stage1 -- --set gcc_override_configure=--disable-libsanitizer: -8 # build_abe linux: -7 # build_abe glibc: -6 # build_abe stage2 -- --set gcc_override_configure=--disable-libsanitizer: -5 # build_llvm true: -3 # true: 0 # benchmark -- -Oz_LTO artifacts/build-131b4620ee7847102479f399ce3e35a3c1cb5461/results_id: 1 # 470.lbm,lbm_base.default regressed by 104
from (for last_good == 3c8e94bc20e5829ab5167d21d242b6b624dd934e) # reset_artifacts: -10 # build_abe binutils: -9 # build_abe stage1 -- --set gcc_override_configure=--disable-libsanitizer: -8 # build_abe linux: -7 # build_abe glibc: -6 # build_abe stage2 -- --set gcc_override_configure=--disable-libsanitizer: -5 # build_llvm true: -3 # true: 0 # benchmark -- -Oz_LTO artifacts/build-3c8e94bc20e5829ab5167d21d242b6b624dd934e/results_id: 1
Artifacts of last_good build: https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-master-a... Results ID of last_good: apm_64/tcwg_bmk_llvm_apm/bisect-llvm-master-aarch64-spec2k6-Oz_LTO/4879 Artifacts of first_bad build: https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-master-a... Results ID of first_bad: apm_64/tcwg_bmk_llvm_apm/bisect-llvm-master-aarch64-spec2k6-Oz_LTO/4868 Build top page/logs: https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-master-a...
Configuration details:
Reproduce builds: <cut> mkdir investigate-llvm-131b4620ee7847102479f399ce3e35a3c1cb5461 cd investigate-llvm-131b4620ee7847102479f399ce3e35a3c1cb5461
git clone https://git.linaro.org/toolchain/jenkins-scripts
mkdir -p artifacts/manifests curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-master-a... --fail curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-master-a... --fail curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-master-a... --fail chmod +x artifacts/test.sh
# Reproduce the baseline build (build all pre-requisites) ./jenkins-scripts/tcwg_bmk-build.sh @@ artifacts/manifests/build-baseline.sh
# Save baseline build state (which is then restored in artifacts/test.sh) mkdir -p ./bisect rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /llvm/ ./ ./bisect/baseline/
cd llvm
# Reproduce first_bad build git checkout --detach 131b4620ee7847102479f399ce3e35a3c1cb5461 ../artifacts/test.sh
# Reproduce last_good build git checkout --detach 3c8e94bc20e5829ab5167d21d242b6b624dd934e ../artifacts/test.sh
cd .. </cut>
History of pending regressions and results: https://git.linaro.org/toolchain/ci/base-artifacts.git/log/?h=linaro-local/c...
Artifacts: https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-master-a... Build log: https://ci.linaro.org/job/tcwg_bmk_ci_llvm-bisect-tcwg_bmk_apm-llvm-master-a...
Full commit (up to 1000 lines): <cut> commit 131b4620ee7847102479f399ce3e35a3c1cb5461 Author: Corentin Jabot corentin.jabot@gmail.com Date: Fri Aug 6 10:29:28 2021 -0400
Implement P1937 consteval in unevaluated contexts
In an unevaluated contexts, consteval functions should not be immediately evaluated. --- clang/lib/Sema/SemaExpr.cpp | 7 ++--- clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp | 33 +++++++++++++++++++++++- clang/test/SemaCXX/cxx2a-consteval.cpp | 18 +++++++++++++ clang/www/cxx_status.html | 3 ++- 4 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d316687c4cd8..8ef4a9d96320 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -16641,7 +16641,8 @@ void Sema::CheckUnusedVolatileAssignment(Expr *E) { }
ExprResult Sema::CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl) { - if (!E.isUsable() || !Decl || !Decl->isConsteval() || isConstantEvaluated() || + if (isUnevaluatedContext() || !E.isUsable() || !Decl || + !Decl->isConsteval() || isConstantEvaluated() || RebuildingImmediateInvocation) return E;
@@ -18758,8 +18759,8 @@ void Sema::MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base) { OdrUse = false;
if (auto *FD = dyn_cast<FunctionDecl>(E->getDecl())) - if (!isConstantEvaluated() && FD->isConsteval() && - !RebuildingImmediateInvocation) + if (!isUnevaluatedContext() && !isConstantEvaluated() && + FD->isConsteval() && !RebuildingImmediateInvocation) ExprEvalContexts.back().ReferenceToConsteval.insert(E); MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E, OdrUse, RefsMinusAssignments); diff --git a/clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp b/clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp index 55debe3ca731..fafcd127feec 100644 --- a/clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp +++ b/clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
// C++ [basic.def.odr]p2: // An expression is potentially evaluated unless it [...] is the @@ -16,7 +17,7 @@ struct Poly {
struct NonPoly { };
-template<typename T, typename Result = T> +template<typename T, typename Result = T> struct X { Result f(T t) { return t + t; } // expected-error{{invalid operands}}
@@ -34,3 +35,33 @@ void test(X<Poly> xp, X<Poly, Poly&> xpr, X<NonPoly> xnp, X<NonPoly, NonPoly&> x // Triggers an error (as it should); xpr.g(Poly()); // expected-note{{instantiation of member function}} } + +#if __cplusplus >= 202002L + +namespace unevaluated { + +struct S { + void f(); +}; +struct T { + virtual void f(); +}; + +consteval S *null_s() { return nullptr; } +consteval S *make_s() { return new S; } +consteval T *null_t() { return nullptr; } +consteval T *make_t() { return new T; } // #alloc + +void func() { + (void)typeid(*null_s()); + (void)typeid(*make_s()); + (void)typeid(*null_t()); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}} + (void)typeid(*make_t()); // expected-error {{call to consteval function 'unevaluated::make_t' is not a constant expression}} \ + expected-note {{pointer to heap-allocated object is not a constant expression}} \ + expected-note@#alloc {{heap allocation performed here}} \ + expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}} +} + +} // namespace unevaluated + +#endif diff --git a/clang/test/SemaCXX/cxx2a-consteval.cpp b/clang/test/SemaCXX/cxx2a-consteval.cpp index ecf8c1e0f5bd..04c8898aa5ba 100644 --- a/clang/test/SemaCXX/cxx2a-consteval.cpp +++ b/clang/test/SemaCXX/cxx2a-consteval.cpp @@ -594,3 +594,21 @@ void test() { }
} // namespace special_ctor + +namespace unevaluated { + +template <typename T, typename U> struct is_same { static const bool value = false; }; +template <typename T> struct is_same<T, T> { static const bool value = true; }; + +long f(); // expected-note {{declared here}} +auto consteval g(auto a) { + return a; +} + +auto e = g(f()); // expected-error {{is not a constant expression}} + // expected-note@-1 {{non-constexpr function 'f' cannot be used in a constant expression}} + +using T = decltype(g(f())); +static_assert(is_same<long, T>::value); + +} // namespace unevaluated diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html index 60ce69db9922..3cbee7026c5c 100755 --- a/clang/www/cxx_status.html +++ b/clang/www/cxx_status.html @@ -1105,10 +1105,11 @@ code. This issue is expected to be rectified soon. <tr> <td rowspan=2>Immediate functions (<tt>consteval</tt>)</td> <td><a href="https://wg21.link/p1073r3">P1073R3</a></td> - <td rowspan=2 class="none" align="center">No</td> + <td class="partial" align="center">Partial</td> </tr> <tr> <!-- from Prague --> <td><a href="https://wg21.link/p1937r2">P1937R2</a></td> + <td class="unreleased" align="center">Clang 14</td> </tr> <tr> <td><tt>std::is_constant_evaluated</tt></td> </cut>
linaro-toolchain@lists.linaro.org