[PATCH] D101968: Fix bad mangling of for a closure in the initializer of a variable at global namespace scope.
This revision was automatically updated to reflect the committed changes. Closed by commit rG5bb7e81c64bd: Fix bad mangling of data-member-prefix for a closure in the initializer of a… (authored by rsmith). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101968/new/ https://reviews.llvm.org/D101968 Files: clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Basic/LangOptions.h clang/lib/AST/ItaniumMangle.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGenCXX/clang-abi-compat.cpp clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp Index: clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp === --- clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp +++ clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp @@ -38,7 +38,7 @@ inline auto pack = [](T (&...)[N]) {}; int arr1[] = {1}; int arr2[] = {1, 2}; -// CHECK: @_ZNK4packMUlTpTyTpTnT_DpRAT0__S_E_clIJiiEJLi1ELi2DaS2_( +// CHECK: @_ZNK4packMUlTpTyTpTnT_DpRAT0__S0_E_clIJiiEJLi1ELi2DaS3_( void use_pack() { pack(arr1, arr2); } inline void collision() { Index: clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp === --- clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp +++ clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp @@ -22,6 +22,13 @@ L l; } +// It's important that this is not in a namespace; we're testing the mangling +// of lambdas in top-level inline variables here. +inline auto lambda_in_inline_variable = [] {}; +template struct Wrap {}; +// CHECK-LABEL: define {{.*}} @_Z30test_lambda_in_inline_variable4WrapIN25lambda_in_inline_variableMUlvE_EE +void test_lambda_in_inline_variable(Wrap) {} + namespace lambdas_in_NSDMIs_template_class { template struct L { Index: clang/test/CodeGenCXX/clang-abi-compat.cpp === --- clang/test/CodeGenCXX/clang-abi-compat.cpp +++ clang/test/CodeGenCXX/clang-abi-compat.cpp @@ -13,11 +13,13 @@ // RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \ // RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s // RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \ -// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20 %s +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20 %s +// RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=12 %s -emit-llvm -o - \ +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20 %s // RUN: %clang_cc1 -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - -Wno-c++11-extensions \ // RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12 %s // RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - \ -// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20 %s +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20 %s typedef __attribute__((vector_size(8))) long long v1xi64; void clang39(v1xi64) {} @@ -136,3 +138,12 @@ void test9(void) __attribute__((enable_if(1, ""))) {} } + +#if __cplusplus >= 202002L +// PRE13-CXX20: @_Z15observe_lambdasI17inline_var_lambdaMUlvE_17inline_var_lambdaMUlvE0_PiS2_S0_S1_EiT_T0_T1_T2_ +// V13-CXX20: @_Z15observe_lambdasIN17inline_var_lambdaMUlvE_ENS0_UlvE0_EPiS3_S1_S2_EiT_T0_T1_T2_ +template +int observe_lambdas(T, U, V, W) { return 0; } +inline auto inline_var_lambda = observe_lambdas([]{}, []{}, (int*)0, (int*)0); +int use_inline_var_lambda() { return inline_var_lambda; } +#endif Index: clang/lib/Frontend/CompilerInvocation.cpp === --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -3509,6 +3509,8 @@ GenerateArg(Args, OPT_fclang_abi_compat_EQ, "9.0", SA); else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver11) GenerateArg(Args, OPT_fclang_abi_compat_EQ, "11.0", SA); + else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver12) +GenerateArg(Args, OPT_fclang_abi_compat_EQ, "12.0", SA); if (Opts.getSignReturnAddressScope() == LangOptions::SignReturnAddressScopeKind::All) @@ -3970,6 +3972,8 @@ Opts.setClangABICompat(LangOptions::ClangABI::Ver9); else if (Major <= 11) Opts.setClangABICompat(LangOptions::ClangABI::Ver11); + else if (Major <= 12) +Opts.setClangABICompat(LangOptions::ClangABI::Ver12); } else if (Ver
[PATCH] D101968: Fix bad mangling of for a closure in the initializer of a variable at global namespace scope.
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101968/new/ https://reviews.llvm.org/D101968 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D101968: Fix bad mangling of for a closure in the initializer of a variable at global namespace scope.
rsmith reopened this revision. rsmith added a comment. (Reopening, earlier commit was accidental.) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101968/new/ https://reviews.llvm.org/D101968 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D101968: Fix bad mangling of for a closure in the initializer of a variable at global namespace scope.
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG697ac15a0fc7: Fix bad mangling of data-member-prefix for a closure in the initializer of a… (authored by rsmith). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D101968/new/ https://reviews.llvm.org/D101968 Files: clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Basic/LangOptions.h clang/lib/AST/ItaniumMangle.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGenCXX/clang-abi-compat.cpp clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp Index: clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp === --- clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp +++ clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp @@ -38,7 +38,7 @@ inline auto pack = [](T (&...)[N]) {}; int arr1[] = {1}; int arr2[] = {1, 2}; -// CHECK: @_ZNK4packMUlTpTyTpTnT_DpRAT0__S_E_clIJiiEJLi1ELi2DaS2_( +// CHECK: @_ZNK4packMUlTpTyTpTnT_DpRAT0__S0_E_clIJiiEJLi1ELi2DaS3_( void use_pack() { pack(arr1, arr2); } inline void collision() { Index: clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp === --- clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp +++ clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp @@ -22,6 +22,13 @@ L l; } +// It's important that this is not in a namespace; we're testing the mangling +// of lambdas in top-level inline variables here. +inline auto lambda_in_inline_variable = [] {}; +template struct Wrap {}; +// CHECK-LABEL: define {{.*}} @_Z30test_lambda_in_inline_variable4WrapIN25lambda_in_inline_variableMUlvE_EE +void test_lambda_in_inline_variable(Wrap) {} + namespace lambdas_in_NSDMIs_template_class { template struct L { Index: clang/test/CodeGenCXX/clang-abi-compat.cpp === --- clang/test/CodeGenCXX/clang-abi-compat.cpp +++ clang/test/CodeGenCXX/clang-abi-compat.cpp @@ -13,11 +13,13 @@ // RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \ // RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s // RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \ -// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20 %s +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20 %s +// RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=12 %s -emit-llvm -o - \ +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20 %s // RUN: %clang_cc1 -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - -Wno-c++11-extensions \ // RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12 %s // RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - \ -// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20 %s +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20 %s typedef __attribute__((vector_size(8))) long long v1xi64; void clang39(v1xi64) {} @@ -136,3 +138,12 @@ void test9(void) __attribute__((enable_if(1, ""))) {} } + +#if __cplusplus >= 202002L +// PRE13-CXX20: @_Z15observe_lambdasI17inline_var_lambdaMUlvE_17inline_var_lambdaMUlvE0_PiS2_S0_S1_EiT_T0_T1_T2_ +// V13-CXX20: @_Z15observe_lambdasIN17inline_var_lambdaMUlvE_ENS0_UlvE0_EPiS3_S1_S2_EiT_T0_T1_T2_ +template +int observe_lambdas(T, U, V, W) { return 0; } +inline auto inline_var_lambda = observe_lambdas([]{}, []{}, (int*)0, (int*)0); +int use_inline_var_lambda() { return inline_var_lambda; } +#endif Index: clang/lib/Frontend/CompilerInvocation.cpp === --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -3509,6 +3509,8 @@ GenerateArg(Args, OPT_fclang_abi_compat_EQ, "9.0", SA); else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver11) GenerateArg(Args, OPT_fclang_abi_compat_EQ, "11.0", SA); + else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver12) +GenerateArg(Args, OPT_fclang_abi_compat_EQ, "12.0", SA); if (Opts.getSignReturnAddressScope() == LangOptions::SignReturnAddressScopeKind::All) @@ -3970,6 +3972,8 @@ Opts.setClangABICompat(LangOptions::ClangABI::Ver9); else if (Major <= 11)
[PATCH] D101968: Fix bad mangling of for a closure in the initializer of a variable at global namespace scope.
rsmith created this revision. rsmith added a reviewer: rjmccall. Herald added a subscriber: dexonsmith. rsmith requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. This implements the direction proposed in https://github.com/itanium-cxx-abi/cxx-abi/pull/126. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D101968 Files: clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Basic/LangOptions.h clang/lib/AST/ItaniumMangle.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGenCXX/clang-abi-compat.cpp clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp Index: clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp === --- clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp +++ clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp @@ -38,7 +38,7 @@ inline auto pack = [](T (&...)[N]) {}; int arr1[] = {1}; int arr2[] = {1, 2}; -// CHECK: @_ZNK4packMUlTpTyTpTnT_DpRAT0__S_E_clIJiiEJLi1ELi2DaS2_( +// CHECK: @_ZNK4packMUlTpTyTpTnT_DpRAT0__S0_E_clIJiiEJLi1ELi2DaS3_( void use_pack() { pack(arr1, arr2); } inline void collision() { Index: clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp === --- clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp +++ clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp @@ -22,6 +22,13 @@ L l; } +// It's important that this is not in a namespace; we're testing the mangling +// of lambdas in top-level inline variables here. +inline auto lambda_in_inline_variable = [] {}; +template struct Wrap {}; +// CHECK-LABEL: define {{.*}} @_Z30test_lambda_in_inline_variable4WrapIN25lambda_in_inline_variableMUlvE_EE +void test_lambda_in_inline_variable(Wrap) {} + namespace lambdas_in_NSDMIs_template_class { template struct L { Index: clang/test/CodeGenCXX/clang-abi-compat.cpp === --- clang/test/CodeGenCXX/clang-abi-compat.cpp +++ clang/test/CodeGenCXX/clang-abi-compat.cpp @@ -13,11 +13,13 @@ // RUN: %clang_cc1 -std=c++17 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \ // RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17 %s // RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=11 %s -emit-llvm -o - \ -// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20 %s +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,PRE12,PRE12-CXX17,PRE12-CXX20,PRE13-CXX20 %s +// RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=12 %s -emit-llvm -o - \ +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,PRE13-CXX20 %s // RUN: %clang_cc1 -std=c++98 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - -Wno-c++11-extensions \ // RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12 %s // RUN: %clang_cc1 -std=c++20 -triple x86_64-linux-gnu -fenable-matrix -fclang-abi-compat=latest %s -emit-llvm -o - \ -// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20 %s +// RUN: | FileCheck --check-prefixes=CHECK,V39,V5,V12,V12-CXX17,V12-CXX20,V13-CXX20 %s typedef __attribute__((vector_size(8))) long long v1xi64; void clang39(v1xi64) {} @@ -136,3 +138,12 @@ void test9(void) __attribute__((enable_if(1, ""))) {} } + +#if __cplusplus >= 202002L +// PRE13-CXX20: @_Z15observe_lambdasI17inline_var_lambdaMUlvE_17inline_var_lambdaMUlvE0_PiS2_S0_S1_EiT_T0_T1_T2_ +// V13-CXX20: @_Z15observe_lambdasIN17inline_var_lambdaMUlvE_ENS0_UlvE0_EPiS3_S1_S2_EiT_T0_T1_T2_ +template +int observe_lambdas(T, U, V, W) { return 0; } +inline auto inline_var_lambda = observe_lambdas([]{}, []{}, (int*)0, (int*)0); +int use_inline_var_lambda() { return inline_var_lambda; } +#endif Index: clang/lib/Frontend/CompilerInvocation.cpp === --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -3501,6 +3501,8 @@ GenerateArg(Args, OPT_fclang_abi_compat_EQ, "9.0", SA); else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver11) GenerateArg(Args, OPT_fclang_abi_compat_EQ, "11.0", SA); + else if (Opts.getClangABICompat() == LangOptions::ClangABI::Ver12) +GenerateArg(Args, OPT_fclang_abi_compat_EQ, "12.0", SA); if (Opts.getSignReturnAddressScope() == LangOptions::SignReturnAddressScopeKind::All) @@ -3962,6 +3964,8 @@ Opts.setClangABICompat(LangOptions::ClangABI::Ver9); else if (Major <= 11) Opts.setClangABICompat(LangOptions::ClangABI::Ver11); + else if (Major <= 12) +