[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/70606 >From 19dd7db8ab5f98a618c717944c96b34e604fbc30 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 29 Oct 2023 14:58:04 -0700 Subject: [PATCH 1/8] [CodeGen] Revamp counted_by calculations Break down the co

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/70606 >From 19dd7db8ab5f98a618c717944c96b34e604fbc30 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 29 Oct 2023 14:58:04 -0700 Subject: [PATCH 1/9] [CodeGen] Revamp counted_by calculations Break down the co

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/70606 >From 19dd7db8ab5f98a618c717944c96b34e604fbc30 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 29 Oct 2023 14:58:04 -0700 Subject: [PATCH 01/10] [CodeGen] Revamp counted_by calculations Break down the

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
@@ -859,53 +859,60 @@ CodeGenFunction::emitBuiltinObjectSize(const Expr *E, unsigned Type, } if (IsDynamic) { -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel = -getLangOpts().getStrictFlexArraysLevel(); -const Expr *Base = E->IgnoreParenImpCa

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-10-31 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/70606 >From 19dd7db8ab5f98a618c717944c96b34e604fbc30 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 29 Oct 2023 14:58:04 -0700 Subject: [PATCH 01/11] [CodeGen] Revamp counted_by calculations Break down the

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-01 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/70606 >From 19dd7db8ab5f98a618c717944c96b34e604fbc30 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 29 Oct 2023 14:58:04 -0700 Subject: [PATCH 01/12] [CodeGen] Revamp counted_by calculations Break down the

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-01 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/70606 >From 19dd7db8ab5f98a618c717944c96b34e604fbc30 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 29 Oct 2023 14:58:04 -0700 Subject: [PATCH 01/13] [CodeGen] Revamp counted_by calculations Break down the

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-01 Thread Bill Wendling via cfe-commits
bwendling wrote: @kees, @nickdesaulniers, @rapidsna, and @apple-fcloutier Should this feature support a `__bdos` to an address inside the FAM? ``` #include #include struct flex { double dummy; char count; char fam[] __attribute__((counted_by(count))); }; int main() {

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-03 Thread Bill Wendling via cfe-commits
bwendling wrote: > ``` > #include > #include > struct flex { > int c; > int fam[] __attribute__((counted_by(c))); > }; > > int main() { > struct flex *p = (struct flex *)malloc(sizeof(struct flex) + sizeof(int) > * 10); > p->c = 100; > printf("%lu\n", __builtin_dynamic_obj

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-03 Thread Bill Wendling via cfe-commits
@@ -966,9 +962,65 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -FieldDecl *CodeGenFunction::FindCountedByField( -const Expr *Base, -LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel) { +const Expr * +CodeGenFunction

[clang] [CodeGen] Revamp counted_by calculations (PR #70606)

2023-11-03 Thread Bill Wendling via cfe-commits
bwendling wrote: > I just wanted to call out that this case is interesting because the size > derived from malloc and __counted_by compete each other. And __counted_by > always wins. This conforms to how -fbounds-safety will see the size of > objects, so sounds like we are all happy with it.

[clang-tools-extra] [clang] [llvm] [compiler-rt] [libc] [libcxx] [flang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -956,60 +951,199 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * -CodeGenFunction::BuildCountedByFieldExpr(const Expr *Base, - const ValueDecl *CountedByVD) { +namespace { + +/// \

[llvm] [compiler-rt] [clang] [libc] [libcxx] [flang] [clang-tools-extra] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -956,60 +951,199 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * -CodeGenFunction::BuildCountedByFieldExpr(const Expr *Base, - const ValueDecl *CountedByVD) { +namespace { + +/// \

[compiler-rt] [libcxx] [libc] [flang] [clang] [llvm] [clang-tools-extra] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -956,60 +951,199 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * -CodeGenFunction::BuildCountedByFieldExpr(const Expr *Base, - const ValueDecl *CountedByVD) { +namespace { + +/// \

[llvm] [libcxx] [clang] [flang] [libc] [clang-tools-extra] [compiler-rt] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -876,31 +876,26 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, } // Get the flexible array member Decl. - const ValueDecl *FAMDecl = nullptr; + const RecordDecl *OuterRD = nullptr; if (const auto *ME = dyn_cast(Base)) { // Check

[clang-tools-extra] [libcxx] [clang] [libc] [compiler-rt] [flang] [llvm] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[clang-tools-extra] [llvm] [libcxx] [libc] [flang] [clang] [compiler-rt] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -956,60 +951,199 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * -CodeGenFunction::BuildCountedByFieldExpr(const Expr *Base, - const ValueDecl *CountedByVD) { +namespace { + +/// \

[llvm] [compiler-rt] [libcxx] [clang-tools-extra] [clang] [libc] [flang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[clang-tools-extra] [compiler-rt] [libcxx] [clang] [libc] [llvm] [flang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[libcxx] [libc] [clang] [clang-tools-extra] [compiler-rt] [flang] [llvm] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-12 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[llvm] [libc] [clang] [flang] [clang-tools-extra] [compiler-rt] [libcxx] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-14 Thread Bill Wendling via cfe-commits
bwendling wrote: @efriedma-quic, @nickdesaulniers, @rapidsna: This is the latest version of this patch. I believe it's ready to submit. I _really_ tried to implement @efriedma-quic's idea, but there were too corner cases that made it much trickier than first imagined. I know that it's not imp

[compiler-rt] [llvm] [clang] [flang] [libcxx] [clang-tools-extra] [libc] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4073,6 +4221,51 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitLValue(Array); auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOpts.has(SanitizerKind::ArrayBounds)) { + // If the array being accessed h

[llvm] [libcxx] [flang] [clang] [clang-tools-extra] [compiler-rt] [libc] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4073,6 +4221,51 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitLValue(Array); auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOpts.has(SanitizerKind::ArrayBounds)) { + // If the array being accessed h

[compiler-rt] [clang] [libcxx] [libc] [flang] [llvm] [clang-tools-extra] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[llvm] [libcxx] [clang-tools-extra] [compiler-rt] [clang] [flang] [libc] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[clang] [clang-tools-extra] [libc] [flang] [compiler-rt] [llvm] [libcxx] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[clang-tools-extra] [compiler-rt] [flang] [libcxx] [libc] [llvm] [clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[flang] [libcxx] [compiler-rt] [llvm] [libc] [clang-tools-extra] [clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/73730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[flang] [libcxx] [compiler-rt] [llvm] [libc] [clang-tools-extra] [clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/73730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[flang] [libcxx] [compiler-rt] [llvm] [libc] [clang-tools-extra] [clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/73730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [flang] [compiler-rt] [clang] [llvm] [libc] [libcxx] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[libc] [libcxx] [llvm] [flang] [clang-tools-extra] [compiler-rt] [clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[clang] [clang-tools-extra] [libcxx] [flang] [compiler-rt] [libc] [llvm] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-15 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[compiler-rt] [clang-tools-extra] [libcxx] [clang] [libc] [llvm] [flang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true); else ArrayLV = EmitLValue(Array); + auto *Idx = EmitIdxAfterBase(/*Promote*/true); +if (SanOp

[compiler-rt] [clang-tools-extra] [libcxx] [clang] [libc] [llvm] [flang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
bwendling wrote: > I don't mean for this next bit to sound as aggressive or irritated as it > might but #73168 has been open for almost a month now and it is actively > preventing us from testing the Linux kernel against tip of tree LLVM because > (for better or worse...) the kernel has starte

[flang] [llvm] [clang] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
@@ -740,3 +1058,589 @@ void test10(struct union_of_fams *p, int index) { void test11(struct annotated *p, int index) { p->array[index] = __builtin_dynamic_object_size(&p->count, 1); } + +// SANITIZE-WITH-ATTR-LABEL: define dso_local i64 @test11_bdos( +// SANITIZE-WITH-ATTR-SA

[llvm] [clang] [clang-tools-extra] [libcxx] [flang] [compiler-rt] [libc] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
bwendling wrote: > > > Can we please come to some consensus so that issue can be resolved? > > > > > > This supposed bug fix snowballed out of control. I'd be happy to revert to > > a previous version and then submit the newer work as a improvements. > > Linux kernel builds have been broken s

[clang] Revert counted_by attribute feature (PR #75857)

2023-12-18 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/75857 There are many issues that popped up with the counted_by feature. The patch has grown too large and approval is blocking Linux testing. Includes reverts of: commit 769bc11f684d ("[Clang] Implement the 'counted

[compiler-rt] [libcxx] [clang-tools-extra] [flang] [clang] [llvm] [libc] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
bwendling wrote: Here's a revert of the feature. https://github.com/llvm/llvm-project/pull/75857 https://github.com/llvm/llvm-project/pull/73730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cf

[clang] Revert counted_by attribute feature (PR #75857)

2023-12-18 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/75857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert counted_by attribute feature (PR #75857)

2023-12-18 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/75857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libcxx] [flang] [compiler-rt] [llvm] [clang] [libc] [clang-tools-extra] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
@@ -8522,6 +8522,22 @@ bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) { } } + // We don't support 'counted_by' on flexible array members in substructures. + const DeclContext *DC = FD->getParent(); + while (const auto *RD = dyn_cast(DC)) { +if (!RD-

[llvm] [libc] [clang] [flang] [clang-tools-extra] [libcxx] [compiler-rt] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
@@ -8522,6 +8522,22 @@ bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) { } } + // We don't support 'counted_by' on flexible array members in substructures. + const DeclContext *DC = FD->getParent(); + while (const auto *RD = dyn_cast(DC)) { +if (!RD-

[libcxx] [llvm] [compiler-rt] [clang-tools-extra] [clang] [flang] [libc] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
@@ -3946,6 +4080,32 @@ static Address emitArraySubscriptGEP(CodeGenFunction &CGF, Address addr, return Address(eltPtr, CGF.ConvertTypeForMem(eltType), eltAlign); } +static bool GetFieldOffsetInBits(CodeGenFunction &CGF, const RecordDecl *RD, +

[clang-tools-extra] [flang] [clang] [libc] [libcxx] [compiler-rt] [llvm] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
@@ -8522,6 +8522,22 @@ bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) { } } + // We don't support 'counted_by' on flexible array members in substructures. + const DeclContext *DC = FD->getParent(); + while (const auto *RD = dyn_cast(DC)) { +if (!RD-

[libcxx] [compiler-rt] [clang] [llvm] [libc] [clang-tools-extra] [flang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
@@ -3946,6 +4080,32 @@ static Address emitArraySubscriptGEP(CodeGenFunction &CGF, Address addr, return Address(eltPtr, CGF.ConvertTypeForMem(eltType), eltAlign); } +static bool GetFieldOffsetInBits(CodeGenFunction &CGF, const RecordDecl *RD, +

[clang] Revert counted_by attribute feature (PR #75857)

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

[libcxx] [compiler-rt] [clang] [llvm] [libc] [clang-tools-extra] [flang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
bwendling wrote: https://github.com/llvm/llvm-project/pull/75857 has been merged in. This PR is no longer valid. https://github.com/llvm/llvm-project/pull/73730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang] [compiler-rt] [flang] [clang-tools-extra] [libcxx] [libc] [llvm] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

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

[libcxx] [compiler-rt] [llvm] [flang] [clang-tools-extra] [clang] [libc] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-18 Thread Bill Wendling via cfe-commits
bwendling wrote: > > #75857 has been merged in. This PR is no longer valid. > > Couldn't you just rebase it like: > > * base: `main` > * pick revert of [Revert counted_by attribute featureĀ  > #75857](https://github.com/llvm/llvm-project/pull/75857) > * all the commits of this PR > > It's a bit

[libc] [libcxx] [clang] [llvm] [compiler-rt] [flang] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

2023-11-26 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/73465 I'll add some testcases later today. >From 3aa35a39184ff8d4ff11b9f41b4551bec78bdca5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 22 Nov 2023 15:16:19 -0800 Subject: [PATCH] [Clang] Use correct base

[flang] [llvm] [libcxx] [libc] [clang] [compiler-rt] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

2023-11-26 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/73465 >From 3aa35a39184ff8d4ff11b9f41b4551bec78bdca5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 22 Nov 2023 15:16:19 -0800 Subject: [PATCH 1/2] [Clang] Use correct base expression for counted_by field T

[flang] [llvm] [clang] [libc] [libcxx] [compiler-rt] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

2023-11-27 Thread Bill Wendling via cfe-commits
@@ -916,7 +916,7 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, // Build a load of the counted_by field. bool IsSigned = CountedByFD->getType()->isSignedIntegerType(); - const Expr *CountedByExpr = BuildCountedByFieldExpr(Base, CountedByFD)

[flang] [llvm] [clang] [libc] [libcxx] [compiler-rt] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

2023-11-27 Thread Bill Wendling via cfe-commits
@@ -956,37 +956,55 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * -CodeGenFunction::BuildCountedByFieldExpr(const Expr *Base, - const ValueDecl *CountedByVD) { +Expr *CodeGenFunction

[flang] [libcxx] [compiler-rt] [clang] [libc] [llvm] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

2023-11-27 Thread Bill Wendling via cfe-commits
@@ -916,7 +916,7 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, // Build a load of the counted_by field. bool IsSigned = CountedByFD->getType()->isSignedIntegerType(); - const Expr *CountedByExpr = BuildCountedByFieldExpr(Base, CountedByFD)

[libcxx] [flang] [clang] [llvm] [compiler-rt] [libc] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

2023-11-27 Thread Bill Wendling via cfe-commits
@@ -916,7 +916,7 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type, // Build a load of the counted_by field. bool IsSigned = CountedByFD->getType()->isSignedIntegerType(); - const Expr *CountedByExpr = BuildCountedByFieldExpr(Base, CountedByFD)

[libc] [compiler-rt] [llvm] [flang] [libcxx] [clang] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

2023-11-27 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/73465 >From 3aa35a39184ff8d4ff11b9f41b4551bec78bdca5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 22 Nov 2023 15:16:19 -0800 Subject: [PATCH 1/4] [Clang] Use correct base expression for counted_by field T

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-28 Thread Bill Wendling via cfe-commits
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/73730 This is an alternative to https://github.com/llvm/llvm-project/pull/73465. It generates the GEP directly. It's not tested well, but it might be a nicer solution rather than adding AST nodes. PTAL >From 3e500

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-28 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/73730 >From 3e500c2a7c6b7895ebe292a1ed50e04409ba149c Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 28 Nov 2023 17:17:54 -0800 Subject: [PATCH 1/2] [Clang] Generate the GEP instead of adding AST nodes ---

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
@@ -956,42 +956,70 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * +namespace { + +struct MemberExprBaseVisitor +: public StmtVisitor { + MemberExprBaseVisitor() = default; + + //===--

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
@@ -956,42 +956,70 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * +namespace { + +struct MemberExprBaseVisitor +: public StmtVisitor { + MemberExprBaseVisitor() = default; + + //===--

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
@@ -956,42 +956,70 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * +namespace { + +struct MemberExprBaseVisitor +: public StmtVisitor { + MemberExprBaseVisitor() = default; + + //===--

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: > Hey, that looks pretty good! I'm surprised it wasn't too much more work to > convert to generating the GEP directly. Nice job! > > Does this change result in codegen differences in IR? (was expecting test > changes that used "fork" loads and "bork" GEPs) Thanks. There will

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/73730 >From 3e500c2a7c6b7895ebe292a1ed50e04409ba149c Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 28 Nov 2023 17:17:54 -0800 Subject: [PATCH 1/3] [Clang] Generate the GEP instead of adding AST nodes ---

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/73730 >From 3e500c2a7c6b7895ebe292a1ed50e04409ba149c Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 28 Nov 2023 17:17:54 -0800 Subject: [PATCH 1/4] [Clang] Generate the GEP instead of adding AST nodes ---

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
@@ -956,42 +956,72 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * +namespace { + +struct MemberExprBaseVisitor +: public StmtVisitor { + MemberExprBaseVisitor() = default; + + //===--

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: @AaronBallman It's not letting me comment on your comment. While a compound literal doesn't have a DRE, it's also not a flexible array, so it's not supposed to get this far. https://github.com/llvm/llvm-project/pull/73730 ___ cfe-com

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/73730 >From 3e500c2a7c6b7895ebe292a1ed50e04409ba149c Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 28 Nov 2023 17:17:54 -0800 Subject: [PATCH 1/5] [Clang] Generate the GEP instead of adding AST nodes ---

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/73730 >From 3e500c2a7c6b7895ebe292a1ed50e04409ba149c Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 28 Nov 2023 17:17:54 -0800 Subject: [PATCH 1/6] [Clang] Generate the GEP instead of adding AST nodes ---

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
@@ -956,42 +956,72 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * +namespace { + +struct MemberExprBaseVisitor +: public StmtVisitor { + MemberExprBaseVisitor() = default; + + //===--

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: > > @AaronBallman It's not letting me comment on your comment. While a compound > > literal doesn't have a DRE, it's also not a flexible array, so it's not > > supposed to get this far. Note that this method should only be executed if > > the flexible array member exists and h

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
@@ -956,42 +956,72 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * +namespace { + +struct MemberExprBaseVisitor +: public StmtVisitor { + MemberExprBaseVisitor() = default; + + //===--

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/73730 >From 3e500c2a7c6b7895ebe292a1ed50e04409ba149c Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 28 Nov 2023 17:17:54 -0800 Subject: [PATCH 1/7] [Clang] Generate the GEP instead of adding AST nodes ---

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
@@ -956,42 +956,70 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF, return nullptr; } -const Expr * +namespace { + +struct MemberExprBaseVisitor +: public StmtVisitor { + MemberExprBaseVisitor() = default; + + //===--

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: This should be ready for a final review now. https://github.com/llvm/llvm-project/pull/73730 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[libcxx] [flang] [compiler-rt] [clang] [llvm] [libc] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

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

[libc] [llvm] [flang] [clang] [compiler-rt] [libcxx] [Clang] Use correct base expression for counted_by field (#73168) (PR #73465)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: Closing in favor of https://github.com/llvm/llvm-project/pull/73730. https://github.com/llvm/llvm-project/pull/73465 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: > CodeGenFunction::FindCountedByField finds a field with a corresponding base > expression. Currently, it throws away the base expression. And the code > you've just written tries to recompute the base. Instead of doing this dance, > can we just make CodeGenFunction::FindCount

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: > I'd like to see a few tests involving multiple arrows in the same expression. > (If my understanding is correct, you want to cut the recursion when you see > an arrow member.) Correct. I'll add the code and some testcases. > Looking at the code again, I guess FindCountedByF

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: > I agree users probably shouldn't be doing that... but given it compiles your > code should handle it gracefully. (It should just be a matter of making sure > you don't recurse too deeply through the "base".) *nods* However, the code it generates might not be what they want..

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-11-29 Thread Bill Wendling via cfe-commits
bwendling wrote: Okay. With the latest commit, I handle some of the weird accesses. As it turns out, looking at `isArrow()` for a `MemberExpr` isn't going to work, because it'll happen with ordinary accesses: ``` ImplicitCastExpr 0x564fa8c3fd48 'int *' `-MemberExpr 0x564fa8c3fcf8 'int[]' lval

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-01 Thread Bill Wendling via cfe-commits
bwendling wrote: This is a PITA. There are two situations: 1. The expression was processed before getting to the `EmitBoundsCheck` call, and is thus recorded in the `LocalDeclMap` for easy access. Grand! 2. Using a FAM in a `__builtin_dynamic_object_size` cannot have side effects. Also, it may

[clang] [Clang] Implement the 'counted_by' attribute (PR #76348)

2023-12-26 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/76348 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Implement the 'counted_by' attribute (PR #76348)

2023-12-27 Thread Bill Wendling via cfe-commits
bwendling wrote: Some (hopefully) helpful comments on this admittedly very large patch. General Comment: I pulled back on allowing the `count` to be in a non-anonymous struct that doesn't contain the flexible array. So this is no longer allowed: ``` struct count_not_in_substruct { unsigned

[llvm] [libc] [lldb] [mlir] [clang] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-03 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/76882 >From ca7a96a40952fe94b916dacc52f07aa90bbdb1e7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 3 Jan 2024 13:22:37 -0800 Subject: [PATCH 1/3] [builtin_object_size] Use classes instead of std::pair (NFC

[libc] [clang] [lldb] [llvm] [mlir] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-03 Thread Bill Wendling via cfe-commits
@@ -187,80 +187,147 @@ Value *lowerObjectSizeCall( const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed, SmallVectorImpl *InsertedInstructions = nullptr); -using SizeOffsetType = std::pair; +/// SizeOffsetType - A base template class for the object size visito

[libc] [clang] [lldb] [llvm] [mlir] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

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

[libc] [clang] [lldb] [llvm] [mlir] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-03 Thread Bill Wendling via cfe-commits
bwendling wrote: > I am unsure I understand why we do the base template rather than inheritance. > Where is the base template used? If we do inheritance we could avoid > duplicating of members and provide default impls that work with many things, > e.g., all operator== are the same. I made th

[llvm] [libc] [mlir] [clang] [lldb] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-03 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/76882 >From ca7a96a40952fe94b916dacc52f07aa90bbdb1e7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 3 Jan 2024 13:22:37 -0800 Subject: [PATCH 1/4] [builtin_object_size] Use classes instead of std::pair (NFC

[mlir] [libc] [llvm] [clang] [lldb] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-03 Thread Bill Wendling via cfe-commits
bwendling wrote: @jdoerfert I reworked the structs to use inheritance instead of template specialization. It should work better now and not duplicate so much. https://github.com/llvm/llvm-project/pull/76882 ___ cfe-commits mailing list cfe-commits@lis

[lldb] [clang] [llvm] [mlir] [libc] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-04 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/76882 >From ca7a96a40952fe94b916dacc52f07aa90bbdb1e7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 3 Jan 2024 13:22:37 -0800 Subject: [PATCH 1/5] [builtin_object_size] Use classes instead of std::pair (NFC

<    1   2   3   4   5   6   7   8   >