https://github.com/JustinStitt created
https://github.com/llvm/llvm-project/pull/86618
## Intro
This attribute would allow for more granular control over what expressions can
emit integer overflow warnings or integer overflow sanitizer errors.
Here are some examples:
_copy-pasted from m
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 0fa8f07c722f9d7f80a90824f961ae6e9c5bdef7 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 1/2] implement wraps attribute
Signed-off-by: Justin Stitt
---
JustinStitt wrote:
cc: @MaskRay (since they also reviewed
https://github.com/llvm/llvm-project/pull/82432)
https://github.com/llvm/llvm-project/pull/86618
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/l
JustinStitt wrote:
> Adding attributes to types as type sugar (not part of the canonical type) is
> generally problematic: non-canonical types are not reliably preserved
> throughout the compiler, particularly in cases involving templates.
I see, here's an example that currently breaks my attr
JustinStitt wrote:
ping!
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECKSIW
+
+// Check that -fsanitize=signed-integer-over
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/80089
>From 7774e4036ac1de7fdf5fe4c6b3208b492853ffc5 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jan 2024 23:28:42 +
Subject: [PATCH 1/6] add signed-integer-wrap sanitizer
---
clang/include/clan
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/80089
>From 7774e4036ac1de7fdf5fe4c6b3208b492853ffc5 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jan 2024 23:28:42 +
Subject: [PATCH 1/8] add signed-integer-wrap sanitizer
---
clang/include/clan
@@ -3554,12 +3572,20 @@ Value
*ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
const std::string *handlerName =
&CGF.getLangOpts().OverflowHandler;
if (handlerName->empty()) {
-// If the signed-integer-overflow sanitizer is enabled, emit a call
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECKSIW
+
+// Check that -fsanitize=signed-integer-over
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECKSIW
+
+// Check that -fsanitize=signed-integer-over
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
JustinStitt wrote:
Gotcha, I did just that in
[5497e8b](https://github.com/llvm/llvm-project/pull/80089/commits/5497e8bc6849bf64c1158ff16b4aa04fd9141920).
Thanks Nick!
http
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/80089
>From 7774e4036ac1de7fdf5fe4c6b3208b492853ffc5 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jan 2024 23:28:42 +
Subject: [PATCH 1/9] add signed-integer-wrap sanitizer
---
clang/include/clan
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/80089
>From 7774e4036ac1de7fdf5fe4c6b3208b492853ffc5 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jan 2024 23:28:42 +
Subject: [PATCH 01/10] add signed-integer-wrap sanitizer
---
clang/include/cl
JustinStitt wrote:
> UBSan is documented clang/docs/UndefinedBehaviorSanitizer.rst
> https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
>
> Please make sure to update the list [of available
> checks](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks).
>
>
https://github.com/JustinStitt created
https://github.com/llvm/llvm-project/pull/80089
**Reasoning**
Clang has a `signed-integer-overflow` sanitizer to catch arithmetic overflow;
however, most* of its instrumentation [fails to
apply](https://godbolt.org/z/ee41rE8o6) when `-fwrapv` is enabled.
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/80089
>From 68805d7871230033be43c1d87dfcd2aa2b668589 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jan 2024 23:28:42 +
Subject: [PATCH 1/4] add signed-integer-wrap sanitizer
---
clang/include/clan
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/80089
>From 68805d7871230033be43c1d87dfcd2aa2b668589 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jan 2024 23:28:42 +
Subject: [PATCH 1/5] add signed-integer-wrap sanitizer
---
clang/include/clan
@@ -0,0 +1,66 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECK
+
+// Check that -fsanitize=signed-integer-overflo
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
JustinStitt wrote:
I must be doing something wrong because it suggest I remove all my `Check:
...`'s and replcae them with `Check: {{.*}}`
https://github.com/llvm/llvm-proje
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECK
JustinStitt wrote:
> `CHECK` is
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
JustinStitt wrote:
Hey, does anyone know why the CI bot (buildkite) fails my builds for a trailing
whitespace in a file I did not touch?
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://li
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/80089
>From 68805d7871230033be43c1d87dfcd2aa2b668589 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jan 2024 23:28:42 +
Subject: [PATCH 1/6] add signed-integer-wrap sanitizer
---
clang/include/clan
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECK
JustinStitt wrote:
Gotcha. Fixed
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECKSIW
+
+// Check that -fsanitize=signed-integer-over
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
JustinStitt wrote:
I believe @tschuett was saying that to be confident we are instrumenting the
arithmetic (and the correct operands therein) we should check the overflow bit
https://github.com/JustinStitt deleted
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,77 @@
+// Check that -fsanitize=signed-integer-wrap instruments with -fwrapv
+// RUN: %clang_cc1 -fwrapv -triple x86_64-apple-darwin -emit-llvm -o - %s
-fsanitize=signed-integer-wrap | FileCheck %s --check-prefix=CHECKSIW
+
+// Check that -fsanitize=signed-integer-over
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt approved this pull request.
LGTM!
FWIW, here's a test file that does not trip the sanitizer before this PR and
_does_ trip after the PR:
```c
#include
int main(int argc, char **argv) {
void *p = NULL;
printf("p: %p\n", p);
p = p - argc;
printf("p: %p\n"
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/80089
>From 7774e4036ac1de7fdf5fe4c6b3208b492853ffc5 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jan 2024 23:28:42 +
Subject: [PATCH 01/11] add signed-integer-wrap sanitizer
---
clang/include/cl
JustinStitt wrote:
> I think this patch is good to go. Thanks for working on it!
Thanks for the review Nick! BTW, I forgot to update the `ReleaseNotes.rst`,
I've done so now (hopefully not voiding your previous review)
https://github.com/llvm/llvm-project/pull/80089
_
JustinStitt wrote:
My original idea was to get the SIO sanitizer working with `-fwrapv`, the issue
[here](https://github.com/KSPP/linux/issues/26) even suggests it as a viable
option. However, after seeing literal checks like:
```cpp
case LangOptions::SOB_Undefined:
if (!CGF.SanOpts.ha
JustinStitt wrote:
> I believe we can move forward by reusing
> `-fsanitize=signed-integer-overflow`, which adds least complexity to Clang
> and is very reasonable.
I see a few problems with changing `-fsanitize=signed-integer-overflow`:
1) Clang no longer matches GCC's SIO functionality
2)
@@ -193,7 +193,14 @@ Available checks are:
signed division overflow (``INT_MIN/-1``), but not checks for
lossy implicit conversions performed before the computation
(see ``-fsanitize=implicit-conversion``). Both of these two issues are
- handled by ``-fsaniti
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -193,7 +193,14 @@ Available checks are:
signed division overflow (``INT_MIN/-1``), but not checks for
lossy implicit conversions performed before the computation
(see ``-fsanitize=implicit-conversion``). Both of these two issues are
- handled by ``-fsaniti
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -193,7 +193,14 @@ Available checks are:
signed division overflow (``INT_MIN/-1``), but not checks for
lossy implicit conversions performed before the computation
(see ``-fsanitize=implicit-conversion``). Both of these two issues are
- handled by ``-fsaniti
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/80089
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt created
https://github.com/llvm/llvm-project/pull/82432
**Reasoning**
Clang has a `signed-integer-overflow` sanitizer to catch arithmetic overflow;
however, most of its instrumentation [fails to
apply](https://godbolt.org/z/ee41rE8o6) when `-fwrapv` is enabled; t
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/82432
>From b02b09b9eb4f9a8ac60dd077d95c67b959db3b70 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 20 Feb 2024 22:21:02 +
Subject: [PATCH 1/2] support fwrapv with signed int overflow sanitizer
---
cl
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/82432
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
JustinStitt wrote:
> ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️
>
> You can test this locally with the following command:
> View the diff from clang-format here.
Fixed in
[e5e92e6](https://github.com/llvm/llvm-project/pull/82432/commits/e5e92e6c07a9fbbac698a3b6bb4422f2
@@ -723,7 +723,9 @@ class ScalarExprEmitter
if (Ops.Ty->isSignedIntegerOrEnumerationType()) {
switch (CGF.getLangOpts().getSignedOverflowBehavior()) {
case LangOptions::SOB_Defined:
-return Builder.CreateMul(Ops.LHS, Ops.RHS, "mul");
+if (!CGF.Sa
@@ -399,6 +399,9 @@ Moved checkers
Sanitizers
--
+- ``-fsanitize=signed-integer-overflow`` now instruments signed arithmetic even
+ when ``-fwrapv`` is enabled. Previously, only division checks were enabled.
JustinStitt wrote:
Doesn't `-fno-sanitizer
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/82432
>From b02b09b9eb4f9a8ac60dd077d95c67b959db3b70 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 20 Feb 2024 22:21:02 +
Subject: [PATCH 1/3] support fwrapv with signed int overflow sanitizer
---
cl
@@ -399,6 +399,9 @@ Moved checkers
Sanitizers
--
+- ``-fsanitize=signed-integer-overflow`` now instruments signed arithmetic even
+ when ``-fwrapv`` is enabled. Previously, only division checks were enabled.
JustinStitt wrote:
Gotcha, resolved with
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/82432
>From b02b09b9eb4f9a8ac60dd077d95c67b959db3b70 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 20 Feb 2024 22:21:02 +
Subject: [PATCH 1/4] support fwrapv with signed int overflow sanitizer
---
cl
@@ -70,6 +77,7 @@ void test1(void) {
// WRAPV: add i8 {{.*}}, 1
JustinStitt wrote:
How's
[1d9cb0a](https://github.com/llvm/llvm-project/pull/82432/commits/1d9cb0aca8985aa1636780b3ff9a863962cc2d57)
look?
https://github.com/llvm/llvm-project/pull/82432
__
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/82432
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 06250aa308d1662848726528bd31395fb2ad3ea0 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH] implement wraps attribute
Signed-off-by: Justin Stitt
---
cl
https://github.com/JustinStitt created
https://github.com/llvm/llvm-project/pull/107332
[Related
RFC](https://discourse.llvm.org/t/rfc-support-globpattern-add-operator-to-invert-matches/80683/5?u=justinstitt)
### Summary
Implement type-based filtering via [Sanitizer Special Case
Lists](https
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/107332
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 154d3505ab13275086b3dffed67bcdcac52f79a3 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 1/8] implement idiom exclusions
Add flag `-fno-sanitize-overf
@@ -4248,6 +4248,22 @@ bool CompilerInvocation::ParseLangArgs(LangOptions
&Opts, ArgList &Args,
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
}
+ if (auto *A = Args.getLastArg(OPT_fsanitize_overflow_pattern_exclusion_EQ)) {
+for (int i
@@ -0,0 +1,83 @@
+// Check for potential false positives from patterns that _almost_ match
classic overflow-dependent or overflow-prone code patterns
JustinStitt wrote:
resolved in 4b3efbb41ff86eeff15671b1d876e1ef6a58a536
https://github.com/llvm/llvm-project/pu
@@ -293,6 +293,40 @@ To silence reports from unsigned integer overflow, you can
set
``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for
providing fuzzing signal without blowing up logs.
+Disabling instrumentation for common overflow patterns
+
@@ -555,6 +570,11 @@ class LangOptions : public LangOptionsBase {
/// The default stream kind used for HIP kernel launching.
GPUDefaultStreamKind GPUDefaultStream;
+ /// Which overflow patterns should be excluded from sanitizer instrumentation
+ int OverflowPatternExclus
@@ -293,6 +293,40 @@ To silence reports from unsigned integer overflow, you can
set
``-fsanitize-recover=unsigned-integer-overflow``, is particularly useful for
providing fuzzing signal without blowing up logs.
+Disabling instrumentation for common overflow patterns
+
@@ -2877,6 +2888,17 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const
UnaryOperator *E, LValue LV,
} else if (type->isIntegerType()) {
QualType promotedType;
bool canPerformLossyDemotionCheck = false;
+
+// Is the pattern "while (i--)" and overflow exclusion?
+
JustinStitt wrote:
@bwendling I tried to address all your feedback points with
4b3efbb41ff86eeff15671b1d876e1ef6a58a536 Let me know how that looks 👍
https://github.com/llvm/llvm-project/pull/100272
___
cfe-commits mailing list
cfe-commits@lists.llvm.
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 154d3505ab13275086b3dffed67bcdcac52f79a3 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 1/9] implement idiom exclusions
Add flag `-fno-sanitize-overf
@@ -4759,6 +4759,55 @@ ParenListExpr *ParenListExpr::CreateEmpty(const
ASTContext &Ctx,
return new (Mem) ParenListExpr(EmptyShell(), NumExprs);
}
+namespace {
JustinStitt wrote:
resolved by
https://github.com/llvm/llvm-project/pull/100272/commits/2e3d4795
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 154d3505ab13275086b3dffed67bcdcac52f79a3 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 01/10] implement idiom exclusions
Add flag `-fno-sanitize-ove
@@ -195,13 +196,23 @@ static bool CanElideOverflowCheck(const ASTContext &Ctx,
const BinOpInfo &Op) {
if (!Op.mayHaveIntegerOverflow())
return true;
+ const UnaryOperator *UO = dyn_cast(Op.E);
+
+ if (UO && UO->getOpcode() == UO_Minus && UO->isIntegerConstantExpr(Ctx)
@@ -3860,6 +3860,7 @@ class CStyleCastExpr final
class BinaryOperator : public Expr {
enum { LHS, RHS, END_EXPR };
Stmt *SubExprs[END_EXPR];
+ bool ExcludedOverflowPattern = false;
JustinStitt wrote:
Ok, I think I found a spare bit in `BinaryOperatorBits`
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 154d3505ab13275086b3dffed67bcdcac52f79a3 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 01/11] implement idiom exclusions
Add flag `-fno-sanitize-ove
@@ -649,6 +649,8 @@ class alignas(void *) Stmt {
/// It is 0 otherwise.
LLVM_PREFERRED_TYPE(bool)
unsigned HasFPFeatures : 1;
+LLVM_PREFERRED_TYPE(bool)
JustinStitt wrote:
Good idea, see
https://github.com/llvm/llvm-project/pull/100272/commits
JustinStitt wrote:
> 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.
It's queried when we check
JustinStitt wrote:
A good example of a Linux kernel contributor running into an overflow that
should really have its type marked as wrapping :
https://lore.kernel.org/all/zrzk8hiladaj+...@gmail.com/
They could use this feature to mark the suspected field
`percpu_ref->percpu_ref_data->count` a
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 154d3505ab13275086b3dffed67bcdcac52f79a3 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 01/12] implement idiom exclusions
Add flag `-fno-sanitize-ove
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 154d3505ab13275086b3dffed67bcdcac52f79a3 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 01/13] implement idiom exclusions
Add flag `-fno-sanitize-ove
JustinStitt wrote:
@bwendling we want to use `-triple` not `-target`, can you cherry pick
3ef83ad323dfbe99028c774c3716706671ba7b8b
I also reordered the tests and added labels so the tests are actually checking
the right stuff -- debugging was really difficult but will be easier now.
https://g
JustinStitt wrote:
> Sorry, but I am not sure why this didn't show up my
> https://github.com/llvm/llvm-project/pulls?q=is%3Aopen+is%3Apr+review-requested%3A%40me+sort%3Aupdated-desc
> I wanted to review this patch.
Did I do something wrong with my PR or fork settings? I am not sure why you
w
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 0fa8f07c722f9d7f80a90824f961ae6e9c5bdef7 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 1/4] implement wraps attribute
Signed-off-by: Justin Stitt
---
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 10ee32826fc2acb6bd993c88bdb7142360b6f263 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 1/3] implement wraps attribute
Signed-off-by: Justin Stitt
---
JustinStitt wrote:
Hi, I've made some changes and am looking for some more review on this PR:
* This attribute no longer supports C++ as there are other solutions for that
language [1] that allow for the same fine-grained wrapping control without
changing syntax patterns.
* Add bypass for impl
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/86618
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/86618
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/86618
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 10ee32826fc2acb6bd993c88bdb7142360b6f263 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 1/4] implement wraps attribute
Signed-off-by: Justin Stitt
---
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 10ee32826fc2acb6bd993c88bdb7142360b6f263 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 1/7] implement wraps attribute
Signed-off-by: Justin Stitt
---
@@ -4077,6 +4077,9 @@ class BinaryOperator : public Expr {
static unsigned sizeOfTrailingObjects(bool HasFPFeatures) {
return HasFPFeatures * sizeof(FPOptionsOverride);
}
+
+ /// Do one of the subexpressions have the wraps attribute?
+ bool oneOfWraps(const ASTContext
@@ -4506,3 +4506,9 @@ def CodeAlign: StmtAttr {
static constexpr int MaximumAlignment = 4096;
}];
}
+
+def Wraps : DeclOrTypeAttr {
+ let Spellings = [GNU<"wraps">];
JustinStitt wrote:
Right, I had that originally. I shouldn't have changed it :)
Anyway
@@ -4506,3 +4506,9 @@ def CodeAlign: StmtAttr {
static constexpr int MaximumAlignment = 4096;
}];
}
+
+def Wraps : DeclOrTypeAttr {
+ let Spellings = [GNU<"wraps">];
+ let Subjects = SubjectList<[Var, TypedefName, Field]>;
+ let Documentation = [WrapsDocs];
+}
@@ -2237,6 +2237,21 @@ bool
BinaryOperator::isNullPointerArithmeticExtension(ASTContext &Ctx,
return true;
}
+bool BinaryOperator::oneOfWraps(const ASTContext &Ctx) const {
+ llvm::SmallVector Both = {getLHS(), getRHS()};
JustinStitt wrote:
I had trouble
@@ -147,6 +147,15 @@ struct BinOpInfo {
return UnOp->getSubExpr()->getType()->isFixedPointType();
return false;
}
+
+ /// Does the BinaryOperator have the wraps attribute?
+ /// If so, we can ellide overflow sanitizer checks.
+ bool oneOfWraps() const {
+cons
@@ -6954,6 +6954,23 @@ static void HandleBTFTypeTagAttribute(QualType &Type,
const ParsedAttr &Attr,
::new (Ctx) BTFTypeTagAttr(Ctx, Attr, BTFTypeTag), Type);
}
+static void handleWrapsAttr(QualType &Type, const ParsedAttr &Attr,
+TypeProcess
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 10ee32826fc2acb6bd993c88bdb7142360b6f263 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 1/8] implement wraps attribute
Signed-off-by: Justin Stitt
---
JustinStitt wrote:
The most recent commits have massively simplified checking for the wrapping
attributes.
FWIW, the tests I am running are:
✅ `$ llvm-lit clang/test/CodeGen/integer-overflow.c -v`
✅ `$ llvm-lit clang/test/CodeGen/unsigned-overflow.c -v`
✅ `$ llvm-lit clang/test/Sema/attr-wraps.
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 10ee32826fc2acb6bd993c88bdb7142360b6f263 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 1/9] implement wraps attribute
Signed-off-by: Justin Stitt
---
JustinStitt wrote:
> > Forbidding usage in C++ probably avoids the worst of the canonical-type
> > issues, but there's still some potential for weird results. Particularly
> > with type merging; for example, if you write `a ? (wrap_int)x : 1`, is the
> > result a wrapping type?
>
> I had a si
1 - 100 of 275 matches
Mail list logo