[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-21 Thread Justin Stitt via cfe-commits
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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-21 Thread Nico Weber via cfe-commits
nico wrote: The test added here was tweaked a bit and then deleted in 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 PR with working tests. https://github.c

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-16 Thread Vitaly Buka via cfe-commits
vitalybuka wrote: > > Can we split `-fsanitize=unsigned-integer-overflow` into > > `-fsanitize=unsigned-integer-overflow-patternA,unsigned-integer-overflow-patternB,unsigned-integer-overflow-patternC...` > > ? > > Then it's quite intuitive to disable them with `no-sanitize`. > > Yikes, no way.

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-15 Thread Kees Cook via cfe-commits
kees wrote: > Can we split `-fsanitize=unsigned-integer-overflow` into > `-fsanitize=unsigned-integer-overflow-patternA,unsigned-integer-overflow-patternB,unsigned-integer-overflow-patternC...` > ? > > Then it's quite intuitive to disable them with `no-sanitize`. Yikes, no way. The pattern ex

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-15 Thread Vitaly Buka via cfe-commits
vitalybuka wrote: > > Before reland, please include me into review I'd like to understand why > > `-fsanitize-pattern-exclusion=all` is better than something like > > `-fno-sanitize=overflow-pattern-all` > > The latter doesn't make sense to me. `no-sanitize` takes a list of sanitizers > to co

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-15 Thread Justin Stitt via cfe-commits
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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-15 Thread Kees Cook via cfe-commits
kees wrote: > Before reland, please include me into review I'd like to understand why > `-fsanitize-pattern-exclusion=all` is better than something like > `-fno-sanitize=overflow-pattern-all` The latter doesn't make sense to me. `no-sanitize` takes a list of sanitizers to completely disable.

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-15 Thread Bill Wendling via cfe-commits
bwendling wrote: @vitalybuka Are they still broken? Which ones? 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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-15 Thread Vitaly Buka via cfe-commits
vitalybuka wrote: Before reland, please include me into review I'd like to understand why `-fsanitize-pattern-exclusion=all` is better than something like `-fno-sanitize=overflow-pattern-all` https://github.com/llvm/llvm-project/pull/100272 ___ cfe-co

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-15 Thread Vitaly Buka via cfe-commits
vitalybuka wrote: We should revert this patch. It breaks mupltiple bots, introducing Msan reports. Also on a first look I don't like `-fsanitize-pattern-exclusion=` at all, very inconsistent. I assumed we agreed to splitting sanitizers into smaller sets? I would like to know why we need to intr

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Bill Wendling via cfe-commits
bwendling wrote: I removed it temporarily. 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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread via cfe-commits
dyung wrote: > Hopefully > [6e2d9df](https://github.com/llvm/llvm-project/commit/6e2d9df02502e16659e4a9397260baf9df224f17) > fixes the buildbots. I think we should using update_cc_test_checks.py to > generate these testcases though. The test overflow-idiom-exclusion-fp.c appears to have been

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Bill Wendling via cfe-commits
bwendling wrote: Hopefully 6e2d9df02502 fixes the buildbots. I think we should using update_cc_test_checks.py to generate these testcases though. https://github.com/llvm/llvm-project/pull/100272 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Justin Stitt via cfe-commits
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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread via cfe-commits
dyung wrote: @bwendling The follow-up commit you made to the tests added here (7275919cd5fc89c42a52168c9f4411b4e5421c95) seems to have caused the test to start failing on at least a few bots. - https://lab.llvm.org/buildbot/#/builders/154/builds/2752 - https://lab.llvm.org/buildbot/#/builders/

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread LLVM Continuous Integration via cfe-commits
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-ve-ninja` running on `hpce-ve-main` while building `clang` at step 4 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/12/builds/3786 Here is the relevant piece of the build log for the

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling closed 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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Justin Stitt via 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 01/13] implement idiom exclusions Add flag `-fno-sanitize-ove

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic approved this pull request. LGTM The other thing you could do is modify ScalarExprEmitter::EmitCompare... if it sees an overflow pattern, it passes that down as an argument to the visit of the add. But I guess given the current structure of the code, that gets

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Bill Wendling via cfe-commits
bwendling wrote: > @efriedma-quic > > > 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. >

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Justin Stitt via 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 01/12] implement idiom exclusions Add flag `-fno-sanitize-ove

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Justin Stitt via cfe-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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-14 Thread Eli Friedman via cfe-commits
https://github.com/efriedma-quic commented: I think serialization is missing for the new bit on BinaryOperator. 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. https://github.com/llvm/llvm-p

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-13 Thread Bill Wendling via cfe-commits
bwendling wrote: Thanks! @efriedma-quic anymore comments? 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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-13 Thread Justin Stitt via cfe-commits
@@ -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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-13 Thread Justin Stitt via 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 01/11] implement idiom exclusions Add flag `-fno-sanitize-ove

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Bill Wendling via cfe-commits
@@ -649,6 +649,8 @@ class alignas(void *) Stmt { /// It is 0 otherwise. LLVM_PREFERRED_TYPE(bool) unsigned HasFPFeatures : 1; +LLVM_PREFERRED_TYPE(bool) bwendling wrote: Nit: Newline and maybe a comment? https://github.com/llvm/llvm-project/pu

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Justin Stitt via cfe-commits
@@ -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`

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Justin Stitt via cfe-commits
@@ -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)

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Justin Stitt via 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 01/10] implement idiom exclusions Add flag `-fno-sanitize-ove

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Eli Friedman via cfe-commits
@@ -3860,6 +3860,7 @@ class CStyleCastExpr final class BinaryOperator : public Expr { enum { LHS, RHS, END_EXPR }; Stmt *SubExprs[END_EXPR]; + bool ExcludedOverflowPattern = false; efriedma-quic wrote: I'd prefer to avoid increasing the size of BinaryOper

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Eli Friedman via cfe-commits
@@ -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)

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Bill Wendling via cfe-commits
https://github.com/bwendling approved this pull request. LGTM 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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Justin Stitt via cfe-commits
@@ -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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-12 Thread Justin Stitt via 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/9] implement idiom exclusions Add flag `-fno-sanitize-overf

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-09 Thread Bill Wendling via cfe-commits
@@ -4759,6 +4759,55 @@ ParenListExpr *ParenListExpr::CreateEmpty(const ASTContext &Ctx, return new (Mem) ParenListExpr(EmptyShell(), NumExprs); } +namespace { bwendling wrote: You don't need both an anonymous namespace and marking the function 'static'. I

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Justin Stitt via cfe-commits
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.

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Justin Stitt via cfe-commits
@@ -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? +

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Justin Stitt via cfe-commits
@@ -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 +

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Justin Stitt via cfe-commits
@@ -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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Justin Stitt via cfe-commits
@@ -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 +

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Justin Stitt via cfe-commits
@@ -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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Justin Stitt via cfe-commits
@@ -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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Justin Stitt via 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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Bill Wendling via cfe-commits
@@ -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 +

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Bill Wendling via cfe-commits
@@ -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 +

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Bill Wendling via cfe-commits
@@ -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? +

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Bill Wendling via cfe-commits
@@ -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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Bill Wendling via cfe-commits
@@ -0,0 +1,83 @@ +// Check for potential false positives from patterns that _almost_ match classic overflow-dependent or overflow-prone code patterns bwendling wrote: In general, I think it's expected the RUN lines will be first and any comments about the test

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-08 Thread Bill Wendling via cfe-commits
@@ -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

[clang] [Clang] Overflow Pattern Exclusions (PR #100272)

2024-08-06 Thread Justin Stitt via 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