[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Internally ::allocate uses sided new:

```
 void*
allocate(size_t __bytes, size_t __alignment = _S_max_align)
__attribute__((__returns_nonnull__,__alloc_size__(2),__alloc_align__(3)))
{ return ::operator new(__bytes, do_allocate(__bytes, __alignment)); }

```

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> > > Based on my rough understanding, this is expected?
> > 
> > 
> > What do you mean?
> > Isn't this test needs to be updated or disabled?
> 
> I think this ASAN failure is not caused by this PR because these memorys are 
> allocated/deallocated by

100% sure by this PR
https://lab.llvm.org/buildbot/#/builders/168/builds/20461 only two patches on 
the blame list and the second one is unrelated for sure.

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-23 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> Based on my rough understanding, this is expected?

What do you mean?

Isn't this test needs to be updated or disabled?

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-05-22 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

This one is broken https://lab.llvm.org/buildbot/#/builders/168/builds/20461

https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c587483 - Revert "[Bounds-Safety] Fix `pragma-attribute-supported-attributes-list.test`"

2024-05-19 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-05-19T06:21:40-07:00
New Revision: c587483da0b50efa04146fde205da1d16731e12e

URL: 
https://github.com/llvm/llvm-project/commit/c587483da0b50efa04146fde205da1d16731e12e
DIFF: 
https://github.com/llvm/llvm-project/commit/c587483da0b50efa04146fde205da1d16731e12e.diff

LOG: Revert "[Bounds-Safety] Fix 
`pragma-attribute-supported-attributes-list.test`"

Issue #92687

This reverts commit 112eadd55f06bee15caadff688ea0b45acbfa804.

Added: 


Modified: 
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test 
b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
index 99732694f72a5..fd0e6d71baa80 100644
--- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -63,6 +63,7 @@
 // CHECK-NEXT: CoroOnlyDestroyWhenComplete (SubjectMatchRule_record)
 // CHECK-NEXT: CoroReturnType (SubjectMatchRule_record)
 // CHECK-NEXT: CoroWrapper (SubjectMatchRule_function)
+// CHECK-NEXT: CountedBy (SubjectMatchRule_field)
 // CHECK-NEXT: DLLExport (SubjectMatchRule_function, 
SubjectMatchRule_variable, SubjectMatchRule_record, 
SubjectMatchRule_objc_interface)
 // CHECK-NEXT: DLLImport (SubjectMatchRule_function, 
SubjectMatchRule_variable, SubjectMatchRule_record, 
SubjectMatchRule_objc_interface)
 // CHECK-NEXT: Destructor (SubjectMatchRule_function)



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6447abe - Revert "[BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (#90786)"

2024-05-19 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-05-19T05:44:40-07:00
New Revision: 6447abe067c8088a5cc093fe872719374e174068

URL: 
https://github.com/llvm/llvm-project/commit/6447abe067c8088a5cc093fe872719374e174068
DIFF: 
https://github.com/llvm/llvm-project/commit/6447abe067c8088a5cc093fe872719374e174068.diff

LOG: Revert "[BoundsSafety] Allow 'counted_by' attribute on pointers in structs 
in C (#90786)"

Memory leak: https://lab.llvm.org/buildbot/#/builders/5/builds/43403

Issue #92687

This reverts commit 0ec3b972e58bcbcdc1bebe1696ea37f2931287c3.

Added: 
clang/test/Sema/attr-counted-by.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Type.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Type.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseObjc.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h

Removed: 
clang/test/AST/attr-counted-by-late-parsed-struct-ptrs.c
clang/test/AST/attr-counted-by-struct-ptrs.c
clang/test/Sema/attr-counted-by-late-parsed-off.c
clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c
clang/test/Sema/attr-counted-by-struct-ptrs-sizeless-types.c
clang/test/Sema/attr-counted-by-struct-ptrs.c
clang/test/Sema/attr-counted-by-vla-sizeless-types.c
clang/test/Sema/attr-counted-by-vla.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2f83f5c6d54e9..7af5869d21768 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -317,8 +317,7 @@ New Compiler Flags
 
 - ``-fexperimental-late-parse-attributes`` enables an experimental feature to
   allow late parsing certain attributes in specific contexts where they would
-  not normally be late parsed. Currently this allows late parsing the
-  `counted_by` attribute in C. See `Attribute Changes in Clang`_.
+  not normally be late parsed.
 
 - ``-fseparate-named-sections`` uses separate unique sections for global
   symbols in named special sections (i.e. symbols annotated with
@@ -407,24 +406,6 @@ Attribute Changes in Clang
 - The ``clspv_libclc_builtin`` attribute has been added to allow clspv
   (`OpenCL-C to Vulkan SPIR-V compiler `_) to 
identify functions coming from libclc
   (`OpenCL-C builtin library `_).
-- The ``counted_by`` attribute is now allowed on pointers that are members of a
-  struct in C.
-
-- The ``counted_by`` attribute can now be late parsed in C when
-  ``-fexperimental-late-parse-attributes`` is passed but only when attribute is
-  used in the declaration attribute position. This allows using the
-  attribute on existing code where it previously impossible to do so without
-  re-ordering struct field declarations would break ABI as shown below.
-
-  .. code-block:: c
-
- struct BufferTy {
-   /* Refering to `count` requires late parsing */
-   char* buffer __counted_by(count);
-   /* Swapping `buffer` and `count` to avoid late parsing would break ABI 
*/
-   size_t count;
- };
-
 
 Improvements to Clang's diagnostics
 ---

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index c7a8e785913b3..da3834f19ca04 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2515,7 +2515,6 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isRecordType() const;
   bool isClassType() const;
   bool isStructureType() const;
-  bool isStructureTypeWithFlexibleArrayMember() const;
   bool isObjCBoxableRecordType() const;
   bool isInterfaceType() const;
   bool isStructureOrClassType() const;

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7a7721239a28f..38ee8356583be 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2229,8 +2229,7 @@ def TypeNullUnspecified : TypeAttr {
 def CountedBy : DeclOrTypeAttr {
   let Spellings = [Clang<"counted_by">];
   let Subjects = SubjectList<[Field], ErrorDiag>;
-  let Args = [ExprArgument<"Count">, IntArgument<"NestedLevel", 1>];
-  let LateParsed = LateAttrParseExperimentalExt;
+  let Args = [ExprArgument<"Count">, IntArgument<"NestedLevel">];
   let ParseArgumentsAsUnevaluated = 1;
   let Documentation = [CountedByDocs];
   let LangOpts = [COnly];

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8e6596410c5d0..09b1874f9fddd 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6533,10 +6533,8 @@ def warn_superclass_variable_sized_type_not_at_end : 
Warning<
 
 def 

[clang] ed9007d - Revert "[Bounds-Safety] Temporarily relax a `counted_by` attribute restriction on flexible array members"

2024-05-19 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-05-19T05:44:40-07:00
New Revision: ed9007d0d219726db01f211e9c9ab72fbfe4ecb1

URL: 
https://github.com/llvm/llvm-project/commit/ed9007d0d219726db01f211e9c9ab72fbfe4ecb1
DIFF: 
https://github.com/llvm/llvm-project/commit/ed9007d0d219726db01f211e9c9ab72fbfe4ecb1.diff

LOG: Revert "[Bounds-Safety] Temporarily relax a `counted_by` attribute 
restriction on flexible array members"

Together with 0ec3b972e58bcbcdc1bebe1696ea37f2931287c3
breaks https://lab.llvm.org/buildbot/#/builders/5/builds/43403

Issue #92687

This reverts commit cef6387e52578366c2332275dad88b9953b55336.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Sema/attr-counted-by-vla.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 4fad4d1a0eca7..4cb4f3d999f7a 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1447,10 +1447,6 @@ def FunctionMultiVersioning
 
 def NoDeref : DiagGroup<"noderef">;
 
-// -fbounds-safety and bounds annotation related warnings
-def BoundsSafetyCountedByEltTyUnknownSize :
-  DiagGroup<"bounds-safety-counted-by-elt-type-unknown-size">;
-
 // A group for cross translation unit static analysis related warnings.
 def CrossTU : DiagGroup<"ctu">;
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1efa3af121c10..8e6596410c5d0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6552,7 +6552,7 @@ def err_counted_by_attr_refer_to_union : Error<
 def note_flexible_array_counted_by_attr_field : Note<
   "field %0 declared here">;
 def err_counted_by_attr_pointee_unknown_size : Error<
-  "'counted_by' %select{cannot|should not}3 be applied to %select{"
+  "'counted_by' cannot be applied to %select{"
 "a pointer with pointee|" // pointer
 "an array with element}0" // array
   " of unknown size because %1 is %select{"
@@ -6561,14 +6561,8 @@ def err_counted_by_attr_pointee_unknown_size : Error<
 "a function type|" // CountedByInvalidPointeeTypeKind::FUNCTION
 // CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER
 "a struct type with a flexible array member"
-"%select{|. This will be an error in a future compiler version}3"
-""
   "}2">;
 
-def warn_counted_by_attr_elt_type_unknown_size :
-  Warning,
-  InGroup;
-
 let CategoryName = "ARC Semantic Issue" in {
 
 // ARC-mode diagnostics.

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e816ea3647a7c..c8b71631076ba 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -8687,7 +8687,6 @@ static bool CheckCountedByAttrOnField(
   // Note: The `Decl::isFlexibleArrayMemberLike` check earlier on means
   // only `PointeeTy->isStructureTypeWithFlexibleArrayMember()` is reachable
   // when `FieldTy->isArrayType()`.
-  bool ShouldWarn = false;
   if (PointeeTy->isIncompleteType()) {
 InvalidTypeKind = CountedByInvalidPointeeTypeKind::INCOMPLETE;
   } else if (PointeeTy->isSizelessType()) {
@@ -8695,25 +8694,13 @@ static bool CheckCountedByAttrOnField(
   } else if (PointeeTy->isFunctionType()) {
 InvalidTypeKind = CountedByInvalidPointeeTypeKind::FUNCTION;
   } else if (PointeeTy->isStructureTypeWithFlexibleArrayMember()) {
-if (FieldTy->isArrayType()) {
-  // This is a workaround for the Linux kernel that has already adopted
-  // `counted_by` on a FAM where the pointee is a struct with a FAM. This
-  // should be an error because computing the bounds of the array cannot be
-  // done correctly without manually traversing every struct object in the
-  // array at runtime. To allow the code to be built this error is
-  // downgraded to a warning.
-  ShouldWarn = true;
-}
 InvalidTypeKind = CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER;
   }
 
   if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID) {
-unsigned DiagID = ShouldWarn
-  ? diag::warn_counted_by_attr_elt_type_unknown_size
-  : diag::err_counted_by_attr_pointee_unknown_size;
-S.Diag(FD->getBeginLoc(), DiagID)
+S.Diag(FD->getBeginLoc(), diag::err_counted_by_attr_pointee_unknown_size)
 << SelectPtrOrArr << PointeeTy << (int)InvalidTypeKind
-<< (ShouldWarn ? 1 : 0) << FD->getSourceRange();
+<< FD->getSourceRange();
 return true;
   }
 

diff  --git a/clang/test/Sema/attr-counted-by-vla.c 
b/clang/test/Sema/attr-counted-by-vla.c
index b25f719f3b95a..3de6bd55e2d8e 100644
--- a/clang/test/Sema/attr-counted-by-vla.c
+++ b/clang/test/Sema/attr-counted-by-vla.c
@@ 

[clang] [Bounds-Safety] Reserve slot in SanitizerHandler enum for Bounds-Safety (PR #91032)

2024-05-18 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka commented:

LGTM

https://github.com/llvm/llvm-project/pull/91032
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-08 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> Greetings and hello from the UK!
> 
> it looks as though this commit caused a test failure on the following build 
> bot, is anyone able to take a look see?
> 
> https://lab.llvm.org/buildbot/#/builders/139/builds/65066
> 
> Will give it an hour for a reply before looking at a revert.
> 
> Have a great day all.

I am not looking into this, and not sure if @jyu2-git 
revert is LGTM 

https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (PR #91141)

2024-05-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka approved this pull request.


https://github.com/llvm/llvm-project/pull/91141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[OpenMP][TR12] change property of map-type modifier." (PR #90935)

2024-05-03 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Yes, its there
but it's too late

we can't cast to enum invalid values 
it should be like:
```
  unsigned MapType = getOpenMPSimpleClauseType(
  OMPC_map, PP.getSpelling(Tok), P.getLangOpts());
  if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_from ||
  MapType == OMPC_MAP_tofrom || MapType == OMPC_MAP_alloc ||
  MapType == OMPC_MAP_delete || MapType == OMPC_MAP_release)
return static_cast<>(MapType);
  return OMPC_MAP_unkno
```


https://github.com/llvm/llvm-project/pull/90935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[OpenMP][TR12] change property of map-type modifier." (PR #90935)

2024-05-03 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

```
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 53d89ce2fa3e..1a4442f38f6d 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4326,6 +4326,7 @@ static OpenMPMapClauseKind isMapType(Parser ) {
   OpenMPMapClauseKind MapType =
   static_cast(getOpenMPSimpleClauseType(
   OMPC_map, PP.getSpelling(Tok), P.getLangOpts()));
+  assert((int)MapType < 6);
   return MapType;
 }
```

https://github.com/llvm/llvm-project/pull/90935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[OpenMP][TR12] change property of map-type modifier." (PR #90935)

2024-05-03 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> > 7c28408
> 
> good point, maybe not, I scheduled it as with, without rebase. Let's try 
> again.

Still fails after rebase https://lab.llvm.org/buildbot/#/builders/5/builds/43115

https://github.com/llvm/llvm-project/pull/90935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[OpenMP][TR12] change property of map-type modifier." (PR #90885)

2024-05-03 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> > BTW, Hi @vitalybuka, do you know how to reproduce the problem with 
> > sanitizer build? Thanks.
> 
> There is a basic instruction, should work with Linux 
> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild I guess 
> this issue should be detectable with appropriate `assert(val > a && val <= 
> b)` a the point of the report.

Still fails after rebase https://lab.llvm.org/buildbot/#/builders/5/builds/43115

https://github.com/llvm/llvm-project/pull/90885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[OpenMP][TR12] change property of map-type modifier." (PR #90935)

2024-05-03 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/90935

>From 8468a10bf34e4c432b181d40c370043ad21b5801 Mon Sep 17 00:00:00 2001
From: jyu2-git 
Date: Thu, 2 May 2024 20:55:18 -0700
Subject: [PATCH] Revert "Revert "[OpenMP][TR12] change property of map-type
 modifier." (#90885)"

This reverts commit eea81aa29848361eb5b24f24d2af643fdeb9adfd.
---
 .../clang/Basic/DiagnosticParseKinds.td   |   5 +
 clang/lib/Parse/ParseOpenMP.cpp   |  44 +++-
 clang/test/OpenMP/target_ast_print.cpp|  58 ++
 clang/test/OpenMP/target_map_messages.cpp | 105 ++
 4 files changed, 162 insertions(+), 50 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index fdffb35ea0d955..44bc4e0e130de8 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1438,6 +1438,9 @@ def err_omp_decl_in_declare_simd_variant : Error<
 def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 
%select{sink:|source:}1' must be with '%select{omp_cur_iteration - 
1|omp_cur_iteration}1'">;
 def err_omp_unknown_map_type : Error<
   "incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 
'release', or 'delete'">;
+def err_omp_more_one_map_type : Error<"map type is already specified">;
+def note_previous_map_type_specified_here
+: Note<"map type '%0' is previous specified here">;
 def err_omp_unknown_map_type_modifier : Error<
   "incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
   "%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
@@ -1445,6 +1448,8 @@ def err_omp_map_type_missing : Error<
   "missing map type">;
 def err_omp_map_type_modifier_missing : Error<
   "missing map type modifier">;
+def err_omp_map_modifier_specification_list : Error<
+  "empty modifier-specification-list is not allowed">;
 def err_omp_declare_simd_inbranch_notinbranch : Error<
   "unexpected '%0' clause, '%1' is specified already">;
 def err_omp_expected_clause_argument
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 18ba1185ee8de7..b1cff11af590a5 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4228,13 +4228,20 @@ bool 
Parser::parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy ) {
   return T.consumeClose();
 }
 
+static OpenMPMapClauseKind isMapType(Parser );
+
 /// Parse map-type-modifiers in map clause.
-/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
+/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] [map-type] : ] list)
 /// where, map-type-modifier ::= always | close | mapper(mapper-identifier) |
 /// present
+/// where, map-type ::= alloc | delete | from | release | to | tofrom
 bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
+  bool HasMapType = false;
+  SourceLocation PreMapLoc = Tok.getLocation();
+  StringRef PreMapName = "";
   while (getCurToken().isNot(tok::colon)) {
 OpenMPMapModifierKind TypeModifier = isMapModifier(*this);
+OpenMPMapClauseKind MapKind = isMapType(*this);
 if (TypeModifier == OMPC_MAP_MODIFIER_always ||
 TypeModifier == OMPC_MAP_MODIFIER_close ||
 TypeModifier == OMPC_MAP_MODIFIER_present ||
@@ -4257,6 +4264,19 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 Diag(Data.MapTypeModifiersLoc.back(), diag::err_omp_missing_comma)
 << "map type modifier";
 
+} else if (getLangOpts().OpenMP >= 60 && MapKind != OMPC_MAP_unknown) {
+  if (!HasMapType) {
+HasMapType = true;
+Data.ExtraModifier = MapKind;
+MapKind = OMPC_MAP_unknown;
+PreMapLoc = Tok.getLocation();
+PreMapName = Tok.getIdentifierInfo()->getName();
+  } else {
+Diag(Tok, diag::err_omp_more_one_map_type);
+Diag(PreMapLoc, diag::note_previous_map_type_specified_here)
+<< PreMapName;
+  }
+  ConsumeToken();
 } else {
   // For the case of unknown map-type-modifier or a map-type.
   // Map-type is followed by a colon; the function returns when it
@@ -4267,8 +4287,14 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 continue;
   }
   // Potential map-type token as it is followed by a colon.
-  if (PP.LookAhead(0).is(tok::colon))
-return false;
+  if (PP.LookAhead(0).is(tok::colon)) {
+if (getLangOpts().OpenMP >= 60) {
+  break;
+} else {
+  return false;
+}
+  }
+
   Diag(Tok, diag::err_omp_unknown_map_type_modifier)
   << (getLangOpts().OpenMP >= 51 ? (getLangOpts().OpenMP >= 52 ? 2 : 1)
  : 0)
@@ -4278,6 +4304,14 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 if (getCurToken().is(tok::comma))
   

[clang] Reland "[OpenMP][TR12] change property of map-type modifier." (PR #90935)

2024-05-03 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> 7c28408

good point, maybe not, I scheduled it as with, without rebase.
Let's try again.

https://github.com/llvm/llvm-project/pull/90935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[OpenMP][TR12] change property of map-type modifier." (PR #90935)

2024-05-03 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> Looks broken 
> https://lab.llvm.org/buildbot/#/builders/5/builds/43104/steps/9/logs/stdio

This is special build from this PR see `git status` here
https://lab.llvm.org/buildbot/#/builders/5/builds/43104/steps/6/logs/stdio

https://github.com/llvm/llvm-project/pull/90935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[OpenMP][TR12] change property of map-type modifier." (PR #90935)

2024-05-03 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka requested changes to this pull request.

Looks broken 
https://lab.llvm.org/buildbot/#/builders/5/builds/43104/steps/9/logs/stdio

https://github.com/llvm/llvm-project/pull/90935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Fix sanitize problem. (PR #90800)

2024-05-02 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Please include this fix into re-land.

https://github.com/llvm/llvm-project/pull/90800
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[OpenMP][TR12] change property of map-type modifier." (PR #90885)

2024-05-02 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/90885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[OpenMP][TR12] change property of map-type modifier." (PR #90885)

2024-05-02 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> BTW, Hi @vitalybuka, do you know how to reproduce the problem with sanitizer 
> build? Thanks.

There is a basic instruction, should work with Linux 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild
I guess this issue should be detectable with appropriate `assert(val > a && val 
<= b)` a the point of the report.

https://github.com/llvm/llvm-project/pull/90885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[OpenMP][TR12] change property of map-type modifier." (PR #90885)

2024-05-02 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Oh, it's not landed. I looked at wrong PR. Lets revert if it can't be landed 
soon. 

https://github.com/llvm/llvm-project/pull/90885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[OpenMP][TR12] change property of map-type modifier." (PR #90885)

2024-05-02 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> How long do you need?

Looks like it's landed.
Thanks!

https://github.com/llvm/llvm-project/pull/90885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[OpenMP][TR12] change property of map-type modifier." (PR #90885)

2024-05-02 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> I already has patch in #90800 waiting for test to finish.

Fix forward is good for something < 1H, but looks like you started 19H ago.
Such cases must be reverted and then fixed.

How long do you need?

https://github.com/llvm/llvm-project/pull/90885
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [OpenMP][TR12] change property of map-type modifier. (PR #90499)

2024-05-02 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

I am not sure what should be a correct fix, so I'll revert?

https://github.com/llvm/llvm-project/pull/90499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[OpenMP][TR12] change property of map-type modifier." (PR #90885)

2024-05-02 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/90885

Breaks 
https://lab.llvm.org/buildbot/#/builders/5/builds/43086/steps/9/logs/stdio

Reverts llvm/llvm-project#90499

>From a6ca95f5e2991fb7f857f70436148a6abdecec00 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Thu, 2 May 2024 11:32:32 -0700
Subject: [PATCH] Revert "[OpenMP][TR12] change property of map-type modifier.
 (#90499)"

This reverts commit f050660f4a60415cd840f7fba7ac3698c38376d0.
---
 .../clang/Basic/DiagnosticParseKinds.td   |   5 -
 clang/lib/Parse/ParseOpenMP.cpp   |  44 +---
 clang/test/OpenMP/target_ast_print.cpp|  58 --
 clang/test/OpenMP/target_map_messages.cpp | 105 --
 4 files changed, 50 insertions(+), 162 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 44bc4e0e130de8..fdffb35ea0d955 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1438,9 +1438,6 @@ def err_omp_decl_in_declare_simd_variant : Error<
 def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 
%select{sink:|source:}1' must be with '%select{omp_cur_iteration - 
1|omp_cur_iteration}1'">;
 def err_omp_unknown_map_type : Error<
   "incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 
'release', or 'delete'">;
-def err_omp_more_one_map_type : Error<"map type is already specified">;
-def note_previous_map_type_specified_here
-: Note<"map type '%0' is previous specified here">;
 def err_omp_unknown_map_type_modifier : Error<
   "incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
   "%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
@@ -1448,8 +1445,6 @@ def err_omp_map_type_missing : Error<
   "missing map type">;
 def err_omp_map_type_modifier_missing : Error<
   "missing map type modifier">;
-def err_omp_map_modifier_specification_list : Error<
-  "empty modifier-specification-list is not allowed">;
 def err_omp_declare_simd_inbranch_notinbranch : Error<
   "unexpected '%0' clause, '%1' is specified already">;
 def err_omp_expected_clause_argument
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 53d89ce2fa3e99..480201bc06f613 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -4228,20 +4228,13 @@ bool 
Parser::parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy ) {
   return T.consumeClose();
 }
 
-static OpenMPMapClauseKind isMapType(Parser );
-
 /// Parse map-type-modifiers in map clause.
-/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] [map-type] : ] list)
+/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
 /// where, map-type-modifier ::= always | close | mapper(mapper-identifier) |
 /// present
-/// where, map-type ::= alloc | delete | from | release | to | tofrom
 bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
-  bool HasMapType = false;
-  SourceLocation PreMapLoc = Tok.getLocation();
-  StringRef PreMapName = "";
   while (getCurToken().isNot(tok::colon)) {
 OpenMPMapModifierKind TypeModifier = isMapModifier(*this);
-OpenMPMapClauseKind MapKind = isMapType(*this);
 if (TypeModifier == OMPC_MAP_MODIFIER_always ||
 TypeModifier == OMPC_MAP_MODIFIER_close ||
 TypeModifier == OMPC_MAP_MODIFIER_present ||
@@ -4264,19 +4257,6 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 Diag(Data.MapTypeModifiersLoc.back(), diag::err_omp_missing_comma)
 << "map type modifier";
 
-} else if (getLangOpts().OpenMP >= 60 && MapKind != OMPC_MAP_unknown) {
-  if (!HasMapType) {
-HasMapType = true;
-Data.ExtraModifier = MapKind;
-MapKind = OMPC_MAP_unknown;
-PreMapLoc = Tok.getLocation();
-PreMapName = Tok.getIdentifierInfo()->getName();
-  } else {
-Diag(Tok, diag::err_omp_more_one_map_type);
-Diag(PreMapLoc, diag::note_previous_map_type_specified_here)
-<< PreMapName;
-  }
-  ConsumeToken();
 } else {
   // For the case of unknown map-type-modifier or a map-type.
   // Map-type is followed by a colon; the function returns when it
@@ -4287,14 +4267,8 @@ bool 
Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy ) {
 continue;
   }
   // Potential map-type token as it is followed by a colon.
-  if (PP.LookAhead(0).is(tok::colon)) {
-if (getLangOpts().OpenMP >= 60) {
-  break;
-} else {
-  return false;
-}
-  }
-
+  if (PP.LookAhead(0).is(tok::colon))
+return false;
   Diag(Tok, diag::err_omp_unknown_map_type_modifier)
   << (getLangOpts().OpenMP >= 51 ? (getLangOpts().OpenMP >= 52 ? 2 : 1)
  : 0)
@@ -4304,14 +4278,6 @@ bool 

[clang] [OpenMP][TR12] change property of map-type modifier. (PR #90499)

2024-05-02 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Breaks https://lab.llvm.org/buildbot/#/builders/5/builds/43086


https://github.com/llvm/llvm-project/pull/90499
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)

2024-04-30 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> Thanks a lot, that was quick! There is another AddressSanitizer issue that 
> may possibly be fixed by #90292. cc @vitalybuka

Yes, please wait for #90292.


https://github.com/llvm/llvm-project/pull/90373
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Revert "[clang] Enable sized deallocation by default in C++14 onwards (#83774)" (PR #90299)

2024-04-26 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka demilestoned 
https://github.com/llvm/llvm-project/pull/90299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Revert "[clang] Enable sized deallocation by default in C++14 onwards (#83774)" (PR #90299)

2024-04-26 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka milestoned 
https://github.com/llvm/llvm-project/pull/90299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Revert "[clang] Enable sized deallocation by default in C++14 onwards (#83774)" (PR #90299)

2024-04-26 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/90299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-04-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Lets revert #90299 to recover bots before the weekend.


https://github.com/llvm/llvm-project/pull/83774
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Revert "[clang] Enable sized deallocation by default in C++14 onwards (#83774)" (PR #90299)

2024-04-26 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/90299
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] Revert "[clang] Enable sized deallocation by default in C++14 onwards (#83774)" (PR #90299)

2024-04-26 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/90299

https://lab.llvm.org/buildbot/#/builders/168/builds/20063

This reverts commit cf5a8b489464d09dfdd7a48ce7c8b41d3c9bf819.


>From b4c0a3f4835a686a15a3ed90a4058f353f844f26 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Fri, 26 Apr 2024 16:50:25 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../clangd/unittests/FindTargetTests.cpp  |   4 +-
 .../checkers/misc/new-delete-overloads.cpp|  10 +
 clang/docs/ReleaseNotes.rst   |   5 -
 clang/include/clang/Driver/Options.td |   8 +-
 clang/lib/Driver/ToolChains/Clang.cpp |  13 +-
 clang/lib/Driver/ToolChains/Darwin.cpp|  58 +
 clang/lib/Driver/ToolChains/Darwin.h  |   4 -
 clang/lib/Driver/ToolChains/ZOS.cpp   |   6 -
 clang/test/AST/ast-dump-expr-json.cpp |   2 +-
 clang/test/AST/ast-dump-expr.cpp  |   2 +-
 clang/test/AST/ast-dump-stmt-json.cpp | 244 +-
 clang/test/Analysis/cxxnewexpr-callback.cpp   |   4 +-
 .../basic.stc.dynamic.deallocation/p2.cpp |   2 +-
 clang/test/CXX/drs/cwg292.cpp |  17 +-
 .../test/CXX/expr/expr.unary/expr.new/p14.cpp |   2 +-
 .../CodeGenCXX/cxx1y-sized-deallocation.cpp   |  10 +-
 .../CodeGenCXX/cxx1z-aligned-allocation.cpp   |   6 +-
 .../CodeGenCXX/cxx2a-destroying-delete.cpp|   4 +-
 clang/test/CodeGenCXX/delete-two-arg.cpp  |   4 +-
 clang/test/CodeGenCXX/delete.cpp  |  12 +-
 clang/test/CodeGenCXX/dllimport.cpp   |   4 +-
 clang/test/CodeGenCXX/new.cpp |   6 +-
 .../coro-aligned-alloc-2.cpp  |   2 +
 .../CodeGenCoroutines/coro-aligned-alloc.cpp  |   6 +-
 clang/test/CodeGenCoroutines/coro-alloc.cpp   |   6 +-
 clang/test/CodeGenCoroutines/coro-cleanup.cpp |   6 +-
 clang/test/CodeGenCoroutines/coro-dealloc.cpp |   2 +
 clang/test/CodeGenCoroutines/coro-gro.cpp |   3 +-
 clang/test/CodeGenCoroutines/pr56919.cpp  |   9 +-
 clang/test/Lexer/cxx-features.cpp |  20 +-
 clang/test/PCH/cxx1z-aligned-alloc.cpp|  10 +-
 clang/test/SemaCXX/MicrosoftExtensions.cpp|   8 +-
 .../SemaCXX/builtin-operator-new-delete.cpp   |   2 +-
 .../test/SemaCXX/cxx1y-sized-deallocation.cpp |   2 +-
 .../unavailable_aligned_allocation.cpp|  15 +-
 clang/tools/clang-repl/CMakeLists.txt |  59 -
 clang/unittests/Interpreter/CMakeLists.txt|  59 -
 .../StaticAnalyzer/CallEventTest.cpp  |   2 +-
 clang/www/cxx_status.html |  11 +-
 .../support.dynamic/libcpp_deallocate.sh.cpp  |   3 -
 .../sized_delete_array14.pass.cpp |   8 +-
 .../new.delete.single/sized_delete14.pass.cpp |   8 +-
 42 files changed, 113 insertions(+), 555 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 88aae2729904f4a..799a549ff0816e3 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -839,9 +839,7 @@ TEST_F(TargetDeclTest, OverloadExpr) {
   [[delete]] x;
 }
   )cpp";
-  // Sized deallocation is enabled by default in C++14 onwards.
-  EXPECT_DECLS("CXXDeleteExpr",
-   "void operator delete(void *, unsigned long) noexcept");
+  EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
index f86fe8a4c5b14f6..78f021144b2e19c 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
@@ -12,6 +12,16 @@ struct S {
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
 void *operator new(size_t size) noexcept(false);
 
+struct T {
+  // Sized deallocations are not enabled by default, and so this new/delete 
pair
+  // does not match. However, we expect only one warning, for the new, because
+  // the operator delete is a placement delete and we do not warn on 
mismatching
+  // placement operations.
+  // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' 
has no matching declaration of 'operator delete' at the same scope
+  void *operator new(size_t size) noexcept;
+  void operator delete(void *ptr, size_t) noexcept; // ok only if sized 
deallocation is enabled
+};
+
 struct U {
   void *operator new(size_t size) noexcept;
   void operator delete(void *ptr) noexcept;
diff --git a/clang/docs/ReleaseNotes.rst 

[clang] [compiler-rt] [asan][windows] Eliminate the static asan runtime on windows (PR #81677)

2024-04-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

It's LGTM, but it's going to be annoying to merge.
I bet this patch has several reasons to be reverted, and will be reverted 
multiple times.
It would be nice to try to split into smaller parts.


https://github.com/llvm/llvm-project/pull/81677
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [asan][windows] Eliminate the static asan runtime on windows (PR #81677)

2024-04-26 Thread Vitaly Buka via cfe-commits


@@ -35,6 +35,9 @@
 // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc  
   \
 // RUN:  | grep -e "INTERFACE_\(WEAK_\)\?FUNCTION" 
   \
 // RUN:  | grep -v "__sanitizer_weak_hook" 
   \
+// RUN:  | grep -v "__sanitizer_override_function" 
   \

vitalybuka wrote:

can we move related changes into a separate patch

https://github.com/llvm/llvm-project/pull/81677
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-04-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Delete uses __get_long_cap()

```
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void 
__set_long_cap(size_type __s) _NOEXCEPT {
__r_.first().__l.__cap_ = __s / __endian_factor;
__r_.first().__l.__is_long_ = true;
  }

  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type 
__get_long_cap() const _NOEXCEPT {
return __r_.first().__l.__cap_ * __endian_factor;
  }
```

And if __set_long_cap() provided with odd number, and __endian_factor == 2, 
__get_long_cap() will be short by 1.

https://github.com/llvm/llvm-project/pull/83774
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-04-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

@ldionne looks like a bug in std::string

```
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1123,7 +1123,7 @@ public:
   inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() {
 __annotate_delete();
 if (__is_long())
-  __alloc_traits::deallocate(__alloc(), __get_long_pointer(), 
__get_long_cap());
+  __alloc_traits::deallocate(__alloc(), __get_long_pointer(), 
__get_long_cap() + 1);
   }
 
```

https://github.com/llvm/llvm-project/pull/83774
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-04-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

This is causing new/delete mismatch 
https://lab.llvm.org/buildbot/#/builders/168/builds/20063

```
=
==2164144==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x503035b0 
in thread T0:
  object passed to delete has wrong type:
  size of the allocated type:   25 bytes;
  size of the deallocated type: 24 bytes.
#0 0x555c21886d82 in operator delete(void*, unsigned long) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:155:3
#1 0x555c21a2d47c in __libcpp_operator_delete 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:279:3
#2 0x555c21a2d47c in __do_deallocate_handle_size<> 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:303:10
#3 0x555c21a2d47c in __libcpp_deallocate 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:316:12
#4 0x555c21a2d47c in deallocate 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator.h:133:7
#5 0x555c21a2d47c in deallocate 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator_traits.h:312:9
#6 0x555c21a2d47c in ~basic_string 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1126:7
#7 0x555c21a2d47c in 
llvm::TGParser::addDefOne(std::__1::unique_ptr>) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:545:22
#8 0x555c21a2bc41 in llvm::TGParser::addEntry(llvm::RecordsEntry) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:416:10
#9 0x555c21a5948e in llvm::TGParser::ParseDef(llvm::MultiClass*) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:3625:10
#10 0x555c21a5ccab in llvm::TGParser::ParseObject(llvm::MultiClass*) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4325:31
#11 0x555c21a651f1 in ParseObjectList 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4356:9
#12 0x555c21a651f1 in llvm::TGParser::ParseFile() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:4365:7
#13 0x555c219ba36f in llvm::TableGenMain(char const*, 
std::__1::function) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/Main.cpp:125:14
#14 0x555c218986c5 in main 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/TableGen/TableGen.cpp:84:10
#15 0x7f0373e2814f  (/lib/x86_64-linux-gnu/libc.so.6+0x2814f) (BuildId: 
6a981b07a3731293c24c10a21397416d3c3d52ed)
#16 0x7f0373e28208 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x28208) (BuildId: 
6a981b07a3731293c24c10a21397416d3c3d52ed)
#17 0x555c217b2cb4 in _start 
(/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/llvm-min-tblgen+0x134cb4)
0x503035b0 is located 0 bytes inside of 25-byte region 
[0x503035b0,0x503035c9)
allocated by thread T0 here:
#0 0x555c2188611d in operator new(unsigned long) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:86:3
#1 0x555c219f9c45 in __libcpp_operator_new 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:270:10
#2 0x555c219f9c45 in __libcpp_allocate 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/new:294:10
#3 0x555c219f9c45 in allocate 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator.h:119:32
#4 0x555c219f9c45 in __allocate_at_least > 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocate_at_least.h:41:19
#5 0x555c219f9c45 in __init 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:2228:25
#6 0x555c219f9c45 in basic_string 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1071:5
#7 0x555c219f9c45 in llvm::StringInit::getAsUnquotedString() const 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/TableGen/Record.h:736:12
#8 0x555c21a2d398 in getNameInitAsString 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/TableGen/Record.h:1718:27
#9 0x555c21a2d398 in 
llvm::TGParser::addDefOne(std::__1::unique_ptr>) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:545:42
#10 0x555c21a2bc41 in llvm::TGParser::addEntry(llvm::RecordsEntry) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/TableGen/TGParser.cpp:416:10
#11 0x555c21a5948e in llvm::TGParser::ParseDef(llvm::MultiClass*) 

[clang] [llvm] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)

2024-04-16 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/87568
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/89006
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> I would not run clang-format on the revert

Done. Reverted to github generated 1d59298

https://github.com/llvm/llvm-project/pull/89006
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/89006

>From 1d59298cd9ed21e1ac860d64f965514a577f45bb Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 16 Apr 2024 17:23:47 -0700
Subject: [PATCH 1/2] Revert "Improve stack usage to increase recursive
 initialization depth (#88546)"

This reverts commit 4082a7554521572a65a5a0008c4661a534df659d.
---
 clang/docs/ReleaseNotes.rst   |  6 --
 clang/include/clang/Sema/Initialization.h |  6 +-
 clang/include/clang/Sema/Overload.h   | 70 +--
 clang/lib/Sema/SemaInit.cpp   | 26 -
 clang/lib/Sema/SemaOverload.cpp   | 21 ---
 5 files changed, 75 insertions(+), 54 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4aedfafcb26aea..3752b6ce157600 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -203,12 +203,6 @@ Non-comprehensive list of changes in this release
 - ``__typeof_unqual__`` is available in all C modes as an extension, which 
behaves
   like ``typeof_unqual`` from C23, similar to ``__typeof__`` and ``typeof``.
 
-- Improved stack usage with C++ initialization code. This allows significantly
-  more levels of recursive initialization before reaching stack exhaustion
-  limits. This will positively impact recursive template instantiation code,
-  but should also reduce memory overhead for initializations in general.
-  Fixes #GH88330
-
 New Compiler Flags
 --
 - ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
diff --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 1ceacf0f49f568..2072cd8d1c3ef8 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -1134,7 +1134,7 @@ class InitializationSequence {
   OverloadingResult FailedOverloadResult;
 
   /// The candidate set created when initialization failed.
-  std::unique_ptr FailedCandidateSet;
+  OverloadCandidateSet FailedCandidateSet;
 
   /// The incomplete type that caused a failure.
   QualType FailedIncompleteType;
@@ -1403,9 +1403,7 @@ class InitializationSequence {
   /// Retrieve a reference to the candidate set when overload
   /// resolution fails.
   OverloadCandidateSet () {
-assert(FailedCandidateSet &&
-   "this should have been allocated in the constructor!");
-return *FailedCandidateSet;
+return FailedCandidateSet;
   }
 
   /// Get the overloading result, for when the initialization
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e6f88bbf7c4f47..76311b00d2fc58 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -37,7 +37,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace clang {
@@ -875,8 +874,7 @@ class Sema;
 ConversionFixItGenerator Fix;
 
 /// Viable - True to indicate that this overload candidate is viable.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Viable : 1;
+bool Viable : 1;
 
 /// Whether this candidate is the best viable function, or tied for being
 /// the best viable function.
@@ -885,14 +883,12 @@ class Sema;
 /// was part of the ambiguity kernel: the minimal non-empty set of viable
 /// candidates such that all elements of the ambiguity kernel are better
 /// than all viable candidates not in the ambiguity kernel.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Best : 1;
+bool Best : 1;
 
 /// IsSurrogate - True to indicate that this candidate is a
 /// surrogate for a conversion to a function pointer or reference
 /// (C++ [over.call.object]).
-LLVM_PREFERRED_TYPE(bool)
-unsigned IsSurrogate : 1;
+bool IsSurrogate : 1;
 
 /// IgnoreObjectArgument - True to indicate that the first
 /// argument's conversion, which for this function represents the
@@ -901,20 +897,18 @@ class Sema;
 /// implicit object argument is just a placeholder) or a
 /// non-static member function when the call doesn't have an
 /// object argument.
-LLVM_PREFERRED_TYPE(bool)
-unsigned IgnoreObjectArgument : 1;
+bool IgnoreObjectArgument : 1;
 
 /// True if the candidate was found using ADL.
-LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
-unsigned IsADLCandidate : 1;
+CallExpr::ADLCallKind IsADLCandidate : 1;
 
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
 
 /// FailureKind - The reason why this candidate is not viable.
-LLVM_PREFERRED_TYPE(OverloadFailureKind)
-unsigned FailureKind : 5;
+/// Actually an OverloadFailureKind.
+unsigned char FailureKind;
 
 /// The number of call arguments that were explicitly provided,
 /// to be used while performing partial ordering of function templates.
@@ -978,9 +972,7 @@ class Sema;
   

[clang] Improve stack usage to increase recursive initialization depth (PR #88546)

2024-04-16 Thread Vitaly Buka via cfe-commits


@@ -1163,12 +1136,7 @@ class Sema;
 ConversionSequenceList
 allocateConversionSequences(unsigned NumConversions) {
   ImplicitConversionSequence *Conversions =
-  slabAllocate(NumConversions);
-
-  // Construct the new objects.
-  for (unsigned I = 0; I != NumConversions; ++I)
-new ([I]) ImplicitConversionSequence();
-
+  new ImplicitConversionSequence[NumConversions];

vitalybuka wrote:

Seems unusual to keep ownership in ArrayRef.
Could we make ConversionSequenceList just a std::vector if it owns the memory?

https://github.com/llvm/llvm-project/pull/88546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Improve stack usage to increase recursive initialization depth (PR #88546)

2024-04-16 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

have ideas about leak, but not sure what to do with perf regression and #88330

Proposing revert https://github.com/llvm/llvm-project/pull/89006 

https://github.com/llvm/llvm-project/pull/88546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "Improve stack usage to increase recursive initialization depth" (PR #89006)

2024-04-16 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/89006

Reverts llvm/llvm-project#88546

Leak and performance regression.
Details in #88546

>From 1d59298cd9ed21e1ac860d64f965514a577f45bb Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 16 Apr 2024 17:23:47 -0700
Subject: [PATCH] Revert "Improve stack usage to increase recursive
 initialization depth (#88546)"

This reverts commit 4082a7554521572a65a5a0008c4661a534df659d.
---
 clang/docs/ReleaseNotes.rst   |  6 --
 clang/include/clang/Sema/Initialization.h |  6 +-
 clang/include/clang/Sema/Overload.h   | 70 +--
 clang/lib/Sema/SemaInit.cpp   | 26 -
 clang/lib/Sema/SemaOverload.cpp   | 21 ---
 5 files changed, 75 insertions(+), 54 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4aedfafcb26aea..3752b6ce157600 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -203,12 +203,6 @@ Non-comprehensive list of changes in this release
 - ``__typeof_unqual__`` is available in all C modes as an extension, which 
behaves
   like ``typeof_unqual`` from C23, similar to ``__typeof__`` and ``typeof``.
 
-- Improved stack usage with C++ initialization code. This allows significantly
-  more levels of recursive initialization before reaching stack exhaustion
-  limits. This will positively impact recursive template instantiation code,
-  but should also reduce memory overhead for initializations in general.
-  Fixes #GH88330
-
 New Compiler Flags
 --
 - ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
diff --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index 1ceacf0f49f568..2072cd8d1c3ef8 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -1134,7 +1134,7 @@ class InitializationSequence {
   OverloadingResult FailedOverloadResult;
 
   /// The candidate set created when initialization failed.
-  std::unique_ptr FailedCandidateSet;
+  OverloadCandidateSet FailedCandidateSet;
 
   /// The incomplete type that caused a failure.
   QualType FailedIncompleteType;
@@ -1403,9 +1403,7 @@ class InitializationSequence {
   /// Retrieve a reference to the candidate set when overload
   /// resolution fails.
   OverloadCandidateSet () {
-assert(FailedCandidateSet &&
-   "this should have been allocated in the constructor!");
-return *FailedCandidateSet;
+return FailedCandidateSet;
   }
 
   /// Get the overloading result, for when the initialization
diff --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index e6f88bbf7c4f47..76311b00d2fc58 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -37,7 +37,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 namespace clang {
@@ -875,8 +874,7 @@ class Sema;
 ConversionFixItGenerator Fix;
 
 /// Viable - True to indicate that this overload candidate is viable.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Viable : 1;
+bool Viable : 1;
 
 /// Whether this candidate is the best viable function, or tied for being
 /// the best viable function.
@@ -885,14 +883,12 @@ class Sema;
 /// was part of the ambiguity kernel: the minimal non-empty set of viable
 /// candidates such that all elements of the ambiguity kernel are better
 /// than all viable candidates not in the ambiguity kernel.
-LLVM_PREFERRED_TYPE(bool)
-unsigned Best : 1;
+bool Best : 1;
 
 /// IsSurrogate - True to indicate that this candidate is a
 /// surrogate for a conversion to a function pointer or reference
 /// (C++ [over.call.object]).
-LLVM_PREFERRED_TYPE(bool)
-unsigned IsSurrogate : 1;
+bool IsSurrogate : 1;
 
 /// IgnoreObjectArgument - True to indicate that the first
 /// argument's conversion, which for this function represents the
@@ -901,20 +897,18 @@ class Sema;
 /// implicit object argument is just a placeholder) or a
 /// non-static member function when the call doesn't have an
 /// object argument.
-LLVM_PREFERRED_TYPE(bool)
-unsigned IgnoreObjectArgument : 1;
+bool IgnoreObjectArgument : 1;
 
 /// True if the candidate was found using ADL.
-LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
-unsigned IsADLCandidate : 1;
+CallExpr::ADLCallKind IsADLCandidate : 1;
 
 /// Whether this is a rewritten candidate, and if so, of what kind?
 LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
 unsigned RewriteKind : 2;
 
 /// FailureKind - The reason why this candidate is not viable.
-LLVM_PREFERRED_TYPE(OverloadFailureKind)
-unsigned FailureKind : 5;
+/// Actually an OverloadFailureKind.
+unsigned char FailureKind;
 
 /// The number of call arguments that were explicitly provided,
 /// to be used while performing 

[clang] Improve stack usage to increase recursive initialization depth (PR #88546)

2024-04-16 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

A new memory leak https://lab.llvm.org/buildbot/#/builders/5/builds/42694

https://github.com/llvm/llvm-project/pull/88546
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)

2024-04-12 Thread Vitaly Buka via cfe-commits


@@ -3233,6 +3233,17 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 if (BuiltinCountZeroBitsGeneric(*this, TheCall))
   return ExprError();
 break;
+
+  case Builtin::BI__builtin_allow_runtime_check: {
+Expr *Arg = TheCall->getArg(0);
+// Check if the argument is a string literal.
+if (!isa(Arg->IgnoreParenImpCasts())) {

vitalybuka wrote:

Resolving in favor of the longer thread above.

https://github.com/llvm/llvm-project/pull/87568
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)

2024-04-12 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/87568
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)

2024-04-12 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/87568
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)

2024-04-12 Thread Vitaly Buka via cfe-commits


@@ -3464,6 +3464,34 @@ Query for this feature with 
``__has_builtin(__builtin_trap)``.
 
 ``__builtin_arm_trap`` is lowered to the ``llvm.aarch64.break`` builtin, and 
then to ``brk #payload``.
 
+``__builtin_allow_runtime_check``

vitalybuka wrote:

Similar __builtin_cpu_is, also works only with literals.

The closest thing I see is c++26 `static_assert` 
https://en.cppreference.com/w/cpp/language/static_assert
And it's parsed in a weird way `EvaluateStaticAssertMessageAsString`
https://godbolt.org/z/Gcf74Ysjs

https://github.com/llvm/llvm-project/pull/87568
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)

2024-04-12 Thread Vitaly Buka via cfe-commits


@@ -3464,6 +3464,34 @@ Query for this feature with 
``__has_builtin(__builtin_trap)``.
 
 ``__builtin_arm_trap`` is lowered to the ``llvm.aarch64.break`` builtin, and 
then to ``brk #payload``.
 
+``__builtin_allow_runtime_check``

vitalybuka wrote:

Not sure how to do that. I would expected that from `__builtin_nan`, but it 
can't do that:
https://godbolt.org/z/hWx47Gqvn

https://github.com/llvm/llvm-project/pull/87568
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][builtin] Implement __builtin_allow_runtime_check (PR #87568)

2024-04-12 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/87568
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][UBSan] Remove rigid metadata checks for `ubsan-bitfield-conversion` (PR #88116)

2024-04-09 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka approved this pull request.


https://github.com/llvm/llvm-project/pull/88116
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

ok
please paste here what ever looks like real failure from the patch
buildbot does not sent me, as I am not on the blame list

https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

I'll land after presubmit checks


https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka approved this pull request.


https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka commented:

Fail i386
```
  UBSan-AddressSanitizer-i386 :: 
TestCases/ImplicitConversion/bitfield-conversion.c
  UBSan-Standalone-i386 :: TestCases/ImplicitConversion/bitfield-conversion.c
```

https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-05 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

This is fixed version of https://github.com/llvm/llvm-project/pull/75481 ?

https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [UBSAN] Preserve ubsan code with ubsan-unique-traps (PR #83470)

2024-04-05 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/83470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [UBSAN] Preserve ubsan code with ubsan-unique-traps (PR #83470)

2024-04-05 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

abandoning

https://github.com/llvm/llvm-project/pull/83470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [UBSAN] Preserve ubsan code with ubsan-unique-traps (PR #83470)

2024-04-05 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

I changed my design, so I don't need that change as is.
Given https://godbolt.org/z/4KfEKq7zb, I can revert your patch, or just leave 
it as is. I have no preference.

https://github.com/llvm/llvm-project/pull/83470
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Guard ubsan checks with `llvm.allow.ubsan.check` (PR #87436)

2024-04-05 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/87436
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Guard ubsan checks with `llvm.allow.ubsan.check` (PR #87436)

2024-04-05 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

I will land, and address followup comments, if any.
It does not change behavior without -mllvm flags.

https://github.com/llvm/llvm-project/pull/87436
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [UBSAN] Rename `remove-traps` to `lower-allow-check` (PR #84853)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/84853
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [UBSAN] Rename `remove-traps` to `lower-allow-check` (PR #84853)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/84853

>From d98585586148f2084e36d06996d6c9190cec57d7 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Mon, 11 Mar 2024 16:32:06 -0700
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 clang/lib/CodeGen/BackendUtil.cpp | 12 +--
 clang/lib/CodeGen/CGExpr.cpp  | 15 +++-
 clang/test/CodeGen/remote-traps.c | 23 -
 llvm/docs/LangRef.rst | 50 ++-
 llvm/include/llvm/IR/Intrinsics.td|  5 ++
 .../SelectionDAG/SelectionDAGBuilder.cpp  |  6 ++
 .../InstCombine/InstCombineCalls.cpp  |  8 ++
 .../Instrumentation/RemoveTrapsPass.cpp   | 26 +++---
 llvm/test/CodeGen/Generic/builtin-hot.ll  | 19 
 .../Transforms/InstCombine/builtin-hot.ll | 25 ++
 .../Transforms/RemoveTraps/remove-traps.ll| 89 +--
 11 files changed, 228 insertions(+), 50 deletions(-)
 create mode 100644 llvm/test/CodeGen/Generic/builtin-hot.ll
 create mode 100644 llvm/test/Transforms/InstCombine/builtin-hot.ll

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 82b30b8d815629..7eab1c4ed44b89 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -84,7 +84,6 @@
 #include "llvm/Transforms/Scalar/EarlyCSE.h"
 #include "llvm/Transforms/Scalar/GVN.h"
 #include "llvm/Transforms/Scalar/JumpThreading.h"
-#include "llvm/Transforms/Scalar/SimplifyCFG.h"
 #include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -100,9 +99,9 @@ using namespace llvm;
 namespace llvm {
 extern cl::opt PrintPipelinePasses;
 
-cl::opt ClRemoveTraps("clang-remove-traps", cl::Optional,
-cl::desc("Insert remove-traps pass."),
-cl::init(false));
+static cl::opt ClRemoveTraps("clang-remove-traps", cl::Optional,
+   cl::desc("Insert remove-traps pass."),
+   cl::init(false));
 
 // Experiment to move sanitizers earlier.
 static cl::opt ClSanitizeOnOptimizerEarlyEP(
@@ -757,11 +756,6 @@ static void addSanitizers(const Triple ,
 // from `buildInlinerPipeline`, which called after profile matching.
 PB.registerScalarOptimizerLateEPCallback(
 [](FunctionPassManager , OptimizationLevel Level) {
-  // RemoveTrapsPass expects trap blocks preceded by conditional
-  // branches, which usually is not the case without SimplifyCFG.
-  // TODO: Remove `SimplifyCFGPass` after switching to dedicated
-  // intrinsic.
-  FPM.addPass(SimplifyCFGPass());
   FPM.addPass(RemoveTrapsPass());
 });
   }
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 59a7fe8925001c..3a27622f165995 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -56,7 +56,14 @@ using namespace CodeGen;
 // Experiment to make sanitizers easier to debug
 static llvm::cl::opt ClSanitizeDebugDeoptimization(
 "ubsan-unique-traps", llvm::cl::Optional,
-llvm::cl::desc("Deoptimize traps for UBSAN so there is 1 trap per check"),
+llvm::cl::desc("Deoptimize traps for UBSAN so there is 1 trap per check."),
+llvm::cl::init(false));
+
+// TODO: Introduce frontend options to enabled per sanitizers, similar to
+// `fsanitize-trap`.
+static llvm::cl::opt ClSanitizeExpHot(
+"ubsan-exp-hot", llvm::cl::Optional,
+llvm::cl::desc("Pass UBSAN checks if `llvm.experimental.hot()` is true."),
 llvm::cl::init(false));
 
 //======//
@@ -3805,6 +3812,12 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
 SanitizerHandler CheckHandlerID) {
   llvm::BasicBlock *Cont = createBasicBlock("cont");
 
+  if (ClSanitizeExpHot) {
+Checked =
+Builder.CreateOr(Checked, Builder.CreateCall(CGM.getIntrinsic(
+  llvm::Intrinsic::experimental_hot)));
+  }
+
   // If we're optimizing, collapse all calls to trap down to just one per
   // check-type per function to save on code size.
   if ((int)TrapBBs.size() <= CheckHandlerID)
diff --git a/clang/test/CodeGen/remote-traps.c 
b/clang/test/CodeGen/remote-traps.c
index 6751afb96d25f2..16e4ebecb5c326 100644
--- a/clang/test/CodeGen/remote-traps.c
+++ b/clang/test/CodeGen/remote-traps.c
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow 
-fsanitize-trap=signed-integer-overflow %s -o - | FileCheck %s 
-// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow 

[clang] [llvm] [UBSAN] Rename `remove-traps` to `lower-allow-check` (PR #84853)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/84853
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Rename `remove-traps` to `lower-builtin-hot` (PR #84853)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/84853
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][CodeGen] Remove SimplifyCFGPass preceding RemoveTrapsPass (PR #84852)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/84852
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][CodeGen] Remove SimplifyCFGPass preceding RemoveTrapsPass (PR #84852)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/84852
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][ubsan] Switch UBSAN optimization to `llvm.allow.{runtime,ubsan}.check()` (PR #84858)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/84858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][ubsan] Switch UBSAN optimization to `llvm.allow.{runtime,ubsan}.check()` (PR #84858)

2024-04-04 Thread Vitaly Buka via cfe-commits


@@ -3805,6 +3812,12 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked,
 SanitizerHandler CheckHandlerID) {
   llvm::BasicBlock *Cont = createBasicBlock("cont");
 
+  if (ClSanitizeExpHot) {
+Checked =
+Builder.CreateOr(Checked, Builder.CreateCall(CGM.getIntrinsic(
+  llvm::Intrinsic::experimental_hot)));

vitalybuka wrote:

Thanks, Added TODO, will do in followup patches.
In this patch I'd like just switch approach.

https://github.com/llvm/llvm-project/pull/84858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][ubsan] Switch UBSAN optimization to `llvm.allow.{runtime,ubsan}.check()` (PR #84858)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/84858

>From 014644897f25ed88a1e17192531cf92110758470 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Mon, 11 Mar 2024 16:58:15 -0700
Subject: [PATCH] [clang][ubsan] Switch UBSAN optimization to
 `llvm.allow.{runtime,ubsan}.check()`

Intrinsic introduced with #84850. Intrinsics improves performance
by 3% comparing to removing traps (on
"test-suite/MultiSource/Benchmarks" with PGO+ThinLTO).

The pass will be renamed with #84853.

RFC: 
https://discourse.llvm.org/t/rfc-add-llvm-experimental-hot-intrinsic-or-llvm-hot/77641

Reviewers: aeubanks, nikic, kstoimenov, dvyukov

Reviewed By: kstoimenov

Pull Request: https://github.com/llvm/llvm-project/pull/84858
---
 clang/test/CodeGen/remote-traps.c |  37 --
 .../Instrumentation/RemoveTrapsPass.cpp   |  27 ++--
 .../Transforms/RemoveTraps/remove-traps.ll| 115 ++
 3 files changed, 107 insertions(+), 72 deletions(-)
 delete mode 100644 clang/test/CodeGen/remote-traps.c

diff --git a/clang/test/CodeGen/remote-traps.c 
b/clang/test/CodeGen/remote-traps.c
deleted file mode 100644
index b12c2c6e23b2d1..00
--- a/clang/test/CodeGen/remote-traps.c
+++ /dev/null
@@ -1,37 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
-// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow 
-fsanitize-trap=signed-integer-overflow %s -o - | FileCheck %s
-// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow 
-fsanitize-trap=signed-integer-overflow -mllvm -remove-traps-random-rate=1 %s 
-o - | FileCheck %s --implicit-check-not="call void @llvm.ubsantrap" 
--check-prefixes=REMOVE
-
-// CHECK-LABEL: define dso_local noundef i32 @test(
-// CHECK-SAME: i32 noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call { i32, i1 } 
@llvm.sadd.with.overflow.i32(i32 [[X]], i32 123), !nosanitize [[META2:![0-9]+]]
-// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, 
!nosanitize [[META2]]
-// CHECK-NEXT:br i1 [[TMP1]], label [[TRAP:%.*]], label [[CONT:%.*]], 
!nosanitize [[META2]]
-// CHECK:   trap:
-// CHECK-NEXT:tail call void @llvm.ubsantrap(i8 0) #[[ATTR3:[0-9]+]], 
!nosanitize [[META2]]
-// CHECK-NEXT:unreachable, !nosanitize [[META2]]
-// CHECK:   cont:
-// CHECK-NEXT:[[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, 
!nosanitize [[META2]]
-// CHECK-NEXT:ret i32 [[TMP2]]
-//
-// REMOVE-LABEL: define dso_local noundef i32 @test(
-// REMOVE-SAME: i32 noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
-// REMOVE-NEXT:  entry:
-// REMOVE-NEXT:[[TMP0:%.*]] = tail call { i32, i1 } 
@llvm.sadd.with.overflow.i32(i32 [[X]], i32 123), !nosanitize [[META2:![0-9]+]]
-// REMOVE-NEXT:[[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, 
!nosanitize [[META2]]
-// REMOVE-NEXT:[[TMP2:%.*]] = xor i1 [[TMP1]], true
-// REMOVE-NEXT:tail call void @llvm.assume(i1 [[TMP2]])
-// REMOVE-NEXT:[[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, 
!nosanitize [[META2]]
-// REMOVE-NEXT:ret i32 [[TMP3]]
-//
-int test(int x) {
-  return x + 123;
-}
-
-
-//.
-// CHECK: [[META2]] = !{}
-//.
-// REMOVE: [[META2]] = !{}
-//.
diff --git a/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp 
b/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp
index b281468cb84ee1..6adc29f8572b54 100644
--- a/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp
+++ b/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
+#include "llvm/IR/Constant.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
@@ -35,9 +36,11 @@ STATISTIC(NumChecksRemoved, "Number of removed checks");
 
 static bool removeUbsanTraps(Function , const BlockFrequencyInfo ,
  const ProfileSummaryInfo *PSI) {
-  SmallVector Remove;
+  SmallVector, 16> ReplaceWithValue;
   std::unique_ptr Rng;
 
+  // TODO:
+  // https://github.com/llvm/llvm-project/pull/84858#discussion_r1520603139
   auto ShouldRemove = [&](bool IsHot) {
 if (!RandomRate.getNumOccurrences())
   return IsHot;
@@ -54,21 +57,23 @@ static bool removeUbsanTraps(Function , const 
BlockFrequencyInfo ,
 continue;
   auto ID = II->getIntrinsicID();
   switch (ID) {
-  case Intrinsic::ubsantrap: {
+  case Intrinsic::allow_ubsan_check:
+  case Intrinsic::allow_runtime_check: {
 ++NumChecksTotal;
 
 bool IsHot = false;
 if (PSI) {
-  uint64_t Count = 0;
-  for (const auto *PR : predecessors())
-Count += BFI.getBlockProfileCount(PR).value_or(0);
+  uint64_t Count = BFI.getBlockProfileCount().value_or(0);
   IsHot = 

[clang] [llvm] [clang][ubsan] Switch UBSAN optimization to `llvm.allow.{runtime,ubsan}.check()` (PR #84858)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/84858
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Guard ubsan checks with `llvm.allow.ubsan.check` (PR #87436)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/87436

>From eec9a27ff0451b923d8ca7d4ff23eb6b8dffa56c Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 2 Apr 2024 17:18:58 -0700
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 clang/test/CodeGen/allow-ubsan-check.c | 207 +
 1 file changed, 207 insertions(+)
 create mode 100644 clang/test/CodeGen/allow-ubsan-check.c

diff --git a/clang/test/CodeGen/allow-ubsan-check.c 
b/clang/test/CodeGen/allow-ubsan-check.c
new file mode 100644
index 00..bc425230c8ec75
--- /dev/null
+++ b/clang/test/CodeGen/allow-ubsan-check.c
@@ -0,0 +1,207 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s 
-fsanitize=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s 
-fsanitize=signed-integer-overflow,integer-divide-by-zero,null 
-fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck 
%s --check-prefixes=TRAP
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s 
-fsanitize=signed-integer-overflow,integer-divide-by-zero,null 
-fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | 
FileCheck %s --check-prefixes=RECOVER
+
+
+// CHECK-LABEL: define dso_local i32 @div(
+// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] 
{
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// CHECK-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[Y_ADDR]], align 4
+// CHECK-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0, !nosanitize 
[[META2:![0-9]+]]
+// CHECK-NEXT:[[TMP3:%.*]] = icmp ne i32 [[TMP0]], -2147483648, 
!nosanitize [[META2]]
+// CHECK-NEXT:[[TMP4:%.*]] = icmp ne i32 [[TMP1]], -1, !nosanitize 
[[META2]]
+// CHECK-NEXT:[[OR:%.*]] = or i1 [[TMP3]], [[TMP4]], !nosanitize [[META2]]
+// CHECK-NEXT:[[TMP5:%.*]] = and i1 [[TMP2]], [[OR]], !nosanitize [[META2]]
+// CHECK-NEXT:br i1 [[TMP5]], label [[CONT:%.*]], label 
[[HANDLER_DIVREM_OVERFLOW:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
+// CHECK:   handler.divrem_overflow:
+// CHECK-NEXT:[[TMP6:%.*]] = zext i32 [[TMP0]] to i64, !nosanitize 
[[META2]]
+// CHECK-NEXT:[[TMP7:%.*]] = zext i32 [[TMP1]] to i64, !nosanitize 
[[META2]]
+// CHECK-NEXT:call void @__ubsan_handle_divrem_overflow_abort(ptr 
@[[GLOB1:[0-9]+]], i64 [[TMP6]], i64 [[TMP7]]) #[[ATTR3:[0-9]+]], !nosanitize 
[[META2]]
+// CHECK-NEXT:unreachable, !nosanitize [[META2]]
+// CHECK:   cont:
+// CHECK-NEXT:[[DIV:%.*]] = sdiv i32 [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret i32 [[DIV]]
+//
+// TRAP-LABEL: define dso_local i32 @div(
+// TRAP-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] {
+// TRAP-NEXT:  entry:
+// TRAP-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// TRAP-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4
+// TRAP-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// TRAP-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4
+// TRAP-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// TRAP-NEXT:[[TMP1:%.*]] = load i32, ptr [[Y_ADDR]], align 4
+// TRAP-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0, !nosanitize 
[[META2:![0-9]+]]
+// TRAP-NEXT:[[TMP3:%.*]] = icmp ne i32 [[TMP0]], -2147483648, !nosanitize 
[[META2]]
+// TRAP-NEXT:[[TMP4:%.*]] = icmp ne i32 [[TMP1]], -1, !nosanitize [[META2]]
+// TRAP-NEXT:[[OR:%.*]] = or i1 [[TMP3]], [[TMP4]], !nosanitize [[META2]]
+// TRAP-NEXT:[[TMP5:%.*]] = and i1 [[TMP2]], [[OR]], !nosanitize [[META2]]
+// TRAP-NEXT:br i1 [[TMP5]], label [[CONT:%.*]], label [[TRAP:%.*]], 
!nosanitize [[META2]]
+// TRAP:   trap:
+// TRAP-NEXT:call void @llvm.ubsantrap(i8 3) #[[ATTR3:[0-9]+]], 
!nosanitize [[META2]]
+// TRAP-NEXT:unreachable, !nosanitize [[META2]]
+// TRAP:   cont:
+// TRAP-NEXT:[[DIV:%.*]] = sdiv i32 [[TMP0]], [[TMP1]]
+// TRAP-NEXT:ret i32 [[DIV]]
+//
+// RECOVER-LABEL: define dso_local i32 @div(
+// RECOVER-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) 
#[[ATTR0:[0-9]+]] {
+// RECOVER-NEXT:  entry:
+// RECOVER-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// RECOVER-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4
+// RECOVER-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// RECOVER-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4
+// RECOVER-NEXT:[[TMP0:%.*]] = 

[clang] 96a99a5 - [NFC][UBSAN] Regenerate a test

2024-04-04 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-04-04T15:54:54-07:00
New Revision: 96a99a5e2f62475f13d7ba18b15acad733909e7f

URL: 
https://github.com/llvm/llvm-project/commit/96a99a5e2f62475f13d7ba18b15acad733909e7f
DIFF: 
https://github.com/llvm/llvm-project/commit/96a99a5e2f62475f13d7ba18b15acad733909e7f.diff

LOG: [NFC][UBSAN] Regenerate a test

Added: 


Modified: 
clang/test/CodeGen/remote-traps.c

Removed: 




diff  --git a/clang/test/CodeGen/remote-traps.c 
b/clang/test/CodeGen/remote-traps.c
index 6983ddbca89291..b12c2c6e23b2d1 100644
--- a/clang/test/CodeGen/remote-traps.c
+++ b/clang/test/CodeGen/remote-traps.c
@@ -1,15 +1,37 @@
-// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow 
-fsanitize-trap=signed-integer-overflow %s -o - | FileCheck %s 
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow 
-fsanitize-trap=signed-integer-overflow %s -o - | FileCheck %s
 // RUN: %clang_cc1 -O1 -emit-llvm -fsanitize=signed-integer-overflow 
-fsanitize-trap=signed-integer-overflow -mllvm -remove-traps-random-rate=1 %s 
-o - | FileCheck %s --implicit-check-not="call void @llvm.ubsantrap" 
--check-prefixes=REMOVE
 
+// CHECK-LABEL: define dso_local noundef i32 @test(
+// CHECK-SAME: i32 noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { i32, i1 } 
@llvm.sadd.with.overflow.i32(i32 [[X]], i32 123), !nosanitize [[META2:![0-9]+]]
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, 
!nosanitize [[META2]]
+// CHECK-NEXT:br i1 [[TMP1]], label [[TRAP:%.*]], label [[CONT:%.*]], 
!nosanitize [[META2]]
+// CHECK:   trap:
+// CHECK-NEXT:tail call void @llvm.ubsantrap(i8 0) #[[ATTR3:[0-9]+]], 
!nosanitize [[META2]]
+// CHECK-NEXT:unreachable, !nosanitize [[META2]]
+// CHECK:   cont:
+// CHECK-NEXT:[[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, 
!nosanitize [[META2]]
+// CHECK-NEXT:ret i32 [[TMP2]]
+//
+// REMOVE-LABEL: define dso_local noundef i32 @test(
+// REMOVE-SAME: i32 noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// REMOVE-NEXT:  entry:
+// REMOVE-NEXT:[[TMP0:%.*]] = tail call { i32, i1 } 
@llvm.sadd.with.overflow.i32(i32 [[X]], i32 123), !nosanitize [[META2:![0-9]+]]
+// REMOVE-NEXT:[[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1, 
!nosanitize [[META2]]
+// REMOVE-NEXT:[[TMP2:%.*]] = xor i1 [[TMP1]], true
+// REMOVE-NEXT:tail call void @llvm.assume(i1 [[TMP2]])
+// REMOVE-NEXT:[[TMP3:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0, 
!nosanitize [[META2]]
+// REMOVE-NEXT:ret i32 [[TMP3]]
+//
 int test(int x) {
   return x + 123;
 }
 
-// CHECK-LABEL: define {{.*}}i32 @test(
-// CHECK: call { i32, i1 } @llvm.sadd.with.overflow.i32(
-// CHECK: trap:
-// CHECK-NEXT: call void @llvm.ubsantrap(i8 0)
-// CHECK-NEXT: unreachable
 
-// REMOVE-LABEL: define {{.*}}i32 @test(
-// REMOVE: call { i32, i1 } @llvm.sadd.with.overflow.i32(
+//.
+// CHECK: [[META2]] = !{}
+//.
+// REMOVE: [[META2]] = !{}
+//.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Guard ubsan checks with `llvm.allow.ubsan.check` (PR #87436)

2024-04-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/87436

>From eec9a27ff0451b923d8ca7d4ff23eb6b8dffa56c Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Tue, 2 Apr 2024 17:18:58 -0700
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 clang/test/CodeGen/allow-ubsan-check.c | 207 +
 1 file changed, 207 insertions(+)
 create mode 100644 clang/test/CodeGen/allow-ubsan-check.c

diff --git a/clang/test/CodeGen/allow-ubsan-check.c 
b/clang/test/CodeGen/allow-ubsan-check.c
new file mode 100644
index 00..bc425230c8ec75
--- /dev/null
+++ b/clang/test/CodeGen/allow-ubsan-check.c
@@ -0,0 +1,207 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s 
-fsanitize=signed-integer-overflow,integer-divide-by-zero,null | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s 
-fsanitize=signed-integer-overflow,integer-divide-by-zero,null 
-fsanitize-trap=signed-integer-overflow,integer-divide-by-zero,null | FileCheck 
%s --check-prefixes=TRAP
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s 
-fsanitize=signed-integer-overflow,integer-divide-by-zero,null 
-fsanitize-recover=signed-integer-overflow,integer-divide-by-zero,null | 
FileCheck %s --check-prefixes=RECOVER
+
+
+// CHECK-LABEL: define dso_local i32 @div(
+// CHECK-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] 
{
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// CHECK-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[Y_ADDR]], align 4
+// CHECK-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0, !nosanitize 
[[META2:![0-9]+]]
+// CHECK-NEXT:[[TMP3:%.*]] = icmp ne i32 [[TMP0]], -2147483648, 
!nosanitize [[META2]]
+// CHECK-NEXT:[[TMP4:%.*]] = icmp ne i32 [[TMP1]], -1, !nosanitize 
[[META2]]
+// CHECK-NEXT:[[OR:%.*]] = or i1 [[TMP3]], [[TMP4]], !nosanitize [[META2]]
+// CHECK-NEXT:[[TMP5:%.*]] = and i1 [[TMP2]], [[OR]], !nosanitize [[META2]]
+// CHECK-NEXT:br i1 [[TMP5]], label [[CONT:%.*]], label 
[[HANDLER_DIVREM_OVERFLOW:%.*]], !prof [[PROF3:![0-9]+]], !nosanitize [[META2]]
+// CHECK:   handler.divrem_overflow:
+// CHECK-NEXT:[[TMP6:%.*]] = zext i32 [[TMP0]] to i64, !nosanitize 
[[META2]]
+// CHECK-NEXT:[[TMP7:%.*]] = zext i32 [[TMP1]] to i64, !nosanitize 
[[META2]]
+// CHECK-NEXT:call void @__ubsan_handle_divrem_overflow_abort(ptr 
@[[GLOB1:[0-9]+]], i64 [[TMP6]], i64 [[TMP7]]) #[[ATTR3:[0-9]+]], !nosanitize 
[[META2]]
+// CHECK-NEXT:unreachable, !nosanitize [[META2]]
+// CHECK:   cont:
+// CHECK-NEXT:[[DIV:%.*]] = sdiv i32 [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret i32 [[DIV]]
+//
+// TRAP-LABEL: define dso_local i32 @div(
+// TRAP-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) #[[ATTR0:[0-9]+]] {
+// TRAP-NEXT:  entry:
+// TRAP-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// TRAP-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4
+// TRAP-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// TRAP-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4
+// TRAP-NEXT:[[TMP0:%.*]] = load i32, ptr [[X_ADDR]], align 4
+// TRAP-NEXT:[[TMP1:%.*]] = load i32, ptr [[Y_ADDR]], align 4
+// TRAP-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0, !nosanitize 
[[META2:![0-9]+]]
+// TRAP-NEXT:[[TMP3:%.*]] = icmp ne i32 [[TMP0]], -2147483648, !nosanitize 
[[META2]]
+// TRAP-NEXT:[[TMP4:%.*]] = icmp ne i32 [[TMP1]], -1, !nosanitize [[META2]]
+// TRAP-NEXT:[[OR:%.*]] = or i1 [[TMP3]], [[TMP4]], !nosanitize [[META2]]
+// TRAP-NEXT:[[TMP5:%.*]] = and i1 [[TMP2]], [[OR]], !nosanitize [[META2]]
+// TRAP-NEXT:br i1 [[TMP5]], label [[CONT:%.*]], label [[TRAP:%.*]], 
!nosanitize [[META2]]
+// TRAP:   trap:
+// TRAP-NEXT:call void @llvm.ubsantrap(i8 3) #[[ATTR3:[0-9]+]], 
!nosanitize [[META2]]
+// TRAP-NEXT:unreachable, !nosanitize [[META2]]
+// TRAP:   cont:
+// TRAP-NEXT:[[DIV:%.*]] = sdiv i32 [[TMP0]], [[TMP1]]
+// TRAP-NEXT:ret i32 [[DIV]]
+//
+// RECOVER-LABEL: define dso_local i32 @div(
+// RECOVER-SAME: i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) 
#[[ATTR0:[0-9]+]] {
+// RECOVER-NEXT:  entry:
+// RECOVER-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// RECOVER-NEXT:[[Y_ADDR:%.*]] = alloca i32, align 4
+// RECOVER-NEXT:store i32 [[X]], ptr [[X_ADDR]], align 4
+// RECOVER-NEXT:store i32 [[Y]], ptr [[Y_ADDR]], align 4
+// RECOVER-NEXT:[[TMP0:%.*]] = 

[clang] abd05eb - [clang] Init fields added by #87357

2024-04-03 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-04-03T17:48:25-07:00
New Revision: abd05eb4a53e6c7760496620da417733f52d4bf9

URL: 
https://github.com/llvm/llvm-project/commit/abd05eb4a53e6c7760496620da417733f52d4bf9
DIFF: 
https://github.com/llvm/llvm-project/commit/abd05eb4a53e6c7760496620da417733f52d4bf9.diff

LOG: [clang] Init fields added by #87357

Added: 


Modified: 
clang/include/clang/Frontend/FrontendOptions.h

Removed: 




diff  --git a/clang/include/clang/Frontend/FrontendOptions.h 
b/clang/include/clang/Frontend/FrontendOptions.h
index 864af66b337069..5ee4d471670f48 100644
--- a/clang/include/clang/Frontend/FrontendOptions.h
+++ b/clang/include/clang/Frontend/FrontendOptions.h
@@ -580,7 +580,9 @@ class FrontendOptions {
 BuildingImplicitModuleUsesLock(true), ModulesEmbedAllFiles(false),
 IncludeTimestamps(true), UseTemporary(true),
 AllowPCMWithCompilerErrors(false), ModulesShareFileManager(true),
-TimeTraceGranularity(500) {}
+EmitSymbolGraph(false), EmitExtensionSymbolGraphs(false),
+EmitSymbolGraphSymbolLabelsForTesting(false),
+EmitPrettySymbolGraphs(false), TimeTraceGranularity(500) {}
 
   /// getInputKindForExtension - Return the appropriate input kind for a file
   /// extension. For example, "c" would return Language::C.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 633bc3b - [CodeGen][NFC] Make an opt<> static

2024-04-02 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-04-02T15:47:04-07:00
New Revision: 633bc3bfda71c55bc38d5a3bfdb426bab61ff101

URL: 
https://github.com/llvm/llvm-project/commit/633bc3bfda71c55bc38d5a3bfdb426bab61ff101
DIFF: 
https://github.com/llvm/llvm-project/commit/633bc3bfda71c55bc38d5a3bfdb426bab61ff101.diff

LOG: [CodeGen][NFC] Make an opt<> static

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 1220c575d1df9f..c8b2a93ae47add 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -100,8 +100,8 @@ using namespace llvm;
 namespace llvm {
 extern cl::opt PrintPipelinePasses;
 
-cl::opt ClRemoveTraps("clang-remove-traps", cl::Optional,
-cl::desc("Insert remove-traps pass."));
+static cl::opt ClRemoveTraps("clang-remove-traps", cl::Optional,
+   cl::desc("Insert remove-traps pass."));
 
 // Experiment to move sanitizers earlier.
 static cl::opt ClSanitizeOnOptimizerEarlyEP(



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Better bitfield access units (PR #65742)

2024-04-01 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

This failure is caused by the patch
https://lab.llvm.org/buildbot/#/builders/239/builds/6363/steps/10/logs/stdio
cc @hctim 

https://github.com/llvm/llvm-project/pull/65742
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix bitfield access unit for vbase corner case (PR #87238)

2024-04-01 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

This failure is caused by the patch 
https://lab.llvm.org/buildbot/#/builders/239/builds/6363/steps/10/logs/stdio

https://github.com/llvm/llvm-project/pull/87238
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e93b5f5 - [ubsan][NFC] Remove recently added `cl::init(false)`

2024-04-01 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2024-04-01T13:37:42-07:00
New Revision: e93b5f5a4776ffea12d03652559dfdf8d421184c

URL: 
https://github.com/llvm/llvm-project/commit/e93b5f5a4776ffea12d03652559dfdf8d421184c
DIFF: 
https://github.com/llvm/llvm-project/commit/e93b5f5a4776ffea12d03652559dfdf8d421184c.diff

LOG: [ubsan][NFC] Remove recently added `cl::init(false)`

Extracted from #84858

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 82b30b8d815629..1220c575d1df9f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -101,20 +101,19 @@ namespace llvm {
 extern cl::opt PrintPipelinePasses;
 
 cl::opt ClRemoveTraps("clang-remove-traps", cl::Optional,
-cl::desc("Insert remove-traps pass."),
-cl::init(false));
+cl::desc("Insert remove-traps pass."));
 
 // Experiment to move sanitizers earlier.
 static cl::opt ClSanitizeOnOptimizerEarlyEP(
 "sanitizer-early-opt-ep", cl::Optional,
-cl::desc("Insert sanitizers on OptimizerEarlyEP."), cl::init(false));
+cl::desc("Insert sanitizers on OptimizerEarlyEP."));
 
 extern cl::opt ProfileCorrelate;
 
 // Re-link builtin bitcodes after optimization
 cl::opt ClRelinkBuiltinBitcodePostop(
 "relink-builtin-bitcode-postop", cl::Optional,
-cl::desc("Re-link builtin bitcodes after optimization."), cl::init(false));
+cl::desc("Re-link builtin bitcodes after optimization."));
 } // namespace llvm
 
 namespace {

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index e0d5575d57d02d..54432353e7420d 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -56,8 +56,7 @@ using namespace CodeGen;
 // Experiment to make sanitizers easier to debug
 static llvm::cl::opt ClSanitizeDebugDeoptimization(
 "ubsan-unique-traps", llvm::cl::Optional,
-llvm::cl::desc("Deoptimize traps for UBSAN so there is 1 trap per check"),
-llvm::cl::init(false));
+llvm::cl::desc("Deoptimize traps for UBSAN so there is 1 trap per check"));
 
 //======//
 //Miscellaneous Helper Methods



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstCombiner] Remove trivially dead `llvm.allow.{runtime,ubsan}.check()` (PR #84851)

2024-04-01 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/84851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [InstCombiner] Remove trivially dead `llvm.allow.{runtime,ubsan}.check()` (PR #84851)

2024-03-31 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/84851
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix buffer overflow in compareHeaders (PR #87213)

2024-03-31 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/87213
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix buffer overflow in compareHeaders (PR #87213)

2024-03-31 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/87213
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Fix buffer overflow in compareHeaders (PR #87213)

2024-03-31 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/87213

`RHS` can be shorter than `LHS`.

Reported by asan after #83440.


>From a6d57814761cb74de98b40a4cc3acdd9b262e854 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Sun, 31 Mar 2024 18:42:25 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp 
b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
index b6d9c50d0b109c..a44720c47eca2d 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -108,7 +108,7 @@ int compareHeaders(StringRef LHS, StringRef RHS,
IncludeSorter::IncludeStyle Style) {
   if (Style == IncludeSorter::IncludeStyle::IS_Google_ObjC) {
 const std::pair  =
-std::mismatch(LHS.begin(), LHS.end(), RHS.begin());
+std::mismatch(LHS.begin(), LHS.end(), RHS.begin(), RHS.end());
 if ((Mismatch.first != LHS.end()) && (Mismatch.second != RHS.end())) {
   if ((*Mismatch.first == '.') && (*Mismatch.second == '+')) {
 return -1;

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [flang] [libc] [libcxx] [lld] [lldb] [llvm] [NFC][IR] Add SetNoSanitize helpers (PR #86772)

2024-03-27 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka closed 
https://github.com/llvm/llvm-project/pull/86772
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [flang] [libc] [libcxx] [lld] [lldb] [llvm] [NFC][IR] Add SetNoSanitize helpers (PR #86772)

2024-03-27 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/86772
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> ah I see. I feel like this should be a more principled approach that other 
> sanitizers also share, as you've mentioned as an alternative. do people not 
> care about other sanitizers in production?

Actually Asan should not exhibit this behavior, by some lack it does not 
instrument PGO counters.

I will try generic approach by marking PGO as MD_nosanitize


https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka converted_to_draft 
https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Looked into IR and HWASAN instrument stuff which it should not 
https://godbolt.org/z/MnYs75Meq

Should be easy to fix.

https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:


> I think I'm still confused on exactly what the use case is and why we can't 
> just ask the user to not specify hwasan in the PGO instrumented build. Just 
> for user convenience? Or does clang change the emitted IR when hwasan is 
> enabled? And that's what will lead to mismatched profiles?

-fno-sanitize= IR changes:
1. #ifdef branches on sanitizer
2. function attributes
3. some pre-profile optimization suppressed with sanitizer

maybe other reasons, but as is profile does not match if collected with 
-fno-sanitize=hwsan

https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Alternative is we need a new clang fronted flag to control this behavior.
Assuming that this is rather strange use case, I'd prefer to land the patch and 
introduce new flag only when we have request for that case.

https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

We already have similar stuff:
```
if (PGOOpt && Phase != ThinOrFullLTOPhase::ThinLTOPostLink &&
  !PGOOpt->MemoryProfile.empty())
MPM.addPass(MemProfUsePass(PGOOpt->MemoryProfile, PGOOpt->FS));
```

https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> > > why can't hwasan and PGO instrumentation coexist?
> > 
> > 
> > They can, but binary is like 5x times slower, on top of 10x slowdown of PGO 
> > instrumentation. (don't quote me on these numbers, they are from large but 
> > single benchmark, still it's very slow)
> 
> If it's usable as a configuration, I don't see why we should prevent this. It 
> still may be useful to some people. Seems like this checking should be done 
> at a build system level if you don't want some codebase to compile with this 
> configuration.
> 

At the moment builds system can only disable HWASAN, there is no option to 
enabled HWASAN but drop the pass.

> > > and this seems like it should be an error at the clang driver level, 
> > > instead of silently turning off one of the requested features
> > 
> > 
> > 
> > 1. We need -fsanitizer=hwaddress, for attributes and profile matching, and 
> > some special handling done in earlier passes.
> 
> Do you mean that if you want a hwasan/PGO optimized build, you want the 
> corresponding PGO instrumented build to also use hwasan?

I want PGO optimized binary with HWASAN.
But I don't rely want collect PGO profile with HWASAN, because the process is 
very slow.

> 
> Doesn't PGO instrumentation/use happen before the sanitizer passes run?

Instrumentation/use happens before sanitizer pass.
This is why drooping the pass will still produce the same optimized binary.

> 
> > 2. We don't wan't users care about profile instrumentation/use difference.



https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> why can't hwasan and PGO instrumentation coexist?

They can, but binary is like 5x times slower, on top of 10x slowdown of PGO 
instrumentation.

> 
> and this seems like it should be an error at the clang driver level, instead 
> of silently turning off one of the requested features

1. We need -fsanitizer=hwaddress, for attributes and profile matching, and some 
special handling done in earlier passes.
2. We don't wan't users care about profile instrumentation/use difference.

https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [hwasan] Don't instrument when PGO profile is collected (PR #86739)

2024-03-26 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka edited 
https://github.com/llvm/llvm-project/pull/86739
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   >