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 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 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
@@ -817,6 +817,37 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
return CanonTTP;
}
+/// Check if a type can have its sanitizer instrumentation elided.
+/// Determine this by its presence in a SCL alongside its specified categories.
+/// For example:
+/// ignorelist.tx
@@ -48,6 +49,63 @@ Example
$ clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c ;
./a.out
# No error report here.
+Usage with UndefinedBehaviorSanitizer
+=
+
+The arithmetic overflow sanitizers ``unsigned-integer-overfl
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/107332
>From 548efc6414503f8ae005f1bd9ef2c7f15ad16241 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 3 Sep 2024 18:28:53 -0700
Subject: [PATCH 1/5] hook up sscl categories with overflow/truncation
sanitize
@@ -1,7 +1,28 @@
+// Verify ubsan doesn't emit checks for ignorelisted types
+// RUN: echo "[{unsigned-integer-overflow,signed-integer-overflow}]" >
%t-int.ignorelist
+// RUN: echo "type:int" >> %t-int.ignorelist
+// RUN: %clang_cc1 -triple x86_64-linux-gnu
-fsanitize=signed-int
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/107332
>From 548efc6414503f8ae005f1bd9ef2c7f15ad16241 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 3 Sep 2024 18:28:53 -0700
Subject: [PATCH 1/4] hook up sscl categories with overflow/truncation
sanitize
@@ -817,6 +817,37 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
return CanonTTP;
}
+/// Check if a type can have its sanitizer instrumentation elided.
+/// Determine this by its presence in a SCL alongside its specified categories.
+/// For example:
+/// ignorelist.tx
@@ -48,6 +49,63 @@ Example
$ clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c ;
./a.out
# No error report here.
+Usage with UndefinedBehaviorSanitizer
+=
+
+The arithmetic overflow sanitizers ``unsigned-integer-overfl
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/86618
>From 6fb8f6841795c44471a326a9d096a226cea9f4a8 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 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 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 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 updated
https://github.com/llvm/llvm-project/pull/86618
>From e73df4dedbb2e2be8b72ca3a8e847d5cbca29bed 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 edited
https://github.com/llvm/llvm-project/pull/105709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -4806,6 +4806,34 @@ getOverflowPatternBinOp(const BinaryOperator *E) {
return {};
}
+/// Compute and set the OverflowPatternExclusion bit based on whether the
JustinStitt wrote:
I wanted to avoid calling `getOverflowPatternBinOp()` as it is more expensiv
JustinStitt wrote:
> Iām a little concerned about not allowing the attribute in C++ - the
> existence of other options in C++ does not mean they are an option (due to
> various and sundry restrictions of C++ version upgrades different projects
> have), but also you trivially end up in cases wh
JustinStitt wrote:
> Regarding there not being a `no-wraps` attribute. What happens with code like
> this? Is the attribute lost / casted away during the addition?
>
> ```
> wrapping_int a = INT_MAX;
> a = (int) a + 1;
> ```
Good question, the attribute is cast away (intentionally so). Additio
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/105709
___
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/105709
>From @vitalybuka's review on https://github.com/llvm/llvm-project/pull/104889:
- [x] remove unused variable in tests
- [x] rename `post-decr-while` --> `unsigned-post-decr-while`
- [x] split `add-overflow-te
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/105709
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -293,6 +293,48 @@ 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
+
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/104889
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu
-fsanitize=signed-integer-overflow,unsigned-integer-overflow
-fsanitize-undefined-ignore-overflow-pattern=all %s -emit-llvm -o - | FileCheck
%s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu
-fsanitize
@@ -293,6 +293,48 @@ 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
+
@@ -293,6 +293,48 @@ 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
+
@@ -293,6 +293,48 @@ 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
+
@@ -438,6 +438,36 @@ Moved checkers
Sanitizers
--
+- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
+ used to disable specific overflow-dependent code patterns. The supported
+ patterns are: ``add-overflow-test``, ``negated-unsigned-cons
@@ -293,6 +293,48 @@ 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
+
@@ -293,6 +293,48 @@ 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
+
@@ -293,6 +293,48 @@ 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
+
@@ -438,6 +438,36 @@ Moved checkers
Sanitizers
--
+- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
+ used to disable specific overflow-dependent code patterns. The supported
+ patterns are: ``add-overflow-test``, ``negated-unsigned-cons
JustinStitt wrote:
@nico
> The test added here was tweaked a bit and then deleted in
> [07a8cba](https://github.com/llvm/llvm-project/commit/07a8cbaf8dc16bebf6e875173d20299d9cc47cc5)
>
> What gives?
>
> Instead of deleting tests, we should revert the PR that adds them and then
> reland the P
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 97de8998e2efd2362f9119c3ceea0938347278f4 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
@@ -119,6 +119,10 @@ static SanitizerMask parseArgValues(const Driver &D, const
llvm::opt::Arg *A,
static int parseCoverageFeatures(const Driver &D, const llvm::opt::Arg *A,
bool DiagnoseErrors);
+static int parseOverflowPatternExclusionValues
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
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
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
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
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
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
@@ -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
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
@@ -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`
@@ -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)
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
@@ -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 1/9] implement idiom exclusions
Add flag `-fno-sanitize-overf
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.
@@ -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?
+
@@ -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
+
@@ -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
@@ -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
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
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/100272
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/100272
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
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/7] implement idiom exclusions
Add flag `-fno-sanitize-overf
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/6] implement idiom exclusions
Add flag `-fno-sanitize-overf
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 06b702cd38943314b2e6f873e64d70baed6f57f7 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 1/5] implement idiom exclusions
Add flag `-fno-sanitize-overf
JustinStitt wrote:
@kees @vitalybuka 3ef8d3c implements `-fsanitize=pattern-exclusion=`.
It supports the following values:
`all` - turn all supported pattern exclusions ON
`none` - turn them all off (has precedence over others, I will add a warning
soon if users try to use this with "all" or an
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 06b702cd38943314b2e6f873e64d70baed6f57f7 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 1/4] implement idiom exclusions
Add flag `-fno-sanitize-overf
JustinStitt wrote:
> > Right, unsigned overflow is well-defined. This isn't about the semantics of
> > "undefined-ness". We want the unsigned sanitizer ON but some of the things
> > it reports are noisy -- that's what this PR is about
>
> "Idiom" seems to vague to me. kernel has own opinion on
JustinStitt wrote:
> I assume you are going to change fronted to avoid compiler abusing these UBs?
Well, like you said, none of this is really undefined behavior and isn't
getting optimized away. The exception being `if ( a + b < a )` which can
definitely have some unexpected results with high
JustinStitt wrote:
> Actually stuff like unsigned overflows are not UB.
>
> Maybe instead of `-fno-sanitize-overflow-idioms` we convert into
> `unsigned-integer-overflow` into ` check group` so user can
> -fno-sanitize=-unsigned-integer-overflow
Right, unsigned overflow is well-defined. This
@@ -312,6 +312,38 @@ This attribute may not be
supported by other compilers, so consider using it together with
``#if defined(__clang__)``.
+Disabling instrumentation of common overflow idioms
+=
+
+There are certain overflow
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/100272
>From 06b702cd38943314b2e6f873e64d70baed6f57f7 Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 23 Jul 2024 20:21:49 +
Subject: [PATCH 1/3] implement idiom exclusions
Add flag `-fno-sanitize-overf
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/100272
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt edited
https://github.com/llvm/llvm-project/pull/100272
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/JustinStitt created
https://github.com/llvm/llvm-project/pull/100272
## Summary
Introduce `-fno-sanitize-overflow-idioms` which disables sanitizer
instrumentation for common overflow-dependent code idioms.
## Background
For a wide selection of projects, proper overflow sanit
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 58df542edf7d1a9f65fc804f23a2b209a49f5c5f 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 updated
https://github.com/llvm/llvm-project/pull/86618
>From af16c497b1323983d55f92d6cfb9ab2c99a21639 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 updated
https://github.com/llvm/llvm-project/pull/86618
>From 6152bd26438a32711589424f705281291475d548 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
JustinStitt wrote:
Hi, gentle ping.
@efriedma-quic, do you still have concerns with the current implementation (as
an attribute attached to typedefs)? After limiting `wraps` to C and adding
warnings to let users know when the attribute may be stripped, I think it's in
a good spot.
```c
type
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 1df2f520f6a8ab0e45b80f7a1d680d34f8ab37c9 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
JustinStitt wrote:
FYI: I've rebased and handled merge conflicts (mainly in ReleaseNotes.rst).
This, of course, required a force push.
https://github.com/llvm/llvm-project/pull/86618
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://list
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 1df2f520f6a8ab0e45b80f7a1d680d34f8ab37c9 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 updated
https://github.com/llvm/llvm-project/pull/86618
>From 238e3242d12473a072d0d2adc51f18fbeaa927a8 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
JustinStitt wrote:
Ping!
Any chance we could land this soon?
I know @efriedma-quic has some different ideas for the implementation of this
feature. However, adding a new type is most likely overkill for what is needed
out of `wraps`. I think the implementation/documentation and testing has la
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 01/18] implement wraps attribute
Signed-off-by: Justin Stitt
-
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 01/17] implement wraps attribute
Signed-off-by: Justin Stitt
-
JustinStitt wrote:
In an effort to appease the build bot, I am adding a `-W` flag to turn of
`warn_wraps_attr_var_decl_type_not_integer` which yells at users for trying to
add `__attribute__((wraps))` to things that don't really wrap in the
traditional sense.
https://github.com/llvm/llvm-proj
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 01/16] implement wraps attribute
Signed-off-by: Justin Stitt
-
JustinStitt wrote:
@efriedma-quic:
> Attributes mostly do modify the type. The few that don't, like "aligned" and
> "may_alias", are a constant source of problems because they get accidentally
> stripped off. (I don't have any personal experience with "noderef".)
So do you believe the current
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 01/15] implement wraps attribute
Signed-off-by: Justin Stitt
-
JustinStitt wrote:
@efriedma-quic:
> This is declaring, then defining, a global variable; sorry if that wasn't
> clear.
Gotcha.
> Probably should be an error? It'll be confusing no matter what we do.
I think it's OK for a global variable to be declared then later defined with
additional att
JustinStitt wrote:
> > > If you declare a variable as both wrapping and non-wrapping, is it
> > > wrapping?
> >
> >
> > I am not sure how to do this. I am sure that with the magic of C anything
> > is possible but I can't conceive a way to have a variable both have the
> > attribute and not
JustinStitt wrote:
Hi @efriedma-quic, thanks for dumping all these cases! I will respond to each
one individually.
I understand you think adding a type would be better so I am exploring that
option (I am thinking something similar to [extended
vectors](https://clang.llvm.org/docs/LanguageExte
JustinStitt wrote:
@efriedma-quic said:
> I'm still not happy with the AST representation here. The current
> representation is likely to cause unpredictable results in edge cases, and
> compatibility constraints mean whatever result the current version happens to
> produce for those cases is
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple x86_64-pc-linux-gnu
+// expected-no-diagnostics
+typedef int __attribute__((wraps)) wrapping_int;
+
+void foo(void) {
+ const wrapping_int A = 1;
+ int D = 2147483647 + A;
JustinStitt wrote:
O
https://github.com/JustinStitt updated
https://github.com/llvm/llvm-project/pull/86618
>From 50e7b1039e514dacc05bb8cd9ff9a3e3df9ed24d Mon Sep 17 00:00:00 2001
From: Justin Stitt
Date: Tue, 5 Mar 2024 03:14:49 +
Subject: [PATCH 01/13] implement wraps attribute
Signed-off-by: Justin Stitt
-
@@ -4249,6 +4270,10 @@ Value *ScalarExprEmitter::EmitFixedPointBinOp(const
BinOpInfo &op) {
Value *ScalarExprEmitter::EmitSub(const BinOpInfo &op) {
// The LHS is always a pointer if either side is.
if (!op.LHS->getType()->isPointerTy()) {
+if ((op.Ty->isSignedIntegerO
@@ -4455,6 +4455,14 @@ void Sema::AddAlignValueAttr(Decl *D, const
AttributeCommonInfo &CI, Expr *E) {
D->addAttr(::new (Context) AlignValueAttr(Context, CI, E));
}
+static void handleWrapsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+ S.AddWrapsAttr(D, AL);
+}
+
+void S
@@ -4093,6 +4109,11 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &op) {
op.RHS->getType()->isPointerTy())
return emitPointerArithmetic(CGF, op, CodeGenFunction::NotSubtraction);
+ if ((op.Ty->isSignedIntegerOrEnumerationType() ||
JustinStitt
@@ -2831,6 +2840,9 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const
UnaryOperator *E, LValue LV,
} else if (type->isIntegerType()) {
QualType promotedType;
bool canPerformLossyDemotionCheck = false;
+BinOpInfo Ops = (createBinOpInfoFromIncDec(
@@ -156,6 +156,10 @@ struct BinOpInfo {
}
return false;
}
+
+ /// Does the BinaryOperator have the wraps attribute?
+ /// If so, we can ellide overflow sanitizer checks.
JustinStitt wrote:
fixed in
[872e5d6](https://github.com/llvm/llvm-project/pu
@@ -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?
JustinStitt wrote:
1 - 100 of 183 matches
Mail list logo