[clang] [clang-tools-extra] [llvm] [Clang] Add some CodeGen tests for CWG 2xx issues (PR #80823)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 06:21:31 PST 2024


================
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O0 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -O3 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
----------------
AaronBallman wrote:

CC @rjmccall and @efriedma-quic as Clang codegen code owners.

> Lowering AST to IR _is_ in purview of Clang, and we're responsible that this happens correctly (even if no single individual in this conversation is an expert in that part of Clang). I hope everyone here agrees that middle-end folks are not responsible for the correctness of our CodeGen from the C++ language semantics perspective.

There's a handshake involved between Clang and LLVM, so I don't think there's *one* responsible party for correctness here. Part of the correctness comes from Clang lowering to sensible LLVM IR, but we sometimes need LLVM folks to tell us what that sensible IR is or to provide different tools for us if existing IR doesn't suffice. However, in terms of DR testing, I think most of the effort should be expended on Clang's side of things.

> It wouldn't take too much time for a list of language modes to have the same length. Is cutting a number of language modes DR tests are run in also on the table because of arbitrary limits (as I see them at the moment)?

IMO, we want to find a happy middle ground between testing too much and testing too little. The issues with testing too little are obvious, but the issue from over-testing is that we waste significant resources for little benefit. Everyone runs the test suite (precommit CI, postcommit CI, and developers on their local machines) so if we increase the test time significantly without discernible benefit, that can lead to death-by-a-thousand-cuts problems.

FWIW, I wasn't insisting on code coverage measurements. I was more pointing out that I think we should not add the extra RUN lines for -O3 while speculating that it increases test coverage. We should have some reason to believe it increases test coverage, and we might want to consider splitting those tests out into their own file so we don't run 100 DR tests in two optimization modes for every standard version we're testing.

https://github.com/llvm/llvm-project/pull/80823


More information about the cfe-commits mailing list