[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)

2025-01-08 Thread Bill Wendling via cfe-commits
bwendling wrote: Howdy! This is essentially a complete rewrite of 00b6d032a22196bc14e4e30e413c040eb1b65da4. The original was overly complex and fragile. The main difference with this PR is basing the calculations off of the already emitted `Expr` instead of doing it within this function. It a

[clang] [Clang][CodeGen] Remove extraneous dot prefixes [NFC] (PR #119275)

2024-12-09 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/119275 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][CodeGen] Remove extraneous dot prefixes [NFC] (PR #119275)

2024-12-09 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/119275 None >From 7db6b68013c70e0b048171bb11f17bdc703b5bb7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 9 Dec 2024 13:59:02 -0800 Subject: [PATCH] [Clang][CodeGen] Remove extraneous dot prefixes [NFC] --

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-27 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-27 Thread Bill Wendling via cfe-commits
bwendling wrote: Fine. https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-27 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/9] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-26 Thread Bill Wendling via cfe-commits
@@ -14690,6 +14690,13 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) { } } + // The result of __builtin_counted_by_ref cannot be assigned to a variable. + // It allows leaking and modification of bounds safety information. + if (IsBuiltinCountedByRef(VD->getInit())

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-25 Thread Bill Wendling via cfe-commits
bwendling wrote: Ah, okay. Thanks. https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-25 Thread Bill Wendling via cfe-commits
bwendling wrote: Yeah, but I'd like to get this off my plate. :-) https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-25 Thread Bill Wendling via cfe-commits
bwendling wrote: I image @AaronBallman is on vacation this week. @Sirraide would you be willing to LGTM this so that I can move it along? It's certainly better than what we have and I can address any concerns Aaron has afterwards. https://github.com/llvm/llvm-project/pull/116719 __

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/8] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via cfe-commits
bwendling wrote: > I think this might honestly be fine the way it is now Yeah. It's going kind of the opposite way from what you suggested with the placeholder, just instead of allowing for different uses at various places in Sema we disallow without using the placeholder. https://github.com/

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-21 Thread Bill Wendling via cfe-commits
@@ -14690,6 +14690,14 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) { } } + // The result of __builtin_counted_by_ref cannot be assigned to a variable. + // It allows leaking and modification of bounds safety information. + if (const auto *CE = dyn_cast_if_present

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/4] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/5] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/6] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/7] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
bwendling wrote: > > Could you point to a place in the code where it creates a placeholder? > > I mean, e.g. `CheckPointerToMemberOperands()` can return `BoundMemberTy` as > the type of a `.*` expression, and `CreateBuiltinMatrixSubscriptExpr()` > creates a `MatrixSubscriptExpr` with type `Inc

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-20 Thread Bill Wendling via cfe-commits
bwendling wrote: > The main thing I’m concerned about here is that I feel like there ought to be > a better way of doing this than checking for and disallowing it in every > place where we can have a subexpression in C. Yeah, but we don't have such a method, partially due to the languages Clan

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
bwendling wrote: I removed the Placeholder code. It's a much smaller patch and has the better timing profile. PTAL. https://github.com/llvm/llvm-project/pull/116719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/3] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/116719 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 15 Nov 2024 15:41:48 -0800 Subject: [PATCH 1/2] [Clang] Improve Sema diagnostic performance for __builtin

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
@@ -14690,6 +14690,17 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) { } } + // The result of __builtin_counted_by_ref cannot be assigned to a variable. + // It allows leaking and modification of bounds safety information. + if (const auto *CE = dyn_cast_if_present

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
@@ -755,6 +755,7 @@ static ExprResult BuiltinDumpStruct(Sema &S, CallExpr *TheCall) { case BuiltinType::PseudoObject: case BuiltinType::UnknownAny: case BuiltinType::BuiltinFn: +case BuiltinType::BuiltinCountedByRef: bwendling wrote: Then shou

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-19 Thread Bill Wendling via cfe-commits
bwendling wrote: > Hmm, I don’t think this is the right way of going about it—copy-pasting the > check across 6 or so different places seems like it’s missing the point of > using a placeholder in the first place. Could you point to a place in the code where it creates a placeholder? I'm unab

[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)

2024-11-18 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/116719 Implement the sema checks with a placeholder. We then check for that placeholder in all of the places we care to emit a diagnostic. Fixes: #115520 >From 2dcf18163de2ccce959f46bf82df1fa40e3fd1fc Mon Sep 17 0

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -13,7 +13,10 @@ void init(void * __attribute__((pass_dynamic_object_size(0; // CHECK-LABEL: define dso_local void @_ZN3foo3barC1Ev( // CHECK-SAME: ptr noundef nonnull align 4 dereferenceable(1) [[THIS:%.*]]) unnamed_addr #[[ATTR0:[0-9]+]] align 2 { // CHECK-NEXT: entr

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -16,6 +16,8 @@ void test1(struct fam_struct *ptr, int size, int idx) { *__builtin_counted_by_ref(ptr->array) = size; // ok *__builtin_counted_by_ref(&ptr->array[idx]) = size; // ok + *__builtin_counted_by_ref(&ptr->array) = size;// ok

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -4914,3 +4914,9 @@ def ArithmeticFence : LangBuiltin<"ALL_LANGUAGES"> { let Attributes = [CustomTypeChecking, Constexpr]; let Prototype = "void(...)"; } + +def CountedByRef : Builtin { + let Spellings = ["__builtin_counted_by_ref"]; + let Attributes = [NoThrow, CustomT

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -16,6 +16,8 @@ void test1(struct fam_struct *ptr, int size, int idx) { *__builtin_counted_by_ref(ptr->array) = size; // ok *__builtin_counted_by_ref(&ptr->array[idx]) = size; // ok + *__builtin_counted_by_ref(&ptr->array) = size;// ok

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
@@ -0,0 +1,182 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=X86_64 +// RUN: %clang_cc1 -triple i386-unknown-unknown

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-04 Thread Bill Wendling via cfe-commits
bwendling wrote: -ast-print testcase added. https://github.com/llvm/llvm-project/pull/114495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-11-01 Thread Bill Wendling via cfe-commits
bwendling wrote: @AaronBallman @rapidsna -- I think I covered all of the comments you made on the other PR (stupid git!). PTAL. https://github.com/llvm/llvm-project/pull/114495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm

[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)

2024-10-31 Thread Bill Wendling via cfe-commits
bwendling wrote: This is a new PR, because GitHub messed up. Here's the original: https://github.com/llvm/llvm-project/pull/102549 https://github.com/llvm/llvm-project/pull/114495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.l

[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

2024-10-30 Thread Bill Wendling via cfe-commits
@@ -197,6 +197,18 @@ static bool CanElideOverflowCheck(const ASTContext &Ctx, const BinOpInfo &Op) { if (!Op.mayHaveIntegerOverflow()) return true; + if (Op.Ty->isSignedIntegerType() && bwendling wrote: Does this (and the following if-then) need a com

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-25 Thread Bill Wendling via cfe-commits
bwendling wrote: I think the calculation in https://github.com/llvm/llvm-project/pull/112636#issuecomment-2436559387 is correct. It's probably worthwhile to perform some analysis to see if using that to calculate the new size results in allocation size changes in the kernel. If not, then perh

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-17 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/112636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-17 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/112636 >From d3c689f5b0ece80eba784afe67e3412e2dc6d595 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 16 Oct 2024 17:03:23 -0700 Subject: [PATCH 1/2] [Clang] Disable use of the counted_by attribute for whole

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-17 Thread Bill Wendling via cfe-commits
@@ -1013,6 +1013,24 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, // Can't find the field referenced by the "counted_by" attribute. return nullptr; + if (isa(Base)) bwendling wrote: It's possibly a bug, but we current

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-17 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/112636 >From d3c689f5b0ece80eba784afe67e3412e2dc6d595 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 16 Oct 2024 17:03:23 -0700 Subject: [PATCH 1/2] [Clang] Disable use of the counted_by attribute for whole

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-16 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/112636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

2024-10-16 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/112636 The whole struct is specificed in the __bdos. The calculation of the whole size of the structure can be done in two ways: 1) sizeof(struct S) + count * sizeof(typeof(fam)) 2) offsetof(struct S, fam) +

[clang] [llvm] [Clang] Correct __builtin_dynamic_object_size for subobject types (PR #83204)

2024-10-15 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/83204 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix __builtin_dynamic_object_size off by 4 (PR #111015)

2024-10-07 Thread Bill Wendling via cfe-commits
bwendling wrote: > > This is why I believe the gcc behavior is correct. When it knows the size > > given to `malloc` it uses that. When it doesn't know that it simply returns > > INT_MAX. When you ask gcc for the `__bdos` of the FAM it will use the > > `count` to calculate the size. > > (nit:

[clang] [Clang] Fix __builtin_dynamic_object_size off by 4 (PR #111015)

2024-10-07 Thread Bill Wendling via cfe-commits
bwendling wrote: > So, we would actually get gcc's behavior with this patch: > > ``` > diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp > index c864714182e0..21ffe7b46a6e 100644 > --- a/clang/lib/CodeGen/CGBuiltin.cpp > +++ b/clang/lib/CodeGen/CGBuiltin.cpp > @@ -10

[clang] [Clang] Fix __builtin_dynamic_object_size off by 4 (PR #111015)

2024-10-07 Thread Bill Wendling via cfe-commits
bwendling wrote: > After looking at the assembly produced by gcc more, it actually looks like > it's using the allocation size if it's known in the current context (for > example if the struct was just malloced in the same function) and otherwise > returns INT_MAX for the __bdos of a struct co

[clang] [Clang] Check that we have the correct RecordDecl (PR #111448)

2024-10-07 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/111448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110497)

2024-10-07 Thread Bill Wendling via cfe-commits
@@ -1095,6 +1095,8 @@ class StructAccessBase return Visit(E->getBase()); } const Expr *VisitCastExpr(const CastExpr *E) { +if (E->getCastKind() == CK_LValueToRValue) + return E; bwendling wrote: See https://github.com/llvm/llvm-project/pull/11

[clang] [Clang] Check that we have the correct RecordDecl (PR #111448)

2024-10-07 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/111448 Ensure we have the correct RecordDecl before returning the Expr we're looking for. >From 1936cd507a38d3085fa13016fb40a9a7df35a821 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 7 Oct 2024 15:25:47 -

[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110497)

2024-10-07 Thread Bill Wendling via cfe-commits
@@ -1095,6 +1095,8 @@ class StructAccessBase return Visit(E->getBase()); } const Expr *VisitCastExpr(const CastExpr *E) { +if (E->getCastKind() == CK_LValueToRValue) + return E; bwendling wrote: It might be a good sanity check, though I think

[clang] [Clang] Fix __builtin_dynamic_object_size off by 4 (PR #111015)

2024-10-03 Thread Bill Wendling via cfe-commits
bwendling wrote: I wrote a similar conclusion to @efriedma-quic in the email thread. The problem with your example is that, in the absence of the `counted_by` attribute, the `__builtin_dynamic_object_size` uses the `alloc_size` attribute that's implicit on the `malloc` call. https://github.co

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-02 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/110487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110497)

2024-10-02 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/110497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110497)

2024-10-02 Thread Bill Wendling via cfe-commits
https://github.com/bwendling approved this pull request. Thanks for the patch! https://github.com/llvm/llvm-project/pull/110497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110497)

2024-10-02 Thread Bill Wendling via cfe-commits
@@ -10,6 +10,7 @@ // //===--===// +#include bwendling wrote: Please don't include this (I know it's left from debugging). If you want to debug things, you can use: ```c++ llvm::errs() <<

[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110497)

2024-10-02 Thread Bill Wendling via cfe-commits
bwendling wrote: The problem we're faced with here is that the `Base` pointer could point to anywhere within the structure. We already jump through several hoops to get the flexible array member's `Decl` and the counter's `Decl`. So because `Base` could be a pointer to anywhere in the struct,

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits
bwendling wrote: > @bwendling I think you accidentally compiled the wrong branch. Looks like > that is in `builtin_get_counted_by`, but this PR is in > `bdos-member-expr-error` Yeah, sorry about that. https://github.com/llvm/llvm-project/pull/110487 ___

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits
bwendling wrote: > > I reverted my last commit. This leaves the original patch, which seems to > > work. @efriedma-quic, would you be okay with this patch while I work to > > improve the code in follow-up? > > The original (and current) patch in this PR still introduces a regression. So > it

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits
bwendling wrote: I reverted my last commit. This leaves the original patch, which seems to work. @efriedma-quic, would you be okay with this patch while I work to improve the code in follow-up? https://github.com/llvm/llvm-project/pull/110487 ___ cfe

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/110487 >From 375a71d114fffb94c16455f476364a7de9e08191 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 30 Sep 2024 03:41:15 -0700 Subject: [PATCH 1/3] [Clang][CodeGen] Emit load of value We were missing a loa

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-10-01 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/110487 >From 375a71d114fffb94c16455f476364a7de9e08191 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 30 Sep 2024 03:41:15 -0700 Subject: [PATCH 1/2] [Clang][CodeGen] Emit load of value We were missing a loa

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits
bwendling wrote: > > If I return the LValueToRValue cast and run EmitLValue on it > > I'm surprised EmitLValue didn't error out on that. The result of an > LValueToRValue cast is an rvalue. Calling EmitPointerWithAlignment on it > should work, I think. > > > I understand, but there are ~30 di

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/110487 >From 375a71d114fffb94c16455f476364a7de9e08191 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 30 Sep 2024 03:41:15 -0700 Subject: [PATCH 1/2] [Clang][CodeGen] Emit load of value We were missing a loa

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits
bwendling wrote: > This is sort of the same comment I've made on other related patches... but I > think the fundamental issue here is that StructAccessBase is skipping over > CK_LValueToRValue casts. Once you jump over such a cast, you're looking at > expressions which are at a different level

[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/110487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110437)

2024-09-30 Thread Bill Wendling via cfe-commits
bwendling wrote: Thanks for this, but I think the issue is more basic. We should be issuing a "load" instruction after the `EmitMemberExpr` call. (That's what happens outside of using this in `__builtin_dynamic_object_size`.) https://github.com/llvm/llvm-project/pull/110437 ___

[clang] [Clang][CodeGen] Emit load of value (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits
https://github.com/bwendling milestoned https://github.com/llvm/llvm-project/pull/110487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][CodeGen] Emit load of value (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/110487 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][CodeGen] Emit load of value (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/110487 We were missing a load of the value after emitting the MemberExpr. This was causing __builtin_dynamic_object_size to return 0 incorrectly. >From 375a71d114fffb94c16455f476364a7de9e08191 Mon Sep 17 00:00:00 20

[clang] [Parser][NFC] Move the core parsing of an attribute into a separate method (PR #107300)

2024-09-06 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/107300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Parser][NFC] Move the core parsing of an attribute into a separate method (PR #107300)

2024-09-06 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/107300 >From c30c6c11686cc95ba20eb7000d210b17757fbfe3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 4 Sep 2024 12:49:04 -0700 Subject: [PATCH 1/3] [Parser][NFC] Move the core parsing of an attribute into a

[clang] [Parser][NFC] Move the core parsing of an attribute into a separate method (PR #107300)

2024-09-06 Thread Bill Wendling via cfe-commits
@@ -2943,6 +2943,9 @@ class Parser : public CodeCompletionHandler { return false; } + bool ParseGNUSingleAttribute(ParsedAttributes &Attrs, SourceLocation &EndLoc, bwendling wrote: > Ah, I see. The WG14 specified one is __builtin_has_c_attribute, corre

[clang] [Parser][NFC] Move the core parsing of an attribute into a separate method (PR #107300)

2024-09-04 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/107300 >From c30c6c11686cc95ba20eb7000d210b17757fbfe3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 4 Sep 2024 12:49:04 -0700 Subject: [PATCH 1/2] [Parser][NFC] Move the core parsing of an attribute into a

[clang] [Parser][NFC] Move the core parsing of an attribute into a separate method (PR #107300)

2024-09-04 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/107300 Refactor attribute parsing so that the main code parsing an attribute can be called by a separate code path that doesn't start with the '__attribute' keyword. >From c30c6c11686cc95ba20eb7000d210b17757fbfe3 M

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2024-08-26 Thread Bill Wendling via cfe-commits
bwendling wrote: Also, I think there was a PR that added delayed parsing of attributes? Is that correct, or a false memory? :-) https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.

[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

2024-08-26 Thread Bill Wendling via cfe-commits
bwendling wrote: @rapidsna, what's the status of this PR? If it's bit-rotted, I can try to take over. https://github.com/llvm/llvm-project/pull/70480 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-20 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/104889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Re-land Overflow Pattern Exclusions (PR #104889)

2024-08-20 Thread Bill Wendling via cfe-commits
@@ -119,6 +119,10 @@ static SanitizerMask parseArgValues(const Driver &D, const llvm::opt::Arg *A, static int parseCoverageFeatures(const Driver &D, const llvm::opt::Arg *A, bool DiagnoseErrors); +static int parseOverflowPatternExclusionValues

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-15 Thread Bill Wendling via cfe-commits
bwendling wrote: @vitalybuka Are they still broken? Which ones? https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] a2830d6 - Revert "Remove empty line."

2024-08-15 Thread Bill Wendling via cfe-commits
Author: Bill Wendling Date: 2024-08-15T02:34:04-07:00 New Revision: a2830d6aa2e8ad0da0e58f1642ed09723602e838 URL: https://github.com/llvm/llvm-project/commit/a2830d6aa2e8ad0da0e58f1642ed09723602e838 DIFF: https://github.com/llvm/llvm-project/commit/a2830d6aa2e8ad0da0e58f1642ed09723602e838.diff

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Bill Wendling via cfe-commits
bwendling wrote: I removed it temporarily. https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] 07a8cba - Remove failing test until it can be fixed properly.

2024-08-14 Thread Bill Wendling via cfe-commits
Author: Bill Wendling Date: 2024-08-14T22:51:26-07:00 New Revision: 07a8cbaf8dc16bebf6e875173d20299d9cc47cc5 URL: https://github.com/llvm/llvm-project/commit/07a8cbaf8dc16bebf6e875173d20299d9cc47cc5 DIFF: https://github.com/llvm/llvm-project/commit/07a8cbaf8dc16bebf6e875173d20299d9cc47cc5.diff

[clang] [Clang][NFC] Move FindCountedByField into FieldDecl (PR #104235)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/104235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][NFC] Move FindCountedByField into FieldDecl (PR #104235)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/104235 >From a87bc65687b687073e8ff37606ca9e783f1edcf9 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 14 Aug 2024 13:44:56 -0700 Subject: [PATCH 1/2] [Clang][NFC] Move FindCountedByField into FieldDecl FindC

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Bill Wendling via cfe-commits
bwendling wrote: Hopefully 6e2d9df02502 fixes the buildbots. I think we should using update_cc_test_checks.py to generate these testcases though. https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] 6e2d9df - Fix testcases. Use -emit-llvm and not -S. Use LABEL checking.

2024-08-14 Thread Bill Wendling via cfe-commits
Author: Bill Wendling Date: 2024-08-14T22:14:29-07:00 New Revision: 6e2d9df02502e16659e4a9397260baf9df224f17 URL: https://github.com/llvm/llvm-project/commit/6e2d9df02502e16659e4a9397260baf9df224f17 DIFF: https://github.com/llvm/llvm-project/commit/6e2d9df02502e16659e4a9397260baf9df224f17.diff

[clang] 5873aa8 - Remove '-emit-llvm' and use '-triple'

2024-08-14 Thread Bill Wendling via cfe-commits
Author: Bill Wendling Date: 2024-08-14T17:49:34-07:00 New Revision: 5873aa83b871393b5ada4c2033445d5fd52d7461 URL: https://github.com/llvm/llvm-project/commit/5873aa83b871393b5ada4c2033445d5fd52d7461 DIFF: https://github.com/llvm/llvm-project/commit/5873aa83b871393b5ada4c2033445d5fd52d7461.diff

[clang] 7275919 - Use clang_cc1 and specify the target explicitly.

2024-08-14 Thread Bill Wendling via cfe-commits
Author: Bill Wendling Date: 2024-08-14T17:46:30-07:00 New Revision: 7275919cd5fc89c42a52168c9f4411b4e5421c95 URL: https://github.com/llvm/llvm-project/commit/7275919cd5fc89c42a52168c9f4411b4e5421c95 DIFF: https://github.com/llvm/llvm-project/commit/7275919cd5fc89c42a52168c9f4411b4e5421c95.diff

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Bill Wendling via cfe-commits
bwendling wrote: > @efriedma-quic > > > I think serialization is missing for the new bit on BinaryOperator. > > How do I add this? > > > I'm not sure why we're storing it in the first place, though; it's queried > > in exactly one place, so there isn't really any benefit to precomputing it. >

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling commented: I made changes to use the CustomTypeChecking for the builtin. PTAL https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
@@ -6590,8 +6590,34 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy, VK_PRValue, RParenLoc, CurFPFeatureOverrides()); } - return BuildResol

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
@@ -4678,6 +4678,19 @@ void FieldDecl::printName(raw_ostream &OS, const PrintingPolicy &Policy) const { DeclaratorDecl::printName(OS, Policy); } +const FieldDecl *FieldDecl::FindCountedByField() const { + const auto *CAT = getType()->getAs(); + if (!CAT) +return nullp

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/102549 >From 7ba43ae2b737fbd868848a23b58b3965f8d36ce1 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 6 Aug 2024 17:49:01 -0700 Subject: [PATCH 01/11] [WIP][Clang] Add __builtin_get_counted_by builtin The __

[clang] [Clang][NFC] Move FindCountedByField into FieldDecl (PR #104235)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/104235 FindCountedByField can be used in more places than CodeGen. Move it into FieldDecl to avoid layering issues. >From a87bc65687b687073e8ff37606ca9e783f1edcf9 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date:

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-13 Thread Bill Wendling via cfe-commits
bwendling wrote: Thanks! @efriedma-quic anymore comments? https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread Bill Wendling via cfe-commits
@@ -4774,3 +4774,9 @@ def ArithmeticFence : LangBuiltin<"ALL_LANGUAGES"> { let Attributes = [CustomTypeChecking, Constexpr]; let Prototype = "void(...)"; } + +def GetCountedBy : Builtin { + let Spellings = ["__builtin_get_counted_by"]; + let Attributes = [NoThrow]; + let

  1   2   3   4   5   6   7   >