[clang] [Clang] Add __datasizeof (PR #67805)

2023-11-13 Thread via cfe-commits
https://github.com/philnik777 closed https://github.com/llvm/llvm-project/pull/67805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __datasizeof (PR #67805)

2023-11-13 Thread via cfe-commits
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/67805 >From 71742243aeab0e51238eaa6df9487a0c37e97087 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 29 Sep 2023 15:45:56 +0200 Subject: [PATCH] [Clang] Add __datasizeof --- clang/docs/LanguageExtensions

[clang] [Clang] Add __datasizeof (PR #67805)

2023-11-01 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM with the new codegen test, thank you! https://github.com/llvm/llvm-project/pull/67805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-31 Thread via cfe-commits
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/67805 >From 8010f6178df82305b5790610f0114ddfb3c0a5f8 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 29 Sep 2023 15:45:56 +0200 Subject: [PATCH] [Clang] Add __datasizeof --- clang/docs/LanguageExtensions

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-31 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple x86_64 -emit-llvm %s -o - | FileCheck %s + +// CHECK: define dso_local noundef i32 @_Z4testi(i32 noundef %i) #0 { +// CHECK-NEXT: entry: +// CHECK-NEXT: %i.addr = alloca i32, align 4 +// CHECK-NEXT: store i32 %i, ptr %i.addr, a

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-27 Thread via cfe-commits
philnik777 wrote: @AaronBallman This did indeed catch a bug. Also, I think there was something about how codegen tests should be written, but I don't remember exactly anymore. Could you take a look at the test? https://github.com/llvm/llvm-project/pull/67805 ___

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-27 Thread via cfe-commits
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/67805 >From f384bc5feab5b2a0ae71d4c96d123c3fe0d13a73 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 29 Sep 2023 15:45:56 +0200 Subject: [PATCH] [Clang] Add __datasizeof --- clang/docs/LanguageExtensions

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-25 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM assuming the requested codegen tests don't bring up any surprises for you. https://github.com/llvm/llvm-project/pull/67805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-25 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-gnu -verify %s AaronBallman wrote: Yeah, a codegen test would make sense (just to show that we actually do emit code for that monstrosity). https://github.com/llvm/llvm-project/pull/67805 _

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-25 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/67805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-21 Thread via cfe-commits
@@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-gnu -verify %s philnik777 wrote: It looks like the VLA test can't be constant evaluated. Should I add a CodeGen test for that? https://github.com/llvm/llvm-project/pull/67805 __

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-14 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 5e1c2bf3e6fca35ee0445b2a81d47e8576024186 e6770ca7735285e1e669032a5a99b07709957803 --

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-14 Thread via cfe-commits
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/67805 >From e6770ca7735285e1e669032a5a99b07709957803 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 29 Sep 2023 15:45:56 +0200 Subject: [PATCH] [Clang] Add __datasizeof --- clang/docs/LanguageExtensions

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits
@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack, FEATURE(tls, PP.getTargetInfo().isTLSSupported()) FEATURE(underlying_type, LangOpts.CPlusPlus) FEATURE(experimental_library, LangOpts.ExperimentalLibrary) +FEATURE(datasizeof, LangOpts.CPlusPlus) philnik777 wrote:

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack, FEATURE(tls, PP.getTargetInfo().isTLSSupported()) FEATURE(underlying_type, LangOpts.CPlusPlus) FEATURE(experimental_library, LangOpts.ExperimentalLibrary) +FEATURE(datasizeof, LangOpts.CPlusPlus) AaronBallman wrote

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits
@@ -1016,4 +1016,7 @@ def warn_unpacked_field def warn_unaligned_access : Warning< "field %1 within %0 is less aligned than %2 and is usually due to %0 being " "packed, which can lead to unaligned accesses">, InGroup, DefaultIgnore; + +def err_cannot_mangle_expression : Er

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
@@ -1016,4 +1016,7 @@ def warn_unpacked_field def warn_unaligned_access : Warning< "field %1 within %0 is less aligned than %2 and is usually due to %0 being " "packed, which can lead to unaligned accesses">, InGroup, DefaultIgnore; + +def err_cannot_mangle_expression : Er

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits
@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack, FEATURE(tls, PP.getTargetInfo().isTLSSupported()) FEATURE(underlying_type, LangOpts.CPlusPlus) FEATURE(experimental_library, LangOpts.ExperimentalLibrary) +FEATURE(datasizeof, LangOpts.CPlusPlus) philnik777 wrote:

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack, FEATURE(tls, PP.getTargetInfo().isTLSSupported()) FEATURE(underlying_type, LangOpts.CPlusPlus) FEATURE(experimental_library, LangOpts.ExperimentalLibrary) +FEATURE(datasizeof, LangOpts.CPlusPlus) AaronBallman wrote

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits
@@ -1016,4 +1016,7 @@ def warn_unpacked_field def warn_unaligned_access : Warning< "field %1 within %0 is less aligned than %2 and is usually due to %0 being " "packed, which can lead to unaligned accesses">, InGroup, DefaultIgnore; + +def err_cannot_mangle_expression : Er

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread via cfe-commits
@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack, FEATURE(tls, PP.getTargetInfo().isTLSSupported()) FEATURE(underlying_type, LangOpts.CPlusPlus) FEATURE(experimental_library, LangOpts.ExperimentalLibrary) +FEATURE(datasizeof, LangOpts.CPlusPlus) philnik777 wrote:

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
@@ -1016,4 +1016,7 @@ def warn_unpacked_field def warn_unaligned_access : Warning< "field %1 within %0 is less aligned than %2 and is usually due to %0 being " "packed, which can lead to unaligned accesses">, InGroup, DefaultIgnore; + +def err_cannot_mangle_expression : Er

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-gnu -verify %s AaronBallman wrote: We should also show it's strange behavior with VLAs in C++: ``` int n = 12; __datasizeof(int[n++]); // Surprise, n is incremented, you're welcome ``` and wi

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: I think this is a reasonable minor extension, but it should come with documentation in `clang/docs/LanguageExtensions.rst` and release note in `clang/docs/ReleaseNotes.rst` before we're done. https://github.com/llvm/llvm-project/pull/67805 ___

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
@@ -5038,19 +5039,19 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, Out << 'a'; MangleAlignofSizeofArg(); break; +case UETT_DataSizeOf: { + Context.getDiags().Report(diag::err_cannot_mangle_expression) + << "__datasi

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/67805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-13 Thread Aaron Ballman via cfe-commits
@@ -236,6 +236,7 @@ FEATURE(shadow_call_stack, FEATURE(tls, PP.getTargetInfo().isTLSSupported()) FEATURE(underlying_type, LangOpts.CPlusPlus) FEATURE(experimental_library, LangOpts.ExperimentalLibrary) +FEATURE(datasizeof, LangOpts.CPlusPlus) AaronBallman wrote

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-01 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -fsyntax-only -triple x86_64-linux-gnu -verify %s shafik wrote: Maybe we should add tests to show parallels with `sizeof` e.g` *void* types and incomplete types. Also w/o parens etc https://github.com/llvm/llvm-project/pu

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-01 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Looks good but Aaron should look at it as well. https://github.com/llvm/llvm-project/pull/67805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-01 Thread Shafik Yaghmour via cfe-commits
@@ -5038,19 +5039,19 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, Out << 'a'; MangleAlignofSizeofArg(); break; +case UETT_DataSizeOf: { + Context.getDiags().Report(diag::err_cannot_mangle_expression) + << "__datasi

[clang] [Clang] Add __datasizeof (PR #67805)

2023-10-01 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/67805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __datasizeof (PR #67805)

2023-09-29 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Changes The data size is required for implementing the `memmove` optimization for `std::copy`, `std::move` etc. correctly as well as replacing `__compressed_pair` with `[[no_unique_address]]` in libc++. Since the compiler already knows the data s

[clang] [Clang] Add __datasizeof (PR #67805)

2023-09-29 Thread via cfe-commits
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/67805 The data size is required for implementing the `memmove` optimization for `std::copy`, `std::move` etc. correctly as well as replacing `__compressed_pair` with `[[no_unique_address]]` in libc++. Since the com