[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-08-15 Thread Doug Wyatt via cfe-commits
@@ -4914,6 +4920,78 @@ class FunctionEffectsRef { void dump(llvm::raw_ostream &OS) const; }; +/// A mutable set of FunctionEffect::Kind. +class FunctionEffectKindSet { dougsonos wrote: For now I've left the special iterator but replaced the manual bit-twidd

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-08-15 Thread Doug Wyatt via cfe-commits
@@ -15012,6 +14992,12 @@ class Sema final : public SemaBase { return hasAcceptableDefinition(D, &Hidden, Kind); } + /// Try to parse the conditional expression attached to an effect attribute + /// (e.g. 'nonblocking'). (c.f. Sema::ActOnNoexceptSpec). Return an empty +

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-08-15 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > @dougsonos Maybe you’ve just not pushed that change yet, but remember to put > an entry for `SemaFunctionEffects.cpp` in the table of contents at the start > of the `Sema` class definition. Thanks. I started to do that and got distracted by a bunch of sections which aren't

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-08-16 Thread Doug Wyatt via cfe-commits
@@ -10941,6 +10941,55 @@ def warn_imp_cast_drops_unaligned : Warning< InGroup>; // Function effects +def warn_func_effect_allocates : Warning< + "'%0' function must not allocate or deallocate memory">, + InGroup; +def note_func_effect_allocates : Note< + "function cannot

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -464,6 +466,16 @@ class ASTContext : public RefCountedBase { /// This is the top-level (C++20) Named module we are building. Module *CurrentCXXNamedModule = nullptr; + class FunctionEffectSetUniquing { +llvm::DenseSet> Set; + + public: +FunctionEffectSet getUn

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4433,218 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +// TODO: Should FunctionEffect be located elsewhere, where Decl is not +// forw

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4433,218 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +// TODO: Should FunctionEffect be located elsewhere, where Decl is not +// forw

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4433,218 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +// TODO: Should FunctionEffect be located elsewhere, where Decl is not +// forw

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -10798,6 +10798,95 @@ def warn_imp_cast_drops_unaligned : Warning< "implicit cast from type %0 to type %1 drops __unaligned qualifier">, InGroup>; +def warn_func_effect_allocates : Warning< + "'%0' function must not allocate or deallocate memory">, dou

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -3144,6 +3154,9 @@ class Sema final { QualType T, TypeSourceInfo *TSInfo, StorageClass SC); + /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify. + void CheckAddCallableWithEffects(const

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -5016,3 +5024,254 @@ void AutoType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::FunctionE

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -5016,3 +5024,254 @@ void AutoType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +FunctionEffect::FunctionE

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4433,218 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +// TODO: Should FunctionEffect be located elsewhere, where Decl is not +// forw

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -1868,6 +1868,28 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType, FromFn = QT->getAs(); Changed = true; } + +if (getLangOpts().CPlusPlus) { + // For C, when called from checkPointerTypesForAssignment, + // we need not to c

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -7959,6 +7979,122 @@ static Attr *getCCTypeAttr(ASTContext &Ctx, ParsedAttr &Attr) { llvm_unreachable("unexpected attribute kind!"); } +static bool +handleNonBlockingNonAllocatingTypeAttr(TypeProcessingState &state, + ParsedAttr &PAt

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,117 @@ +// RUN: %clang_cc1 %s -ast-dump -fblocks | FileCheck %s + +// Make sure that the attribute gets parsed and attached to the correct AST elements. + +#pragma clang diagnostic ignored "-Wunused-variable" + +// =

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > I understand that you’d want to avoid allocating memory for effects over and > over again, but at the same time—I think it’s fine to just don’t cache effect > sets at all. I agree that this would be simpler and fine. > Each effect has a set of properties, which are represen

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > > I understand that you’d want to avoid allocating memory for effects over > > and over again, but at the same time—I think it’s fine to just don’t cache > > effect sets at all. > > I agree that this would be simpler and fine. > > > Each effect has a set of properties, whic

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,117 @@ +// RUN: %clang_cc1 %s -ast-dump -fblocks | FileCheck %s + +// Make sure that the attribute gets parsed and attached to the correct AST elements. + +#pragma clang diagnostic ignored "-Wunused-variable" + +// =

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > One thing I noticed you bring up on Discourse and which I agree is probably > for the better: this pr can just be about introducing an effect system; > actually using it can be deferred to a follow-up pr. This pr is already big > enough if you consider just those changes, an

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-10 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4433,218 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +// TODO: Should FunctionEffect be located elsewhere, where Decl is not +// forw

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-11 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4433,210 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +class Decl; +class CXXMethodDecl; +class FunctionEffectSet; + +/// Represents a

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-11 Thread Doug Wyatt via cfe-commits
@@ -3637,6 +3637,15 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef params, auto &EllipsisLoc = *getTrailingObjects(); EllipsisLoc = epi.EllipsisLoc; } + + if (epi.FunctionEffects) { +auto &ExtraBits = *getTrailingObjects(); +ExtraBits.HasF

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-11 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,190 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// These are in a separate file because errors (e.g. incompatible attributes) currently prevent dougsonos wrote: Split the file. https://github.com/llvm/llvm-project/pull/

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-11 Thread Doug Wyatt via cfe-commits
@@ -1868,6 +1868,28 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType, FromFn = QT->getAs(); Changed = true; } + +if (getLangOpts().CPlusPlus) { + // For C, when called from checkPointerTypesForAssignment, + // we need not to c

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-11 Thread Doug Wyatt via cfe-commits
@@ -18324,6 +18324,47 @@ bool Sema::CheckOverridingFunctionAttributes(const CXXMethodDecl *New, return true; } + // Virtual overrides: check for matching effects. + const auto OldFX = Old->getFunctionEffects(); + const auto NewFX = New->getFunctionEffects(); + + if

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-11 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,117 @@ +// RUN: %clang_cc1 %s -ast-dump -fblocks | FileCheck %s + +// Make sure that the attribute gets parsed and attached to the correct AST elements. + +#pragma clang diagnostic ignored "-Wunused-variable" + +// =

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-12 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4433,210 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +class Decl; +class CXXMethodDecl; +class FunctionEffectSet; + +/// Represents a

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-18 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-18 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-18 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-18 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-18 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-18 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-20 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-20 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-20 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-20 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-06-20 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,141 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -x c -std=c23 %s + +#if !__has_attribute(nonblocking) +#error "the 'nonblocking' attribute is not available" +#endif + +// --- ATTRIBUTE SYNT

[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce RADSan backend (PR #92460)

2024-05-30 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > Looking for weighing in on any of the code as it stands now, or the naming > question posed by MaskRay > [here](https://discourse.llvm.org/t/rfc-nolock-and-noalloc-attributes/76837/75), > so far there seems to be support for rtsan over radsan :) +1 for rtsan https://github

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-15 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4434,284 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +class Decl; +class CXXMethodDecl; +class FunctionTypeEffectsRef; +class Functio

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-15 Thread Doug Wyatt via cfe-commits
dougsonos wrote: I worked out an idea for moving much of the FunctionEffect plumbing out of Type.h, into somewhere under Sema (probably new files because Sema.h is huge). It's outlined in a comment in Type.h. Initial support for an optional conditional expression attached to an effect is now

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-15 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4434,284 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +class Decl; +class CXXMethodDecl; +class FunctionTypeEffectsRef; +class Functio

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-15 Thread Doug Wyatt via cfe-commits
@@ -4429,6 +4434,284 @@ class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { } }; +// -- + +class Decl; +class CXXMethodDecl; +class FunctionTypeEffectsRef; +class Functio

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-16 Thread Doug Wyatt via cfe-commits
dougsonos wrote: > > I think the code to do this could live in the effect set if it were under > > Sema (as I just described) > > Seeing as the effect set is part of the type, at least the parts that are > stored in the `FunctionProtoType` can’t be in Sema and have to stay in the > AST librar

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-25 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,194 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// These are in a separate file because errors (e.g. incompatible attributes) currently prevent +// the AnalysisBasedWarnings pass from running at all. + +// This diagnostic is re-enabled an

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-25 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,194 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// These are in a separate file because errors (e.g. incompatible attributes) currently prevent +// the AnalysisBasedWarnings pass from running at all. + +// This diagnostic is re-enabled an

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-25 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,194 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s +// These are in a separate file because errors (e.g. incompatible attributes) currently prevent +// the AnalysisBasedWarnings pass from running at all. + +// This diagnostic is re-enabled an

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-25 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s + +#pragma clang diagnostic ignored "-Wperf-constraint-implies-noexcept" + +// Objective-C +@interface OCClass +- (void)method; +@end + +void nl14(OCClass *oc) [[clang::nonblocking]] { +

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-25 Thread Doug Wyatt via cfe-commits
@@ -4699,7 +4699,7 @@ class FunctionEffect { private: LLVM_PREFERRED_TYPE(Kind) - unsigned FKind : 3; + uint8_t FKind : 3; dougsonos wrote: (sorry, what's "NFC" in this context?) https://github.com/llvm/llvm-project/pull/99656 ___

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-25 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/99656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-25 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/99656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-25 Thread Doug Wyatt via cfe-commits
@@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -fcxx-exceptions -verify %s + +#pragma clang diagnostic ignored "-Wperf-constraint-implies-noexcept" + +// Objective-C +@interface OCClass +- (void)method; +@end + +void nl14(OCClass *oc) [[clang::nonblocking]] { +

[clang] [NFC] Reduce size of FunctionEffect to 1 byte. (PR #100753)

2024-07-26 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos created https://github.com/llvm/llvm-project/pull/100753 As a preliminary to PR https://github.com/llvm/llvm-project/pull/99656 , reduce the size of `FunctionEffect` to 1 byte. >From 3cc18ded835f3a25dc98bc81988d3a2f1181c300 Mon Sep 17 00:00:00 2001 From: Doug Wyatt

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -4699,7 +4699,7 @@ class FunctionEffect { private: LLVM_PREFERRED_TYPE(Kind) - unsigned FKind : 3; + uint8_t FKind : 3; dougsonos wrote: Opened PR https://github.com/llvm/llvm-project/pull/100753 for this. https://github.com/llvm/llvm-project/pull/996

[clang] [NFC] Reduce size of FunctionEffect to 1 byte. (PR #100753)

2024-07-26 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos updated https://github.com/llvm/llvm-project/pull/100753 >From 3cc18ded835f3a25dc98bc81988d3a2f1181c300 Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Sun, 5 May 2024 12:36:53 -0700 Subject: [PATCH 1/2] Reduce size of FunctionEffect to 1 byte. --- clang/include/c

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -15609,6 +15661,10 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D, getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation) Diag(FD->getLocation(), diag::warn_function_def_in_objc_container); + if (Context.hasAnyFunctionEffects()) +

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/99656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/99656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/99656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -873,30 +873,17 @@ class Sema final : public SemaBase { /// Warn when implicitly casting 0 to nullptr. void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E); - // - function effects --- + /// All functions/lambdas/blocks which have bodies and which ha

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-26 Thread Doug Wyatt via cfe-commits
@@ -10897,6 +10902,53 @@ Attr *Sema::getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, return nullptr; } +// Should only be called when getFunctionEffects() returns a non-empty set. +// Decl should be a FunctionDecl or BlockDecl. +void Sema::maybeAddDeclWit

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-27 Thread Doug Wyatt via cfe-commits
@@ -4699,7 +4699,7 @@ class FunctionEffect { private: LLVM_PREFERRED_TYPE(Kind) - unsigned FKind : 3; + uint8_t FKind : 3; dougsonos wrote: That PR has been merged. https://github.com/llvm/llvm-project/pull/99656 _

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-30 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-30 Thread Doug Wyatt via cfe-commits
@@ -10897,6 +10902,53 @@ Attr *Sema::getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, return nullptr; } +// Should only be called when getFunctionEffects() returns a non-empty set. +// Decl should be a FunctionDecl or BlockDecl. +void Sema::maybeAddDeclWit

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-30 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/99656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-30 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] Performance optimizations for function effects (nonblocking attribute etc.) (PR #96844)

2024-07-17 Thread Doug Wyatt via cfe-commits
dougsonos wrote: It would be great if we could merge this soon, please; I'd to start another PR for the 2nd-pass effects analysis and it has a dependency or two on these changes. https://github.com/llvm/llvm-project/pull/96844 ___ cfe-commits mailing

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-19 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos created https://github.com/llvm/llvm-project/pull/99656 - In Sema, when encountering Decls with function effects needing verification, add them to a vector, DeclsWithEffectsToVerify. - Update AST serialization to include DeclsWithEffectsToVerify. - In AnalysisBasedW

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-19 Thread Doug Wyatt via cfe-commits
@@ -4699,7 +4699,7 @@ class FunctionEffect { private: LLVM_PREFERRED_TYPE(Kind) - unsigned FKind : 3; + uint8_t FKind : 3; dougsonos wrote: The size of FunctionEffect changes from 4 (sizeof(unsigned)) to 1, and saves on memory footprint in the new analys

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-19 Thread Doug Wyatt via cfe-commits
@@ -10928,6 +10928,55 @@ def warn_imp_cast_drops_unaligned : Warning< InGroup>; // Function effects +def warn_func_effect_allocates : Warning< + "'%0' function must not allocate or deallocate memory">, + InGroup; +def note_func_effect_allocates : Note< + "function cannot

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-19 Thread Doug Wyatt via cfe-commits
@@ -2551,6 +3807,9 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings( SourceLocation())) { CallableVisitor(CallAnalyzers).TraverseTranslationUnitDecl(TU); } + + if (S.Context.hasAnyFunctionEffects()) dougsonos wrote: This

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-19 Thread Doug Wyatt via cfe-commits
@@ -2397,6 +2397,1262 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { }; } // namespace +// = + +namespace FXAnalysis { + +enum class DiagnosticID : uint8_t { + None = 0, // s

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-20 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos updated https://github.com/llvm/llvm-project/pull/99656 >From 8c5f85492091df2432701f15f4ec4b6acfe19944 Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Sun, 5 May 2024 12:36:53 -0700 Subject: [PATCH 1/2] nonblocking/nonallocating attributes: 2nd pass caller/callee a

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-20 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos updated https://github.com/llvm/llvm-project/pull/99656 >From 8c5f85492091df2432701f15f4ec4b6acfe19944 Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Sun, 5 May 2024 12:36:53 -0700 Subject: [PATCH 1/3] nonblocking/nonallocating attributes: 2nd pass caller/callee a

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-20 Thread Doug Wyatt via cfe-commits
@@ -891,6 +898,12 @@ class Sema final : public SemaBase { SourceLocation NewLoc, SourceLocation OldLoc); + /// Potentially add a FunctionDecl or BlockDecl to DeclsWithEffectsToVerify. + void maybeA

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-07-20 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/99656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-23 Thread Doug Wyatt via cfe-commits
@@ -5016,3 +5041,345 @@ void AutoType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) { Profile(ID, Context, getDeducedType(), getKeyword(), isDependentType(), getTypeConstraintConcept(), getTypeConstraintArguments()); } + +StringRef FunctionEffect:

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-23 Thread Doug Wyatt via cfe-commits
@@ -3637,6 +3637,28 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef params, auto &EllipsisLoc = *getTrailingObjects(); EllipsisLoc = epi.EllipsisLoc; } + + if (!epi.FunctionEffects.empty()) { +auto &ExtraBits = *getTrailingObjects(); +// TO

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-24 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos deleted https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes (was: nolock/noalloc) (PR #84983)

2024-04-24 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos deleted https://github.com/llvm/llvm-project/pull/84983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-08-29 Thread Doug Wyatt via cfe-commits
@@ -210,24 +210,88 @@ void nb18(void (^block)() [[clang::nonblocking]]) [[clang::nonblocking]] } // Builtin functions -void nb18a() [[clang::nonblocking]] { +void nb19() [[clang::nonblocking]] { __builtin_assume(1); void *ptr = __builtin_malloc(1); // expected

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-08-29 Thread Doug Wyatt via cfe-commits
@@ -908,9 +936,9 @@ class Analyzer { static bool isSafeBuiltinFunction(const FunctionDecl *FD) { unsigned BuiltinID = FD->getBuiltinID(); switch (BuiltinID) { - case 0: // not builtin + case 0: // Not builtin. return false; - default: //

[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)

2024-08-29 Thread Doug Wyatt via cfe-commits
@@ -1,44 +1,67 @@ -//=== EffectAnalysis.cpp - Sema warnings for function effects -===// +//=== SemaFunctionEffects.cpp - Sema handling of function effects -===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See ht

[clang] Performance optimizations for function effects (nonblocking attribute etc.) (PR #96844)

2024-07-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos updated https://github.com/llvm/llvm-project/pull/96844 >From 038b39d3235c6c8151127c34d34f498dd298273c Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Wed, 26 Jun 2024 10:03:25 -0700 Subject: [PATCH 1/2] Performance optimizations for function effects: - Put new Fun

[clang] Performance optimizations for function effects (nonblocking attribute etc.) (PR #96844)

2024-07-12 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos updated https://github.com/llvm/llvm-project/pull/96844 >From 038b39d3235c6c8151127c34d34f498dd298273c Mon Sep 17 00:00:00 2001 From: Doug Wyatt Date: Wed, 26 Jun 2024 10:03:25 -0700 Subject: [PATCH 1/4] Performance optimizations for function effects: - Put new Fun

[clang] Performance optimizations for function effects (nonblocking attribute etc.) (PR #96844)

2024-07-12 Thread Doug Wyatt via cfe-commits
dougsonos wrote: Added a further tweak: add a bool to ASTContext to track whether any FunctionProtoType's with effects have been created, so that Sema can short-circuit checks involving effects when it knows no one has any. This seems to have the desired effect of only paying for the feature w

[clang] [llvm] [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (PR #90702)

2024-04-30 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos created https://github.com/llvm/llvm-project/pull/90702 This addresses an issue where the explicit alignment of 2 (for C++ ABI reasons) was being propagated to the back end and causing under-aligned functions (in special sections). (#90358) This is an alternate ap

[clang] [llvm] [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (PR #90702)

2024-04-30 Thread Doug Wyatt via cfe-commits
@@ -5387,6 +5387,14 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) { return Res; } + // AArch64 data layout upgrades. + if (T.isAArch64()) { +// Add "-Fn32" +if (!DL.contains("-Fn32")) + Res.append("-Fn32"); doug

[clang] [llvm] [clang backend] In AArch64's DataLayout, specify a minimum function alignment of 4. (PR #90702)

2024-04-30 Thread Doug Wyatt via cfe-commits
https://github.com/dougsonos edited https://github.com/llvm/llvm-project/pull/90702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

<    1   2   3   4   5   >