[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread via cfe-commits


@@ -95,8 +103,31 @@ std::pair 
ClangASTNodesEmitter::EmitNode(raw_ostream &OS,
   if (!Base.isAbstract())
 First = Last = Base;
 
+  class Comp {

cor3ntin wrote:

Yes, this might as well be a lambda.
I also think some comment to explain what PriorizeIfSubclassOf is and why it is 
used would be useful;
We might very well forget why we put classes that are declcontext first in the 
future.

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


[clang] [clang][analyzer] Support 'fdopen' in the StreamChecker (PR #76776)

2024-01-04 Thread Ben Shi via cfe-commits

benshi001 wrote:

> One note that should be added to the documentation: The `StreamChecker` does 
> not handle file descriptors associated to streams. Therefore some issues can 
> appear, for example `fileno` does not return the value that was used to open 
> a stream with `fdopen`, and the standard streams do not work accurately with 
> this checker.

which document file should I modify? Do you mean the release note ?

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


[lldb] [clang] [llvm] [mlir] [libc] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-04 Thread Bill Wendling via cfe-commits

https://github.com/bwendling updated 
https://github.com/llvm/llvm-project/pull/76882

>From ca7a96a40952fe94b916dacc52f07aa90bbdb1e7 Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Wed, 3 Jan 2024 13:22:37 -0800
Subject: [PATCH 1/5] [builtin_object_size] Use classes instead of std::pair
 (NFC)

The use of std::pair makes the values it holds opaque. Using classes
improves this while keeping the POD aspect of a std::pair. As a nice
addition, the "known" functions held inappropriately in the Visitor
classes can now properly reside in the value classes. :-)
---
 llvm/include/llvm/Analysis/MemoryBuiltins.h   | 192 +++
 llvm/lib/Analysis/MemoryBuiltins.cpp  | 314 +-
 .../Transforms/IPO/AttributorAttributes.cpp   |   8 +-
 .../Instrumentation/AddressSanitizer.cpp  |  12 +-
 .../Instrumentation/BoundsChecking.cpp|   8 +-
 5 files changed, 299 insertions(+), 235 deletions(-)

diff --git a/llvm/include/llvm/Analysis/MemoryBuiltins.h 
b/llvm/include/llvm/Analysis/MemoryBuiltins.h
index 827b5081b2ce75..56faa32fb0b226 100644
--- a/llvm/include/llvm/Analysis/MemoryBuiltins.h
+++ b/llvm/include/llvm/Analysis/MemoryBuiltins.h
@@ -187,80 +187,146 @@ Value *lowerObjectSizeCall(
 const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed,
 SmallVectorImpl *InsertedInstructions = nullptr);
 
-using SizeOffsetType = std::pair;
+/// SizeOffsetType - A base template class for the object size visitors. Used
+/// here as a self-documenting way to handle the values rather than using a
+/// \p std::pair.
+template  struct SizeOffsetType {
+  T Size;
+  T Offset;
+
+  bool knownSize() const;
+  bool knownOffset() const;
+  bool anyKnown() const;
+  bool bothKnown() const;
+};
+
+/// SizeOffsetType - Used by \p ObjectSizeOffsetVisitor, which works
+/// with \p APInts.
+template <> struct SizeOffsetType {
+  APInt Size;
+  APInt Offset;
+
+  SizeOffsetType() = default;
+  SizeOffsetType(APInt Size, APInt Offset) : Size(Size), Offset(Offset) {}
+
+  bool knownSize() const { return Size.getBitWidth() > 1; }
+  bool knownOffset() const { return Offset.getBitWidth() > 1; }
+  bool anyKnown() const { return knownSize() || knownOffset(); }
+  bool bothKnown() const { return knownSize() && knownOffset(); }
+
+  bool operator==(const SizeOffsetType &RHS) {
+return Size == RHS.Size && Offset == RHS.Offset;
+  }
+  bool operator!=(const SizeOffsetType &RHS) { return !(*this == RHS); }
+};
+using SizeOffsetAPInt = SizeOffsetType;
 
 /// Evaluate the size and offset of an object pointed to by a Value*
 /// statically. Fails if size or offset are not known at compile time.
 class ObjectSizeOffsetVisitor
-  : public InstVisitor {
+: public InstVisitor {
   const DataLayout &DL;
   const TargetLibraryInfo *TLI;
   ObjectSizeOpts Options;
   unsigned IntTyBits;
   APInt Zero;
-  SmallDenseMap SeenInsts;
+  SmallDenseMap SeenInsts;
   unsigned InstructionsVisited;
 
   APInt align(APInt Size, MaybeAlign Align);
 
-  SizeOffsetType unknown() {
-return std::make_pair(APInt(), APInt());
-  }
+  static SizeOffsetAPInt unknown;
 
 public:
   ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI,
   LLVMContext &Context, ObjectSizeOpts Options = {});
 
-  SizeOffsetType compute(Value *V);
-
-  static bool knownSize(const SizeOffsetType &SizeOffset) {
-return SizeOffset.first.getBitWidth() > 1;
-  }
-
-  static bool knownOffset(const SizeOffsetType &SizeOffset) {
-return SizeOffset.second.getBitWidth() > 1;
-  }
-
-  static bool bothKnown(const SizeOffsetType &SizeOffset) {
-return knownSize(SizeOffset) && knownOffset(SizeOffset);
-  }
+  SizeOffsetAPInt compute(Value *V);
 
   // These are "private", except they can't actually be made private. Only
   // compute() should be used by external users.
-  SizeOffsetType visitAllocaInst(AllocaInst &I);
-  SizeOffsetType visitArgument(Argument &A);
-  SizeOffsetType visitCallBase(CallBase &CB);
-  SizeOffsetType visitConstantPointerNull(ConstantPointerNull&);
-  SizeOffsetType visitExtractElementInst(ExtractElementInst &I);
-  SizeOffsetType visitExtractValueInst(ExtractValueInst &I);
-  SizeOffsetType visitGlobalAlias(GlobalAlias &GA);
-  SizeOffsetType visitGlobalVariable(GlobalVariable &GV);
-  SizeOffsetType visitIntToPtrInst(IntToPtrInst&);
-  SizeOffsetType visitLoadInst(LoadInst &I);
-  SizeOffsetType visitPHINode(PHINode&);
-  SizeOffsetType visitSelectInst(SelectInst &I);
-  SizeOffsetType visitUndefValue(UndefValue&);
-  SizeOffsetType visitInstruction(Instruction &I);
+  SizeOffsetAPInt visitAllocaInst(AllocaInst &I);
+  SizeOffsetAPInt visitArgument(Argument &A);
+  SizeOffsetAPInt visitCallBase(CallBase &CB);
+  SizeOffsetAPInt visitConstantPointerNull(ConstantPointerNull &);
+  SizeOffsetAPInt visitExtractElementInst(ExtractElementInst &I);
+  SizeOffsetAPInt visitExtractValueInst(ExtractValueInst &I);
+  SizeOffsetAPInt visitGlobalAlias(GlobalAlias &GA);
+  SizeOffsetAPInt

[lldb] [clang] [llvm] [lld] [compiler-rt] [libcxx] [flang] [libc] [clang-tools-extra] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-04 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

> Thanks for working on this! There's a fair bit that I've provided comments 
> for, but I think you're off to a great start, and I would like to see this 
> merged in January, if at all possible.
> 
> Some comments are short and repetitive: those are usually coupled with a 
> starter comment that explains my perspective, and then I just flag the others 
> as I see them in a (hopefully) non-intrusive way.

Thank you very much for the review!

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


[clang] [OpenMP][USM] Adds test for -fopenmp-force-usm flag (PR #75467)

2024-01-04 Thread Jan Patrick Lehr via cfe-commits

jplehr wrote:

The IR is impacted for the global that is in that test case. Lines ~46-50 
(first IR section) vs line ~68 (second IR section). The remaining code is 
indeed the same.
The way that this test is executed is out of date however, given that I have 
reimplemented the flag.
My plan is to keep this test and add a few runtime tests as well, since we 
should be able to validate that we do not see data transfers.

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


[clang] [clang] static operators should evaluate object argument (PR #68485)

2024-01-04 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

Ping.

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


[clang] [Cygwin] Cygwin basic support (PR #74868)

2024-01-04 Thread 徐持恒 Xu Chiheng via cfe-commits

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


[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-04 Thread Owen Pan via cfe-commits

owenca wrote:

It had passed my local tests (x64 Native Tools Command Prompt for VS 2022) and 
the buildkite win build, so I wonder if it has something to do with the grep in 
the failed buildbot (only 
https://lab.llvm.org/buildbot/#/builders/123/builds/23808 so far) as I only 
used the POSIX options -F and -x. Should I turn it off for Windows like we did 
to 
[style-on-command-line.cpp](https://github.com/llvm/llvm-project/blob/8c72ff716b3e4b298695fa3faf6add860c6dbcb2/clang/test/Format/style-on-command-line.cpp#L50)?

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


[clang-tools-extra] [lldb] [compiler-rt] [llvm] [clang] [flang] [libc] [lldb][NFC] Fix compilation issue on windows (PR #76453)

2024-01-04 Thread David Spickett via cfe-commits

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


[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2024-01-04 Thread Balazs Benics via cfe-commits

steakhal wrote:

FYI commit 09308122c6c0fa9eb3d729a2b2909733cbbc2160 added [a 
test](https://github.com/llvm/llvm-project/commit/09308122c6c0fa9eb3d729a2b2909733cbbc2160#diff-acfc8d9d85320dbf5e181b8aebb248a91b1d321c8798bae3663b44b0c08213db)
 that does not pass on Windows (MSVC).

An example failure:
https://lab.llvm.org/buildbot/#/builders/123/builds/23811/steps/8/logs/stdio

```
Testing: 
FAIL: Clang :: Format/clang-format-ignore.cpp (1 of 19133)
 TEST 'Clang :: Format/clang-format-ignore.cpp' FAILED 

Exit Code: 1
Command Output (stdout):
--
# RUN: at line 1
rm -rf 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.dir
# executed command: rm -rf 
'C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.dir'
# RUN: at line 2
mkdir -p 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.dir/level1/level2
# executed command: mkdir -p 
'C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.dir/level1/level2'
# RUN: at line 4
cd 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.dir
# executed command: cd 
'C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.dir'
# RUN: at line 5
echo "*" > .clang-format-ignore
# executed command: echo '*'
# RUN: at line 6
echo "level*/*.c*" >> .clang-format-ignore
# executed command: echo 'level*/*.c*'
# RUN: at line 7
echo "*/*2/foo.*" >> .clang-format-ignore
# executed command: echo '*/*2/foo.*'
# RUN: at line 8
touch foo.cc
# executed command: touch foo.cc
# RUN: at line 9
c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\clang-format.exe -verbose 
.clang-format-ignore foo.cc 2> 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr
# executed command: 
'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\clang-format.exe' -verbose 
.clang-format-ignore foo.cc
# RUN: at line 10
not grep Formatting 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr
# executed command: not grep Formatting 
'C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr'
# RUN: at line 12
cd level1
# executed command: cd level1
# RUN: at line 13
touch bar.cc baz.c
# executed command: touch bar.cc baz.c
# RUN: at line 14
c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\clang-format.exe -verbose 
bar.cc baz.c 2> 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr
# executed command: 
'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\clang-format.exe' -verbose 
bar.cc baz.c
# RUN: at line 15
not grep Formatting 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr
# executed command: not grep Formatting 
'C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr'
# RUN: at line 17
cd level2
# executed command: cd level2
# RUN: at line 18
touch foo.c foo.js
# executed command: touch foo.c foo.js
# RUN: at line 19
c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\clang-format.exe -verbose 
foo.c foo.js 2> 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr
# executed command: 
'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\clang-format.exe' -verbose 
foo.c foo.js
# RUN: at line 20
not grep Formatting 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr
# executed command: not grep Formatting 
'C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr'
# RUN: at line 22
touch .clang-format-ignore
# executed command: touch .clang-format-ignore
# RUN: at line 23
c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\clang-format.exe -verbose 
foo.c foo.js 2> 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr
# executed command: 
'c:\b\slave\clang-x64-windows-msvc\build\stage1\bin\clang-format.exe' -verbose 
foo.c foo.js
# RUN: at line 24
grep -Fx "Formatting [1/2] foo.c" 
C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr
# executed command: grep -Fx 'Formatting [1/2] foo.c' 
'C:\b\slave\clang-x64-windows-msvc\build\stage1\tools\clang\test\Format\Output\clang-format-ignore.cpp.tmp.stderr'
# note: command had no output on stdout or stderr
# error: command failed with exit status: 1
--

Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..

Failed Tests (1

[clang] [C++20] [Modules] Introduce reduced BMI (PR #75894)

2024-01-04 Thread Iain Sandoe via cfe-commits

iains wrote:


> Like I said in the commit message, this patch itself doesn't involve anything 
> relevant to user interfaces. I left it to the latter patches.

Are you in a position to post the next patch (at least as a draft)?  That would 
help me see the direction.

> > * I was concerned from earlier conversations that this design might require 
> > a codegen back end to be instantiated to allow the reduced BMI (which would 
> > be bad for --precompile/-fmodule-only type jobs). Any comments?
> 
> I am not sure if I understand this. What does it mean "require a codegen back 
> end to be instantiated to allow the reduced BMI "? Do you mean to not touch 
> CodeGen part or to not touch the CodeGen action? My local patch touched the 
> code gen action without touching any real CodeGen related things.

> > the reduced BMI (which would be bad for --precompile/-fmodule-only type 
> > jobs)
> 
> For `--precompile/-fmodule-only` type jobs, I'll create another action to 
> make it (Similar to existing `GenerateModuleInterfaceAction`). Then both of 
> the actions will try to reuse the same consumer `ReducedBMIGenerator` to 
> avoid repeated works.

OK, that answers my concern (which was that we might have to add the code-gen 
backend to a --precompile if that was the mechanism used to do the BMI 
reduction).

> > * It would be better to avoid introducing more layering violations but, as 
> > we discussed in face-to-face meetings, I have less concern on the output 
> > side.  It still seems to me that the best model is one where we have AST 
> > transforms (that very likely need Sema to be correct) and then the 
> > serializer is a simple as possible.
> 
> Yeah, it should be less concerned. BTW, currently the simpler 
> serializer/deserializer should be ASTRecordWriter/ASTRecordReader. And the 
> current ASTReader/ASTWriter takes some semantical job.

... and, on the reader side, that already gives us some big problems (as I say, 
I am less concerned on the writer side, but who can see the whole future?).

> > so something like
> > ```
> > raw AST + > codegen (when required)
> > |
> > + => AST transforms > BMI output.
> > ```
> > As I understand the patch you are combining the transform with the output?
> 
> On the one hand, the **current** patch doesn't do that. The current patch is 
> almost a NFC patch. It belongs to the following patch. On the other hand, the 
> answer may be yes. Probably I did the `AST transforms` you said in the AST 
> Writer. I don't feel it is so awful.

Maybe not for the short-term relatively simple tasks - but we should also take 
a view on the medium and longer term (for example, GMF decl elision is likely 
to be helpful to users in reducing both the size of the BMI and the number of 
decls that need merging on input).

We need the AST in this path to be mutable (including removal of decls); that 
way each transform can be maintained as a separate entity - I think that if we 
end up doing "many transforms" as part of the output, it will become very 
confusing.

_(although, to be clear, i**n the short-term we might agree to do the work in 
the output** - I really do think it would be bad to make that the long term 
mechanism)._

> Given all of us loves reduced BMI, I suggest we can fosus on current patch 
> then discuss user interfaces related things in the next patch after this got 
> landed.

We do all want to produce the reduced BMI, I agree; but we also always have 
limited resources to do the work, so that it would be good to try and pick an 
implementation that will be smooth for the future work too.

I understand the purpose of the current patch better now - and will try to take 
a more detailed look over the next few days - as noted above, it would help 
very much to have a preview of the next patch in the series.


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


[lld] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [clang] [flang] [libc] [libcxx] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-04 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,333 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___RANGES_ENUMERATE_VIEW_H
+#define _LIBCPP___RANGES_ENUMERATE_VIEW_H
+
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/iter_move.h>
+#include <__iterator/iterator_traits.h>
+#include <__ranges/access.h>
+#include <__ranges/all.h>
+#include <__ranges/concepts.h>
+#include <__ranges/enable_borrowed_range.h>
+#include <__ranges/range_adaptor.h>
+#include <__ranges/size.h>
+#include <__ranges/view_interface.h>
+#include <__type_traits/maybe_const.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+namespace ranges {
+
+// [concept.object]
+
+template 
+concept __range_with_movable_references =
+ranges::input_range<_Rp> && 
std::move_constructible> &&
+std::move_constructible>;
+
+// [range.enumerate.view]
+
+template 
+  requires __range_with_movable_references<_View>
+class enumerate_view : public view_interface> {
+  _View __base_ = _View();
+
+  // [range.enumerate.iterator]
+  template 
+  class __iterator;
+
+  // [range.enumerate.sentinel]
+  template 
+  class __sentinel;
+
+  template 
+  _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_current(const 
__iterator<_AnyConst>& __iter) {
+return (__iter.__current_);
+  }
+
+public:
+  _LIBCPP_HIDE_FROM_ABI constexpr enumerate_view()
+requires(default_initializable<_View>)
+  = default;
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit enumerate_view(_View __base) : 
__base_(std::move(__base)){};
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
+requires(!__simple_view<_View>)
+  {
+return __iterator(ranges::begin(__base_), 0);
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
+requires __range_with_movable_references
+  {
+return __iterator(ranges::begin(__base_), 0);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto end()
+requires(!__simple_view<_View>)
+  {
+if constexpr (common_range<_View> && sized_range<_View>)
+  return __iterator(ranges::end(__base_), 
ranges::distance(__base_));
+else
+  return __sentinel(ranges::end(__base_));
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
+requires __range_with_movable_references
+  {
+if constexpr (common_range && sized_range)
+  return __iterator(ranges::end(__base_), ranges::distance(__base_));
+else
+  return __sentinel(ranges::end(__base_));
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr auto size()
+requires sized_range<_View>
+  {
+return ranges::size(__base_);
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
+requires sized_range
+  {
+return ranges::size(__base_);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
+requires copy_constructible<_View>
+  {
+return __base_;
+  }
+  _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); 
}
+};
+
+template 
+enumerate_view(_Range&&) -> enumerate_view>;
+
+// [range.enumerate.iterator]
+
+template 
+  requires __range_with_movable_references<_View>
+template 
+class enumerate_view<_View>::__iterator {
+  using _Base = __maybe_const<_Const, _View>;
+
+  static consteval auto __get_iterator_concept() {
+if constexpr (random_access_range<_Base>) {
+  return random_access_iterator_tag{};
+} else if constexpr (bidirectional_range<_Base>) {
+  return bidirectional_iterator_tag{};
+} else if constexpr (forward_range<_Base>) {
+  return forward_iterator_tag{};
+} else {
+  return input_iterator_tag{};
+}
+  }
+
+  friend class enumerate_view<_View>;
+
+public:
+  using iterator_category = input_iterator_tag;
+  using iterator_concept  = decltype(__get_iterator_concept());
+  using difference_type   = range_difference_t<_Base>;
+  using value_type= tuple>;
+
+private:
+  using __reference_type   = tuple>;
+  iterator_t<_Base> __current_ = iterator_t<_Base>();
+  difference_type __pos_   = 0;
+
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(iterator_t<_Base> 
__current, difference_type __pos)
+  : __current_(std::move(__current)), __pos_(__pos) {}
+
+public:
+  _LIBCPP_HIDE_FROM_ABI __iterator()
+requires(default_initializable>)
+  = default;
+  _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator __i)
+requires _Const && convertible_to, iterator_t<_Base>>
+  : __current_(std::move(__i.__current_)), __pos_(__i.__pos_) {}
+
+  _L

[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Pol M via cfe-commits

Destroyerrrocket wrote:

The reason for puting the classes with DeclContext closer together is to 
achieve a better code generation. Here's an example of the asssembly with just 
the removal of the DECL_CONTEXT_BASE macro:
```
clang::Decl::castToDeclContext(clang::Decl const*): # 
@clang::Decl::castToDeclContext(clang::Decl const*)
.L_ZN5clang4Decl17castToDeclContextEPKS0_$local:
  movl 28(%rdi), %edx
  leaq .LJTI66_0(%rip), %rsi
  movq %rdi, %rax
  movl $40, %ecx
  andl $127, %edx
  decl %edx
  movslq (%rsi,%rdx,4), %rdx
  addq %rsi, %rdx
  jmpq *%rdx
.LBB66_5:
  movl $48, %ecx
  addq %rcx, %rax
  retq
.LBB66_1:
  addq %rcx, %rax
  retq
.LBB66_2:
  movl $72, %ecx
  addq %rcx, %rax
  retq
.LBB66_6:
  movl $64, %ecx
  addq %rcx, %rax
  retq
.LBB66_7:
  movl $56, %ecx
  addq %rcx, %rax
  retq
.LBB66_8:
.LJTI66_0:

```
While this is better, it is still not performing ideally compared to just the 
load and an add of the final implementation. I'm of course open to suggestions 
if there is a better way of getting llvm to emit the right thing.

I agree with @cor3ntin that a comment explaining the need for this order 
priorization is needed.

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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Pol M via cfe-commits


@@ -95,8 +103,31 @@ std::pair 
ClangASTNodesEmitter::EmitNode(raw_ostream &OS,
   if (!Base.isAbstract())
 First = Last = Base;
 
+  class Comp {

Destroyerrrocket wrote:

I'll make this a lambda

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


[clang-tools-extra] [clangd] Dont require confirmation for include-cleaner batch-fixes (PR #76826)

2024-01-04 Thread Haojian Wu via cfe-commits

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


[clang-tools-extra] [clangd] Dont require confirmation for include-cleaner batch-fixes (PR #76826)

2024-01-04 Thread Haojian Wu via cfe-commits

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

This change makes sense for removing all unused includes (as all these unused 
includes are visible in the editor). For missing includes, they are less 
obvious, but it is probably fine.

(I think it would be great to have a way to view all missing includes, VSCode 
has a feature to preview code action changes, but it seems 
[broken](https://github.com/clangd/vscode-clangd/issues/376) with clangd.)

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


[clang-tools-extra] [clangd] Dont require confirmation for include-cleaner batch-fixes (PR #76826)

2024-01-04 Thread Haojian Wu via cfe-commits


@@ -237,18 +236,6 @@ removeAllUnusedIncludes(llvm::ArrayRef 
UnusedIncludes) {
Diag.Fixes.front().Edits.begin(),
Diag.Fixes.front().Edits.end());
   }
-
-  // TODO(hokein): emit a suitable text for the label.
-  ChangeAnnotation Annotation = {/*label=*/"",

hokein wrote:

(I can't comment on the unchanged code), as we don't use ChangeAnnotation for 
both cases, I think we can remove the annotation-propagation code (line 
271-274) in `fixAll`.

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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Pol M via cfe-commits


@@ -196,8 +227,20 @@ void ClangASTNodesEmitter::run(raw_ostream &OS) {
 }
 
 void clang::EmitClangASTNodes(RecordKeeper &RK, raw_ostream &OS,
-  const std::string &N, const std::string &S) {
-  ClangASTNodesEmitter(RK, N, S).run(OS);
+  const std::string &N, const std::string &S,
+  const std::string &PriorizeIfSubclassOf) {

Destroyerrrocket wrote:

Conformity with surrounding code. I code like I see to not introduce another 
style. I can switch to std::string_view if you wish so!

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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Pol M via cfe-commits


@@ -210,38 +253,26 @@ void clang::EmitClangDeclContext(RecordKeeper &Records, 
raw_ostream &OS) {
   OS << "#ifndef DECL_CONTEXT\n";
   OS << "#  define DECL_CONTEXT(DECL)\n";
   OS << "#endif\n";
-  
-  OS << "#ifndef DECL_CONTEXT_BASE\n";
-  OS << "#  define DECL_CONTEXT_BASE(DECL) DECL_CONTEXT(DECL)\n";
-  OS << "#endif\n";
-  
-  typedef std::set RecordSet;
-  typedef std::vector RecordVector;
-  
-  RecordVector DeclContextsVector
-= Records.getAllDerivedDefinitions(DeclContextNodeClassName);
-  RecordVector Decls = Records.getAllDerivedDefinitions(DeclNodeClassName);
-  RecordSet DeclContexts (DeclContextsVector.begin(), 
DeclContextsVector.end());
-   
-  for (RecordVector::iterator i = Decls.begin(), e = Decls.end(); i != e; ++i) 
{
-Record *R = *i;
-
-if (Record *B = R->getValueAsOptionalDef(BaseFieldName)) {
-  if (DeclContexts.find(B) != DeclContexts.end()) {
-OS << "DECL_CONTEXT_BASE(" << B->getName() << ")\n";
-DeclContexts.erase(B);
-  }
-}
+
+  std::vector DeclContextsVector =
+  Records.getAllDerivedDefinitions(DeclContextNodeClassName);
+  std::vector Decls =
+  Records.getAllDerivedDefinitions(DeclNodeClassName);
+
+  std::multimap Tree;
+
+  const std::vector Stmts =
+  Records.getAllDerivedDefinitions(DeclNodeClassName);
+
+  for (unsigned i = 0, e = Stmts.size(); i != e; ++i) {

Destroyerrrocket wrote:

I copied over the Tree implementation a few lines up with some code removed. I 
will update both for loops, it certainly would improve readability.

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


[clang] 7954c57 - [IR] Fix GEP offset computations for vector GEPs (#75448)

2024-01-04 Thread via cfe-commits

Author: Jannik Silvanus
Date: 2024-01-04T10:08:21+01:00
New Revision: 7954c57124b495fbdc73674d71f2e366e4afe522

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

LOG: [IR] Fix GEP offset computations for vector GEPs (#75448)

Vectors are always bit-packed and don't respect the elements' alignment
requirements. This is different from arrays. This means offsets of
vector GEPs need to be computed differently than offsets of array GEPs.

This PR fixes many places that rely on an incorrect pattern
that always relies on `DL.getTypeAllocSize(GTI.getIndexedType())`.
We replace these by usages of  `GTI.getSequentialElementStride(DL)`, 
which is a new helper function added in this PR.

This changes behavior for GEPs into vectors with element types for which
the (bit) size and alloc size is different. This includes two cases:

* Types with a bit size that is not a multiple of a byte, e.g. i1.
GEPs into such vectors are questionable to begin with, as some elements
  are not even addressable.
* Overaligned types, e.g. i16 with 32-bit alignment.

Existing tests are unaffected, but a miscompilation of a new test is fixed.

-

Co-authored-by: Nikita Popov 

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/include/llvm/IR/GetElementPtrTypeIterator.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/Analysis/InlineCost.cpp
llvm/lib/Analysis/Local.cpp
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/IR/Operator.cpp
llvm/lib/IR/Value.cpp
llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/ARM/ARMFastISel.cpp
llvm/lib/Target/Mips/MipsFastISel.cpp
llvm/lib/Target/PowerPC/PPCFastISel.cpp
llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
llvm/lib/Target/X86/X86FastISel.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
llvm/test/Transforms/InstCombine/getelementptr.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 6adf99531e30e3..d2c4c7ee50bc89 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -5292,8 +5292,8 @@ static GEPOffsetAndOverflow EmitGEPOffsetInBytes(Value 
*BasePtr, Value *GEPVal,
 } else {
   // Otherwise this is array-like indexing. The local offset is the index
   // multiplied by the element size.
-  auto *ElementSize = llvm::ConstantInt::get(
-  IntPtrTy, DL.getTypeAllocSize(GTI.getIndexedType()));
+  auto *ElementSize =
+  llvm::ConstantInt::get(IntPtrTy, GTI.getSequentialElementStride(DL));
   auto *IndexS = Builder.CreateIntCast(Index, IntPtrTy, /*isSigned=*/true);
   LocalOffset = eval(BO_Mul, ElementSize, IndexS);
 }

diff  --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h 
b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 7ad3ce512a3552..2be7256423e422 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1048,7 +1048,7 @@ class TargetTransformInfoImplCRTPBase : public 
TargetTransformInfoImplBase {
 if (TargetType->isScalableTy())
   return TTI::TCC_Basic;
 int64_t ElementSize =
-DL.getTypeAllocSize(GTI.getIndexedType()).getFixedValue();
+GTI.getSequentialElementStride(DL).getFixedValue();
 if (ConstIdx) {
   BaseOffset +=
   ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;

diff  --git a/llvm/include/llvm/IR/GetElementPtrTypeIterator.h 
b/llvm/include/llvm/IR/GetElementPtrTypeIterator.h
index f3272327c3f8b2..1092b636e023a2 100644
--- a/llvm/include/llvm/IR/GetElementPtrTypeIterator.h
+++ b/llvm/include/llvm/IR/GetElementPtrTypeIterator.h
@@ -16,6 +16,7 @@
 
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Operator.h"
 #include "llvm/IR/User.h"
@@ -30,7 +31,39 @@ template 
 class generic_gep_type_iterator {
 
   ItTy OpIt;
-  PointerUnion CurTy;
+  // We use two 
diff erent mechanisms to store the type a GEP index applies to.
+  // In some cases, we need to know t

[llvm] [clang] [IR] Fix GEP offset computations for vector GEPs (PR #75448)

2024-01-04 Thread Jannik Silvanus via cfe-commits

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


[clang-tools-extra] [clangd] Do not offer extraction to variable for decl init expression (PR #69477)

2024-01-04 Thread kadir çetinkaya via cfe-commits


@@ -504,68 +502,6 @@ TEST_F(ExtractVariableTest, Test) {
 int main() {
   auto placeholder = []() { return 42; }(); return  placeholder ;
 })cpp"},
-  {R"cpp(
-template 
-void foo(Ts ...args) {
-  auto x = [[ [&args...]() {} ]];
-}
-  )cpp",
-   R"cpp(
-template 
-void foo(Ts ...args) {
-  auto placeholder = [&args...]() {}; auto x =  placeholder ;
-}
-  )cpp"},
-  {R"cpp(

kadircet wrote:

for the following two can you change them to:
```
...
auto f = [[ lambda_expr ]]();
...
```

that way they should turn into
```
...
placeholder = lambda_expr;
auto f = placeholder();
...
```

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


[clang-tools-extra] [clangd] Do not offer extraction to variable for decl init expression (PR #69477)

2024-01-04 Thread kadir çetinkaya via cfe-commits


@@ -422,8 +422,6 @@ TEST_F(ExtractVariableTest, Test) {
 int member = 42;
 };
 )cpp"},
-  {R"cpp(void f() { auto x = [[ [](){ return 42; }]]; })cpp",

kadircet wrote:

let's change this to `auto x = +[[ ... ]]`, to make sure we preserve the test 
for moving around a lambda

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


[clang-tools-extra] [clangd] Do not offer extraction to variable for decl init expression (PR #69477)

2024-01-04 Thread kadir çetinkaya via cfe-commits


@@ -490,6 +491,13 @@ bool eligibleForExtraction(const SelectionTree::Node *N) {
 BO->getRHS() == OuterImplicit.ASTNode.get())
   return false;
   }
+  if (const auto *Decl = Parent->ASTNode.get()) {
+if (!Decl->isInitCapture() &&

kadircet wrote:

it's not obvious to me why we check for anything but initializer being the 
outerimplict node itself. can you add comments and test cases?

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


[clang-tools-extra] [clangd] Do not offer extraction to variable for decl init expression (PR #69477)

2024-01-04 Thread kadir çetinkaya via cfe-commits


@@ -27,10 +27,10 @@ TEST_F(ExtractVariableTest, Test) {
   return t.b[[a]]r]]([[t.z]])]];
 }
 void f() {
-  int a = [[5 +]] [[4 * xyz]]();
+  int a = 5 + [[4 * xyz]]();
   // multivariable initialization
   if(1)
-int x = [[1]], y = [[a + 1]], a = [[1]], z = a + 1;
+int x = [[1]] + 1, y = [[a + 1]], a = [[1]] + 2, z = a + 1;

kadircet wrote:

hmm, it's surprising that this is still available for `y = [[a + 1]]`

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


[clang-tools-extra] [clangd] Do not offer extraction to variable for decl init expression (PR #69477)

2024-01-04 Thread kadir çetinkaya via cfe-commits


@@ -504,68 +502,6 @@ TEST_F(ExtractVariableTest, Test) {
 int main() {
   auto placeholder = []() { return 42; }(); return  placeholder ;
 })cpp"},
-  {R"cpp(

kadircet wrote:

again you can keep this test around by prepending a `+` to the lambda

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


[clang] [Sema] Warning for _Float16 passed to format specifier '%f' (PR #74439)

2024-01-04 Thread Haocong Lu via cfe-commits

https://github.com/Luhaocong updated 
https://github.com/llvm/llvm-project/pull/74439

>From 899e18d1ca94efad41c2e09dff0a3213d7fb0f7e Mon Sep 17 00:00:00 2001
From: Lu Haocong 
Date: Tue, 5 Dec 2023 16:45:22 +0800
Subject: [PATCH] [Sema] Warning for _Float16 passed to format specifier '%f'

According to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2844.pdf,
there are no default argument promotions for _FloatN types.

A warning is needed to notice user to promote _Float16 to double
explicitly, and then pass it to format specifier '%f', which is
consistent with GCC.
---
 clang/lib/AST/FormatString.cpp  |  1 -
 clang/test/AST/variadic-promotion.c |  5 +
 clang/test/Sema/attr-format.c   |  7 +++
 clang/test/SemaCXX/attr-format.cpp  |  1 +
 clang/test/SemaCXX/format-strings-scanf.cpp | 16 ++--
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp
index e0c9e18cfe3a24..c5d14b4af7ff15 100644
--- a/clang/lib/AST/FormatString.cpp
+++ b/clang/lib/AST/FormatString.cpp
@@ -488,7 +488,6 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const {
 return NoMatchPromotionTypeConfusion;
   break;
 case BuiltinType::Half:
-case BuiltinType::Float16:
 case BuiltinType::Float:
   if (T == C.DoubleTy)
 return MatchPromotion;
diff --git a/clang/test/AST/variadic-promotion.c 
b/clang/test/AST/variadic-promotion.c
index 41c7fec8d7943e..7cbadb832ca806 100644
--- a/clang/test/AST/variadic-promotion.c
+++ b/clang/test/AST/variadic-promotion.c
@@ -18,3 +18,8 @@ void test_floating_promotion(__fp16 *f16, float f32, double 
f64) {
 // CHECK: ImplicitCastExpr {{.*}} 'double' 
 // CHECK-NEXT: 'float'
 }
+
+void test_Float16_no_default_promotion(_Float16 f16) {
+  variadic(1, f16);
+// CHECK-NOT: ImplicitCastExpr {{.*}} 'double' 
+}
diff --git a/clang/test/Sema/attr-format.c b/clang/test/Sema/attr-format.c
index 1f4c864d4f78bd..bdfd8425c4e9a5 100644
--- a/clang/test/Sema/attr-format.c
+++ b/clang/test/Sema/attr-format.c
@@ -16,6 +16,8 @@ typedef const char *xpto;
 void j(xpto c, va_list list) __attribute__((format(printf, 1, 0))); // no-error
 void k(xpto c) __attribute__((format(printf, 1, 0)));   // no-error
 
+void l(char *a, _Float16 b) __attribute__((format(printf, 1, 2))); // 
expected-warning {{GCC requires a function with the 'format' attribute to be 
variadic}}
+
 void y(char *str) __attribute__((format(strftime, 1, 0))); // 
no-error
 void z(char *str, int c, ...) __attribute__((format(strftime, 1, 2))); // 
expected-error {{strftime format attribute requires 3rd parameter to be 0}}
 
@@ -93,6 +95,11 @@ void call_nonvariadic(void) {
   d3("%s", 123); // expected-warning{{format specifies type 'char *' but the 
argument has type 'int'}}
 }
 
+void call_no_default_promotion(void) {
+  a("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' 
but the argument has type '_Float16'}}
+  l("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' 
but the argument has type '_Float16'}}
+}
+
 __attribute__((format(printf, 1, 2)))
 void forward_fixed(const char *fmt, _Bool b, char i, short j, int k, float l, 
double m) { // expected-warning{{GCC requires a function with the 'format' 
attribute to be variadic}}
   forward_fixed(fmt, b, i, j, k, l, m);
diff --git a/clang/test/SemaCXX/attr-format.cpp 
b/clang/test/SemaCXX/attr-format.cpp
index adc05fc46776ca..4509c3a95e8efa 100644
--- a/clang/test/SemaCXX/attr-format.cpp
+++ b/clang/test/SemaCXX/attr-format.cpp
@@ -81,6 +81,7 @@ void do_format() {
 
   format("%c %c %hhd %hd %d\n", (char)'a', 'a', 'a', (short)123, (int)123);
   format("%f %f %f\n", (__fp16)123.f, 123.f, 123.);
+  format("%f", (_Float16)123.f);// expected-warning{{format specifies type 
'double' but the argument has type '_Float16'}}
   format("%Lf", (__fp16)123.f); // expected-warning{{format specifies type 
'long double' but the argument has type '__fp16'}}
   format("%Lf", 123.f); // expected-warning{{format specifies type 'long 
double' but the argument has type 'float'}}
   format("%hhi %hhu %hi %hu %i %u", b, b, b, b, b, b);
diff --git a/clang/test/SemaCXX/format-strings-scanf.cpp 
b/clang/test/SemaCXX/format-strings-scanf.cpp
index 25fe5346791a0d..406c2069e28ca7 100644
--- a/clang/test/SemaCXX/format-strings-scanf.cpp
+++ b/clang/test/SemaCXX/format-strings-scanf.cpp
@@ -22,6 +22,7 @@ union bag {
 unsigned long long ull;
 signed long long sll;
 __fp16 f16;
+_Float16 Float16;
 float ff;
 double fd;
 long double fl;
@@ -51,18 +52,21 @@ void test(void) {
 // expected-warning@+1{{format specifies type 'int *' but the argument has 
type 'short *'}}
 scan("%hhi %i %li", &b.ss, &b.ss, &b.ss);
 
-// expected-warning@+3{{format specifies type 'float *' but the argument 
has type '__fp16 *'}}
+/

[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


https://github.com/Destroyerrrocket updated 
https://github.com/llvm/llvm-project/pull/76825

>From 1ab4538e194f9a77c500e4a93b1875eb7e76dcf5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pol=20Marcet=20Sard=C3=A0?= 
Date: Wed, 3 Jan 2024 16:00:42 +0100
Subject: [PATCH 1/2] [clang] Optimize castToDeclContext for 2% improvement in
 build times

---
 clang/include/clang/AST/DeclCXX.h |   8 ++
 clang/lib/AST/DeclBase.cpp|  50 +++-
 clang/utils/TableGen/ClangASTNodesEmitter.cpp | 107 +++---
 clang/utils/TableGen/TableGen.cpp |   3 +-
 clang/utils/TableGen/TableGenBackends.h   |   3 +-
 5 files changed, 97 insertions(+), 74 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 432293583576b5..984a4d8bab5e77 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2044,6 +2044,14 @@ class RequiresExprBodyDecl : public Decl, public 
DeclContext {
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == RequiresExprBody; }
+
+  static DeclContext *castToDeclContext(const RequiresExprBodyDecl *D) {
+return static_cast(const_cast(D));
+  }
+
+  static RequiresExprBodyDecl *castFromDeclContext(const DeclContext *DC) {
+return static_cast(const_cast(DC));
+  }
 };
 
 /// Represents a static or instance method of a struct/union/class.
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 5e03f0223d311c..b1733c2d052a65 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -930,20 +930,14 @@ const AttrVec &Decl::getAttrs() const {
 
 Decl *Decl::castFromDeclContext (const DeclContext *D) {
   Decl::Kind DK = D->getDeclKind();
-  switch(DK) {
-#define DECL(NAME, BASE)
-#define DECL_CONTEXT(NAME) \
-case Decl::NAME:   \
-  return static_cast(const_cast(D));
-#define DECL_CONTEXT_BASE(NAME)
-#include "clang/AST/DeclNodes.inc"
-default:
+  switch (DK) {
 #define DECL(NAME, BASE)
-#define DECL_CONTEXT_BASE(NAME)  \
-  if (DK >= first##NAME && DK <= last##NAME) \
-return static_cast(const_cast(D));
+#define DECL_CONTEXT(NAME) 
\
+  case Decl::NAME: 
\
+return static_cast(const_cast(D));
 #include "clang/AST/DeclNodes.inc"
-  llvm_unreachable("a decl that inherits DeclContext isn't handled");
+  default:
+llvm_unreachable("a decl that inherits DeclContext isn't handled");
   }
 }
 
@@ -951,18 +945,12 @@ DeclContext *Decl::castToDeclContext(const Decl *D) {
   Decl::Kind DK = D->getKind();
   switch(DK) {
 #define DECL(NAME, BASE)
-#define DECL_CONTEXT(NAME) \
-case Decl::NAME:   \
-  return static_cast(const_cast(D));
-#define DECL_CONTEXT_BASE(NAME)
+#define DECL_CONTEXT(NAME) 
\
+  case Decl::NAME: 
\
+return static_cast(const_cast(D));
 #include "clang/AST/DeclNodes.inc"
-default:
-#define DECL(NAME, BASE)
-#define DECL_CONTEXT_BASE(NAME)   \
-  if (DK >= first##NAME && DK <= last##NAME)  \
-return static_cast(const_cast(D));
-#include "clang/AST/DeclNodes.inc"
-  llvm_unreachable("a decl that inherits DeclContext isn't handled");
+  default:
+llvm_unreachable("a decl that inherits DeclContext isn't handled");
   }
 }
 
@@ -1129,20 +1117,14 @@ DeclContext::DeclContext(Decl::Kind K) {
 }
 
 bool DeclContext::classof(const Decl *D) {
-  switch (D->getKind()) {
+  Decl::Kind DK = D->getKind();
+  switch (DK) {
 #define DECL(NAME, BASE)
 #define DECL_CONTEXT(NAME) case Decl::NAME:
-#define DECL_CONTEXT_BASE(NAME)
 #include "clang/AST/DeclNodes.inc"
-  return true;
-default:
-#define DECL(NAME, BASE)
-#define DECL_CONTEXT_BASE(NAME) \
-  if (D->getKind() >= Decl::first##NAME &&  \
-  D->getKind() <= Decl::last##NAME) \
-return true;
-#include "clang/AST/DeclNodes.inc"
-  return false;
+return true;
+  default:
+return false;
   }
 }
 
diff --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp 
b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 16a1c74b9d91ad..63220aad50aecd 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -33,6 +33,7 @@ class ClangASTNodesEmitter {
   typedef std::multimap ChildMap;
   typedef ChildMap::const_iterator ChildIterator;
 
+  std::set PrioritizedClasses;
   RecordKeeper &Records;
   ASTNode Root;
   const std::string &NodeClassName;
@@ -70,8 +71,15 @@ class ClangASTNodesEmitter {
   std::pair EmitNode(raw_ostream& OS, ASTNode Base);
 public:
   explicit ClangASTNod

[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


Destroyerrrocket wrote:

Addressed the first review comments! Thank you for your time, I appreciate it :)

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


[clang] [analyzer] Add std::any checker (PR #76580)

2024-01-04 Thread via cfe-commits
=?utf-8?q?Gábor?= Spaits,=?utf-8?q?Gábor?= Spaits,
=?utf-8?q?Gábor?= Spaits,=?utf-8?q?Gábor?= Spaits,
=?utf-8?q?Gábor?= Spaits
Message-ID:
In-Reply-To: 



@@ -87,6 +85,28 @@ bool isStdVariant(const Type *Type) {
   return isStdType(Type, llvm::StringLiteral("variant"));
 }
 
+bool isStdAny(const Type *Type) {
+  return isStdType(Type, llvm::StringLiteral("any"));
+}
+
+bool isVowel(char a) {
+  switch (a) {
+  case 'a':
+  case 'e':
+  case 'i':
+  case 'o':
+  case 'u':
+return true;
+  default:
+return false;
+  }
+}
+
+llvm::StringRef indefiniteArticleBasedOnVowel(char a) {
+  if (isVowel(a))
+return "an";
+  return "a";
+}

DonatNagyE wrote:

If you skip the article, the message looks as if it was reporting the _value_ 
stored in the `std::any`, which may be an annoying confusion if the type name 
is not immediately recognizable as a type name.

I see that it has some advantages, but overall I think it's worse than any of 
the three other solutions (decision based on `isVowel()`, using a(n) and using 
filler words to dodge the issue).

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


[clang] [C++20] [Modules] Implementing Eliding Unreachable Decls of GMF in ASTWriter (PR #76930)

2024-01-04 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 created 
https://github.com/llvm/llvm-project/pull/76930

This was a patch to try to implement eliding unreachable decls in GMF in 
ASTWriter. It was developed a half year ago and I just rebased it but I did't 
fix the failing test. It ran well. 

The core idea of the patch is that we can implement the idea **reachable** in 
ASTWriter naturally. 

The secret is that we skip writing GMF initially (generally we will write decls 
from the top to the bottom) and we start to write the declarations from module 
purview. Then we will only write the declarations in GMF if it is mentioned 
during the writing process. So the unreachable decls won't be written natually.

The experience in implementing this patch is pretty smooth and the tests from 
the spec can be passed. I felt this should be the natural way to implement this 
feature.

The only one and big problem is that we didn't implement the formal semantics 
in the spec in this way : |

>From b9a03912276d25ff819a755bef4ee72d64ce1480 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 4 Jan 2024 17:24:23 +0800
Subject: [PATCH] [C++20] [Modules] Implementing Eliding Unreachable Decls of
 GMF in ASTWriter

---
 clang/include/clang/AST/DeclBase.h|  16 +-
 clang/include/clang/Basic/LangOptions.def |   1 +
 clang/include/clang/Driver/Options.td |   7 +
 clang/include/clang/Serialization/ASTWriter.h |  24 +++
 clang/lib/Sema/SemaModule.cpp |   6 +-
 clang/lib/Serialization/ASTReaderDecl.cpp |   3 +
 clang/lib/Serialization/ASTWriter.cpp | 160 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |   2 +
 .../basic.scope/basic.scope.namespace/p2.cpp  |   6 +-
 .../module.glob.frag/cxx20-10-4-ex2.cppm  |  72 
 clang/test/CXX/module/module.import/p2.cpp|   7 +-
 .../test/CodeGenCXX/module-intializer-pmf.cpp |   6 +-
 clang/test/CodeGenCXX/module-intializer.cpp   |  39 ++---
 clang/test/Modules/abi-tag.cppm   |  69 
 clang/test/Modules/concept.cppm   |   2 +
 .../explicitly-specialized-template.cpp   |   2 +-
 .../inconsistent-deduction-guide-linkage.cppm |   6 +
 clang/test/Modules/named-modules-adl-2.cppm   |   2 +
 clang/test/Modules/named-modules-adl.cppm |   2 +
 clang/test/Modules/polluted-operator.cppm |  11 +-
 clang/test/Modules/pr58716.cppm   |   2 +
 clang/test/Modules/pr60775.cppm   |   4 +
 clang/test/Modules/pr62589.cppm   |   3 +
 clang/test/Modules/preferred_name.cppm|   2 +
 .../redundant-template-default-arg3.cpp   |   9 +
 .../template-function-specialization.cpp  |   6 +-
 26 files changed, 416 insertions(+), 53 deletions(-)
 create mode 100644 clang/test/CXX/module/module.glob.frag/cxx20-10-4-ex2.cppm
 create mode 100644 clang/test/Modules/abi-tag.cppm

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 10dcbdb262d84e..523b930d59645a 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -233,9 +233,12 @@ class alignas(8) Decl {
 
 /// This declaration has an owning module, but is only visible to
 /// lookups that occur within that module.
-/// The discarded declarations in global module fragment belongs
-/// to this group too.
-ModulePrivate
+ModulePrivate,
+
+/// This declaration is part of a Global Module Fragment, it is permitted
+/// to discard it and therefore it is not reachable or visible to importers
+/// of the named module of which the GMF is part.
+ModuleDiscardable
   };
 
 protected:
@@ -658,9 +661,10 @@ class alignas(8) Decl {
   /// Whether this declaration comes from another module unit.
   bool isInAnotherModuleUnit() const;
 
-  /// FIXME: Implement discarding declarations actually in global module
-  /// fragment. See [module.global.frag]p3,4 for details.
-  bool isDiscardedInGlobalModuleFragment() const { return false; }
+  /// See [module.global.frag]p3,4 for details.
+  bool isDiscardedInGlobalModuleFragment() const {
+return getModuleOwnershipKind() == ModuleOwnershipKind::ModuleDiscardable;
+  }
 
   /// Return true if this declaration has an attribute which acts as
   /// definition of the entity, such as 'alias' or 'ifunc'.
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 21abc346cf17ac..97ba8147bdfbb5 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -178,6 +178,7 @@ LANGOPT(BuiltinHeadersInSystemModules, 1, 0, "builtin 
headers belong to system m
 BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 3, CMK_None,
 "compiling a module interface")
 BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch")
+LANGOPT(DiscardGMFDecls   , 1, 1, "Discard unreachable decls in GMF")
 BENIGN_LANGOPT(BuildingPCHWithObjectFile, 1, 0, "building a pch which has a 
corresponding obje

[clang] [C++20] [Modules] Implementing Eliding Unreachable Decls of GMF in ASTWriter (PR #76930)

2024-01-04 Thread Chuanqi Xu via cfe-commits

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


[clang] [C++20] [Modules] Implementing Eliding Unreachable Decls of GMF in ASTWriter (PR #76930)

2024-01-04 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: Chuanqi Xu (ChuanqiXu9)


Changes

This was a patch to try to implement eliding unreachable decls in GMF in 
ASTWriter. It was developed a half year ago and I just rebased it but I did't 
fix the failing test. It ran well. 

The core idea of the patch is that we can implement the idea **reachable** in 
ASTWriter naturally. 

The secret is that we skip writing GMF initially (generally we will write decls 
from the top to the bottom) and we start to write the declarations from module 
purview. Then we will only write the declarations in GMF if it is mentioned 
during the writing process. So the unreachable decls won't be written natually.

The experience in implementing this patch is pretty smooth and the tests from 
the spec can be passed. I felt this should be the natural way to implement this 
feature.

The only one and big problem is that we didn't implement the formal semantics 
in the spec in this way : |

---

Patch is 32.57 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/76930.diff


26 Files Affected:

- (modified) clang/include/clang/AST/DeclBase.h (+10-6) 
- (modified) clang/include/clang/Basic/LangOptions.def (+1) 
- (modified) clang/include/clang/Driver/Options.td (+7) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+24) 
- (modified) clang/lib/Sema/SemaModule.cpp (+5-1) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+3) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+151-9) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+2) 
- (modified) clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp 
(+2-4) 
- (added) clang/test/CXX/module/module.glob.frag/cxx20-10-4-ex2.cppm (+72) 
- (modified) clang/test/CXX/module/module.import/p2.cpp (+4-3) 
- (modified) clang/test/CodeGenCXX/module-intializer-pmf.cpp (+4-2) 
- (modified) clang/test/CodeGenCXX/module-intializer.cpp (+18-21) 
- (added) clang/test/Modules/abi-tag.cppm (+69) 
- (modified) clang/test/Modules/concept.cppm (+2) 
- (modified) clang/test/Modules/explicitly-specialized-template.cpp (+1-1) 
- (modified) clang/test/Modules/inconsistent-deduction-guide-linkage.cppm (+6) 
- (modified) clang/test/Modules/named-modules-adl-2.cppm (+2) 
- (modified) clang/test/Modules/named-modules-adl.cppm (+2) 
- (modified) clang/test/Modules/polluted-operator.cppm (+9-2) 
- (modified) clang/test/Modules/pr58716.cppm (+2) 
- (modified) clang/test/Modules/pr60775.cppm (+4) 
- (modified) clang/test/Modules/pr62589.cppm (+3) 
- (modified) clang/test/Modules/preferred_name.cppm (+2) 
- (modified) clang/test/Modules/redundant-template-default-arg3.cpp (+9) 
- (modified) clang/test/Modules/template-function-specialization.cpp (+2-4) 


``diff
diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 10dcbdb262d84e..523b930d59645a 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -233,9 +233,12 @@ class alignas(8) Decl {
 
 /// This declaration has an owning module, but is only visible to
 /// lookups that occur within that module.
-/// The discarded declarations in global module fragment belongs
-/// to this group too.
-ModulePrivate
+ModulePrivate,
+
+/// This declaration is part of a Global Module Fragment, it is permitted
+/// to discard it and therefore it is not reachable or visible to importers
+/// of the named module of which the GMF is part.
+ModuleDiscardable
   };
 
 protected:
@@ -658,9 +661,10 @@ class alignas(8) Decl {
   /// Whether this declaration comes from another module unit.
   bool isInAnotherModuleUnit() const;
 
-  /// FIXME: Implement discarding declarations actually in global module
-  /// fragment. See [module.global.frag]p3,4 for details.
-  bool isDiscardedInGlobalModuleFragment() const { return false; }
+  /// See [module.global.frag]p3,4 for details.
+  bool isDiscardedInGlobalModuleFragment() const {
+return getModuleOwnershipKind() == ModuleOwnershipKind::ModuleDiscardable;
+  }
 
   /// Return true if this declaration has an attribute which acts as
   /// definition of the entity, such as 'alias' or 'ifunc'.
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 21abc346cf17ac..97ba8147bdfbb5 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -178,6 +178,7 @@ LANGOPT(BuiltinHeadersInSystemModules, 1, 0, "builtin 
headers belong to system m
 BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 3, CMK_None,
 "compiling a module interface")
 BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch")
+LANGOPT(DiscardGMFDecls   , 1, 1, "Discard unreachable decls in GMF")
 BENIGN_LANGOPT(BuildingPCHWithObjectFile, 1, 0, "building a pch which has a 
corresponding object file")
 BENIGN_LANGOPT(CacheGeneratedPCH, 1, 0

[clang] [C++20] [Modules] Implementing Eliding Unreachable Decls of GMF in ASTWriter (PR #76930)

2024-01-04 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 7a3b0cbb143d02b70b2bfae5cd40e9867c124748 
b9a03912276d25ff819a755bef4ee72d64ce1480 -- 
clang/test/CXX/module/module.glob.frag/cxx20-10-4-ex2.cppm 
clang/test/Modules/abi-tag.cppm clang/include/clang/AST/DeclBase.h 
clang/include/clang/Serialization/ASTWriter.h clang/lib/Sema/SemaModule.cpp 
clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp 
clang/lib/Serialization/ASTWriterDecl.cpp 
clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp 
clang/test/CXX/module/module.import/p2.cpp 
clang/test/CodeGenCXX/module-intializer-pmf.cpp 
clang/test/CodeGenCXX/module-intializer.cpp clang/test/Modules/concept.cppm 
clang/test/Modules/explicitly-specialized-template.cpp 
clang/test/Modules/inconsistent-deduction-guide-linkage.cppm 
clang/test/Modules/named-modules-adl-2.cppm 
clang/test/Modules/named-modules-adl.cppm 
clang/test/Modules/polluted-operator.cppm clang/test/Modules/pr58716.cppm 
clang/test/Modules/pr60775.cppm clang/test/Modules/pr62589.cppm 
clang/test/Modules/preferred_name.cppm 
clang/test/Modules/redundant-template-default-arg3.cpp 
clang/test/Modules/template-function-specialization.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 4823cbd5dd..b981a8e5bd 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -3992,9 +3992,9 @@ ASTWriter::GenerateNameLookupTable(const DeclContext 
*ConstDC,
 if (IsDeclModuleDiscardable(D))
   MarkDeclReachable(D);
 } else if (llvm::all_of(Result.getLookupResult(), [this](NamedDecl *D) {
-return IsDeclModuleDiscardable(D);
-  }))
-continue;
+ return IsDeclModuleDiscardable(D);
+   }))
+  continue;
 
 // We also skip empty results. If any of the results could be external and
 // the currently available results are empty, then all of the results are
@@ -5744,13 +5744,12 @@ bool ASTWriter::IsSpecialDeclNotDiscardable(Decl *D) {
   //
   // This may imply that the ODR checking process is context sensitive.
   // That said, the same type in different module units can be considered to be
-  // different if some module units discard the unused `__gnu_cxx::__cxx11` 
namespace
-  // while other module units don't. This is incorrect.
+  // different if some module units discard the unused `__gnu_cxx::__cxx11`
+  // namespace while other module units don't. This is incorrect.
   //
-  // This is a workaround to make things happen but we indeed to fix the ODR 
checking
-  // process indeed.
-  if (auto *ND = dyn_cast(D);
-  ND && ND->getAttr()) {
+  // This is a workaround to make things happen but we indeed to fix the ODR
+  // checking process indeed.
+  if (auto *ND = dyn_cast(D); ND && ND->getAttr()) {
 MarkDeclReachable(D);
 return true;
   }
@@ -5779,7 +5778,8 @@ bool ASTWriter::IsDeclModuleDiscardable(const Decl 
*ConstD) {
 DC = DC->getParent()->getNonTransparentContext();
 
   assert(DC && "Why is the decl not covered by file context?");
-  if (!DC->isFileContext() && 
!cast(DC)->isDiscardedInGlobalModuleFragment()) {
+  if (!DC->isFileContext() &&
+  !cast(DC)->isDiscardedInGlobalModuleFragment()) {
 MarkDeclReachable(D);
 return false;
   }
@@ -5835,7 +5835,8 @@ DeclID ASTWriter::GetDeclRef(const Decl *D) {
   if (D->isFromASTFile())
 return D->getGlobalID();
 
-  assert(!D->isDiscardedInGlobalModuleFragment() && "We shouldn't write 
discarded decl.\n");
+  assert(!D->isDiscardedInGlobalModuleFragment() &&
+ "We shouldn't write discarded decl.\n");
 
   assert(!(reinterpret_cast(D) & 0x01) && "Invalid decl pointer");
   DeclID &ID = DeclIDs[D];

``




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


[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2024-01-04 Thread Owen Pan via cfe-commits

owenca wrote:

Actually, it's commit 42ec976184ac. Please see 
[here](https://github.com/llvm/llvm-project/pull/76733#issuecomment-1876707005).

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


[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-04 Thread Ilya Biryukov via cfe-commits


@@ -10093,11 +10090,11 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
getGoogleStyleWithColumns(40));
   verifyFormat("Tttt ppp\n"
"ABSL_GUARDED_BY(mutex1)\n"
-   "ABSL_GUARDED_BY(mutex2);",
+   "ABSL_GUARDED_BY(mutex2);",

ilya-biryukov wrote:

It is wrong, but it was like the recent patch where I changed Google style. I 
mentioned it in the commit description  (quote follows):

> Also update the test with two GUARDED_BY directives. While the formatting 
> after 
> https://github.com/llvm/llvm-project/commit/efeb546865c233dfa7706ee0316c676de9f69897
>  seems better, this case is rare enough to not warrant the extra complexity. 
> We are reverting it back to the state it had before
https://github.com/llvm/llvm-project/commit/efeb546865c233dfa7706ee0316c676de9f69897.

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


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2024-01-04 Thread Sam Tebbs via cfe-commits


@@ -1109,10 +1109,10 @@ def SVPFALSE : SInst<"svpfalse[_b]", "Pv", "", 
MergeNone, "", [IsOverloadNone, I
 def SVPTRUE_PAT : SInst<"svptrue_pat_{d}", "PI", "PcPsPiPl", MergeNone, 
"aarch64_sve_ptrue", [IsStreamingCompatible]>;
 def SVPTRUE : SInst<"svptrue_{d}", "Pv",  "PcPsPiPl", MergeNone, 
"aarch64_sve_ptrue", [IsAppendSVALL, IsStreamingCompatible]>;
 
-def SVDUPQ_B8  : SInst<"svdupq[_n]_{d}",  "P",  "Pc", 
MergeNone>;
-def SVDUPQ_B16 : SInst<"svdupq[_n]_{d}", "P",  "Ps", MergeNone>;
-def SVDUPQ_B32 : SInst<"svdupq[_n]_{d}", "P",  "Pi", MergeNone>;
-def SVDUPQ_B64 : SInst<"svdupq[_n]_{d}", "Pss",  "Pl", MergeNone>;
+def SVDUPQ_B8  : SInst<"svdupq[_n]_{d}",  "P",  "Pc", 
MergeNone, "", [IsStreamingCompatible]>;

SamTebbs33 wrote:

It is actually just adding a missing attribute.

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


[clang] [Clang][SME] Add IsStreamingOrSVE2p1 (PR #75958)

2024-01-04 Thread Sam Tebbs via cfe-commits

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


[llvm] [clang-tools-extra] [clang] Add out-of-line-atomics support to GlobalISel (PR #74588)

2024-01-04 Thread Matt Arsenault via cfe-commits

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


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


[clang] 26993f6 - Revert "[clang-format] Optimize processing .clang-format-ignore files (#76733)"

2024-01-04 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2024-01-04T10:47:51+01:00
New Revision: 26993f61673e3d9b29785f9baa5bac50c09f8bcf

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

LOG: Revert "[clang-format] Optimize processing .clang-format-ignore files 
(#76733)"

This reverts commit 42ec976184acd40436acd7104ad715c60ca3e7ed.

Reason: Broke the sanitizer buildbots. See more information on the
github comment thread at
https://github.com/llvm/llvm-project/commit/42ec976184acd40436acd7104ad715c60ca3e7ed

Added: 


Modified: 
clang/docs/ClangFormat.rst
clang/test/Format/clang-format-ignore.cpp
clang/tools/clang-format/ClangFormat.cpp

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 819d9ee9f9cde1..8d4017b29fb8ee 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -131,9 +131,6 @@ An easy way to create the ``.clang-format`` file is:
 
 Available style options are described in :doc:`ClangFormatStyleOptions`.
 
-.clang-format-ignore
-
-
 You can create ``.clang-format-ignore`` files to make ``clang-format`` ignore
 certain files. A ``.clang-format-ignore`` file consists of patterns of file 
path
 names. It has the following format:
@@ -144,8 +141,7 @@ names. It has the following format:
 * A non-comment line is a single pattern.
 * The slash (``/``) is used as the directory separator.
 * A pattern is relative to the directory of the ``.clang-format-ignore`` file
-  (or the root directory if the pattern starts with a slash). Patterns
-  containing drive names (e.g. ``C:``) are not supported.
+  (or the root directory if the pattern starts with a slash).
 * Patterns follow the rules specified in `POSIX 2.13.1, 2.13.2, and Rule 1 of
   2.13.3 `_.

diff  --git a/clang/test/Format/clang-format-ignore.cpp 
b/clang/test/Format/clang-format-ignore.cpp
index 5a2267b302d22f..0d6396a64a668d 100644
--- a/clang/test/Format/clang-format-ignore.cpp
+++ b/clang/test/Format/clang-format-ignore.cpp
@@ -21,26 +21,13 @@
 
 // RUN: touch .clang-format-ignore
 // RUN: clang-format -verbose foo.c foo.js 2> %t.stderr
-// RUN: grep -Fx "Formatting [1/2] foo.c" %t.stderr
-// RUN: grep -Fx "Formatting [2/2] foo.js" %t.stderr
+// RUN: grep "Formatting \[1/2] foo.c" %t.stderr
+// RUN: grep "Formatting \[2/2] foo.js" %t.stderr
 
 // RUN: echo "*.js" > .clang-format-ignore
 // RUN: clang-format -verbose foo.c foo.js 2> %t.stderr
-// RUN: grep -Fx "Formatting [1/2] foo.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
+// RUN: grep "Formatting \[1/2] foo.c" %t.stderr
+// RUN: not grep "Formatting \[2/2] foo.js" %t.stderr
 
-// RUN: cd ../..
-// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
-// RUN: grep -x "Formatting \[1/5] .*foo\.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
-
-// RUN: rm .clang-format-ignore
-// RUN: clang-format -verbose *.cc level1/*.c* level1/level2/foo.* 2> %t.stderr
-// RUN: grep -x "Formatting \[1/5] .*foo\.cc" %t.stderr
-// RUN: grep -x "Formatting \[2/5] .*bar\.cc" %t.stderr
-// RUN: grep -x "Formatting \[3/5] .*baz\.c" %t.stderr
-// RUN: grep -x "Formatting \[4/5] .*foo\.c" %t.stderr
-// RUN: not grep -F foo.js %t.stderr
-
-// RUN: cd ..
-// RUN: rm -r %t.dir
+// RUN: cd ../../..
+// RUN: rm -rf %t.dir

diff  --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index 787e56a6eccc0e..be34dbbe886a15 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -571,11 +571,6 @@ static int dumpConfig(bool IsSTDIN) {
   return 0;
 }
 
-using String = SmallString<128>;
-static String IgnoreDir; // Directory of .clang-format-ignore file.
-static StringRef PrevDir;// Directory of previous `FilePath`.
-static SmallVector Patterns; // Patterns in .clang-format-ignore file.
-
 // Check whether `FilePath` is ignored according to the nearest
 // .clang-format-ignore file based on the rules below:
 // - A blank line is skipped.
@@ -591,50 +586,33 @@ static bool isIgnored(StringRef FilePath) {
   if (!is_regular_file(FilePath))
 return false;
 
-  String Path;
-  String AbsPath{FilePath};
-
   using namespace llvm::sys::path;
+  SmallString<128> Path, AbsPath{FilePath};
+
   make_absolute(AbsPath);
   remove_dots(AbsPath, /*remove_dot_dot=*/true);
 
-  if (StringRef Dir{parent_path(AbsPath)}; PrevDir != Dir) {
-PrevDir = Dir;
-
-for (;;) {
-  Path = Dir;
-  append(Path, ".clang-format-ignore");
-  if (is_regular_file(Path))
-break;
-  Dir = parent_path(Dir);
-  if (Dir.empty())
-return false;
-}
-
-IgnoreDir = convert_to_slash(Dir);
-
-std::

[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-04 Thread Ilya Biryukov via cfe-commits


@@ -1698,8 +1698,6 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
   /*BasedOnStyle=*/"google",
   },
   };
-  GoogleStyle.AttributeMacros.push_back("GUARDED_BY");

ilya-biryukov wrote:

They are attribute macros indeed, the problem is that we actually need more. 
The ones used with fields are at least:
- ABSL_PT_GUARDED_BY
- ABSL_ACQUIRED_AFTER
- ABSL_ACQUIRED_BEFORE
- ABSL_GUARDED_BY_FIXME

We could also consider including the annotations for functions, but the patch 
only broke formatting for variables, so it's not strictly necessary to unblock 
the release.

If we want to also include the ones that are used with functions (they are not 
strictly necessary because `clang-format` does a decent job there without 
config), we would need to add at least these:
- ABSL_EXCLUSIVE_LOCKS_REQUIRED
- ABSL_LOCKS_EXCLUDED
- ABSL_LOCK_RETURNED
- ABSL_EXCLUSIVE_LOCK_FUNCTION
- ABSL_EXCLUSIVE_TRYLOCK_FUNCTION
- ABSL_SHARED_TRYLOCK_FUNCTION
- ABSL_ASSERT_EXCLUSIVE_LOCK
- ABSL_ASSERT_SHARED_LOCK
- ABSL_NO_THREAD_SAFETY_ANALYSIS


I am not sure how to best approach it and would appreciate some guidance here. 
Should we have all these attribute macros inside `AttributeMacros` or should we 
aim for clang-format formatting them reasonably without configuration?

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


[clang] [Sema] Warning for _Float16 passed to format specifier '%f' (PR #74439)

2024-01-04 Thread Haocong Lu via cfe-commits

Luhaocong wrote:

Thanks for everyone's review. Do you have any other suggestions for this 
change, and can this pull request be accepted ?

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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Vlad Serebrennikov via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Vlad Serebrennikov via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 



@@ -95,8 +103,23 @@ std::pair 
ClangASTNodesEmitter::EmitNode(raw_ostream &OS,
   if (!Base.isAbstract())
 First = Last = Base;
 
+  auto comp = [this](ASTNode LHS, ASTNode RHS) {
+auto LHSPriorized = PrioritizedClasses.count(LHS) > 0;

Endilll wrote:

```suggestion
auto LHSPrioritized = PrioritizedClasses.count(LHS) > 0;
```

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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Vlad Serebrennikov via cfe-commits
Pol Marcet =?utf-8?q?Sard=C3=A0?= 
Message-ID:
In-Reply-To: 


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

LGTM, but you should wait for more approvals before merging.

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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Vlad Serebrennikov via cfe-commits
Pol Marcet =?utf-8?q?Sard=C3=A0?= 
Message-ID:
In-Reply-To: 



@@ -70,8 +71,15 @@ class ClangASTNodesEmitter {
   std::pair EmitNode(raw_ostream& OS, ASTNode Base);
 public:
   explicit ClangASTNodesEmitter(RecordKeeper &R, const std::string &N,
-const std::string &S)
-: Records(R), NodeClassName(N), BaseSuffix(S) {}
+const std::string &S,
+std::string_view PriorizeIfSubclassOf)
+  : Records(R), NodeClassName(N), BaseSuffix(S) {
+auto vecPriorized = PriorizeIfSubclassOf.empty()

Endilll wrote:

```suggestion
auto vecPrioritized = PriorizeIfSubclassOf.empty()
```

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


[clang] [C++20] [Modules] Introduce reduced BMI (PR #75894)

2024-01-04 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> > Like I said in the commit message, this patch itself doesn't involve 
> > anything relevant to user interfaces. I left it to the latter patches.
> 
> Are you in a position to post the next patch (at least as a draft)? That 
> would help me see the direction.

I post it here 
https://github.com/ChuanqiXu9/llvm-project/commit/efcc7e888a96e9935a354759de320dea55e93105
 since I didn't get how to send stacked pr in github yet. But I guess it might 
be sufficient since it is really in an early phase.

> 
> > > * I was concerned from earlier conversations that this design might 
> > > require a codegen back end to be instantiated to allow the reduced BMI 
> > > (which would be bad for --precompile/-fmodule-only type jobs). Any 
> > > comments?
> > 
> > 
> > I am not sure if I understand this. What does it mean "require a codegen 
> > back end to be instantiated to allow the reduced BMI "? Do you mean to not 
> > touch CodeGen part or to not touch the CodeGen action? My local patch 
> > touched the code gen action without touching any real CodeGen related 
> > things.
> 
> > > the reduced BMI (which would be bad for --precompile/-fmodule-only type 
> > > jobs)
> > 
> > 
> > For `--precompile/-fmodule-only` type jobs, I'll create another action to 
> > make it (Similar to existing `GenerateModuleInterfaceAction`). Then both of 
> > the actions will try to reuse the same consumer `ReducedBMIGenerator` to 
> > avoid repeated works.
> 
> OK, that answers my concern (which was that we might have to add the code-gen 
> backend to a --precompile if that was the mechanism used to do the BMI 
> reduction).
> 
> > > * It would be better to avoid introducing more layering violations but, 
> > > as we discussed in face-to-face meetings, I have less concern on the 
> > > output side.  It still seems to me that the best model is one where we 
> > > have AST transforms (that very likely need Sema to be correct) and then 
> > > the serializer is a simple as possible.
> > 
> > 
> > Yeah, it should be less concerned. BTW, currently the simpler 
> > serializer/deserializer should be ASTRecordWriter/ASTRecordReader. And the 
> > current ASTReader/ASTWriter takes some semantical job.
> 
> ... and, on the reader side, that already gives us some big problems (as I 
> say, I am less concerned on the writer side, but who can see the whole 
> future?).

I guess you're referring the process how we decide a declaration is visible?

> 
> > > so something like
> > > ```
> > > raw AST + > codegen (when required)
> > > |
> > > + => AST transforms > BMI output.
> > > ```
> > > 
> > > 
> > > 
> > >   
> > > 
> > > 
> > >   
> > > 
> > > 
> > > 
> > >   
> > > As I understand the patch you are combining the transform with the output?
> > 
> > 
> > On the one hand, the **current** patch doesn't do that. The current patch 
> > is almost a NFC patch. It belongs to the following patch. On the other 
> > hand, the answer may be yes. Probably I did the `AST transforms` you said 
> > in the AST Writer. I don't feel it is so awful.
> 
> Maybe not for the short-term relatively simple tasks - but we should also 
> take a view on the medium and longer term (for example, GMF decl elision is 
> likely to be helpful to users in reducing both the size of the BMI and the 
> number of decls that need merging on input).

For GMF decl elision, I posted a patch to implement it in ASTWriter and I 
reposted it in https://github.com/llvm/llvm-project/pull/76930. The big problem 
is that this is not formal. (Just for sharing, I am not proposing this now)

> 
> We need the AST in this path to be mutable (including removal of decls); that 
> way each transform can be maintained as a separate entity - I think that if 
> we end up doing "many transforms" as part of the output, it will become very 
> confusing.

While the model sounds good, I am pessimistic for making it correctly, 
completely, and efficiently.

> 
> _(although, to be clear, i**n the short-term we might agree to do the work in 
> the output** - I really do think it would be bad to make that the long term 
> mechanism)._

Not against, I just think it is not so bad. There already many optimizations in 
the current serializations.

> 
> > Given all of us loves reduced BMI, I suggest we can fosus on current patch 
> > then discuss user interfaces related things in the next patch after this 
> > got landed.
> 
> We do all want to produce the reduced BMI, I agree; but we also always have 
> limited resources to do the work, so that it would be good to try and pick an 
> implementation that will be smooth for the future work too.

Understood. I just think it won't be too bad. Or it is not easy for us to get a 
much better solution in the resources we have. I prefer the style that don't 
make perfect the enemy of better.

> 
> I understand the purpose of the current patch better now - and will try to 
> take a more detailed look over the ne

[llvm] [clang-tools-extra] [clang] Add out-of-line-atomics support to GlobalISel (PR #74588)

2024-01-04 Thread Thomas Preud'homme via cfe-commits

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


[clang-tools-extra] [llvm] [clang] [clang] Accept recursive non-dependent calls to functions with deduced return type (PR #75456)

2024-01-04 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/75456

>From 0e190f131862dd8f4b07891c3ee712a0a163f936 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Thu, 14 Dec 2023 01:33:17 -0800
Subject: [PATCH 1/2] [clang] Accept recursive non-dependent calls to functions
 with deduced return type

Treat such calls as dependent since it is much easier to implement.

Fixes https://github.com/llvm/llvm-project/issues/71015
---
 clang/docs/ReleaseNotes.rst   |  3 ++
 clang/lib/AST/ComputeDependence.cpp   |  2 ++
 clang/lib/Sema/SemaOverload.cpp   | 18 ++
 .../SemaCXX/deduced-return-type-cxx14.cpp | 33 +++
 4 files changed, 56 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 05d59d0da264f3..9ffc7500414981 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -688,6 +688,9 @@ Bug Fixes in This Version
 - Fixed false positive error emitted when templated alias inside a class
   used private members of the same class.
   Fixes (`#41693 `_)
+- Clang now accepts recursive non-dependent calls to functions with deduced 
return
+  type.
+  Fixes (`#71015 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index 097753fd3267b5..584b58473294be 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -603,6 +603,8 @@ ExprDependence clang::computeDependence(PredefinedExpr *E) {
 ExprDependence clang::computeDependence(CallExpr *E,
 llvm::ArrayRef PreArgs) {
   auto D = E->getCallee()->getDependence();
+  if (E->getType()->isDependentType())
+D |= ExprDependence::Type;
   for (auto *A : llvm::ArrayRef(E->getArgs(), E->getNumArgs())) {
 if (A)
   D |= A->getDependence();
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5026e1d603e5ee..9fb767101e1eb7 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -13994,6 +13994,24 @@ ExprResult Sema::BuildOverloadedCallExpr(Scope *S, 
Expr *Fn,
   OverloadCandidateSet::iterator Best;
   OverloadingResult OverloadResult =
   CandidateSet.BestViableFunction(*this, Fn->getBeginLoc(), Best);
+  FunctionDecl *FDecl = Best->Function;
+
+  // Model the case with a call to a templated function whose definition
+  // encloses the call and whose return type contains a placeholder type as if
+  // the UnresolvedLookupExpr was type-dependent.
+  if (OverloadResult == OR_Success && FDecl &&
+  FDecl->isTemplateInstantiation() &&
+  FDecl->getReturnType()->isUndeducedType()) {
+if (auto TP = FDecl->getTemplateInstantiationPattern(false)) {
+  if (TP->willHaveBody()) {
+CallExpr *CE =
+CallExpr::Create(Context, Fn, Args, Context.DependentTy, 
VK_PRValue,
+ RParenLoc, CurFPFeatureOverrides());
+result = CE;
+return result;
+  }
+}
+  }
 
   return FinishOverloadedCallExpr(*this, S, Fn, ULE, LParenLoc, Args, 
RParenLoc,
   ExecConfig, &CandidateSet, &Best,
diff --git a/clang/test/SemaCXX/deduced-return-type-cxx14.cpp 
b/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
index 6344d1df3fbaeb..1da597499d34f5 100644
--- a/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
+++ b/clang/test/SemaCXX/deduced-return-type-cxx14.cpp
@@ -640,3 +640,36 @@ namespace PR46637 {
   template struct Y { T x; };
   Y auto> y; // expected-error {{'auto' not allowed in template 
argument}}
 }
+
+namespace GH71015 {
+
+// Check that there is no error in case a templated function is recursive and
+// has a placeholder return type.
+struct Node {
+  int value;
+  Node* left;
+  Node* right;
+};
+
+bool parse(const char*);
+Node* parsePrimaryExpr();
+
+auto parseMulExpr(auto node) { // cxx14-error {{'auto' not allowed in function 
prototype}}
+  if (node == nullptr) node = parsePrimaryExpr();
+  if (!parse("*")) return node;
+  return parseMulExpr(new Node{.left = node, .right = parsePrimaryExpr()});
+}
+
+template 
+auto parseMulExpr2(T node) {
+  if (node == nullptr) node = parsePrimaryExpr();
+  if (!parse("*")) return node;
+  return parseMulExpr2(new Node{.left = node, .right = parsePrimaryExpr()});
+}
+
+auto f(auto x) { // cxx14-error {{'auto' not allowed in function prototype}}
+  if (x == 0) return 0;
+  return f(1) + 1;
+}
+
+}

>From 9981ec5663fd039cb2ddfc00ae8f1468f2b56d61 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Thu, 4 Jan 2024 02:23:33 -0800
Subject: [PATCH 2/2] Add a testcase

---
 clang/test/SemaCXX/deduced-return-type-cxx14.cpp | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/clang/test/SemaCXX/deduced-return-typ

[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-04 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


https://github.com/Destroyerrrocket updated 
https://github.com/llvm/llvm-project/pull/76615

>From cba67a73ea1e59eb8eeb4e702d77f329028f4c22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pol=20Marcet=20Sard=C3=A0?= 
Date: Sat, 30 Dec 2023 13:59:00 +0100
Subject: [PATCH 1/2] [clang] Constexpr for __builtin_shufflevector and
 __builtin_convertvector

Summary:

This patch adds constexpr support for __builtin_shufflevector
and __builtin_convertvector.

A small oddity encountered was that the arg to the intrinsics may be an
lvalue without any sort of implicit cast of any kind. I solved this
through the EvaluateVectorOrLValue function, which treats the lvalue as
if it was in an rvalue cast, which gets me the desired vector.
---
 clang/docs/LanguageExtensions.rst |   5 +-
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/lib/AST/ExprConstant.cpp| 138 +-
 clang/test/Sema/constant-builtins-2.c |  61 
 4 files changed, 203 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 23a7f4f5d5b926..5f06c3d4b86f94 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2853,7 +2853,7 @@ Query for this feature with 
``__has_builtin(__builtin_dump_struct)``
 ``__builtin_shufflevector`` is used to express generic vector
 permutation/shuffle/swizzle operations.  This builtin is also very important
 for the implementation of various target-specific header files like
-.
+. This builtin can be used within constant expressions.
 
 **Syntax**:
 
@@ -2907,7 +2907,8 @@ Query for this feature with 
``__has_builtin(__builtin_shufflevector)``.
 
 ``__builtin_convertvector`` is used to express generic vector
 type-conversion operations. The input vector and the output vector
-type must have the same number of elements.
+type must have the same number of elements. This builtin can be used within
+constant expressions.
 
 **Syntax**:
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c8fec691bf3c9..b6f1407436ed4f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -237,6 +237,8 @@ Non-comprehensive list of changes in this release
 * Since MSVC 19.33 added undocumented attribute ``[[msvc::constexpr]]``, this 
release adds the attribute as well.
 
 * Added ``#pragma clang fp reciprocal``.
+* Builtins ``__builtin_shufflevector()`` and ``__builtin_convertvector()`` may 
now be used within constant
+ expressions.
 
 New Compiler Flags
 --
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f6aeee1a4e935d..e8afa10fe7aaac 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2702,7 +2702,8 @@ static bool checkFloatingPointResult(EvalInfo &Info, 
const Expr *E,
 static bool HandleFloatToFloatCast(EvalInfo &Info, const Expr *E,
QualType SrcType, QualType DestType,
APFloat &Result) {
-  assert(isa(E) || isa(E));
+  assert(isa(E) || isa(E) ||
+ isa(E));
   llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
   APFloat::opStatus St;
   APFloat Value = Result;
@@ -10643,6 +10644,9 @@ namespace {
 bool VisitUnaryImag(const UnaryOperator *E);
 bool VisitBinaryOperator(const BinaryOperator *E);
 bool VisitUnaryOperator(const UnaryOperator *E);
+bool VisitConvertVectorExpr(const ConvertVectorExpr *E);
+bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E);
+
 // FIXME: Missing: conditional operator (for GNU
 // conditional select), shufflevector, ExtVectorElementExpr
   };
@@ -10895,6 +10899,138 @@ bool VectorExprEvaluator::VisitUnaryOperator(const 
UnaryOperator *E) {
   return Success(APValue(ResultElements.data(), ResultElements.size()), E);
 }
 
+static bool EvaluateVectorOrLValue(APValue &Result, EvalInfo &Info,
+   const Expr *E, const QualType &Type) {
+  if (!Evaluate(Result, Info, E))
+return false;
+
+  if (Result.isLValue()) {
+// Source of the data is an lvalue; Manually handle the lvalue as if
+// it was an rvalue to get the current APValue.
+LValue LValueFound;
+LValueFound.setFrom(Info.Ctx, Result);
+if (!handleLValueToRValueConversion(Info, E, Type, LValueFound, Result)) {
+  return false;
+}
+  }
+
+  if (!Result.isVector()) {
+return false;
+  }
+  return true;
+}
+
+static bool handleVectorConversion(EvalInfo &Info, const FPOptions FPO,
+   const Expr *E, QualType SourceTy,
+   QualType DestTy, APValue const &Original,
+   APValue &Result) {
+  if (SourceTy->isIntegerType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = APValue(APFloat(0.0));
+  return HandleIntToFloatCast(Info, E, FPO, Sourc

[clang-tools-extra] [llvm] [clang] [clang] Accept recursive non-dependent calls to functions with deduced return type (PR #75456)

2024-01-04 Thread Mariya Podchishchaeva via cfe-commits


@@ -640,3 +640,36 @@ namespace PR46637 {
   template struct Y { T x; };
   Y auto> y; // expected-error {{'auto' not allowed in template 
argument}}
 }
+
+namespace GH71015 {
+
+// Check that there is no error in case a templated function is recursive and
+// has a placeholder return type.
+struct Node {
+  int value;
+  Node* left;
+  Node* right;
+};
+
+bool parse(const char*);
+Node* parsePrimaryExpr();
+
+auto parseMulExpr(auto node) { // cxx14-error {{'auto' not allowed in function 
prototype}}
+  if (node == nullptr) node = parsePrimaryExpr();
+  if (!parse("*")) return node;
+  return parseMulExpr(new Node{.left = node, .right = parsePrimaryExpr()});

Fznamznon wrote:

Added the test.

A note here is that It will only be rejected if the function instantiated 
because clang doesn't take into account return statements if the function is 
templated due to this part:

https://github.com/llvm/llvm-project/blob/11276563c81987791a2326950dbc3315a32dd709/clang/lib/Sema/SemaStmt.cpp#L3806

gcc rejects even if the function is not instantiated. msvc doesn't. 
https://compiler-explorer.com/z/hGc8M1esT


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


[clang] loop bind : bug in checking Parent region (PR #76938)

2024-01-04 Thread via cfe-commits

https://github.com/SunilKuravinakop created 
https://github.com/llvm/llvm-project/pull/76938

Changes uploaded to the phabricator on Dec 16th are lost because the 
phabricator is down. Hence re-uploading it to the github.com.

  Changes to be committed:
modified:   clang/include/clang/Sema/Sema.h
modified:   clang/lib/Sema/SemaOpenMP.cpp
modified:   clang/test/OpenMP/generic_loop_ast_print.cpp
modified:   clang/test/OpenMP/loop_bind_messages.cpp
modified:   clang/test/PCH/pragma-loop.cpp

>From 1dcd4703002acdde370a285089008e409043717b Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Thu, 4 Jan 2024 04:08:28 -0600
Subject: [PATCH] Changes uploaded to the phabricator on Dec 16th are lost
 because the phabricator is down. Hence re-uploading it to the github.com.

  Changes to be committed:
modified:   clang/include/clang/Sema/Sema.h
modified:   clang/lib/Sema/SemaOpenMP.cpp
modified:   clang/test/OpenMP/generic_loop_ast_print.cpp
modified:   clang/test/OpenMP/loop_bind_messages.cpp
modified:   clang/test/PCH/pragma-loop.cpp
---
 clang/include/clang/Sema/Sema.h  |   8 +-
 clang/lib/Sema/SemaOpenMP.cpp|  62 ---
 clang/test/OpenMP/generic_loop_ast_print.cpp |   4 +-
 clang/test/OpenMP/loop_bind_messages.cpp | 180 +--
 clang/test/PCH/pragma-loop.cpp   |   8 +-
 5 files changed, 226 insertions(+), 36 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5e3b57ea33220b..3d8d94d200ac58 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11335,6 +11335,7 @@ class Sema final {
   /// on the parameter of the bind clause. In the methods for the
   /// mapped directives, check the parameters of the lastprivate clause.
   bool checkLastPrivateForMappedDirectives(ArrayRef Clauses);
+
   /// Depending on the bind clause of OMPD_loop map the directive to new
   /// directives.
   ///1) loop bind(parallel) --> OMPD_for
@@ -11344,9 +11345,12 @@ class Sema final {
   /// rigorous semantic checking in the new mapped directives.
   bool mapLoopConstruct(llvm::SmallVector &ClausesWithoutBind,
 ArrayRef Clauses,
-OpenMPBindClauseKind BindKind,
+OpenMPBindClauseKind &BindKind,
 OpenMPDirectiveKind &Kind,
-OpenMPDirectiveKind &PrevMappedDirective);
+OpenMPDirectiveKind &PrevMappedDirective,
+SourceLocation StartLoc, SourceLocation EndLoc,
+const DeclarationNameInfo &DirName,
+OpenMPDirectiveKind CancelRegion);
 
 public:
   /// The declarator \p D defines a function in the scope \p S which is nested
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f34d2959dc6191..6e060e5b8ee268 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5072,6 +5072,18 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 CurrentRegion != OMPD_cancellation_point &&
 CurrentRegion != OMPD_cancel && CurrentRegion != OMPD_scan)
   return false;
+// Checks needed for mapping "loop" construct. Please check 
mapLoopConstruct
+// for a detailed explanation
+if (SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion == OMPD_loop &&
+((BindKind == OMPC_BIND_parallel) || (BindKind == OMPC_BIND_teams)) &&
+(isOpenMPWorksharingDirective(ParentRegion) ||
+ ParentRegion == OMPD_loop)) {
+  int ErrorMsgNumber = (BindKind == OMPC_BIND_parallel) ? 1 : 4;
+  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
+  << true << getOpenMPDirectiveName(ParentRegion) << ErrorMsgNumber
+  << getOpenMPDirectiveName(CurrentRegion);
+  return true;
+}
 if (CurrentRegion == OMPD_cancellation_point ||
 CurrentRegion == OMPD_cancel) {
   // OpenMP [2.16, Nesting of Regions]
@@ -6124,35 +6136,36 @@ processImplicitMapsWithDefaultMappers(Sema &S, 
DSAStackTy *Stack,
 
 bool Sema::mapLoopConstruct(llvm::SmallVector &ClausesWithoutBind,
 ArrayRef Clauses,
-OpenMPBindClauseKind BindKind,
+OpenMPBindClauseKind &BindKind,
 OpenMPDirectiveKind &Kind,
-OpenMPDirectiveKind &PrevMappedDirective) {
+OpenMPDirectiveKind &PrevMappedDirective,
+SourceLocation StartLoc, SourceLocation EndLoc,
+const DeclarationNameInfo &DirName,
+OpenMPDirectiveKind CancelRegion) {
 
   bool UseClausesWithoutBind = false;
 
   // Restricting to "#pragma omp loop bind"
   if (getLangOpts().OpenMP >= 50 && Kind == OMPD_loop) {
+
+const OpenMPDirec

[clang] loop bind : bug in checking Parent region (PR #76938)

2024-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (SunilKuravinakop)


Changes

Changes uploaded to the phabricator on Dec 16th are lost because the 
phabricator is down. Hence re-uploading it to the github.com.

  Changes to be committed:
modified:   clang/include/clang/Sema/Sema.h
modified:   clang/lib/Sema/SemaOpenMP.cpp
modified:   clang/test/OpenMP/generic_loop_ast_print.cpp
modified:   clang/test/OpenMP/loop_bind_messages.cpp
modified:   clang/test/PCH/pragma-loop.cpp

---
Full diff: https://github.com/llvm/llvm-project/pull/76938.diff


5 Files Affected:

- (modified) clang/include/clang/Sema/Sema.h (+6-2) 
- (modified) clang/lib/Sema/SemaOpenMP.cpp (+42-20) 
- (modified) clang/test/OpenMP/generic_loop_ast_print.cpp (+2-2) 
- (modified) clang/test/OpenMP/loop_bind_messages.cpp (+170-10) 
- (modified) clang/test/PCH/pragma-loop.cpp (+6-2) 


``diff
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5e3b57ea33220b..3d8d94d200ac58 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11335,6 +11335,7 @@ class Sema final {
   /// on the parameter of the bind clause. In the methods for the
   /// mapped directives, check the parameters of the lastprivate clause.
   bool checkLastPrivateForMappedDirectives(ArrayRef Clauses);
+
   /// Depending on the bind clause of OMPD_loop map the directive to new
   /// directives.
   ///1) loop bind(parallel) --> OMPD_for
@@ -11344,9 +11345,12 @@ class Sema final {
   /// rigorous semantic checking in the new mapped directives.
   bool mapLoopConstruct(llvm::SmallVector &ClausesWithoutBind,
 ArrayRef Clauses,
-OpenMPBindClauseKind BindKind,
+OpenMPBindClauseKind &BindKind,
 OpenMPDirectiveKind &Kind,
-OpenMPDirectiveKind &PrevMappedDirective);
+OpenMPDirectiveKind &PrevMappedDirective,
+SourceLocation StartLoc, SourceLocation EndLoc,
+const DeclarationNameInfo &DirName,
+OpenMPDirectiveKind CancelRegion);
 
 public:
   /// The declarator \p D defines a function in the scope \p S which is nested
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f34d2959dc6191..6e060e5b8ee268 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5072,6 +5072,18 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 CurrentRegion != OMPD_cancellation_point &&
 CurrentRegion != OMPD_cancel && CurrentRegion != OMPD_scan)
   return false;
+// Checks needed for mapping "loop" construct. Please check 
mapLoopConstruct
+// for a detailed explanation
+if (SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion == OMPD_loop &&
+((BindKind == OMPC_BIND_parallel) || (BindKind == OMPC_BIND_teams)) &&
+(isOpenMPWorksharingDirective(ParentRegion) ||
+ ParentRegion == OMPD_loop)) {
+  int ErrorMsgNumber = (BindKind == OMPC_BIND_parallel) ? 1 : 4;
+  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
+  << true << getOpenMPDirectiveName(ParentRegion) << ErrorMsgNumber
+  << getOpenMPDirectiveName(CurrentRegion);
+  return true;
+}
 if (CurrentRegion == OMPD_cancellation_point ||
 CurrentRegion == OMPD_cancel) {
   // OpenMP [2.16, Nesting of Regions]
@@ -6124,35 +6136,36 @@ processImplicitMapsWithDefaultMappers(Sema &S, 
DSAStackTy *Stack,
 
 bool Sema::mapLoopConstruct(llvm::SmallVector &ClausesWithoutBind,
 ArrayRef Clauses,
-OpenMPBindClauseKind BindKind,
+OpenMPBindClauseKind &BindKind,
 OpenMPDirectiveKind &Kind,
-OpenMPDirectiveKind &PrevMappedDirective) {
+OpenMPDirectiveKind &PrevMappedDirective,
+SourceLocation StartLoc, SourceLocation EndLoc,
+const DeclarationNameInfo &DirName,
+OpenMPDirectiveKind CancelRegion) {
 
   bool UseClausesWithoutBind = false;
 
   // Restricting to "#pragma omp loop bind"
   if (getLangOpts().OpenMP >= 50 && Kind == OMPD_loop) {
+
+const OpenMPDirectiveKind ParentDirective = DSAStack->getParentDirective();
+
 if (BindKind == OMPC_BIND_unknown) {
   // Setting the enclosing teams or parallel construct for the loop
   // directive without bind clause.
   BindKind = OMPC_BIND_thread; // Default bind(thread) if binding is 
unknown
 
-  const OpenMPDirectiveKind ParentDirective =
-  DSAStack->getParentDirective();
   if (ParentDirective == OMPD_unknown) {
 Diag(DSAStack->getDefaultDSALocation(),
  diag::err_omp_bind_required_on_loop);
   } el

[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-04 Thread Kerry McLaughlin via cfe-commits

https://github.com/kmclaughlin-arm commented:

Thanks for fixing these tests @MDevereau!
There are also some tests in acle_sme2_mlal.c, acle_sme2_mlall.c & 
acle_sme2_mlsl.c which have a similar issue, could you please update them in 
this patch too?

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


[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-04 Thread Kerry McLaughlin via cfe-commits

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


[clang] [AArch64][SME2] Fix SME2 mla/mls tests (PR #76711)

2024-01-04 Thread Kerry McLaughlin via cfe-commits


@@ -246,7 +246,7 @@ void test_svmls_single2_f64(uint32_t slice_base, 
svfloat64x2_t zn, svfloat64_t z
 // CPP-CHECK-NEXT:ret void
 //
 void test_svmls_single4_f64(uint32_t slice_base, svfloat64x4_t zn, svfloat64_t 
zm) __arm_streaming __arm_shared_za {
-  SVE_ACLE_FUNC(svmls_single_za64,,_f64,,_vg1x4)(slice_base, zn, zm);
+  SVE_ACLE_FUNC(svmls,_single,_za64,_f64,_vg1x4)(slice_base, zn, zm);

kmclaughlin-arm wrote:

I think there are some `svmls` & `svmls_lane` tests that should be updated in 
this test file as well, for example on line 39:
`SVE_ACLE_FUNC(svmls_za32,,_f32,,_vg1x2)(slice_base, zn, zm);`

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


[clang] [clang] Add per-global code model attribute (PR #72078)

2024-01-04 Thread via cfe-commits

heiher wrote:

@erichkeane gentle ping

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


[llvm] [clang] [libcxx] "Reapply "[Sema] Fix crash on invalid code with parenthesized aggrega… (PR #76833)

2024-01-04 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

> @ilya-biryukov this is the new attempt to land this patch, the version you 
> committed breaks the libc++ CI. I'll try to fix it this week.

Wow, I didn't expect that. Is libc++ ok with disabling this test until the 
nightly build catches up? (The PR is in the Draft state, so it's hard to tell 
if that's acceptable).

In the long-term, how should people land changes like this? Compiler 
diagnostics are expected to change sometimes, so we should figure out some way 
that allows landing these without reverts. Any thoughts?

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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread via cfe-commits
Pol Marcet =?utf-8?q?Sard=C3=A0?= 
Message-ID:
In-Reply-To: 



@@ -196,8 +217,20 @@ void ClangASTNodesEmitter::run(raw_ostream &OS) {
 }
 
 void clang::EmitClangASTNodes(RecordKeeper &RK, raw_ostream &OS,
-  const std::string &N, const std::string &S) {
-  ClangASTNodesEmitter(RK, N, S).run(OS);
+  const std::string &N, const std::string &S,
+  std::string_view PriorizeIfSubclassOf) {
+  ClangASTNodesEmitter(RK, N, S, PriorizeIfSubclassOf).run(OS);
+}
+
+void printDeclContext(std::multimap &Tree,

cor3ntin wrote:

```suggestion
void printDeclContext(const std::multimap &Tree,
```

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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread via cfe-commits
Pol Marcet =?utf-8?q?Sard=C3=A0?= 
Message-ID:
In-Reply-To: 


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

LGTM.
1% is a very consequential improvement, congrats!

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


[clang-tools-extra] [clang] [llvm] Add out-of-line-atomics support to GlobalISel (PR #74588)

2024-01-04 Thread Thomas Preud'homme via cfe-commits

RoboTux wrote:

Thanks for fixing the unused variable @DamonFool , I was about to revert and 
push a new patch.

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


[clang-tools-extra] [clangd] Allow specifying what headers are always included via "" or <> (PR #67749)

2024-01-04 Thread kleines Filmröllchen via cfe-commits

kleinesfilmroellchen wrote:

> > What is the relationship between this patch, and clangd 17's ["missing 
> > include" 
> > warning](https://clangd.llvm.org/guides/include-cleaner#missing-include-warning)?
> >  Does the quick-fix for the "missing include" warning also respect these 
> > config options?
> 
> Same question from me -- this is the main reason I personally care about this 
> PR :) We have directories in our project tree that we'd like to be included 
> as `#include ` (as those would be installed system-wide in an 
> open-source version) and others that we'd like to be included as `#include 
> "dir/foo.h"` (internal headers that are in the same subtree as the C++ 
> source) and I'd really like clangd in vscode to suggest fixing the missing 
> include warnings appropriately. Thanks!

As far as I can tell, clangd uses the correct header style for inserted 
includes regardles of how those includes are created (via auto-include on code 
completion or fix suggestions).

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


[clang-tools-extra] [clangd] Allow specifying what headers are always included via "" or <> (PR #67749)

2024-01-04 Thread kleines Filmröllchen via cfe-commits

https://github.com/kleinesfilmroellchen updated 
https://github.com/llvm/llvm-project/pull/67749

From 8a2b22e69f82e3f4caa271b57b998d1c03b21d39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= 
Date: Thu, 4 Jan 2024 11:53:23 +0100
Subject: [PATCH] [clangd] Allow specifying what headers are always included
 via "" or <>

Projects can now add config fragments like this to their .clangd:

```yaml
Style:
  QuotedHeaders: "src/.*"
  AngledHeaders: ["path/sdk/.*", "third-party/.*"]
```

to force headers inserted via the --header-insertion=iwyu mode matching
at least one of the regexes to have <> (AngledHeaders) or ""
(QuotedHeaders) around them, respectively. For other headers (and in
conflicting cases where both styles have a matching regex), the current
system header detection remains.

Ref https://github.com/clangd/clangd/issues/1247

Based on https://reviews.llvm.org/D145843

This solution does not affect other clang tools like clang-format.
---
 clang-tools-extra/clangd/CodeComplete.cpp | 15 --
 clang-tools-extra/clangd/Config.h |  4 ++
 clang-tools-extra/clangd/ConfigCompile.cpp| 49 +++
 clang-tools-extra/clangd/ConfigFragment.h | 13 +
 clang-tools-extra/clangd/ConfigYAML.cpp   |  8 +++
 clang-tools-extra/clangd/Headers.cpp  | 34 +++--
 clang-tools-extra/clangd/Headers.h| 11 -
 clang-tools-extra/clangd/IncludeCleaner.h |  1 -
 clang-tools-extra/clangd/ParsedAST.cpp|  3 +-
 .../clangd/unittests/ConfigCompileTests.cpp   | 36 ++
 .../clangd/unittests/ConfigYAMLTests.cpp  |  8 ++-
 .../clangd/unittests/HeadersTests.cpp | 29 +--
 12 files changed, 193 insertions(+), 18 deletions(-)

diff --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 0e5f08cec440ce..419bd659898506 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -21,6 +21,7 @@
 #include "AST.h"
 #include "CodeCompletionStrings.h"
 #include "Compiler.h"
+#include "Config.h"
 #include "ExpectedTypes.h"
 #include "Feature.h"
 #include "FileDistance.h"
@@ -786,8 +787,8 @@ SpecifiedScope getQueryScopes(CodeCompletionContext 
&CCContext,
   llvm::StringRef SpelledSpecifier = Lexer::getSourceText(
   CharSourceRange::getCharRange(SemaSpecifier->getRange()),
   CCSema.SourceMgr, clang::LangOptions());
-  if (SpelledSpecifier.consume_front("::")) 
-  Scopes.QueryScopes = {""};
+  if (SpelledSpecifier.consume_front("::"))
+Scopes.QueryScopes = {""};
   Scopes.UnresolvedQualifier = std::string(SpelledSpecifier);
   // Sema excludes the trailing "::".
   if (!Scopes.UnresolvedQualifier->empty())
@@ -1580,7 +1581,7 @@ class CodeCompleteFlow {
   CompletionPrefix HeuristicPrefix;
   std::optional Filter; // Initialized once Sema runs.
   Range ReplacedRange;
-  std::vector QueryScopes; // Initialized once Sema runs.
+  std::vector QueryScopes;  // Initialized once Sema runs.
   std::vector AccessibleScopes; // Initialized once Sema runs.
   // Initialized once QueryScopes is initialized, if there are scopes.
   std::optional ScopeProximity;
@@ -1639,7 +1640,9 @@ class CodeCompleteFlow {
   Inserter.emplace(
   SemaCCInput.FileName, SemaCCInput.ParseInput.Contents, Style,
   SemaCCInput.ParseInput.CompileCommand.Directory,
-  &Recorder->CCSema->getPreprocessor().getHeaderSearchInfo());
+  &Recorder->CCSema->getPreprocessor().getHeaderSearchInfo(),
+  Config::current().Style.QuotedHeaders,
+  Config::current().Style.AngledHeaders);
   for (const auto &Inc : Includes.MainFileIncludes)
 Inserter->addExisting(Inc);
 
@@ -1722,7 +1725,9 @@ class CodeCompleteFlow {
 auto Style = getFormatStyleForFile(FileName, Content, TFS);
 // This will only insert verbatim headers.
 Inserter.emplace(FileName, Content, Style,
- /*BuildDir=*/"", /*HeaderSearchInfo=*/nullptr);
+ /*BuildDir=*/"", /*HeaderSearchInfo=*/nullptr,
+ Config::current().Style.QuotedHeaders,
+ Config::current().Style.AngledHeaders);
 
 auto Identifiers = collectIdentifiers(Content, Style);
 std::vector IdentifierResults;
diff --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 4371c80a6c5877..12ed1420c93e19 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -123,6 +123,10 @@ struct Config {
 // declarations, always spell out the whole name (with or without leading
 // ::). All nested namespaces are affected as well.
 std::vector FullyQualifiedNamespaces;
+
+// List of regexes for inserting certain headers with <> or "".
+std::vector> QuotedHeaders;
+std::vector> AngledHeaders;
   } Style;
 
   /// Configures code completion feature.
diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/cl

[clang-tools-extra] [clang] Reapply "[Clang][Sema] Diagnose unexpanded packs in the template argument lists of function template specializations" (#76876) (PR #76915)

2024-01-04 Thread via cfe-commits

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


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


[clang] f5efa74 - [Sema] When checking for constraint equivalence, do not calculate satisfaction (#74490)

2024-01-04 Thread via cfe-commits

Author: Ilya Biryukov
Date: 2024-01-04T11:57:53+01:00
New Revision: f5efa74961560070a1e6f127214bcf6b570fef98

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

LOG: [Sema] When checking for constraint equivalence, do not calculate 
satisfaction (#74490)

... and only look at equivalence of substituted expressions, not results
of constraint satisfaction.
This is required by the standard when matching redeclarations.

Fixes #74314.

There is already some existing machinery for that in
`TemplateInstantiator` and `Sema` exposed separate functions for
substituting expressions with intention to do that:
- `Sema::SubstExpr` should not evaluate constraints.
- `Sema::SubstConstraintExpr` should.

However, both functions used to be equivalent. Introduce a new function
that does not evaluate constraint and use it when matching declarations.

Also change implementation of `SubstConstraintExpr` to call `SubstExpr`
directly so it's obvious they behave in the same way and add a FIXME to
call out that we might need to revamp this approach in the future.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/SemaTemplate/concepts-out-of-line-def.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5e3b57ea33220b..8f44adef38159e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10263,11 +10263,13 @@ class Sema final {
 ~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
   };
 
-  // Unlike the above, this evaluates constraints, which should only happen at
-  // 'constraint checking' time.
+  // Must be used instead of SubstExpr at 'constraint checking' time.
   ExprResult
   SubstConstraintExpr(Expr *E,
   const MultiLevelTemplateArgumentList &TemplateArgs);
+  // Unlike the above, this does not evaluates constraints.
+  ExprResult SubstConstraintExprWithoutSatisfaction(
+  Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs);
 
   /// Substitute the given template arguments into a list of
   /// expressions, expanding pack expansions if required.

diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index 2a553054a0ce51..ce44aca797b0fb 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -564,6 +564,7 @@ enum class TemplateSubstitutionKind : char {
 const MultiLevelTemplateArgumentList &TemplateArgs;
 Sema::LateInstantiatedAttrVec* LateAttrs = nullptr;
 LocalInstantiationScope *StartingScope = nullptr;
+// Whether to evaluate the C++20 constraints or simply substitute into 
them.
 bool EvaluateConstraints = true;
 
 /// A list of out-of-line class template partial

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 719c6aab74e017..acfc00f4125407 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -771,10 +771,9 @@ namespace {
   };
 } // namespace
 
-static const Expr *
-SubstituteConstraintExpression(Sema &S,
-   const Sema::TemplateCompareNewDeclInfo 
&DeclInfo,
-   const Expr *ConstrExpr) {
+static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
+Sema &S, const Sema::TemplateCompareNewDeclInfo &DeclInfo,
+const Expr *ConstrExpr) {
   MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs(
   DeclInfo.getDecl(), DeclInfo.getLexicalDeclContext(), /*Final=*/false,
   /*Innermost=*/nullptr,
@@ -797,8 +796,8 @@ SubstituteConstraintExpression(Sema &S,
   std::optional ThisScope;
   if (auto *RD = dyn_cast(DeclInfo.getDeclContext()))
 ThisScope.emplace(S, const_cast(RD), Qualifiers());
-  ExprResult SubstConstr =
-  S.SubstConstraintExpr(const_cast(ConstrExpr), MLTAL);
+  ExprResult SubstConstr = S.SubstConstraintExprWithoutSatisfaction(
+  const_cast(ConstrExpr), MLTAL);
   if (SFINAE.hasErrorOccurred() || !SubstConstr.isUsable())
 return nullptr;
   return SubstConstr.get();
@@ -814,12 +813,14 @@ bool Sema::AreConstraintExpressionsEqual(const NamedDecl 
*Old,
   if (Old && !New.isInvalid() && !New.ContainsDecl(Old) &&
   Old->getLexicalDeclContext() != New.getLexicalDeclContext()) {
 if (const Expr *SubstConstr =
-SubstituteConstraintExpression(*this, Old, OldConstr))
+SubstituteConstraintExpressionWithoutSatisfaction(*this, Old,
+  OldConstr))
   OldConstr = SubstConstr;
 else
   return false;
 if (const Expr *SubstConstr =
-Substit

[clang-tools-extra] [clang] [llvm] [Sema] When checking for constraint equivalence, do not calculate satisfaction (PR #74490)

2024-01-04 Thread Ilya Biryukov via cfe-commits

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


[clang] loop bind : correction for bug in checking Parent region (PR #76938)

2024-01-04 Thread via cfe-commits

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


[clang] loop bind : patch correction for bug in checking Parent region (PR #76938)

2024-01-04 Thread via cfe-commits

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


[clang-tools-extra] [clangd] [C++20] [Modules] Introduce initial support for C++20 Modules (PR #66462)

2024-01-04 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

I'm Sam's colleague and wanted to mention that Sam won't be available until 
January 15.
It probably does not make much sense for someone else to take over at this 
point as the change is large and waiting for Sam is more efficient than ramping 
up someone else at this point.

Sorry about the delays.

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


[clang] [OpenMP] Patch for Support to loop bind clause : Checking Parent Region (PR #76938)

2024-01-04 Thread via cfe-commits

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


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-04 Thread Simon Pilgrim via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


RKSimon wrote:

Please can you rename constat_builtins_vector.cpp -> 
constant_builtins_vector.cpp

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


[clang] [NFC][clang][test][asan] Make `instantiation-depth-default.cpp` a valid test case under `asan` and `ubsan` configs (PR #75254)

2024-01-04 Thread via cfe-commits


@@ -1,18 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit=2 %s
-//
-// FIXME: Disable this test when Clang was built with ASan, because ASan
-// increases our per-frame stack usage enough that this test no longer fits
-// within our normal stack space allocation.
-// UNSUPPORTED: asan
-//
+// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit=2 
-Wno-stack-exhausted %s

goussepi wrote:

Is it possible to disable the stack-exhausted warning only if asan or ubsan? I 
am thinking we still might want to be able to detect stack usage regressions. 
It also helps documenting.
Not tested but maybe something like ```// RUN: %clang_cc1 -fsyntax-only -verify 
-ftemplate-backtrace-limit=2 %if {{asan|ubsan}} %{ -Wno-stack-exhausted %} %s```
If not possible then LGTM, let me know if you need someone to commit for you.

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


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-04 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= ,
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


https://github.com/Destroyerrrocket updated 
https://github.com/llvm/llvm-project/pull/76615

>From cba67a73ea1e59eb8eeb4e702d77f329028f4c22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pol=20Marcet=20Sard=C3=A0?= 
Date: Sat, 30 Dec 2023 13:59:00 +0100
Subject: [PATCH 1/3] [clang] Constexpr for __builtin_shufflevector and
 __builtin_convertvector

Summary:

This patch adds constexpr support for __builtin_shufflevector
and __builtin_convertvector.

A small oddity encountered was that the arg to the intrinsics may be an
lvalue without any sort of implicit cast of any kind. I solved this
through the EvaluateVectorOrLValue function, which treats the lvalue as
if it was in an rvalue cast, which gets me the desired vector.
---
 clang/docs/LanguageExtensions.rst |   5 +-
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/lib/AST/ExprConstant.cpp| 138 +-
 clang/test/Sema/constant-builtins-2.c |  61 
 4 files changed, 203 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 23a7f4f5d5b926..5f06c3d4b86f94 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2853,7 +2853,7 @@ Query for this feature with 
``__has_builtin(__builtin_dump_struct)``
 ``__builtin_shufflevector`` is used to express generic vector
 permutation/shuffle/swizzle operations.  This builtin is also very important
 for the implementation of various target-specific header files like
-.
+. This builtin can be used within constant expressions.
 
 **Syntax**:
 
@@ -2907,7 +2907,8 @@ Query for this feature with 
``__has_builtin(__builtin_shufflevector)``.
 
 ``__builtin_convertvector`` is used to express generic vector
 type-conversion operations. The input vector and the output vector
-type must have the same number of elements.
+type must have the same number of elements. This builtin can be used within
+constant expressions.
 
 **Syntax**:
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c8fec691bf3c9..b6f1407436ed4f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -237,6 +237,8 @@ Non-comprehensive list of changes in this release
 * Since MSVC 19.33 added undocumented attribute ``[[msvc::constexpr]]``, this 
release adds the attribute as well.
 
 * Added ``#pragma clang fp reciprocal``.
+* Builtins ``__builtin_shufflevector()`` and ``__builtin_convertvector()`` may 
now be used within constant
+ expressions.
 
 New Compiler Flags
 --
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f6aeee1a4e935d..e8afa10fe7aaac 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2702,7 +2702,8 @@ static bool checkFloatingPointResult(EvalInfo &Info, 
const Expr *E,
 static bool HandleFloatToFloatCast(EvalInfo &Info, const Expr *E,
QualType SrcType, QualType DestType,
APFloat &Result) {
-  assert(isa(E) || isa(E));
+  assert(isa(E) || isa(E) ||
+ isa(E));
   llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
   APFloat::opStatus St;
   APFloat Value = Result;
@@ -10643,6 +10644,9 @@ namespace {
 bool VisitUnaryImag(const UnaryOperator *E);
 bool VisitBinaryOperator(const BinaryOperator *E);
 bool VisitUnaryOperator(const UnaryOperator *E);
+bool VisitConvertVectorExpr(const ConvertVectorExpr *E);
+bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E);
+
 // FIXME: Missing: conditional operator (for GNU
 // conditional select), shufflevector, ExtVectorElementExpr
   };
@@ -10895,6 +10899,138 @@ bool VectorExprEvaluator::VisitUnaryOperator(const 
UnaryOperator *E) {
   return Success(APValue(ResultElements.data(), ResultElements.size()), E);
 }
 
+static bool EvaluateVectorOrLValue(APValue &Result, EvalInfo &Info,
+   const Expr *E, const QualType &Type) {
+  if (!Evaluate(Result, Info, E))
+return false;
+
+  if (Result.isLValue()) {
+// Source of the data is an lvalue; Manually handle the lvalue as if
+// it was an rvalue to get the current APValue.
+LValue LValueFound;
+LValueFound.setFrom(Info.Ctx, Result);
+if (!handleLValueToRValueConversion(Info, E, Type, LValueFound, Result)) {
+  return false;
+}
+  }
+
+  if (!Result.isVector()) {
+return false;
+  }
+  return true;
+}
+
+static bool handleVectorConversion(EvalInfo &Info, const FPOptions FPO,
+   const Expr *E, QualType SourceTy,
+   QualType DestTy, APValue const &Original,
+   APValue &Result) {
+  if (SourceTy->isIntegerType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = APValue(APFloat(0.0));
+  return HandleInt

[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-04 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sard=C3=A0?= ,
Pol Marcet =?utf-8?q?Sard=C3=A0?= 
Message-ID:
In-Reply-To: 


Destroyerrrocket wrote:

(sorry about the typo!)

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


[llvm] [clang] [clang-tools-extra] [X86] Use plain load/store instead of cmpxchg16b for atomics with AVX (PR #74275)

2024-01-04 Thread Matt Arsenault via cfe-commits


@@ -30113,32 +30120,40 @@ TargetLoweringBase::AtomicExpansionKind
 X86TargetLowering::shouldExpandAtomicStoreInIR(StoreInst *SI) const {
   Type *MemType = SI->getValueOperand()->getType();
 
-  bool NoImplicitFloatOps =
-  SI->getFunction()->hasFnAttribute(Attribute::NoImplicitFloat);
-  if (MemType->getPrimitiveSizeInBits() == 64 && !Subtarget.is64Bit() &&
-  !Subtarget.useSoftFloat() && !NoImplicitFloatOps &&
-  (Subtarget.hasSSE1() || Subtarget.hasX87()))
-return AtomicExpansionKind::None;
+  if (!SI->getFunction()->hasFnAttribute(Attribute::NoImplicitFloat) &&
+  !Subtarget.useSoftFloat()) {
+if (MemType->getPrimitiveSizeInBits() == 64 && !Subtarget.is64Bit() &&
+(Subtarget.hasSSE1() || Subtarget.hasX87()))
+  return AtomicExpansionKind::None;
+
+if (MemType->getPrimitiveSizeInBits() == 128 && Subtarget.is64Bit() &&
+Subtarget.hasAVX())
+  return AtomicExpansionKind::None;
+  }
 
   return needsCmpXchgNb(MemType) ? AtomicExpansionKind::Expand
  : AtomicExpansionKind::None;
 }
 
 // Note: this turns large loads into lock cmpxchg8b/16b.
-// TODO: In 32-bit mode, use MOVLPS when SSE1 is available?
 TargetLowering::AtomicExpansionKind
 X86TargetLowering::shouldExpandAtomicLoadInIR(LoadInst *LI) const {
   Type *MemType = LI->getType();
 
-  // If this a 64 bit atomic load on a 32-bit target and SSE2 is enabled, we
-  // can use movq to do the load. If we have X87 we can load into an 80-bit
-  // X87 register and store it to a stack temporary.
-  bool NoImplicitFloatOps =
-  LI->getFunction()->hasFnAttribute(Attribute::NoImplicitFloat);
-  if (MemType->getPrimitiveSizeInBits() == 64 && !Subtarget.is64Bit() &&
-  !Subtarget.useSoftFloat() && !NoImplicitFloatOps &&
-  (Subtarget.hasSSE1() || Subtarget.hasX87()))
-return AtomicExpansionKind::None;
+  if (!LI->getFunction()->hasFnAttribute(Attribute::NoImplicitFloat) &&
+  !Subtarget.useSoftFloat()) {
+// If this a 64 bit atomic load on a 32-bit target and SSE2 is enabled, we
+// can use movq to do the load. If we have X87 we can load into an 80-bit
+// X87 register and store it to a stack temporary.
+if (MemType->getPrimitiveSizeInBits() == 64 && !Subtarget.is64Bit() &&

arsenm wrote:

getPrimitiveSizeInBits doesn't work correctly for pointer typed atomics; you 
need to use the DataLayout. Is there appropriate pointer typed atomic load test 
coverage for this?

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


[clang-tools-extra] [clangd] Dont require confirmation for include-cleaner batch-fixes (PR #76826)

2024-01-04 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet updated 
https://github.com/llvm/llvm-project/pull/76826

From 5e9a851584dcfd730fda7d85b54101ebea89f8a3 Mon Sep 17 00:00:00 2001
From: Kadir Cetinkaya 
Date: Wed, 3 Jan 2024 16:06:13 +0100
Subject: [PATCH 1/2] [clangd] Dont require confirmation for include-cleaner
 batch-fixes

False negative/positive rate has decreased to the degree that these
extra confirmations no longer provide any value, but only create
friction in the happy case.

When we have false analysis, people usually need to apply the fixes and
run the builds to discover the failure. At that point they can add
relevant IWYU pragmas to guide analysis, and will be more likely to
create bug reports due to extra annoyance :)
---
 clang-tools-extra/clangd/IncludeCleaner.cpp   | 27 +---
 .../test/include-cleaner-batch-fix.test   | 68 ---
 2 files changed, 1 insertion(+), 94 deletions(-)

diff --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 563a1f5d22f5b5..672140a6f2b4d8 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -237,18 +236,6 @@ removeAllUnusedIncludes(llvm::ArrayRef 
UnusedIncludes) {
Diag.Fixes.front().Edits.begin(),
Diag.Fixes.front().Edits.end());
   }
-
-  // TODO(hokein): emit a suitable text for the label.
-  ChangeAnnotation Annotation = {/*label=*/"",
- /*needsConfirmation=*/true,
- /*description=*/""};
-  static const ChangeAnnotationIdentifier RemoveAllUnusedID =
-  "RemoveAllUnusedIncludes";
-  for (unsigned I = 0; I < RemoveAll.Edits.size(); ++I) {
-ChangeAnnotationIdentifier ID = RemoveAllUnusedID + std::to_string(I);
-RemoveAll.Edits[I].annotationId = ID;
-RemoveAll.Annotations.push_back({ID, Annotation});
-  }
   return RemoveAll;
 }
 
@@ -268,20 +255,8 @@ addAllMissingIncludes(llvm::ArrayRef 
MissingIncludeDiags) {
   Edits.try_emplace(Edit.newText, Edit);
 }
   }
-  // FIXME(hokein): emit used symbol reference in the annotation.
-  ChangeAnnotation Annotation = {/*label=*/"",
- /*needsConfirmation=*/true,
- /*description=*/""};
-  static const ChangeAnnotationIdentifier AddAllMissingID =
-  "AddAllMissingIncludes";
-  unsigned I = 0;
-  for (auto &It : Edits) {
-ChangeAnnotationIdentifier ID = AddAllMissingID + std::to_string(I++);
+  for (auto &It : Edits)
 AddAllMissing.Edits.push_back(std::move(It.second));
-AddAllMissing.Edits.back().annotationId = ID;
-
-AddAllMissing.Annotations.push_back({ID, Annotation});
-  }
   return AddAllMissing;
 }
 Fix fixAll(const Fix &RemoveAllUnused, const Fix &AddAllMissing) {
diff --git a/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test 
b/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
index af7cdba5b05f43..07ebe1009a78f6 100644
--- a/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
+++ b/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
@@ -157,21 +157,10 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "arguments": [
 # CHECK-NEXT:{
-# CHECK-NEXT:  "changeAnnotations": {
-# CHECK-NEXT:"AddAllMissingIncludes0": {
-# CHECK-NEXT:  "label": "",
-# CHECK-NEXT:  "needsConfirmation": true
-# CHECK-NEXT:},
-# CHECK-NEXT:"AddAllMissingIncludes1": {
-# CHECK-NEXT:  "label": "",
-# CHECK-NEXT:  "needsConfirmation": true
-# CHECK-NEXT:}
-# CHECK-NEXT:  },
 # CHECK-NEXT:  "documentChanges": [
 # CHECK-NEXT:{
 # CHECK-NEXT:  "edits": [
 # CHECK-NEXT:{
-# CHECK-NEXT:  "annotationId": "AddAllMissingIncludes0",
 # CHECK-NEXT:  "newText": "#include {{.*}}bar.h{{.*}}",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
@@ -185,7 +174,6 @@
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
 # CHECK-NEXT:{
-# CHECK-NEXT:  "annotationId": "AddAllMissingIncludes1",
 # CHECK-NEXT:  "newText": "#include {{.*}}foo.h{{.*}}",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
@@ -213,29 +201,10 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "arguments": [
 # CHECK-NEXT:{
-# CHECK-NEXT:  "changeAnnotations": {
-# CHECK-NEXT:"AddAllMissingIncludes0": {
-# CHECK-NEXT:  "label": "",
-# CHECK-NEXT:  "needsConfirmation": true
-# CHECK-NEXT:},
-# CHECK-NEXT:"AddAllMissingIncludes1": {
-# CHECK-NEXT:  "label": "",
-# CHECK-NEXT:  "needsConfirmation": true
-# CHECK-NEXT:

[clang-tools-extra] [clangd] Dont require confirmation for include-cleaner batch-fixes (PR #76826)

2024-01-04 Thread kadir çetinkaya via cfe-commits


@@ -237,18 +236,6 @@ removeAllUnusedIncludes(llvm::ArrayRef 
UnusedIncludes) {
Diag.Fixes.front().Edits.begin(),
Diag.Fixes.front().Edits.end());
   }
-
-  // TODO(hokein): emit a suitable text for the label.
-  ChangeAnnotation Annotation = {/*label=*/"",

kadircet wrote:

thanks!

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


[flang] [llvm] [compiler-rt] [clang-tools-extra] [libc] [lldb] [clang] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-04 Thread Matt Arsenault via cfe-commits
Thorsten =?utf-8?q?Schütt?= ,
Thorsten =?utf-8?q?Schütt?= ,
Thorsten =?utf-8?q?Schütt?= 
Message-ID:
In-Reply-To: 



@@ -6548,6 +6534,54 @@ bool CombinerHelper::tryFoldBoolSelectToLogic(GSelect 
*Select,
   return false;
 }
 
+bool CombinerHelper::tryFoldSelectOfBinOps(GSelect *Select,
+   BuildFnTy &MatchInfo) {
+  Register DstReg = Select->getReg(0);
+  Register Cond = Select->getCondReg();
+  Register False = Select->getFalseReg();
+  Register True = Select->getTrueReg();
+  LLT DstTy = MRI.getType(DstReg);
+
+  GBinOp *LHS = getOpcodeDef(True, MRI);
+  GBinOp *RHS = getOpcodeDef(False, MRI);
+
+  // We need two binops of the same kind on the true/false registers.
+  if (!LHS || !RHS || LHS->getOpcode() != RHS->getOpcode())
+return false;
+
+  // Note that there are no constraints on CondTy.
+  unsigned Flags = (LHS->getFlags() & RHS->getFlags()) | Select->getFlags();

arsenm wrote:

I would have split this by matching the DAG behavior in the initial commit but 
doesn't really matter. I *think* this is OK but would be nice to have alive 
verify 

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


[flang] [llvm] [compiler-rt] [clang-tools-extra] [libc] [lldb] [clang] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-04 Thread Matt Arsenault via cfe-commits
Thorsten =?utf-8?q?Sch=C3=BCtt?= ,
Thorsten =?utf-8?q?Sch=C3=BCtt?= ,
Thorsten =?utf-8?q?Sch=C3=BCtt?= 
Message-ID:
In-Reply-To: 


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


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


[llvm] [clang] [RISCV] Deduplicate RISCVISAInfo::toFeatures/toFeatureVector. NFC (PR #76942)

2024-01-04 Thread Luke Lau via cfe-commits

https://github.com/lukel97 created 
https://github.com/llvm/llvm-project/pull/76942

toFeatures and toFeatureVector both output a list of target feature flags, just 
with a slightly different interface. toFeatures keeps any unsupported 
extensions, and also provides a way to append negative extensions 
(AddAllExtensions=true).

This patch combines them into one function, so that a later patch will be be 
able to get a std::vector of features that includes all the negative 
extensions, which was previously only possible through the StrAlloc interface.

>From caa25a73dd69268490c89d5e9e91b8d545bce760 Mon Sep 17 00:00:00 2001
From: Luke Lau 
Date: Thu, 4 Jan 2024 14:02:39 +0900
Subject: [PATCH] [RISCV] Deduplicate RISCVISAInfo::toFeatures/toFeatureVector.
 NFC

toFeatures and toFeatureVector both output a list of target feature flags, just
with a slightly different interface. toFeatures keeps any unsupported
extensions, and also provides a way to append negative extensions
(AddAllExtensions=true).

This patch combines them into one function, so that a later patch will be be
able to get a std::vector of features that includes all the negative
extensions, which was previously only possible through the StrAlloc interface.
---
 clang/lib/Basic/Targets/RISCV.cpp   |  6 ++--
 clang/lib/Driver/ToolChains/Arch/RISCV.cpp  |  6 ++--
 llvm/include/llvm/Support/RISCVISAInfo.h|  6 ++--
 llvm/lib/Object/ELFObjectFile.cpp   |  2 +-
 llvm/lib/Support/RISCVISAInfo.cpp   | 38 +++--
 llvm/unittests/Support/RISCVISAInfoTest.cpp | 30 +---
 6 files changed, 46 insertions(+), 42 deletions(-)

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 6bc57a83a2d5ae..64f5f9e9215dcb 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -245,7 +245,7 @@ collectNonISAExtFeature(ArrayRef 
FeaturesNeedOverride, int XLen) {
 return std::vector();
   }
 
-  std::vector ImpliedFeatures = (*ParseResult)->toFeatureVector();
+  std::vector ImpliedFeatures = (*ParseResult)->toFeatures();
 
   std::vector NonISAExtFeatureVec;
 
@@ -303,7 +303,7 @@ bool RISCVTargetInfo::initFeatureMap(
   }
 
   // RISCVISAInfo makes implications for ISA features
-  std::vector ImpliedFeatures = (*ParseResult)->toFeatureVector();
+  std::vector ImpliedFeatures = (*ParseResult)->toFeatures();
 
   // parseFeatures normalizes the feature set by dropping any explicit
   // negatives, and non-extension features.  We need to preserve the later
@@ -420,7 +420,7 @@ static void handleFullArchString(StringRef FullArchStr,
 // Forward the invalid FullArchStr.
 Features.push_back("+" + FullArchStr.str());
   } else {
-std::vector FeatStrings = (*RII)->toFeatureVector();
+std::vector FeatStrings = (*RII)->toFeatures();
 Features.insert(Features.end(), FeatStrings.begin(), FeatStrings.end());
   }
 }
diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 0717e3b813e1e2..b97224426b916a 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -42,9 +42,9 @@ static bool getArchFeatures(const Driver &D, StringRef Arch,
 return false;
   }
 
-  (*ISAInfo)->toFeatures(
-  Features, [&Args](const Twine &Str) { return Args.MakeArgString(Str); },
-  /*AddAllExtensions=*/true);
+  for (std::string &Str : (*ISAInfo)->toFeatures(/*AddAllExtension=*/true,
+ /*IgnoreUnknown=*/false))
+Features.push_back(Args.MakeArgString(Str));
 
   if (EnableExperimentalExtensions)
 Features.push_back(Args.MakeArgString("+experimental"));
diff --git a/llvm/include/llvm/Support/RISCVISAInfo.h 
b/llvm/include/llvm/Support/RISCVISAInfo.h
index 09c4edd6df60e9..c539448683d368 100644
--- a/llvm/include/llvm/Support/RISCVISAInfo.h
+++ b/llvm/include/llvm/Support/RISCVISAInfo.h
@@ -68,9 +68,8 @@ class RISCVISAInfo {
   parseFeatures(unsigned XLen, const std::vector &Features);
 
   /// Convert RISC-V ISA info to a feature vector.
-  void toFeatures(std::vector &Features,
-  llvm::function_ref StrAlloc,
-  bool AddAllExtensions) const;
+  std::vector toFeatures(bool AddAllExtensions = false,
+  bool IgnoreUnknown = true) const;
 
   const OrderedExtensionMap &getExtensions() const { return Exts; };
 
@@ -83,7 +82,6 @@ class RISCVISAInfo {
 
   bool hasExtension(StringRef Ext) const;
   std::string toString() const;
-  std::vector toFeatureVector() const;
   StringRef computeDefaultABI() const;
 
   static bool isSupportedExtensionFeature(StringRef Ext);
diff --git a/llvm/lib/Object/ELFObjectFile.cpp 
b/llvm/lib/Object/ELFObjectFile.cpp
index 95c4f9f8545db2..ae21b81c10c82a 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -315,7 +315,7 @@ Expected 
ELFObjectFileBase::getRISCVFeatures() const {
 

[llvm] [clang] [RISCV] Deduplicate RISCVISAInfo::toFeatures/toFeatureVector. NFC (PR #76942)

2024-01-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Luke Lau (lukel97)


Changes

toFeatures and toFeatureVector both output a list of target feature flags, just 
with a slightly different interface. toFeatures keeps any unsupported 
extensions, and also provides a way to append negative extensions 
(AddAllExtensions=true).

This patch combines them into one function, so that a later patch will be be 
able to get a std::vector of features that includes all the negative 
extensions, which was previously only possible through the StrAlloc interface.

---
Full diff: https://github.com/llvm/llvm-project/pull/76942.diff


6 Files Affected:

- (modified) clang/lib/Basic/Targets/RISCV.cpp (+3-3) 
- (modified) clang/lib/Driver/ToolChains/Arch/RISCV.cpp (+3-3) 
- (modified) llvm/include/llvm/Support/RISCVISAInfo.h (+2-4) 
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+1-1) 
- (modified) llvm/lib/Support/RISCVISAInfo.cpp (+12-26) 
- (modified) llvm/unittests/Support/RISCVISAInfoTest.cpp (+25-5) 


``diff
diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 6bc57a83a2d5ae..64f5f9e9215dcb 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -245,7 +245,7 @@ collectNonISAExtFeature(ArrayRef 
FeaturesNeedOverride, int XLen) {
 return std::vector();
   }
 
-  std::vector ImpliedFeatures = (*ParseResult)->toFeatureVector();
+  std::vector ImpliedFeatures = (*ParseResult)->toFeatures();
 
   std::vector NonISAExtFeatureVec;
 
@@ -303,7 +303,7 @@ bool RISCVTargetInfo::initFeatureMap(
   }
 
   // RISCVISAInfo makes implications for ISA features
-  std::vector ImpliedFeatures = (*ParseResult)->toFeatureVector();
+  std::vector ImpliedFeatures = (*ParseResult)->toFeatures();
 
   // parseFeatures normalizes the feature set by dropping any explicit
   // negatives, and non-extension features.  We need to preserve the later
@@ -420,7 +420,7 @@ static void handleFullArchString(StringRef FullArchStr,
 // Forward the invalid FullArchStr.
 Features.push_back("+" + FullArchStr.str());
   } else {
-std::vector FeatStrings = (*RII)->toFeatureVector();
+std::vector FeatStrings = (*RII)->toFeatures();
 Features.insert(Features.end(), FeatStrings.begin(), FeatStrings.end());
   }
 }
diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 0717e3b813e1e2..b97224426b916a 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -42,9 +42,9 @@ static bool getArchFeatures(const Driver &D, StringRef Arch,
 return false;
   }
 
-  (*ISAInfo)->toFeatures(
-  Features, [&Args](const Twine &Str) { return Args.MakeArgString(Str); },
-  /*AddAllExtensions=*/true);
+  for (std::string &Str : (*ISAInfo)->toFeatures(/*AddAllExtension=*/true,
+ /*IgnoreUnknown=*/false))
+Features.push_back(Args.MakeArgString(Str));
 
   if (EnableExperimentalExtensions)
 Features.push_back(Args.MakeArgString("+experimental"));
diff --git a/llvm/include/llvm/Support/RISCVISAInfo.h 
b/llvm/include/llvm/Support/RISCVISAInfo.h
index 09c4edd6df60e9..c539448683d368 100644
--- a/llvm/include/llvm/Support/RISCVISAInfo.h
+++ b/llvm/include/llvm/Support/RISCVISAInfo.h
@@ -68,9 +68,8 @@ class RISCVISAInfo {
   parseFeatures(unsigned XLen, const std::vector &Features);
 
   /// Convert RISC-V ISA info to a feature vector.
-  void toFeatures(std::vector &Features,
-  llvm::function_ref StrAlloc,
-  bool AddAllExtensions) const;
+  std::vector toFeatures(bool AddAllExtensions = false,
+  bool IgnoreUnknown = true) const;
 
   const OrderedExtensionMap &getExtensions() const { return Exts; };
 
@@ -83,7 +82,6 @@ class RISCVISAInfo {
 
   bool hasExtension(StringRef Ext) const;
   std::string toString() const;
-  std::vector toFeatureVector() const;
   StringRef computeDefaultABI() const;
 
   static bool isSupportedExtensionFeature(StringRef Ext);
diff --git a/llvm/lib/Object/ELFObjectFile.cpp 
b/llvm/lib/Object/ELFObjectFile.cpp
index 95c4f9f8545db2..ae21b81c10c82a 100644
--- a/llvm/lib/Object/ELFObjectFile.cpp
+++ b/llvm/lib/Object/ELFObjectFile.cpp
@@ -315,7 +315,7 @@ Expected 
ELFObjectFileBase::getRISCVFeatures() const {
 else
   llvm_unreachable("XLEN should be 32 or 64.");
 
-Features.addFeaturesVector(ISAInfo->toFeatureVector());
+Features.addFeaturesVector(ISAInfo->toFeatures());
   }
 
   return Features;
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index a9b7e209915a13..6d267fae5a5dc6 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -466,35 +466,37 @@ bool RISCVISAInfo::compareExtension(const std::string 
&LHS,
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(
-std::vector &Features,
-llvm::function_ref StrAlloc,
-bo

[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


Destroyerrrocket wrote:

Thank you! I truly appreciate the congrats! :D
@Endilll I don't have write access (I think? I'm new here :) ), I think one of 
you will have to make the merge (not used to github, at work I use bitbucket, I 
might be wrong, I'm basing this on "Only those with [write 
access](https://docs.github.com/articles/what-are-the-different-access-permissions)
 to this repository can merge pull requests.")

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


[llvm] [clang] [libcxx] "Reapply "[Sema] Fix crash on invalid code with parenthesized aggrega… (PR #76833)

2024-01-04 Thread Mark de Wever via cfe-commits

mordante wrote:

> > @ilya-biryukov this is the new attempt to land this patch, the version you 
> > committed breaks the libc++ CI. I'll try to fix it this week.
> 
> Wow, I didn't expect that. Is libc++ ok with disabling this test until the 
> nightly build catches up? (The PR is in the Draft state, so it's hard to tell 
> if that's acceptable).

It's not ideal, but I can't think of a better solution. Typically nightly apt 
builds are built nightly so then we can update the Docker CI quickly. If the 
nightly builds are red it might take a bit longer.

The patch is in draft since I wanted to test with the bootstrap build which 
required temporary disabling other builds (the second commit). When the CI is 
green I'll do a final review and publish the patch.

> In the long-term, how should people land changes like this? Compiler 
> diagnostics are expected to change sometimes, so we should figure out some 
> way that allows landing these without reverts. Any thoughts?

Typically we work together with whom changes the tests. When there are libc++ 
changes it is visible in our review queue. For changes in diagnostics it's 
often possible to use a regex matcher. For example, the messages of 
`static_asserts` changed a while back. In general we prefer to minimize the 
tests depending on the compiler diagnostics.



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


[clang] [clang] Optimize castToDeclContext for 2% improvement in build times (PR #76825)

2024-01-04 Thread Pol M via cfe-commits
Pol Marcet =?utf-8?q?Sardà?= ,
Pol Marcet =?utf-8?q?Sardà?= 
Message-ID:
In-Reply-To: 


https://github.com/Destroyerrrocket updated 
https://github.com/llvm/llvm-project/pull/76825

>From 1ab4538e194f9a77c500e4a93b1875eb7e76dcf5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pol=20Marcet=20Sard=C3=A0?= 
Date: Wed, 3 Jan 2024 16:00:42 +0100
Subject: [PATCH 1/3] [clang] Optimize castToDeclContext for 2% improvement in
 build times

---
 clang/include/clang/AST/DeclCXX.h |   8 ++
 clang/lib/AST/DeclBase.cpp|  50 +++-
 clang/utils/TableGen/ClangASTNodesEmitter.cpp | 107 +++---
 clang/utils/TableGen/TableGen.cpp |   3 +-
 clang/utils/TableGen/TableGenBackends.h   |   3 +-
 5 files changed, 97 insertions(+), 74 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 432293583576b5..984a4d8bab5e77 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2044,6 +2044,14 @@ class RequiresExprBodyDecl : public Decl, public 
DeclContext {
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == RequiresExprBody; }
+
+  static DeclContext *castToDeclContext(const RequiresExprBodyDecl *D) {
+return static_cast(const_cast(D));
+  }
+
+  static RequiresExprBodyDecl *castFromDeclContext(const DeclContext *DC) {
+return static_cast(const_cast(DC));
+  }
 };
 
 /// Represents a static or instance method of a struct/union/class.
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 5e03f0223d311c..b1733c2d052a65 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -930,20 +930,14 @@ const AttrVec &Decl::getAttrs() const {
 
 Decl *Decl::castFromDeclContext (const DeclContext *D) {
   Decl::Kind DK = D->getDeclKind();
-  switch(DK) {
-#define DECL(NAME, BASE)
-#define DECL_CONTEXT(NAME) \
-case Decl::NAME:   \
-  return static_cast(const_cast(D));
-#define DECL_CONTEXT_BASE(NAME)
-#include "clang/AST/DeclNodes.inc"
-default:
+  switch (DK) {
 #define DECL(NAME, BASE)
-#define DECL_CONTEXT_BASE(NAME)  \
-  if (DK >= first##NAME && DK <= last##NAME) \
-return static_cast(const_cast(D));
+#define DECL_CONTEXT(NAME) 
\
+  case Decl::NAME: 
\
+return static_cast(const_cast(D));
 #include "clang/AST/DeclNodes.inc"
-  llvm_unreachable("a decl that inherits DeclContext isn't handled");
+  default:
+llvm_unreachable("a decl that inherits DeclContext isn't handled");
   }
 }
 
@@ -951,18 +945,12 @@ DeclContext *Decl::castToDeclContext(const Decl *D) {
   Decl::Kind DK = D->getKind();
   switch(DK) {
 #define DECL(NAME, BASE)
-#define DECL_CONTEXT(NAME) \
-case Decl::NAME:   \
-  return static_cast(const_cast(D));
-#define DECL_CONTEXT_BASE(NAME)
+#define DECL_CONTEXT(NAME) 
\
+  case Decl::NAME: 
\
+return static_cast(const_cast(D));
 #include "clang/AST/DeclNodes.inc"
-default:
-#define DECL(NAME, BASE)
-#define DECL_CONTEXT_BASE(NAME)   \
-  if (DK >= first##NAME && DK <= last##NAME)  \
-return static_cast(const_cast(D));
-#include "clang/AST/DeclNodes.inc"
-  llvm_unreachable("a decl that inherits DeclContext isn't handled");
+  default:
+llvm_unreachable("a decl that inherits DeclContext isn't handled");
   }
 }
 
@@ -1129,20 +1117,14 @@ DeclContext::DeclContext(Decl::Kind K) {
 }
 
 bool DeclContext::classof(const Decl *D) {
-  switch (D->getKind()) {
+  Decl::Kind DK = D->getKind();
+  switch (DK) {
 #define DECL(NAME, BASE)
 #define DECL_CONTEXT(NAME) case Decl::NAME:
-#define DECL_CONTEXT_BASE(NAME)
 #include "clang/AST/DeclNodes.inc"
-  return true;
-default:
-#define DECL(NAME, BASE)
-#define DECL_CONTEXT_BASE(NAME) \
-  if (D->getKind() >= Decl::first##NAME &&  \
-  D->getKind() <= Decl::last##NAME) \
-return true;
-#include "clang/AST/DeclNodes.inc"
-  return false;
+return true;
+  default:
+return false;
   }
 }
 
diff --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp 
b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 16a1c74b9d91ad..63220aad50aecd 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -33,6 +33,7 @@ class ClangASTNodesEmitter {
   typedef std::multimap ChildMap;
   typedef ChildMap::const_iterator ChildIterator;
 
+  std::set PrioritizedClasses;
   RecordKeeper &Records;
   ASTNode Root;
   const std::string &NodeClassName;
@@ -70,8 +71,15 @@ class ClangASTNodesEmitter {
   std::pair EmitNode(raw_ostream& OS, ASTNode Base);
 

[clang-tools-extra] [clangd] Dont require confirmation for include-cleaner batch-fixes (PR #76826)

2024-01-04 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

> This change makes sense for removing all unused includes (as all these unused 
> includes are visible in the editor). For missing includes, they are less 
> obvious, but it is probably fine.

The rationale for missing includes was the same, when things go wrong it's 
usually obscure enough that problems only raise with build systems that have 
visibility restrictions. Hence I am not sure if this extra step provides enough 
value.

> (I think it would be great to have a way to view all missing includes, VSCode 
> has a feature to preview code action changes, but it seems 
> [broken](https://github.com/clangd/vscode-clangd/issues/376) with clangd.)

Agreed, making alt+enter work in these cases would be useful, and last time I 
checked it is actually working. I tried with this patch, and it still gives 
people a way to preview and selectively apply these edits. So we're actually 
not taking away the functionality completely, but rather putting this behind an 
extra shortcut :)

Can you check if it's still broken for you ?
https://github.com/llvm/llvm-project/assets/897555/afe76b42-1ed4-4612-9d83-5499baf90119";>


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


[clang-tools-extra] [clangd] Dont require confirmation for include-cleaner batch-fixes (PR #76826)

2024-01-04 Thread kadir çetinkaya via cfe-commits

kadircet wrote:

oh sorry, this should ofc work with include-cleaner fixes, as we actually 
provide these as edits, instead of commands, as we do with our usual tweaks.

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


[clang-tools-extra] 2336f79 - [clangd] Dont require confirmation for include-cleaner batch-fixes (#76826)

2024-01-04 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2024-01-04T12:57:42+01:00
New Revision: 2336f792bc5a1d9195c1bd995b6040c13e73d4e7

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

LOG: [clangd] Dont require confirmation for include-cleaner batch-fixes (#76826)

False negative/positive rate has decreased to the degree that these
extra confirmations no longer provide any value, but only create
friction in the happy case.

When we have false analysis, people usually need to apply the fixes and
run the builds to discover the failure. At that point they can add
relevant IWYU pragmas to guide analysis, and will be more likely to
create bug reports due to extra annoyance :)

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/test/include-cleaner-batch-fix.test

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 563a1f5d22f5b5..f86a121340f7fb 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -237,18 +236,6 @@ removeAllUnusedIncludes(llvm::ArrayRef 
UnusedIncludes) {
Diag.Fixes.front().Edits.begin(),
Diag.Fixes.front().Edits.end());
   }
-
-  // TODO(hokein): emit a suitable text for the label.
-  ChangeAnnotation Annotation = {/*label=*/"",
- /*needsConfirmation=*/true,
- /*description=*/""};
-  static const ChangeAnnotationIdentifier RemoveAllUnusedID =
-  "RemoveAllUnusedIncludes";
-  for (unsigned I = 0; I < RemoveAll.Edits.size(); ++I) {
-ChangeAnnotationIdentifier ID = RemoveAllUnusedID + std::to_string(I);
-RemoveAll.Edits[I].annotationId = ID;
-RemoveAll.Annotations.push_back({ID, Annotation});
-  }
   return RemoveAll;
 }
 
@@ -268,20 +255,8 @@ addAllMissingIncludes(llvm::ArrayRef 
MissingIncludeDiags) {
   Edits.try_emplace(Edit.newText, Edit);
 }
   }
-  // FIXME(hokein): emit used symbol reference in the annotation.
-  ChangeAnnotation Annotation = {/*label=*/"",
- /*needsConfirmation=*/true,
- /*description=*/""};
-  static const ChangeAnnotationIdentifier AddAllMissingID =
-  "AddAllMissingIncludes";
-  unsigned I = 0;
-  for (auto &It : Edits) {
-ChangeAnnotationIdentifier ID = AddAllMissingID + std::to_string(I++);
+  for (auto &It : Edits)
 AddAllMissing.Edits.push_back(std::move(It.second));
-AddAllMissing.Edits.back().annotationId = ID;
-
-AddAllMissing.Annotations.push_back({ID, Annotation});
-  }
   return AddAllMissing;
 }
 Fix fixAll(const Fix &RemoveAllUnused, const Fix &AddAllMissing) {
@@ -292,11 +267,6 @@ Fix fixAll(const Fix &RemoveAllUnused, const Fix 
&AddAllMissing) {
 FixAll.Edits.push_back(F);
   for (const auto &F : AddAllMissing.Edits)
 FixAll.Edits.push_back(F);
-
-  for (const auto &A : RemoveAllUnused.Annotations)
-FixAll.Annotations.push_back(A);
-  for (const auto &A : AddAllMissing.Annotations)
-FixAll.Annotations.push_back(A);
   return FixAll;
 }
 

diff  --git a/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test 
b/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
index af7cdba5b05f43..07ebe1009a78f6 100644
--- a/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
+++ b/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
@@ -157,21 +157,10 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "arguments": [
 # CHECK-NEXT:{
-# CHECK-NEXT:  "changeAnnotations": {
-# CHECK-NEXT:"AddAllMissingIncludes0": {
-# CHECK-NEXT:  "label": "",
-# CHECK-NEXT:  "needsConfirmation": true
-# CHECK-NEXT:},
-# CHECK-NEXT:"AddAllMissingIncludes1": {
-# CHECK-NEXT:  "label": "",
-# CHECK-NEXT:  "needsConfirmation": true
-# CHECK-NEXT:}
-# CHECK-NEXT:  },
 # CHECK-NEXT:  "documentChanges": [
 # CHECK-NEXT:{
 # CHECK-NEXT:  "edits": [
 # CHECK-NEXT:{
-# CHECK-NEXT:  "annotationId": "AddAllMissingIncludes0",
 # CHECK-NEXT:  "newText": "#include {{.*}}bar.h{{.*}}",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
@@ -185,7 +174,6 @@
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
 # CHECK-NEXT:{
-# CHECK-NEXT:  "annotationId": "AddAllMissingIncludes1",
 # CHECK-NEXT:  "newText": "#include {{.*}}foo.h{{.*}}",
 # CHECK-NEXT:  "range": {
 # C

[clang-tools-extra] [clangd] Dont require confirmation for include-cleaner batch-fixes (PR #76826)

2024-01-04 Thread kadir çetinkaya via cfe-commits

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


[clang] [OpenMP] Patch for Support to loop bind clause : Checking Parent Region (PR #76938)

2024-01-04 Thread Alexey Bataev via cfe-commits


@@ -5072,6 +5072,18 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 CurrentRegion != OMPD_cancellation_point &&
 CurrentRegion != OMPD_cancel && CurrentRegion != OMPD_scan)
   return false;
+// Checks needed for mapping "loop" construct. Please check 
mapLoopConstruct
+// for a detailed explanation
+if (SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion == OMPD_loop &&
+((BindKind == OMPC_BIND_parallel) || (BindKind == OMPC_BIND_teams)) &&

alexey-bataev wrote:

Drop extra parens

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


[clang] [OpenMP] Patch for Support to loop bind clause : Checking Parent Region (PR #76938)

2024-01-04 Thread Alexey Bataev via cfe-commits


@@ -11335,6 +11335,7 @@ class Sema final {
   /// on the parameter of the bind clause. In the methods for the
   /// mapped directives, check the parameters of the lastprivate clause.
   bool checkLastPrivateForMappedDirectives(ArrayRef Clauses);
+

alexey-bataev wrote:

Unrelated change, drop it, make it in a separate NFC patch

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


[clang] [OpenMP] Patch for Support to loop bind clause : Checking Parent Region (PR #76938)

2024-01-04 Thread Alexey Bataev via cfe-commits


@@ -6213,26 +6226,35 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
 OpenMPDirectiveKind PrevMappedDirective) {
   StmtResult Res = StmtError();
   OpenMPBindClauseKind BindKind = OMPC_BIND_unknown;
+  llvm::SmallVector ClausesWithoutBind;
+  bool UseClausesWithoutBind = false;
+
   if (const OMPBindClause *BC =
   OMPExecutableDirective::getSingleClause(Clauses))
 BindKind = BC->getBindKind();
+
+  // Variable used to note down the DirectiveKind because mapLoopConstruct may
+  // change "Kind" variable, due to mapping of "omp loop" to other directives.
+  OpenMPDirectiveKind DK = Kind;
+  if ((Kind == OMPD_loop) || (PrevMappedDirective == OMPD_loop)) {

alexey-bataev wrote:

Extra parens

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


[clang] [X86] Emit Warnings for frontend options to enable knl/knm. (PR #75580)

2024-01-04 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

> @RKSimon @phoebewang Thanks comments! knm has AVX512_VPOPCNTDQ, I guess we 
> also require it work without avx512vl? And we are going to keep 
> -march/mtune/mcpu support for knl/knm, but removing some specific ISA's 
> intrinsic and lowering supports? Did I get your point wrong?

That's correct - we keep -march/mtune/mcpu support for knl/knm but reduce its 
feature set to avx512f/avx512cd and we don't provide any support for xeon-phi 
specific features (avx512pf etc.) apart from the minimal binutils/assembly 
handling necessary.

If we keep support for VPOPCNTDQ on knm then yes we will need to allow non-VLX 
handling, but I don't know much about general availability of knm workstations 
(knl cpus/machines do turn up on ebay etc. quite frequently).



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


[lldb] [libc] [clang] [llvm] [mlir] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-04 Thread Bill Wendling via cfe-commits

https://github.com/bwendling updated 
https://github.com/llvm/llvm-project/pull/76882

>From ca7a96a40952fe94b916dacc52f07aa90bbdb1e7 Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Wed, 3 Jan 2024 13:22:37 -0800
Subject: [PATCH 1/6] [builtin_object_size] Use classes instead of std::pair
 (NFC)

The use of std::pair makes the values it holds opaque. Using classes
improves this while keeping the POD aspect of a std::pair. As a nice
addition, the "known" functions held inappropriately in the Visitor
classes can now properly reside in the value classes. :-)
---
 llvm/include/llvm/Analysis/MemoryBuiltins.h   | 192 +++
 llvm/lib/Analysis/MemoryBuiltins.cpp  | 314 +-
 .../Transforms/IPO/AttributorAttributes.cpp   |   8 +-
 .../Instrumentation/AddressSanitizer.cpp  |  12 +-
 .../Instrumentation/BoundsChecking.cpp|   8 +-
 5 files changed, 299 insertions(+), 235 deletions(-)

diff --git a/llvm/include/llvm/Analysis/MemoryBuiltins.h 
b/llvm/include/llvm/Analysis/MemoryBuiltins.h
index 827b5081b2ce75..56faa32fb0b226 100644
--- a/llvm/include/llvm/Analysis/MemoryBuiltins.h
+++ b/llvm/include/llvm/Analysis/MemoryBuiltins.h
@@ -187,80 +187,146 @@ Value *lowerObjectSizeCall(
 const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed,
 SmallVectorImpl *InsertedInstructions = nullptr);
 
-using SizeOffsetType = std::pair;
+/// SizeOffsetType - A base template class for the object size visitors. Used
+/// here as a self-documenting way to handle the values rather than using a
+/// \p std::pair.
+template  struct SizeOffsetType {
+  T Size;
+  T Offset;
+
+  bool knownSize() const;
+  bool knownOffset() const;
+  bool anyKnown() const;
+  bool bothKnown() const;
+};
+
+/// SizeOffsetType - Used by \p ObjectSizeOffsetVisitor, which works
+/// with \p APInts.
+template <> struct SizeOffsetType {
+  APInt Size;
+  APInt Offset;
+
+  SizeOffsetType() = default;
+  SizeOffsetType(APInt Size, APInt Offset) : Size(Size), Offset(Offset) {}
+
+  bool knownSize() const { return Size.getBitWidth() > 1; }
+  bool knownOffset() const { return Offset.getBitWidth() > 1; }
+  bool anyKnown() const { return knownSize() || knownOffset(); }
+  bool bothKnown() const { return knownSize() && knownOffset(); }
+
+  bool operator==(const SizeOffsetType &RHS) {
+return Size == RHS.Size && Offset == RHS.Offset;
+  }
+  bool operator!=(const SizeOffsetType &RHS) { return !(*this == RHS); }
+};
+using SizeOffsetAPInt = SizeOffsetType;
 
 /// Evaluate the size and offset of an object pointed to by a Value*
 /// statically. Fails if size or offset are not known at compile time.
 class ObjectSizeOffsetVisitor
-  : public InstVisitor {
+: public InstVisitor {
   const DataLayout &DL;
   const TargetLibraryInfo *TLI;
   ObjectSizeOpts Options;
   unsigned IntTyBits;
   APInt Zero;
-  SmallDenseMap SeenInsts;
+  SmallDenseMap SeenInsts;
   unsigned InstructionsVisited;
 
   APInt align(APInt Size, MaybeAlign Align);
 
-  SizeOffsetType unknown() {
-return std::make_pair(APInt(), APInt());
-  }
+  static SizeOffsetAPInt unknown;
 
 public:
   ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI,
   LLVMContext &Context, ObjectSizeOpts Options = {});
 
-  SizeOffsetType compute(Value *V);
-
-  static bool knownSize(const SizeOffsetType &SizeOffset) {
-return SizeOffset.first.getBitWidth() > 1;
-  }
-
-  static bool knownOffset(const SizeOffsetType &SizeOffset) {
-return SizeOffset.second.getBitWidth() > 1;
-  }
-
-  static bool bothKnown(const SizeOffsetType &SizeOffset) {
-return knownSize(SizeOffset) && knownOffset(SizeOffset);
-  }
+  SizeOffsetAPInt compute(Value *V);
 
   // These are "private", except they can't actually be made private. Only
   // compute() should be used by external users.
-  SizeOffsetType visitAllocaInst(AllocaInst &I);
-  SizeOffsetType visitArgument(Argument &A);
-  SizeOffsetType visitCallBase(CallBase &CB);
-  SizeOffsetType visitConstantPointerNull(ConstantPointerNull&);
-  SizeOffsetType visitExtractElementInst(ExtractElementInst &I);
-  SizeOffsetType visitExtractValueInst(ExtractValueInst &I);
-  SizeOffsetType visitGlobalAlias(GlobalAlias &GA);
-  SizeOffsetType visitGlobalVariable(GlobalVariable &GV);
-  SizeOffsetType visitIntToPtrInst(IntToPtrInst&);
-  SizeOffsetType visitLoadInst(LoadInst &I);
-  SizeOffsetType visitPHINode(PHINode&);
-  SizeOffsetType visitSelectInst(SelectInst &I);
-  SizeOffsetType visitUndefValue(UndefValue&);
-  SizeOffsetType visitInstruction(Instruction &I);
+  SizeOffsetAPInt visitAllocaInst(AllocaInst &I);
+  SizeOffsetAPInt visitArgument(Argument &A);
+  SizeOffsetAPInt visitCallBase(CallBase &CB);
+  SizeOffsetAPInt visitConstantPointerNull(ConstantPointerNull &);
+  SizeOffsetAPInt visitExtractElementInst(ExtractElementInst &I);
+  SizeOffsetAPInt visitExtractValueInst(ExtractValueInst &I);
+  SizeOffsetAPInt visitGlobalAlias(GlobalAlias &GA);
+  SizeOffsetAPInt

[clang] [Cygwin] Cygwin basic support (PR #76943)

2024-01-04 Thread 徐持恒 Xu Chiheng via cfe-commits

https://github.com/xu-chiheng created 
https://github.com/llvm/llvm-project/pull/76943

Enable TLS, and set VaListKind to CharPtrBuiltinVaList.
This fix bootstrap failure on Cygwin.

From 35cb22083fc0f842e873c99518a58d673bbcb1ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 00:59:00 +0800
Subject: [PATCH 1/3] [Cygwin] Cygwin basic support

---
 clang/lib/Basic/Targets/X86.h | 5 -
 clang/lib/Driver/ToolChains/Clang.cpp | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 0ab1c10833db26..e77e1e690cfc0c 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -905,7 +905,6 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : 
public X86_64TargetInfo {
   CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : X86_64TargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedShort;
-TLSSupported = false;
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -919,6 +918,10 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : 
public X86_64TargetInfo {
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
   }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::CharPtrBuiltinVaList;
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY DarwinX86_64TargetInfo
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index acfa119805068d..38b9b84cf37c5b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6729,7 +6729,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
+  !RawTriple.isOSAIX()
+  && !RawTriple.isWindowsGNUEnvironment()
+  && !RawTriple.isWindowsMSVCEnvironment() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 99199c9364be0d8cd83a65ea5425715a82e2a40f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 01:08:20 +0800
Subject: [PATCH 2/3] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 38b9b84cf37c5b..58b042266c6091 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6729,9 +6729,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX()
-  && !RawTriple.isWindowsGNUEnvironment()
-  && !RawTriple.isWindowsMSVCEnvironment() &&
+  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
+  !RawTriple.isWindowsMSVCEnvironment() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

From 856ecf178a2487f7449bd291f6ce78b13f07fd24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 
Date: Sat, 9 Dec 2023 12:37:05 +0800
Subject: [PATCH 3/3] 1

---
 clang/lib/Driver/ToolChains/Clang.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 58b042266c6091..acfa119805068d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6729,8 +6729,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // -fuse-cxa-atexit is default.
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
-  !RawTriple.isOSAIX() && !RawTriple.isWindowsGNUEnvironment() &&
-  !RawTriple.isWindowsMSVCEnvironment() &&
+  !RawTriple.isOSAIX() && !RawTriple.isOSWindows() &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
   KernelOrKext)

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


[clang] [Cygwin] Cygwin basic support (PR #76943)

2024-01-04 Thread via cfe-commits
=?utf-8?b?5b6Q5oyB5oGS?= Xu Chiheng,=?utf-8?b?5b6Q5oyB5oGS?= Xu Chiheng
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [Cygwin] Cygwin basic support (PR #76943)

2024-01-04 Thread via cfe-commits
=?utf-8?b?5b6Q5oyB5oGS?= Xu Chiheng,=?utf-8?b?5b6Q5oyB5oGS?= Xu Chiheng
Message-ID:
In-Reply-To: 


llvmbot wrote:




@llvm/pr-subscribers-clang

Author: 徐持恒 Xu Chiheng (xu-chiheng)


Changes

Enable TLS, and set VaListKind to CharPtrBuiltinVaList.
This fix bootstrap failure on Cygwin.

---
Full diff: https://github.com/llvm/llvm-project/pull/76943.diff


1 Files Affected:

- (modified) clang/lib/Basic/Targets/X86.h (+4-1) 


``diff
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 0ab1c10833db26..e77e1e690cfc0c 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -905,7 +905,6 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : 
public X86_64TargetInfo {
   CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : X86_64TargetInfo(Triple, Opts) {
 this->WCharType = TargetInfo::UnsignedShort;
-TLSSupported = false;
   }
 
   void getTargetDefines(const LangOptions &Opts,
@@ -919,6 +918,10 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : 
public X86_64TargetInfo {
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
   }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::CharPtrBuiltinVaList;
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY DarwinX86_64TargetInfo

``




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


[clang] [Clang] Correctly construct template arguments for file-scope template template parameters (PR #76811)

2024-01-04 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

It is interesting to note that, if we exchange the position of two template 
parameters, i.e.

```cpp
template 
concept C = false;

template  struct S {};

template  typename T, unsigned N> // The 
template-template parameter now precedes the NTTP
int wow(T ts);

int main() { return wow(S{}); }
```

then the crash disappears.

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


[clang] 71b3ead - [clang][dataflow] Remove a redundant trailing semicolon. NFC.

2024-01-04 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2024-01-04T15:01:17+02:00
New Revision: 71b3ead870107e39e998f6480e545eb01d9d28be

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

LOG: [clang][dataflow] Remove a redundant trailing semicolon. NFC.

This silences the following warning with GCC:


llvm-project/llvm/tools/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:89:4:
 warning: extra ‘;’ [-Wpedantic]
   89 |   };
  |^
  |-

Added: 


Modified: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git 
a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
index 8d481788af208a..fe5ba5ab5426f7 100644
--- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -86,7 +86,7 @@ class DataflowAnalysisTest : public Test {
 const std::optional &MaybeState = BlockStates[Block->getBlockID()];
 assert(MaybeState.has_value());
 return *MaybeState;
-  };
+  }
 
   std::unique_ptr AST;
   std::unique_ptr CFCtx;



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


[clang] [X86] Emit Warnings for frontend options to enable knl/knm. (PR #75580)

2024-01-04 Thread Freddy Ye via cfe-commits

https://github.com/FreddyLeaf updated 
https://github.com/llvm/llvm-project/pull/75580

>From e16afbdc9f0c04bad0e8f80f90c0eb26c13d3326 Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Fri, 15 Dec 2023 16:50:23 +0800
Subject: [PATCH 1/6] [X86] Emit Warnings for frontend options to enable
 knl/knm.

Since Knight Landing and Knight Mill microarchitectures are EOL, we
would like to remove its support in LLVM 19. In LLVM 18, we will first
emit a warning for the usage.
---
 clang/include/clang/Basic/DiagnosticCommonKinds.td |  2 ++
 clang/lib/Basic/Targets/X86.cpp|  3 +++
 clang/test/CodeGen/X86/avx512er-builtins.c |  2 +-
 clang/test/CodeGen/X86/avx512pf-builtins.c |  2 +-
 clang/test/Driver/cl-x86-flags.c   | 10 --
 clang/test/Frontend/x86-target-cpu.c   | 10 --
 clang/test/Misc/warning-flags.c|  3 ++-
 7 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 65a33f61a6948a..40841e9df547bc 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -349,6 +349,8 @@ def warn_invalid_feature_combination : Warning<
 def warn_target_unrecognized_env : Warning<
   "mismatch between architecture and environment in target triple '%0'; did 
you mean '%1'?">,
   InGroup;
+def warn_knl_knm_target_supports_remove : Warning<
+  "KNL/KNM's feature support will be removed in LLVM 19.">;
 
 // Source manager
 def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index b97f88647fa49f..dc56524d378104 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -295,11 +295,13 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasAVX512BF16 = true;
 } else if (Feature == "+avx512er") {
   HasAVX512ER = true;
+  Diags.Report(diag::warn_knl_knm_target_supports_remove);
 } else if (Feature == "+avx512fp16") {
   HasAVX512FP16 = true;
   HasLegalHalfType = true;
 } else if (Feature == "+avx512pf") {
   HasAVX512PF = true;
+  Diags.Report(diag::warn_knl_knm_target_supports_remove);
 } else if (Feature == "+avx512dq") {
   HasAVX512DQ = true;
 } else if (Feature == "+avx512bitalg") {
@@ -358,6 +360,7 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasPREFETCHI = true;
 } else if (Feature == "+prefetchwt1") {
   HasPREFETCHWT1 = true;
+  Diags.Report(diag::warn_knl_knm_target_supports_remove);
 } else if (Feature == "+clzero") {
   HasCLZERO = true;
 } else if (Feature == "+cldemote") {
diff --git a/clang/test/CodeGen/X86/avx512er-builtins.c 
b/clang/test/CodeGen/X86/avx512er-builtins.c
index ee31236a3c01aa..11ec6aabec1e3f 100644
--- a/clang/test/CodeGen/X86/avx512er-builtins.c
+++ b/clang/test/CodeGen/X86/avx512er-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512f -target-feature +avx512er 
-emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512f -target-feature +avx512er 
-emit-llvm -o - -Wall | FileCheck %s
 
 
 #include 
diff --git a/clang/test/CodeGen/X86/avx512pf-builtins.c 
b/clang/test/CodeGen/X86/avx512pf-builtins.c
index 4ca70f5787968b..3a117ed6a9460e 100644
--- a/clang/test/CodeGen/X86/avx512pf-builtins.c
+++ b/clang/test/CodeGen/X86/avx512pf-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512pf -emit-llvm -o - -Wall 
-Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512pf -emit-llvm -o - -Wall | 
FileCheck %s
 
 
 #include 
diff --git a/clang/test/Driver/cl-x86-flags.c b/clang/test/Driver/cl-x86-flags.c
index 51b16f0ce35463..ae35a312fe8a4b 100644
--- a/clang/test/Driver/cl-x86-flags.c
+++ b/clang/test/Driver/cl-x86-flags.c
@@ -69,7 +69,10 @@
 // RUN: %clang_cl -m32 -arch:avx2 --target=i386-pc-windows -### -- 2>&1 %s | 
FileCheck -check-prefix=avx2 %s
 // avx2: invalid /arch: argument
 
-// RUN: %clang_cl -m32 -arch:AVX512F --target=i386-pc-windows /c /Fo%t.obj 
-Xclang -verify -DTEST_32_ARCH_AVX512F -- %s
+// RUN: %clang_cl -m32 -arch:AVX512F --target=i386-pc-windows /c /Fo%t.obj 
-Xclang -verify=KNL1 -DTEST_32_ARCH_AVX512F -- %s
+// KNL1-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// KNL1-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
+// KNL1-warning@*:* {{KNL/KNM's feature support will be removed in LLVM 19.}}
 #if defined(TEST_32_ARCH_AVX512F)
 #if _M_IX86_FP !=

  1   2   3   4   5   6   >