https://github.com/melver edited
https://github.com/llvm/llvm-project/pull/127396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/melver edited
https://github.com/llvm/llvm-project/pull/127396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
melver wrote:
(Side-note: I cannot figure out what the canonical way to do "stacked commits"
is for LLVM these days, so I'm just doing this the "old" way i.e. plain and
simple normal git commits which I will commit separately after PR review.)
https://github.com/llvm/llvm-project/pull/127396
_
https://github.com/melver created
https://github.com/llvm/llvm-project/pull/127397
Correctly analyze expressions where the address of a guarded variable is taken
and immediately dereferenced, such as (*(type-specifier *)&x). Previously, such
patterns would result in false negatives.
>From a70
https://github.com/melver updated
https://github.com/llvm/llvm-project/pull/127396
>From 13e86fc43071af4c926d3c2d4662423f5c5b4fe8 Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Sun, 16 Feb 2025 12:42:06 +0100
Subject: [PATCH] Thread Safety Analysis: Support warning on passing/returning
point
https://github.com/melver created
https://github.com/llvm/llvm-project/pull/127396
Introduce `-Wthread-safety-pointer` (under `-Wthread-safety-beta`) to warn when
passing or returning pointers to guarded variables or guarded data. This is is
analogous to `-Wthread-safety-reference`, which perf
melver wrote:
> I'm very excited about this, as I have wanted it for many years for my C
> codebase, and TSA is not super useful in C without this!
This PR is being superseded by https://github.com/llvm/llvm-project/pull/127396
(implementation changed completely) - we agreed to go with the mor
melver wrote:
Gentle ping.
Thanks!
https://github.com/llvm/llvm-project/pull/127396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/melver closed
https://github.com/llvm/llvm-project/pull/127396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Author: Marco Elver
Date: 2025-02-26T16:34:33+01:00
New Revision: de10e44b6fe7f3d3cfde3afd8e1222d251172ade
URL:
https://github.com/llvm/llvm-project/commit/de10e44b6fe7f3d3cfde3afd8e1222d251172ade
DIFF:
https://github.com/llvm/llvm-project/commit/de10e44b6fe7f3d3cfde3afd8e1222d251172ade.diff
L
Author: Marco Elver
Date: 2025-02-26T16:34:33+01:00
New Revision: 3c8c0d4d8d9bbc160d160e683f7a74fd28574dc6
URL:
https://github.com/llvm/llvm-project/commit/3c8c0d4d8d9bbc160d160e683f7a74fd28574dc6
DIFF:
https://github.com/llvm/llvm-project/commit/3c8c0d4d8d9bbc160d160e683f7a74fd28574dc6.diff
L
melver wrote:
Committed!
> Looks good to me, and thanks for the contribution!
Thanks for your review!
Fingers crossed the Linux kernel changes will also land soon.
> > Note, I think for now it might be safer to not enable by default yet, but
> > I've made a note (and hinted at in changelog)
https://github.com/melver closed
https://github.com/llvm/llvm-project/pull/123063
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -528,6 +529,9 @@ for a period of time, after which they are migrated into
the standard analysis.
* ``-Wthread-safety-beta``: New features. Off by default.
+ + ``-Wthread-safety-pointer``: Checks when passing or returning pointers to
+guarded variables, or pointers
@@ -4955,13 +4968,18 @@ class Foo {
//showDataCell(*datap2_); // xpected-warning {{reading the value pointed
to by 'datap2_' requires holding mutex 'mu_'}}
int a = data_[0]; // expected-warning {{reading variable 'data_'
requires holding mutex 'mu_'}}
+
+(v
https://github.com/melver updated
https://github.com/llvm/llvm-project/pull/127396
>From f9fec4c8415b2b9c802b1d7ecdcc9f5cb038f7be Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Sun, 16 Feb 2025 14:53:41 +0100
Subject: [PATCH 1/2] Thread Safety Analysis: Handle address-of followed by
derefere
@@ -528,6 +529,9 @@ for a period of time, after which they are migrated into
the standard analysis.
* ``-Wthread-safety-beta``: New features. Off by default.
+ + ``-Wthread-safety-pointer``: Checks when passing or returning pointers to
+guarded variables, or pointers
https://github.com/melver edited
https://github.com/llvm/llvm-project/pull/127396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
melver wrote:
> I think this looks very good! I just have some minor remarks.
>
> Thanks to @aoates for trying this out, this is always appreciated!
>
> And sorry for the delay.
Thanks for the review! I addressed the comments, PTAL.
Note, I think for now it might be safer to not enable by def
https://github.com/melver updated
https://github.com/llvm/llvm-project/pull/127396
>From f9fec4c8415b2b9c802b1d7ecdcc9f5cb038f7be Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Sun, 16 Feb 2025 14:53:41 +0100
Subject: [PATCH 1/2] Thread Safety Analysis: Handle address-of followed by
derefere
https://github.com/melver edited
https://github.com/llvm/llvm-project/pull/127396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/melver edited
https://github.com/llvm/llvm-project/pull/123063
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/melver updated
https://github.com/llvm/llvm-project/pull/127396
>From a70f021becb2888d6c2a63b2d1e619393a996058 Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Sun, 16 Feb 2025 14:53:41 +0100
Subject: [PATCH 1/2] Thread Safety Analysis: Handle address-of followed by
derefere
@@ -143,6 +143,11 @@ Improvements to Clang's diagnostics
- A statement attribute applied to a ``case`` label no longer suppresses
'bypassing variable initialization' diagnostics (#84072).
+- The :doc:`ThreadSafetyAnalysis` now supports ``-Wthread-safety-pointer``
---
melver wrote:
> I only have a few comments about documenting the caveats (no alias analysis).
>
> The actual code changes look very simple and this looks like a clear
> improvement that would catch many useful cases.
>
> I don't have much experience with this code and would still advise to wai
melver wrote:
> > I need to commit this by end of day Wednesday - if I should wait a little
> > longer, let me know so I can plan around it. Thanks.
>
> Sorry, but I'm at C standards meetings this week, so I don't think I'll be
> able to review it by then. CC @aaronpuchert who maybe can help?
@@ -6087,9 +6215,37 @@ class Return {
const Foo &returns_constref_shared_locks_required()
SHARED_LOCKS_REQUIRED(mu) {
return foo;
}
+
+ Foo *returns_ptr_exclusive_locks_required() EXCLUSIVE_LOCKS_REQUIRED(mu) {
+return &foo;
+ }
+
+ Foo *returns_pt_ptr_exclusive
Author: Marco Elver
Date: 2025-05-09T20:14:30+02:00
New Revision: 49c22e3ee147326668aa0b2097f857d0b0c2a81e
URL:
https://github.com/llvm/llvm-project/commit/49c22e3ee147326668aa0b2097f857d0b0c2a81e
DIFF:
https://github.com/llvm/llvm-project/commit/49c22e3ee147326668aa0b2097f857d0b0c2a81e.diff
L
@@ -235,6 +266,20 @@ class FactSet {
return false;
}
+ std::optional replaceLock(FactManager &FM, iterator It,
+std::unique_ptr Entry) {
+if (It == end())
+ return std::nullopt;
+FactID F = FM.newFact(std::move(Entry));
+
melver wrote:
Thanks for the feedback. Addressed comments as best as I could.
Most notable changes:
- Also warns properly for loops with mismatching reentrancy depth.
- Devirtualized new helpers.
- Require ordering `reentrant_capability` after `capability`.
- Stylistic improvements.
PTAL.
http
@@ -1011,6 +979,30 @@ void SExprBuilder::exitCFG(const CFGBlock *Last) {
IncompleteArgs.clear();
}
+static CapabilityExpr makeCapabilityExpr(const til::SExpr *E, QualType VDT,
+ bool Neg) {
+ // We need to look at the declaration of t
@@ -271,26 +272,34 @@ class CFGWalker {
// translateAttrExpr needs it, but that should be moved too.
class CapabilityExpr {
private:
- /// The capability expression and whether it's negated.
- llvm::PointerIntPair CapExpr;
+ static constexpr unsigned FlagNegative = 1u << 0;
@@ -4048,6 +4048,9 @@ def warn_thread_attribute_not_on_scoped_lockable_param :
Warning<
"%0 attribute applies to function parameters only if their type is a "
"reference to a 'scoped_lockable'-annotated type">,
InGroup, DefaultIgnore;
+def warn_reentrant_capability_witho
@@ -271,26 +271,32 @@ class CFGWalker {
// translateAttrExpr needs it, but that should be moved too.
class CapabilityExpr {
private:
- /// The capability expression and whether it's negated.
- llvm::PointerIntPair CapExpr;
+ /// The capability expression and flags.
+ llvm::
melver wrote:
Gentle ping - PTAL.
Many thanks!
https://github.com/llvm/llvm-project/pull/137133
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/melver updated
https://github.com/llvm/llvm-project/pull/137133
>From b264872c3f28f6cf172b0123087adda9d53dc1b9 Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Wed, 23 Apr 2025 11:31:25 +0200
Subject: [PATCH 1/2] Thread Safety Analysis: Convert CapabilityExpr::CapExpr
to hol
@@ -271,26 +271,32 @@ class CFGWalker {
// translateAttrExpr needs it, but that should be moved too.
class CapabilityExpr {
private:
- /// The capability expression and whether it's negated.
- llvm::PointerIntPair CapExpr;
+ /// The capability expression and flags.
+ llvm::
https://github.com/melver created
https://github.com/llvm/llvm-project/pull/141599
The purpose of negative capabilities is documented as helping to prevent double
locking, which is not an issue for most reentrant capabilities (such as
mutexes).
Introduce a pedantic warning group, which is ena
Author: Marco Elver
Date: 2025-05-26T16:59:51+02:00
New Revision: 365dcf48b8aa726fb6a9ace4b37eb1f1cf121941
URL:
https://github.com/llvm/llvm-project/commit/365dcf48b8aa726fb6a9ace4b37eb1f1cf121941
DIFF:
https://github.com/llvm/llvm-project/commit/365dcf48b8aa726fb6a9ace4b37eb1f1cf121941.diff
L
https://github.com/melver updated
https://github.com/llvm/llvm-project/pull/137133
>From b8754a894e8822c43dfce62b7d13d5169ea4a215 Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Thu, 24 Apr 2025 09:02:08 +0200
Subject: [PATCH] Thread Safety Analysis: Support reentrant capabilities
Introduce t
https://github.com/melver created
https://github.com/llvm/llvm-project/pull/141500
In ScopedLockableFactEntry::unlock(), we can avoid a second search, pop_back(),
and push_back() if we use the already obtained iterator into the FactSet to
replace the old FactEntry and take its position in the
https://github.com/melver closed
https://github.com/llvm/llvm-project/pull/137133
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
melver wrote:
> @melver, this request came from @AaronBallman. But since you're also working
> on Thread Safety Analysis in C, you might have some thoughts of your own
> about this.
>
> I haven't checked any real-world code yet. (Specifically, how many functions
> would be affected by this ex
https://github.com/melver updated
https://github.com/llvm/llvm-project/pull/137133
>From bce9df281e5ea7c2efd9c880f791f6572732c31d Mon Sep 17 00:00:00 2001
From: Marco Elver
Date: Wed, 23 Apr 2025 11:31:25 +0200
Subject: [PATCH 1/2] Thread Safety Analysis: Convert CapabilityExpr::CapExpr
to hol
melver wrote:
As additional motivation - quote from a kernel maintainer:
> But I think we should get the infrastructure in once your reentrancy
> support has landed in a release, because with that we can start
> annotation some code and show uses, while also helping to driver more
> requirements
101 - 145 of 145 matches
Mail list logo