[clang-tools-extra] [clang-tidy] Add support for lambdas in cppcoreguidelines-owning-memory (PR #77246)

2024-01-22 Thread Piotr Zegar via cfe-commits


@@ -147,10 +161,52 @@ void OwningMemoryCheck::registerMatchers(MatchFinder 
*Finder) {
   // Matching on functions, that return an owner/resource, but don't declare
   // their return type as owner.
   Finder->addMatcher(
-  functionDecl(hasDescendant(returnStmt(hasReturnValue(ConsideredOwner))
- .bind("bad_owner_return")),
-   unless(returns(qualType(hasDeclaration(OwnerDecl)
-  .bind("function_decl"),
+  functionDecl(
+  decl().bind("function_decl"),
+  hasBody(stmt(
+  stmt().bind("body"),
+  hasDescendant(
+  returnStmt(hasReturnValue(ConsideredOwner),
+ // Ignore sub-lambda expressions
+ hasAncestor(stmt(anyOf(equalsBoundNode("body"),

PiotrZSL wrote:

there is hasAncestor body or lambda. Simply it will match an first one that it 
finds, and that we bind to 'scope'.
In next lines we simply check if body and scope is same, if not then we in 
lambda.

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


[clang] [libclang/python] Expose Rewriter to the python binding (PR #77269)

2024-01-22 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

@linux4life798 Do you mind filing issues for the points you highlighted? Feel 
free to skip this step if you (or someone else) plan to submit PRs that address 
them.

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


[llvm] [clang] [RISCV][MC] Add experimental support of Zaamo and Zalrsc (PR #78970)

2024-01-22 Thread Wang Pengcheng via cfe-commits

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


[clang] [llvm] [RISCV][MC] Add experimental support of Zaamo and Zalrsc (PR #78970)

2024-01-22 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/78970

>From 8cc71cb7ddb2e6691d31138ae2ef683a0690e171 Mon Sep 17 00:00:00 2001
From: wangpc 
Date: Mon, 22 Jan 2024 21:11:42 +0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/lib/Basic/Targets/RISCV.cpp |   2 +-
 .../test/Preprocessor/riscv-target-features.c |  18 ++
 llvm/docs/RISCVUsage.rst  |   2 +
 llvm/lib/Support/RISCVISAInfo.cpp |   2 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|  26 ++-
 llvm/test/CodeGen/RISCV/attributes.ll |   8 +
 llvm/test/MC/RISCV/rv32i-invalid.s|   2 +-
 llvm/test/MC/RISCV/rv32zaamo-invalid.s|  11 ++
 llvm/test/MC/RISCV/rv32zaamo-valid.s  | 122 ++
 llvm/test/MC/RISCV/rv32zalrsc-invalid.s   |   7 +
 llvm/test/MC/RISCV/rv32zalrsc-valid.s |  36 
 llvm/test/MC/RISCV/rv64zaamo-invalid.s|  11 ++
 llvm/test/MC/RISCV/rv64zaamo-valid.s  | 157 ++
 llvm/test/MC/RISCV/rv64zalrsc-invalid.s   |   7 +
 llvm/test/MC/RISCV/rv64zalrsc-valid.s |  42 +
 llvm/unittests/Support/RISCVISAInfoTest.cpp   |   2 +
 16 files changed, 452 insertions(+), 3 deletions(-)
 create mode 100644 llvm/test/MC/RISCV/rv32zaamo-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv32zaamo-valid.s
 create mode 100644 llvm/test/MC/RISCV/rv32zalrsc-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv32zalrsc-valid.s
 create mode 100644 llvm/test/MC/RISCV/rv64zaamo-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv64zaamo-valid.s
 create mode 100644 llvm/test/MC/RISCV/rv64zalrsc-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv64zalrsc-valid.s

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index c71b2e9eeb6c172..9af9bdd1d74e9dd 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -175,7 +175,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
,
 Builder.defineMacro("__riscv_muldiv");
   }
 
-  if (ISAInfo->hasExtension("a")) {
+  if (ISAInfo->hasExtension("a") || ISAInfo->hasExtension("zaamo")) {
 Builder.defineMacro("__riscv_atomic");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 5fde5ccdbeacfb0..38473d07004a574 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -141,7 +141,9 @@
 
 // Experimental extensions
 
+// CHECK-NOT: __riscv_zaamo {{.*$}}
 // CHECK-NOT: __riscv_zacas {{.*$}}
+// CHECK-NOT: __riscv_zalrsc {{.*$}}
 // CHECK-NOT: __riscv_zcmop {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
@@ -1307,6 +1309,14 @@
 // CHECK-ZVKT-EXT: __riscv_zvkt 100{{$}}
 
 // Experimental extensions
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zaamo0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64i_zaamo0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZAAMO-EXT %s
+// CHECK-ZAAMO-EXT: __riscv_atomic 1
+// CHECK-ZAAMO-EXT: __riscv_zaamo 1000{{$}}
 
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32i_zacas1p0 -x c -E -dM %s \
@@ -1316,6 +1326,14 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZACAS-EXT %s
 // CHECK-ZACAS-EXT: __riscv_zacas 100{{$}}
 
+// RUN: %clang --target=riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zalrsc0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
+// RUN: %clang --target=riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64i_zalrsc0p1 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZALRSC-EXT %s
+// CHECK-ZALRSC-EXT: __riscv_zalrsc 1000{{$}}
+
 // RUN: %clang --target=riscv32 -menable-experimental-extensions \
 // RUN: -march=rv32izfbfmin1p0 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZFBFMIN-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 6fdc945ad27078e..005e9f1d7324445 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -100,6 +100,8 @@ on support follow.
  ``V``Supported
  ``Za128rs``  Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
+ ``Zaamo``Supported
+ ``Zalrsc``   Supported
  ``Zawrs``Assembly Support
  ``Zba``  Supported
  ``Zbb``  

[lld] [llvm] [clang] [flang] [AMDGPU] Introduce Code Object V6 (PR #76954)

2024-01-22 Thread Pierre van Houtryve via cfe-commits

Pierre-vh wrote:

ping

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


[clang-tools-extra] [clang-tidy] Add support for lambdas in cppcoreguidelines-owning-memory (PR #77246)

2024-01-22 Thread Congcong Cai via cfe-commits


@@ -147,10 +161,52 @@ void OwningMemoryCheck::registerMatchers(MatchFinder 
*Finder) {
   // Matching on functions, that return an owner/resource, but don't declare
   // their return type as owner.
   Finder->addMatcher(
-  functionDecl(hasDescendant(returnStmt(hasReturnValue(ConsideredOwner))
- .bind("bad_owner_return")),
-   unless(returns(qualType(hasDeclaration(OwnerDecl)
-  .bind("function_decl"),
+  functionDecl(
+  decl().bind("function_decl"),
+  hasBody(stmt(
+  stmt().bind("body"),
+  hasDescendant(
+  returnStmt(hasReturnValue(ConsideredOwner),
+ // Ignore sub-lambda expressions
+ hasAncestor(stmt(anyOf(equalsBoundNode("body"),

HerrCai0907 wrote:

Why here we need to check `hasAncestor(stmt(anyOf(equalsBoundNode("body")`, we 
get this `returnStmt` from `body hasDescendant`.

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


[clang] [llvm] [docs] Add llvm & clang release notes for LoongArch (PR #79097)

2024-01-22 Thread Lu Weining via cfe-commits

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


[clang] 9e2c0f0 - [docs] Add llvm & clang release notes for LoongArch (#79097)

2024-01-22 Thread via cfe-commits

Author: Lu Weining
Date: 2024-01-23T15:27:06+08:00
New Revision: 9e2c0f000549991ea5585d6799ade92811a8faae

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

LOG: [docs] Add llvm & clang release notes for LoongArch (#79097)

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cb15dfb99bec977..93eecbe0e1363de 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1189,8 +1189,14 @@ Windows Support
 
 LoongArch Support
 ^
-- The ``model`` attribute is now supported for overriding the default code
-  model used to access global variables. The following values are supported:
+- Added builtins support for all LSX (128-bits SIMD) and LASX (256-bits SIMD)
+  instructions.
+- Added builtins support for approximate calculation instructions that were
+  introduced in LoongArch Reference Manual V1.10.
+- Made ``-mcmodel=`` compatible with LoongArch gcc that accepted ``normal``,
+  ``medium`` and ``extreme``.
+- The ``model`` attribute was now supported for overriding the default code
+  model used to access global variables. The following values were supported:
   ``normal``, ``medium`` and ``extreme``.
 
   *Example Code*:
@@ -1199,6 +1205,10 @@ LoongArch Support
 
  int var __attribute((model("extreme")));
 
+- Default to ``-fno-direct-access-external-data`` for non-PIC.
+- An ABI mismatch with gcc/g++ about empty structs/unions passing was fixed.
+- ``_mcount`` was generated instead of ``mcount``.
+
 RISC-V Support
 ^^
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index c17c834c8081b8a..8d75b6415e557b8 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -132,8 +132,21 @@ Changes to the Hexagon Backend
 
 Changes to the LoongArch Backend
 
-* The code model of global variables can now be overridden by means of
-  the newly added LLVM IR attribute, ``code_model``.
+
+* Added intrinsics support for all LSX (128-bits SIMD) and LASX (256-bits SIMD)
+  instructions.
+* Added definition and intrinsics support for new instructions that were
+  introduced in LoongArch Reference Manual V1.10.
+* Emitted adjacent ``pcaddu18i+jirl`` instrunction sequence with one relocation
+  ``R_LARCH_CALL36`` instead of ``pcalau12i+jirl`` with two relocations
+  ``R_LARCH_PCALA_{HI20,LO12}`` for function call in medium code model.
+* The code model of global variables can now be overridden by means of the 
newly
+  added LLVM IR attribute, ``code_model``.
+* Added support for the ``llvm.is.fpclass`` intrinsic.
+* ``mulodi4`` and ``muloti4`` libcalls were disabled due to absence in libgcc.
+* Added initial support for auto vectorization.
+* Added initial support for linker relaxation.
+* Assorted codegen improvements.
 
 Changes to the MIPS Backend
 ---



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


[clang] [libclang/python] Expose Rewriter to the python binding (PR #77269)

2024-01-22 Thread Craig Hesling via cfe-commits

linux4life798 wrote:

I don't think this needs to block this change, but another concern I have about 
this API is that it is writing to stdout from C++ intermixed with Python 
writing to its own buffered stdout. This means that the user may see 
inconsistent output. This is somewhat a deficiency of [libclang Rewrite 
API](https://clang.llvm.org/doxygen/Rewrite_8h.html), since there is only one 
specific function to "write the main file out" and that is through stdout.

In an attempt to keep the world consistent, we may want to consider flushing 
the Python stdout buffer (`sys.stdout.flush()`) before calling 
`clang_CXRewriter_writeMainFileToStdOut`. I would hope that 
`clang_CXRewriter_writeMainFileToStdOut` flushes its own C++ stdout buffer 
after writing the file contents, but I honestly haven't looked at the code.

https://github.com/llvm/llvm-project/pull/77269
___
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-22 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 edited 
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-22 Thread Nathan Ridge via cfe-commits


@@ -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 "".

HighCommander4 wrote:

"regexes" --> "matcher functions"

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-22 Thread Nathan Ridge via cfe-commits


@@ -539,6 +539,42 @@ TEST_F(ConfigCompileTests, Style) {
   Frag.Style.FullyQualifiedNamespaces.push_back(std::string("bar"));
   EXPECT_TRUE(compileAndApply());
   EXPECT_THAT(Conf.Style.FullyQualifiedNamespaces, ElementsAre("foo", "bar"));
+
+  {
+Frag = {};
+EXPECT_TRUE(Conf.Style.QuotedHeaders.empty())
+<< Conf.Style.QuotedHeaders.size();
+Frag.Style.QuotedHeaders.push_back(Located("foo.h"));
+Frag.Style.QuotedHeaders.push_back(Located(".*inc"));
+EXPECT_TRUE(compileAndApply());
+auto HeaderFilter = [this](llvm::StringRef Path) {
+  for (auto  : Conf.Style.QuotedHeaders) {
+if (Filter(Path))
+  return true;
+  }
+  return false;
+};
+EXPECT_TRUE(HeaderFilter("foo.h"));

HighCommander4 wrote:

consider checking `"prefix/foo.h"` as well

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-22 Thread Nathan Ridge via cfe-commits


@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_HEADERS_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_HEADERS_H
 
+#include "Config.h"

HighCommander4 wrote:

Nothing in this header uses `Config.h`

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-22 Thread Nathan Ridge via cfe-commits


@@ -211,10 +214,12 @@ class IncludeInserter {
   // include path of non-verbatim header will not be shortened.
   IncludeInserter(StringRef FileName, StringRef Code,
   const format::FormatStyle , StringRef BuildDir,
-  HeaderSearch *HeaderSearchInfo)
+  HeaderSearch *HeaderSearchInfo, HeaderFilter QuotedHeaders,

HighCommander4 wrote:

We're taking `ArrayRef`s here, and passing it `vectors` that live in `Config`.

How confident are we that this is ok from a lifetime point of view, i.e. the 
`Config` object will outlive the `IncludeInserter` object? How confident are we 
that this will remain the case across future refactorings?

Would it be better to copy the vector instead? Each element is a function which 
stores a shared_ptr to a vector of regexes, so we wouldn't be copying the 
regexes the themselves.

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-22 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 commented:

I took a pass through the implementation. Generally looks good.

Would be nice to have a test that exercises the include insertion process in a 
more end-to-end way. I think something in `CodeCompleteTests.cpp` would work, 
using `WithContextValue` to set config values 
([example](https://searchfox.org/llvm/rev/365aa1574a1b4a3cdee6648227d095d00536ffde/clang-tools-extra/clangd/unittests/InlayHintTests.cpp#77-84,100)),
 and using the 
[`insertIncludeText`](https://searchfox.org/llvm/rev/365aa1574a1b4a3cdee6648227d095d00536ffde/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp#83)
 matcher to make assertions about the spelling of inserted includes.

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-22 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 edited 
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] [llvm] [RISCV] Update TargetAttr target-cpu override rule (PR #75804)

2024-01-22 Thread Craig Topper via cfe-commits

topperc wrote:

Is this still needed after #77426

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


[clang-tools-extra] 150a58b - [clang-tidy][DOC] Update list.rst

2024-01-22 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2024-01-23T07:09:24Z
New Revision: 150a58bed08f9f83ae4157a033ef1c67c210bbc4

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

LOG: [clang-tidy][DOC] Update list.rst

Update list.rst to put checks in alphabetical order

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 1fac3874b3c3204..f773e80b562e4fd 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -355,7 +355,6 @@ Clang-Tidy Checks
:doc:`readability-identifier-length `,
:doc:`readability-identifier-naming `, "Yes"
:doc:`readability-implicit-bool-conversion 
`, "Yes"
-   :doc:`readability-redundant-inline-specifier 
`, "Yes"
:doc:`readability-inconsistent-declaration-parameter-name 
`, "Yes"
:doc:`readability-isolate-declaration `, 
"Yes"
:doc:`readability-magic-numbers `,
@@ -371,6 +370,7 @@ Clang-Tidy Checks
:doc:`readability-redundant-control-flow 
`, "Yes"
:doc:`readability-redundant-declaration 
`, "Yes"
:doc:`readability-redundant-function-ptr-dereference 
`, "Yes"
+   :doc:`readability-redundant-inline-specifier 
`, "Yes"
:doc:`readability-redundant-member-init 
`, "Yes"
:doc:`readability-redundant-preprocessor 
`,
:doc:`readability-redundant-smartptr-get 
`, "Yes"



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


[clang] [Clang][RISCV][RVV Intrinsic] Fix codegen redundant intrinsic names (PR #77889)

2024-01-22 Thread Craig Topper via cfe-commits

topperc wrote:

@circYuan do you need me to commit this for you?

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


[clang] [llvm] [lld] [clang-tools-extra] [ELF] --save-temps --lto-emit-asm: derive ELF/asm file names from bitcode file names (PR #78835)

2024-01-22 Thread Fangrui Song via cfe-commits


@@ -352,32 +357,49 @@ std::vector BitcodeCompiler::compile() {
 pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy, files);
 
   if (!config->ltoObjPath.empty()) {
-saveBuffer(buf[0], config->ltoObjPath);
+saveBuffer(buf[0].second, config->ltoObjPath);
 for (unsigned i = 1; i != maxTasks; ++i)
-  saveBuffer(buf[i], config->ltoObjPath + Twine(i));
-  }
-
-  if (config->saveTempsArgs.contains("prelink")) {
-if (!buf[0].empty())
-  saveBuffer(buf[0], config->outputFile + ".lto.o");
-for (unsigned i = 1; i != maxTasks; ++i)
-  saveBuffer(buf[i], config->outputFile + Twine(i) + ".lto.o");
-  }
-
-  if (config->ltoEmitAsm) {
-saveBuffer(buf[0], config->outputFile);
-for (unsigned i = 1; i != maxTasks; ++i)
-  saveBuffer(buf[i], config->outputFile + Twine(i));
-return {};
+  saveBuffer(buf[i].second, config->ltoObjPath + Twine(i));
   }
 
+  bool savePrelink = config->saveTempsArgs.contains("prelink");
   std::vector ret;
-  for (unsigned i = 0; i != maxTasks; ++i)
-if (!buf[i].empty())
-  ret.push_back(createObjFile(MemoryBufferRef(buf[i], "lto.tmp")));
+  const char *ext = config->ltoEmitAsm ? ".s" : ".o";
+  for (unsigned i = 0; i != maxTasks; ++i) {
+StringRef bitcodeFilePath;
+StringRef objBuf;
+if (files[i]) {

MaskRay wrote:

Done!

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


[clang-tools-extra] [llvm] [lld] [clang] [ELF] --save-temps --lto-emit-asm: derive ELF/asm file names from bitcode file names (PR #78835)

2024-01-22 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/78835

>From 37b3ff263f2b46bd4541157bee5b5e1bf2639604 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sat, 20 Jan 2024 00:40:53 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 lld/ELF/LTO.cpp| 70 ++
 lld/ELF/LTO.h  |  3 +-
 lld/test/ELF/common-archive-lookup.s   |  7 ++-
 lld/test/ELF/lto/comdat-mixed-archive.test |  4 +-
 lld/test/ELF/lto/emit-asm.ll   | 13 ++--
 lld/test/ELF/lto/exclude-libs-libcall.ll   |  2 +-
 lld/test/ELF/lto/obj-path.ll   |  4 +-
 lld/test/ELF/lto/parallel-internalize.ll   |  2 +-
 lld/test/ELF/lto/parallel.ll   |  2 +-
 lld/test/ELF/lto/pseudo-probe-lto.ll   |  3 +-
 lld/test/ELF/lto/save-temps-eq.ll  | 10 ++--
 lld/test/ELF/lto/thinlto.ll| 48 +++
 12 files changed, 97 insertions(+), 71 deletions(-)

diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index 504c12aac6c5696..843ee59479eae92 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -12,6 +12,7 @@
 #include "SymbolTable.h"
 #include "Symbols.h"
 #include "lld/Common/Args.h"
+#include "lld/Common/CommonLinkerContext.h"
 #include "lld/Common/ErrorHandler.h"
 #include "lld/Common/Filesystem.h"
 #include "lld/Common/Strings.h"
@@ -26,6 +27,7 @@
 #include "llvm/Support/Caching.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include 
@@ -303,6 +305,7 @@ std::vector BitcodeCompiler::compile() {
   unsigned maxTasks = ltoObj->getMaxTasks();
   buf.resize(maxTasks);
   files.resize(maxTasks);
+  filenames.resize(maxTasks);
 
   // The --thinlto-cache-dir option specifies the path to a directory in which
   // to cache native object files for ThinLTO incremental builds. If a path was
@@ -313,13 +316,15 @@ std::vector BitcodeCompiler::compile() {
  [&](size_t task, const Twine ,
  std::unique_ptr mb) {
files[task] = std::move(mb);
+   filenames[task] = moduleName.str();
  }));
 
   if (!ctx.bitcodeFiles.empty())
 checkError(ltoObj->run(
 [&](size_t task, const Twine ) {
+  buf[task].first = moduleName.str();
   return std::make_unique(
-  std::make_unique(buf[task]));
+  std::make_unique(buf[task].second));
 },
 cache));
 
@@ -338,7 +343,7 @@ std::vector BitcodeCompiler::compile() {
 
   if (config->thinLTOIndexOnly) {
 if (!config->ltoObjPath.empty())
-  saveBuffer(buf[0], config->ltoObjPath);
+  saveBuffer(buf[0].second, config->ltoObjPath);
 
 // ThinLTO with index only option is required to generate only the index
 // files. After that, we exit from linker and ThinLTO backend runs in a
@@ -352,32 +357,49 @@ std::vector BitcodeCompiler::compile() {
 pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy, files);
 
   if (!config->ltoObjPath.empty()) {
-saveBuffer(buf[0], config->ltoObjPath);
+saveBuffer(buf[0].second, config->ltoObjPath);
 for (unsigned i = 1; i != maxTasks; ++i)
-  saveBuffer(buf[i], config->ltoObjPath + Twine(i));
-  }
-
-  if (config->saveTempsArgs.contains("prelink")) {
-if (!buf[0].empty())
-  saveBuffer(buf[0], config->outputFile + ".lto.o");
-for (unsigned i = 1; i != maxTasks; ++i)
-  saveBuffer(buf[i], config->outputFile + Twine(i) + ".lto.o");
-  }
-
-  if (config->ltoEmitAsm) {
-saveBuffer(buf[0], config->outputFile);
-for (unsigned i = 1; i != maxTasks; ++i)
-  saveBuffer(buf[i], config->outputFile + Twine(i));
-return {};
+  saveBuffer(buf[i].second, config->ltoObjPath + Twine(i));
   }
 
+  bool savePrelink = config->saveTempsArgs.contains("prelink");
   std::vector ret;
-  for (unsigned i = 0; i != maxTasks; ++i)
-if (!buf[i].empty())
-  ret.push_back(createObjFile(MemoryBufferRef(buf[i], "lto.tmp")));
+  const char *ext = config->ltoEmitAsm ? ".s" : ".o";
+  for (unsigned i = 0; i != maxTasks; ++i) {
+StringRef bitcodeFilePath;
+StringRef objBuf;
+if (files[i]) {
+  objBuf = files[i]->getBuffer();
+  bitcodeFilePath = filenames[i];
+} else {
+  objBuf = buf[i].second;
+  bitcodeFilePath = buf[i].first;
+}
+if (objBuf.empty())
+  continue;
 
-  for (std::unique_ptr  : files)
-if (file)
-  ret.push_back(createObjFile(*file));
+// If the input bitcode file is path/to/a.o and -o specifies a.out, then 
the
+// corresponding lto object file name will look something like:
+// path/to/a.out.lto.a.o.
+  

[clang] [clang-tools-extra] [llvm] [lld] [ELF] --save-temps --lto-emit-asm: derive ELF/asm file names from bitcode file names (PR #78835)

2024-01-22 Thread Fangrui Song via cfe-commits


@@ -61,10 +61,11 @@
 # RUN: ld.lld --no-fortran-common -o 11 main.o --start-lib 1.o 
strong_data_only.o --end-lib
 # RUN: llvm-readobj --syms 11 | FileCheck --check-prefix=NFC %s
 
-# RUN: ld.lld -o - main.o 4.a --fortran-common --lto-emit-asm | FileCheck 
--check-prefix=ASM %s
+# RUN: ld.lld -o out main.o 4.a --fortran-common --lto-emit-asm
+# RUN: FileCheck --check-prefix=ASM %s < out.lto.s
 
-# RUN: ld.lld -o - main.o  --start-lib 1.bc 2.bc --end-lib --fortran-common 
--lto-emit-asm | \
-# RUN:   FileCheck --check-prefix=ASM %s
+# RUN: ld.lld -o out main.o --start-lib 1.bc 2.bc --end-lib --fortran-common 
--lto-emit-asm
+# RUN: FileCheck --check-prefix=ASM %s < out.lto.s

MaskRay wrote:

Thanks for the suggestion. Removed.

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


[clang] [llvm] [flang] [mlir] [AMDGPU] Update llvm-objdump lit tests for COV5 (PR #79039)

2024-01-22 Thread Saiyedul Islam via cfe-commits

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


[llvm] [clang] [docs] Add llvm & clang release notes for LoongArch (PR #79097)

2024-01-22 Thread via cfe-commits

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

LGTM. Thanks.

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


[clang-tools-extra] [llvm] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-22 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,151 @@
+//===--- UseStdMinMaxCheck.cpp - clang-tidy 
---===//
+//
+// 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
+//
+//===--===//
+
+#include "UseStdMinMaxCheck.h"
+#include "../utils/ASTUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+static const llvm::StringRef AlgorithmHeader("");
+
+static bool MinCondition(const BinaryOperator::Opcode , const Expr *CondLhs,
+ const Expr *CondRhs, const Expr *AssignLhs,
+ const Expr *AssignRhs, const ASTContext ) {
+  if ((Op == BO_LT || Op == BO_LE) &&
+  (tidy::utils::areStatementsIdentical(CondLhs, AssignRhs, Context) &&
+   tidy::utils::areStatementsIdentical(CondRhs, AssignLhs, Context)))
+return true;
+
+  if ((Op == BO_GT || Op == BO_GE) &&
+  (tidy::utils::areStatementsIdentical(CondLhs, AssignLhs, Context) &&
+   tidy::utils::areStatementsIdentical(CondRhs, AssignRhs, Context)))
+return true;
+
+  return false;
+}
+
+static bool MaxCondition(const BinaryOperator::Opcode , const Expr *CondLhs,
+ const Expr *CondRhs, const Expr *AssignLhs,
+ const Expr *AssignRhs, const ASTContext ) {
+  if ((Op == BO_LT || Op == BO_LE) &&
+  (tidy::utils::areStatementsIdentical(CondLhs, AssignLhs, Context) &&
+   tidy::utils::areStatementsIdentical(CondRhs, AssignRhs, Context)))
+return true;
+
+  if ((Op == BO_GT || Op == BO_GE) &&
+  (tidy::utils::areStatementsIdentical(CondLhs, AssignRhs, Context) &&
+   tidy::utils::areStatementsIdentical(CondRhs, AssignLhs, Context)))
+return true;
+
+  return false;
+}
+
+static std::string
+CreateReplacement(const bool UseMax, const BinaryOperator::Opcode ,
+  const Expr *CondLhs, const Expr *CondRhs,
+  const Expr *AssignLhs, const ASTContext ,
+  const SourceManager , const LangOptions ,
+  const StringRef ) {
+  const auto CondLhsStr = Lexer::getSourceText(
+  Source.getExpansionRange(CondLhs->getSourceRange()), Source, LO);
+  const auto CondRhsStr = Lexer::getSourceText(
+  Source.getExpansionRange(CondRhs->getSourceRange()), Source, LO);
+  const auto AssignLhsStr = Lexer::getSourceText(
+  Source.getExpansionRange(AssignLhs->getSourceRange()), Source, LO);
+  return (AssignLhsStr + " = " + FunctionName +
+  ((CondLhs->getType() != CondRhs->getType())
+   ? "<" + AssignLhs->getType().getAsString() + ">("

PiotrZSL wrote:

There is one problem here that is visible in llvm.
Lets take code like this:
```
unsigned char C = 10;
unsigned int B = 257'

if (B < C)
  C = B;
```

this would be changed into `C = std::min(C, B);`  but thats not 
valid, as B casted to unsigned char would be smaller than C but not if C is 
casted to unsigned int and then compared.
Simply as an template argument to std::min we should use wider type, and if we 
don't fine any, we should read type from already existed implicit cast.

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


[clang] [clang-tools-extra] [llvm] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-22 Thread Piotr Zegar via cfe-commits

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


[clang] [llvm] [clang-tools-extra] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

2024-01-22 Thread Piotr Zegar via cfe-commits

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

There are still some functional bugs. I would say safer would be to postpone 
this check to Clang-tidy 19.

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


[clang] [libclang/python] Expose Rewriter to the python binding (PR #77269)

2024-01-22 Thread Craig Hesling via cfe-commits

linux4life798 wrote:

> @linux4life798 Nice catch! I see that so far only CompilationDatabase and 
> CompletionChunk expose functions in camelCase. It would be nice to change 
> them, too, but those are decade-old APIs that I think we promise stability 
> for, so it might not be possible.

Yep. Of course unrelated to this change, we might be able to add the snake_case 
equivalent binding and marking the old ones as depreciated.

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


[llvm] [clang] [docs] Add llvm & clang release notes for LoongArch (PR #79097)

2024-01-22 Thread via cfe-commits

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

LGTM

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


[mlir] [flang] [llvm] [clang] [AMDGPU] Update llvm-objdump lit tests for COV5 (PR #79039)

2024-01-22 Thread Saiyedul Islam via cfe-commits

https://github.com/saiislam updated 
https://github.com/llvm/llvm-project/pull/79039

>From 9791643aa93f70bcaf89cd9ca679dbd1bed58676 Mon Sep 17 00:00:00 2001
From: Saiyedul Islam 
Date: Mon, 22 Jan 2024 13:11:22 -0600
Subject: [PATCH 1/2] [AMDGPU] Change default AMDHSA Code Object version to 5

Also update LIT tests, docs, and release notes for Clang and
LLVM.

For more details, see
https://llvm.org/docs/AMDGPUUsage.html#code-object-v5-metadata
---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/Driver/Options.td |  4 ++--
 clang/test/CodeGen/amdgpu-address-spaces.cpp  |  2 +-
 .../CodeGenCUDA/amdgpu-code-object-version.cu |  2 +-
 clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu   |  4 ++--
 clang/test/CodeGenHIP/default-attributes.hip  |  4 ++--
 clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl |  4 ++--
 clang/test/CodeGenOpenCL/builtins-amdgcn.cl   | 10 +-
 flang/test/Driver/driver-help-hidden.f90  |  2 +-
 flang/test/Driver/driver-help.f90 |  2 +-
 llvm/docs/AMDGPUUsage.rst | 15 +++
 llvm/docs/ReleaseNotes.rst|  2 ++
 llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp   |  2 +-
 .../Dialect/GPU/Transforms/SerializeToHsaco.cpp   |  2 +-
 .../Dialect/ROCDL/ROCDLToLLVMIRTranslation.cpp|  1 +
 mlir/test/Target/LLVMIR/rocdl.mlir|  2 +-
 16 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5846503af3acdfe..472e9fcde2c468a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1104,6 +1104,8 @@ AMDGPU Support
   arguments in C ABI. Callee is responsible for allocating stack memory and
   copying the value of the struct if modified. Note that AMDGPU backend still
   supports byval for struct arguments.
+- The default value for ``-mcode-object-version`` is now 5. See :ref:`AMDHSA 
code object version `
+  for more details.
 
 X86 Support
 ^^^
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f9e883e3e22de86..d4b82b301f12e64 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4777,12 +4777,12 @@ defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
   NegFlag>, Group;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 5. (AMDGPU only)">,
   Visibility<[ClangOption, FlangOption, CC1Option, FC1Option]>,
   Values<"none,4,5">,
   NormalizedValuesScope<"llvm::CodeObjectVersionKind">,
   NormalizedValues<["COV_None", "COV_4", "COV_5"]>,
-  MarshallingInfoEnum, "COV_4">;
+  MarshallingInfoEnum, "COV_5">;
 
 defm cumode : SimpleMFlag<"cumode",
   "Specify CU wavefront", "Specify WGP wavefront",
diff --git a/clang/test/CodeGen/amdgpu-address-spaces.cpp 
b/clang/test/CodeGen/amdgpu-address-spaces.cpp
index 0a808aa6cc75ed3..ae2c61439f4ca53 100644
--- a/clang/test/CodeGen/amdgpu-address-spaces.cpp
+++ b/clang/test/CodeGen/amdgpu-address-spaces.cpp
@@ -29,7 +29,7 @@ int [[clang::address_space(999)]] bbb = 1234;
 // CHECK: @u = addrspace(5) global i32 undef, align 4
 // CHECK: @aaa = addrspace(6) global i32 1000, align 4
 // CHECK: @bbb = addrspace(999) global i32 1234, align 4
-// CHECK: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr 
addrspace(4) constant i32 400
+// CHECK: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr 
addrspace(4) constant i32 500
 //.
 // CHECK-LABEL: define dso_local amdgpu_kernel void @foo(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
diff --git a/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu 
b/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
index ff5deaf9ab850d2..3cb6632fc0b63d3 100644
--- a/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
@@ -1,7 +1,7 @@
 // Create module flag for code object version.
 
 // RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
-// RUN:   -o - %s | FileCheck %s -check-prefix=V4
+// RUN:   -o - %s | FileCheck %s -check-prefix=V5
 
 // RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
 // RUN:   -mcode-object-version=4 -o - %s | FileCheck -check-prefix=V4 %s
diff --git a/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu 
b/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
index 282e0a49b9aa10b..0c846e0936b58b1 100644
--- a/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
-// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: -fcuda-is-device -mcode-object-version=4 -emit-llvm -o - -x hip %s 
\
 // RUN: | FileCheck -check-prefix=PRECOV5 %s
 
 
 // RUN: %clang_cc1 -triple 

[compiler-rt] [clang-tools-extra] [clang] [PGO] Reland PGO's Counter Reset and File Dumping APIs #76471 (PR #78285)

2024-01-22 Thread Rainer Orth via cfe-commits

rorth wrote:

This patch broke both the 
[Solaris/sparcv9](https://lab.llvm.org/buildbot/#/builders/72/builds/2015) and 
[Solaris/amd64](https://lab.llvm.org/staging/#/builders/94/builds/394) 
buildbots.

If it really requires recent `lld`, this is guaranteed to not work: `lld` 
hasn't even been ported to Solaris.  Similar issues most likely will exist on 
other targets where the bot either doesn't build `lld` or it isn't supported at 
all.

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


[clang] [Clang][RISCV][RVV Intrinsic] Fix codegen redundant intrinsic names (PR #77889)

2024-01-22 Thread Craig Topper via cfe-commits

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

LGTM

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


[mlir] [flang] [llvm] [clang] [AMDGPU] Change default AMDHSA Code Object version to 5 (PR #79038)

2024-01-22 Thread Saiyedul Islam via cfe-commits

saiislam wrote:

> Should get a mention in the release notes

Thanks for pointing it out. I have updated it.

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


[mlir] [flang] [llvm] [clang] [AMDGPU] Change default AMDHSA Code Object version to 5 (PR #79038)

2024-01-22 Thread Saiyedul Islam via cfe-commits

https://github.com/saiislam updated 
https://github.com/llvm/llvm-project/pull/79038

>From 9791643aa93f70bcaf89cd9ca679dbd1bed58676 Mon Sep 17 00:00:00 2001
From: Saiyedul Islam 
Date: Mon, 22 Jan 2024 13:11:22 -0600
Subject: [PATCH] [AMDGPU] Change default AMDHSA Code Object version to 5

Also update LIT tests, docs, and release notes for Clang and
LLVM.

For more details, see
https://llvm.org/docs/AMDGPUUsage.html#code-object-v5-metadata
---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/Driver/Options.td |  4 ++--
 clang/test/CodeGen/amdgpu-address-spaces.cpp  |  2 +-
 .../CodeGenCUDA/amdgpu-code-object-version.cu |  2 +-
 clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu   |  4 ++--
 clang/test/CodeGenHIP/default-attributes.hip  |  4 ++--
 clang/test/CodeGenOpenCL/amdgpu-enqueue-kernel.cl |  4 ++--
 clang/test/CodeGenOpenCL/builtins-amdgcn.cl   | 10 +-
 flang/test/Driver/driver-help-hidden.f90  |  2 +-
 flang/test/Driver/driver-help.f90 |  2 +-
 llvm/docs/AMDGPUUsage.rst | 15 +++
 llvm/docs/ReleaseNotes.rst|  2 ++
 llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp   |  2 +-
 .../Dialect/GPU/Transforms/SerializeToHsaco.cpp   |  2 +-
 .../Dialect/ROCDL/ROCDLToLLVMIRTranslation.cpp|  1 +
 mlir/test/Target/LLVMIR/rocdl.mlir|  2 +-
 16 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5846503af3acdf..472e9fcde2c468 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1104,6 +1104,8 @@ AMDGPU Support
   arguments in C ABI. Callee is responsible for allocating stack memory and
   copying the value of the struct if modified. Note that AMDGPU backend still
   supports byval for struct arguments.
+- The default value for ``-mcode-object-version`` is now 5. See :ref:`AMDHSA 
code object version `
+  for more details.
 
 X86 Support
 ^^^
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f9e883e3e22de8..d4b82b301f12e6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4777,12 +4777,12 @@ defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
   NegFlag>, Group;
 
 def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, 
Group,
-  HelpText<"Specify code object ABI version. Defaults to 4. (AMDGPU only)">,
+  HelpText<"Specify code object ABI version. Defaults to 5. (AMDGPU only)">,
   Visibility<[ClangOption, FlangOption, CC1Option, FC1Option]>,
   Values<"none,4,5">,
   NormalizedValuesScope<"llvm::CodeObjectVersionKind">,
   NormalizedValues<["COV_None", "COV_4", "COV_5"]>,
-  MarshallingInfoEnum, "COV_4">;
+  MarshallingInfoEnum, "COV_5">;
 
 defm cumode : SimpleMFlag<"cumode",
   "Specify CU wavefront", "Specify WGP wavefront",
diff --git a/clang/test/CodeGen/amdgpu-address-spaces.cpp 
b/clang/test/CodeGen/amdgpu-address-spaces.cpp
index 0a808aa6cc75ed..ae2c61439f4ca5 100644
--- a/clang/test/CodeGen/amdgpu-address-spaces.cpp
+++ b/clang/test/CodeGen/amdgpu-address-spaces.cpp
@@ -29,7 +29,7 @@ int [[clang::address_space(999)]] bbb = 1234;
 // CHECK: @u = addrspace(5) global i32 undef, align 4
 // CHECK: @aaa = addrspace(6) global i32 1000, align 4
 // CHECK: @bbb = addrspace(999) global i32 1234, align 4
-// CHECK: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr 
addrspace(4) constant i32 400
+// CHECK: @__oclc_ABI_version = weak_odr hidden local_unnamed_addr 
addrspace(4) constant i32 500
 //.
 // CHECK-LABEL: define dso_local amdgpu_kernel void @foo(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
diff --git a/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu 
b/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
index ff5deaf9ab850d..3cb6632fc0b63d 100644
--- a/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
@@ -1,7 +1,7 @@
 // Create module flag for code object version.
 
 // RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
-// RUN:   -o - %s | FileCheck %s -check-prefix=V4
+// RUN:   -o - %s | FileCheck %s -check-prefix=V5
 
 // RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
 // RUN:   -mcode-object-version=4 -o - %s | FileCheck -check-prefix=V4 %s
diff --git a/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu 
b/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
index 282e0a49b9aa10..0c846e0936b58b 100644
--- a/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
+++ b/clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
-// RUN: -fcuda-is-device -emit-llvm -o - -x hip %s \
+// RUN: -fcuda-is-device -mcode-object-version=4 -emit-llvm -o - -x hip %s 
\
 // RUN: | FileCheck -check-prefix=PRECOV5 %s
 
 
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa \
-// 

[llvm] [clang] [LoongArch] Add definitions and feature 'frecipe' for FP approximation intrinsics/builtins (PR #78962)

2024-01-22 Thread Lu Weining via cfe-commits

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


[clang] fcb8342 - [LoongArch] Add definitions and feature 'frecipe' for FP approximation intrinsics/builtins (#78962)

2024-01-22 Thread via cfe-commits

Author: Ami-zhang
Date: 2024-01-23T14:24:58+08:00
New Revision: fcb8342a219ada8ec641790a4c8a9f969d7d64ee

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

LOG: [LoongArch] Add definitions and feature 'frecipe' for FP approximation 
intrinsics/builtins (#78962)

This PR adds definitions and 'frecipe' feature for FP approximation
intrinsics/builtins. In additions, this adds and complements relative
testcases.

Added: 
clang/test/CodeGen/LoongArch/builtin-dbl-approximate.c
clang/test/CodeGen/LoongArch/builtin-flt-approximate.c
clang/test/CodeGen/LoongArch/lasx/builtin-approximate-alias.c
clang/test/CodeGen/LoongArch/lasx/builtin-approximate.c
clang/test/CodeGen/LoongArch/lsx/builtin-approximate-alias.c
clang/test/CodeGen/LoongArch/lsx/builtin-approximate.c
llvm/test/CodeGen/LoongArch/intrinsic-frecipe-dbl.ll
llvm/test/CodeGen/LoongArch/intrinsic-frecipe-flt.ll
llvm/test/CodeGen/LoongArch/lasx/intrinsic-frecipe.ll
llvm/test/CodeGen/LoongArch/lasx/intrinsic-frsqrte.ll
llvm/test/CodeGen/LoongArch/lsx/intrinsic-frecipe.ll
llvm/test/CodeGen/LoongArch/lsx/intrinsic-frsqrte.ll

Modified: 
clang/include/clang/Basic/BuiltinsLoongArchBase.def
clang/include/clang/Basic/BuiltinsLoongArchLASX.def
clang/include/clang/Basic/BuiltinsLoongArchLSX.def
clang/lib/Headers/larchintrin.h
clang/lib/Headers/lasxintrin.h
clang/lib/Headers/lsxintrin.h
clang/test/CodeGen/LoongArch/intrinsic-la64-error.c
llvm/include/llvm/IR/IntrinsicsLoongArch.td
llvm/lib/Target/LoongArch/LoongArch.td
llvm/lib/Target/LoongArch/LoongArchFloat32InstrInfo.td
llvm/lib/Target/LoongArch/LoongArchFloat64InstrInfo.td
llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
llvm/lib/Target/LoongArch/LoongArchSubtarget.h

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsLoongArchBase.def 
b/clang/include/clang/Basic/BuiltinsLoongArchBase.def
index cbb239223aae3b2..a5a07c167908ce4 100644
--- a/clang/include/clang/Basic/BuiltinsLoongArchBase.def
+++ b/clang/include/clang/Basic/BuiltinsLoongArchBase.def
@@ -51,3 +51,8 @@ TARGET_BUILTIN(__builtin_loongarch_iocsrwr_d, "vUWiUi", "nc", 
"64bit")
 
 TARGET_BUILTIN(__builtin_loongarch_lddir_d, "WiWiIUWi", "nc", "64bit")
 TARGET_BUILTIN(__builtin_loongarch_ldpte_d, "vWiIUWi", "nc", "64bit")
+
+TARGET_BUILTIN(__builtin_loongarch_frecipe_s, "ff", "nc", "f,frecipe")
+TARGET_BUILTIN(__builtin_loongarch_frecipe_d, "dd", "nc", "d,frecipe")
+TARGET_BUILTIN(__builtin_loongarch_frsqrte_s, "ff", "nc", "f,frecipe")
+TARGET_BUILTIN(__builtin_loongarch_frsqrte_d, "dd", "nc", "d,frecipe")

diff  --git a/clang/include/clang/Basic/BuiltinsLoongArchLASX.def 
b/clang/include/clang/Basic/BuiltinsLoongArchLASX.def
index 3de200f665b680a..4cf51cc000f6fcb 100644
--- a/clang/include/clang/Basic/BuiltinsLoongArchLASX.def
+++ b/clang/include/clang/Basic/BuiltinsLoongArchLASX.def
@@ -657,9 +657,15 @@ TARGET_BUILTIN(__builtin_lasx_xvfsqrt_d, "V4dV4d", "nc", 
"lasx")
 TARGET_BUILTIN(__builtin_lasx_xvfrecip_s, "V8fV8f", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvfrecip_d, "V4dV4d", "nc", "lasx")
 
+TARGET_BUILTIN(__builtin_lasx_xvfrecipe_s, "V8fV8f", "nc", "lasx,frecipe")
+TARGET_BUILTIN(__builtin_lasx_xvfrecipe_d, "V4dV4d", "nc", "lasx,frecipe")
+
 TARGET_BUILTIN(__builtin_lasx_xvfrsqrt_s, "V8fV8f", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvfrsqrt_d, "V4dV4d", "nc", "lasx")
 
+TARGET_BUILTIN(__builtin_lasx_xvfrsqrte_s, "V8fV8f", "nc", "lasx,frecipe")
+TARGET_BUILTIN(__builtin_lasx_xvfrsqrte_d, "V4dV4d", "nc", "lasx,frecipe")
+
 TARGET_BUILTIN(__builtin_lasx_xvfcvtl_s_h, "V8fV16s", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvfcvth_s_h, "V8fV16s", "nc", "lasx")
 TARGET_BUILTIN(__builtin_lasx_xvfcvtl_d_s, "V4dV8f", "nc", "lasx")

diff  --git a/clang/include/clang/Basic/BuiltinsLoongArchLSX.def 
b/clang/include/clang/Basic/BuiltinsLoongArchLSX.def
index 8e6aec886c50cd9..c90f4dc5458fa6e 100644
--- a/clang/include/clang/Basic/BuiltinsLoongArchLSX.def
+++ b/clang/include/clang/Basic/BuiltinsLoongArchLSX.def
@@ -641,9 +641,15 @@ TARGET_BUILTIN(__builtin_lsx_vfsqrt_d, "V2dV2d", "nc", 
"lsx")
 TARGET_BUILTIN(__builtin_lsx_vfrecip_s, "V4fV4f", "nc", "lsx")
 TARGET_BUILTIN(__builtin_lsx_vfrecip_d, "V2dV2d", "nc", "lsx")
 
+TARGET_BUILTIN(__builtin_lsx_vfrecipe_s, "V4fV4f", "nc", "lsx,frecipe")
+TARGET_BUILTIN(__builtin_lsx_vfrecipe_d, "V2dV2d", "nc", "lsx,frecipe")
+
 TARGET_BUILTIN(__builtin_lsx_vfrsqrt_s, "V4fV4f", "nc", "lsx")
 TARGET_BUILTIN(__builtin_lsx_vfrsqrt_d, "V2dV2d", "nc", "lsx")
 
+TARGET_BUILTIN(__builtin_lsx_vfrsqrte_s, "V4fV4f", "nc", "lsx,frecipe")
+TARGET_BUILTIN(__builtin_lsx_vfrsqrte_d, "V2dV2d", "nc", "lsx,frecipe")
+
 

[llvm] [clang] [LoongArch] Add definitions and feature 'frecipe' for FP approximation intrinsics/builtins (PR #78962)

2024-01-22 Thread Lu Weining via cfe-commits

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


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


[llvm] [clang] [LoongArch] Add definitions and feature 'frecipe' for FP approximation intrinsics/builtins (PR #78962)

2024-01-22 Thread via cfe-commits

Ami-zhang wrote:

@SixWeining  These conflicts have been resolved.

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


[llvm] [compiler-rt] [clang] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

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

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

>From b5c8579c5c8e7ea1e8436348bbf60ecee9c3c799 Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Fri, 19 Jan 2024 09:22:27 +0800
Subject: [PATCH 1/2] [X86] Support more ISAs to enable __builtin_cpu_supports

This patch will also expand supports for attribute/target, while
the priority of newly supported ISAs will be set to zero.
---
 clang/test/CodeGen/target-builtin-noerror.c   |  59 +
 compiler-rt/lib/builtins/cpu_model/x86.c  | 209 +-
 .../llvm/TargetParser/X86TargetParser.def | 135 ++-
 3 files changed, 324 insertions(+), 79 deletions(-)

diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 06bb40a2b71ea9..16097fa08cb9c2 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -84,6 +84,65 @@ void verifyfeaturestrings(void) {
   (void)__builtin_cpu_supports("avx512vp2intersect");
   (void)__builtin_cpu_supports("f16c");
   (void)__builtin_cpu_supports("avx512fp16");
+  (void)__builtin_cpu_supports("3dnow");
+  (void)__builtin_cpu_supports("adx");
+  (void)__builtin_cpu_supports("cldemote");
+  (void)__builtin_cpu_supports("clflushopt");
+  (void)__builtin_cpu_supports("clwb");
+  (void)__builtin_cpu_supports("clzero");
+  (void)__builtin_cpu_supports("cx16");
+  (void)__builtin_cpu_supports("cx8");
+  (void)__builtin_cpu_supports("enqcmd");
+  (void)__builtin_cpu_supports("fsgsbase");
+  (void)__builtin_cpu_supports("lwp");
+  (void)__builtin_cpu_supports("lzcnt");
+  (void)__builtin_cpu_supports("movbe");
+  (void)__builtin_cpu_supports("movdir64b");
+  (void)__builtin_cpu_supports("movdiri");
+  (void)__builtin_cpu_supports("mwaitx");
+  (void)__builtin_cpu_supports("pconfig");
+  (void)__builtin_cpu_supports("pku");
+  (void)__builtin_cpu_supports("prefetchwt1");
+  (void)__builtin_cpu_supports("prfchw");
+  (void)__builtin_cpu_supports("ptwrite");
+  (void)__builtin_cpu_supports("rdpid");
+  (void)__builtin_cpu_supports("rdrnd");
+  (void)__builtin_cpu_supports("rdseed");
+  (void)__builtin_cpu_supports("rtm");
+  (void)__builtin_cpu_supports("serialize");
+  (void)__builtin_cpu_supports("sgx");
+  (void)__builtin_cpu_supports("sha");
+  (void)__builtin_cpu_supports("shstk");
+  (void)__builtin_cpu_supports("tbm");
+  (void)__builtin_cpu_supports("tsxldtrk");
+  (void)__builtin_cpu_supports("vaes");
+  (void)__builtin_cpu_supports("waitpkg");
+  (void)__builtin_cpu_supports("wbnoinvd");
+  (void)__builtin_cpu_supports("xsave");
+  (void)__builtin_cpu_supports("xsavec");
+  (void)__builtin_cpu_supports("xsaveopt");
+  (void)__builtin_cpu_supports("xsaves");
+  (void)__builtin_cpu_supports("amx-tile");
+  (void)__builtin_cpu_supports("amx-int8");
+  (void)__builtin_cpu_supports("amx-bf16");
+  (void)__builtin_cpu_supports("uintr");
+  (void)__builtin_cpu_supports("hreset");
+  (void)__builtin_cpu_supports("kl");
+  (void)__builtin_cpu_supports("widekl");
+  (void)__builtin_cpu_supports("avxvnni");
+  (void)__builtin_cpu_supports("avxifma");
+  (void)__builtin_cpu_supports("avxvnniint8");
+  (void)__builtin_cpu_supports("avxneconvert");
+  (void)__builtin_cpu_supports("cmpccxadd");
+  (void)__builtin_cpu_supports("amx-fp16");
+  (void)__builtin_cpu_supports("prefetchi");
+  (void)__builtin_cpu_supports("raoint");
+  (void)__builtin_cpu_supports("amx-complex");
+  (void)__builtin_cpu_supports("avxvnniint16");
+  (void)__builtin_cpu_supports("sm3");
+  (void)__builtin_cpu_supports("sha512");
+  (void)__builtin_cpu_supports("sm4");
+  (void)__builtin_cpu_supports("usermsr");
 }
 
 void verifycpustrings(void) {
diff --git a/compiler-rt/lib/builtins/cpu_model/x86.c 
b/compiler-rt/lib/builtins/cpu_model/x86.c
index 0750e29f989a8d..c4997548903431 100644
--- a/compiler-rt/lib/builtins/cpu_model/x86.c
+++ b/compiler-rt/lib/builtins/cpu_model/x86.c
@@ -139,20 +139,77 @@ enum ProcessorFeatures {
   FEATURE_AVX512BITALG,
   FEATURE_AVX512BF16,
   FEATURE_AVX512VP2INTERSECT,
+  FEATURE_3DNOW,
+  FEATURE_ADX = 40,
+  FEATURE_CLDEMOTE = 42,
+  FEATURE_CLFLUSHOPT,
+  FEATURE_CLWB,
+  FEATURE_CLZERO,
+  FEATURE_CMPXCHG16B,
+  FEATURE_CMPXCHG8B,
+  FEATURE_ENQCMD,
+  FEATURE_F16C,
+  FEATURE_FSGSBASE,
 
-  FEATURE_CMPXCHG16B = 46,
-  FEATURE_F16C = 49,
   FEATURE_LAHF_LM = 54,
   FEATURE_LM,
-  FEATURE_WP,
+  FEATURE_LWP,
   FEATURE_LZCNT,
   FEATURE_MOVBE,
-
-  FEATURE_AVX512FP16 = 94,
+  FEATURE_MOVDIR64B,
+  FEATURE_MOVDIRI,
+  FEATURE_MWAITX,
+
+  FEATURE_PCONFIG = 63,
+  FEATURE_PKU,
+  FEATURE_PREFETCHWT1,
+  FEATURE_PRFCHW,
+  FEATURE_PTWRITE,
+  FEATURE_RDPID,
+  FEATURE_RDRND,
+  FEATURE_RDSEED,
+  FEATURE_RTM,
+  FEATURE_SERIALIZE,
+  FEATURE_SGX,
+  FEATURE_SHA,
+  FEATURE_SHSTK,
+  FEATURE_TBM,
+  FEATURE_TSXLDTRK,
+  FEATURE_VAES,
+  FEATURE_WAITPKG,
+  FEATURE_WBNOINVD,
+  FEATURE_XSAVE,
+  FEATURE_XSAVEC,
+  FEATURE_XSAVEOPT,
+  FEATURE_XSAVES,
+  FEATURE_AMX_TILE,
+  

[llvm] [clang] [clang-tools-extra] [clang-tidy] Fixes to readability-implicit-bool-conversion (PR #72050)

2024-01-22 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL updated 
https://github.com/llvm/llvm-project/pull/72050

>From 09bc9ecebe2e9d49a690c9864aa09d5b8c4403e4 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Sun, 12 Nov 2023 11:31:21 +
Subject: [PATCH 1/3] [clang-tidy] Fixes to
 readability-implicit-bool-conversion

- Fixed issue with invalid code being generated when static_cast
  is put into fix, and no space were added before it.
- Fixed issue with duplicate parentheses being added when double
  implicit cast is used.
---
 .../ImplicitBoolConversionCheck.cpp   | 22 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  6 +++--
 .../readability/implicit-bool-conversion.cpp  |  9 
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index 11706ffb5b7d4f4..097c9dcd62b5c78 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -151,16 +151,30 @@ StringRef getEquivalentBoolLiteralForExpr(const Expr 
*Expression,
   return {};
 }
 
+bool needsSpacePrefix(SourceLocation Loc, ASTContext ) {
+  SourceRange PrefixRange(Loc.getLocWithOffset(-1), Loc);
+  StringRef SpaceBeforeStmtStr = Lexer::getSourceText(
+  CharSourceRange::getCharRange(PrefixRange), Context.getSourceManager(),
+  Context.getLangOpts(), nullptr);
+  if (SpaceBeforeStmtStr.empty())
+return true;
+
+  const StringRef AllowedCharacters(" \t\n\v\f\r(){}[]<>;,+=-|&~!^*/");
+  return SpaceBeforeStmtStr.rtrim(AllowedCharacters).size() ==
+ SpaceBeforeStmtStr.size();
+}
+
 void fixGenericExprCastFromBool(DiagnosticBuilder ,
 const ImplicitCastExpr *Cast,
 ASTContext , StringRef OtherType) {
   const Expr *SubExpr = Cast->getSubExpr();
-  bool NeedParens = !isa(SubExpr);
+  const bool NeedParens = !isa(SubExpr->IgnoreImplicit());
+  const bool NeedSpace = needsSpacePrefix(Cast->getBeginLoc(), Context);
 
   Diag << FixItHint::CreateInsertion(
-  Cast->getBeginLoc(),
-  (Twine("static_cast<") + OtherType + ">" + (NeedParens ? "(" : ""))
-  .str());
+  Cast->getBeginLoc(), (Twine() + (NeedSpace ? " " : "") + "static_cast<" +
+OtherType + ">" + (NeedParens ? "(" : ""))
+   .str());
 
   if (NeedParens) {
 SourceLocation EndLoc = Lexer::getLocForEndOfToken(
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index d77267588db9158..38befdecd474eb6 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -502,8 +502,10 @@ Changes in existing checks
   ` check to take
   do-while loops into account for the `AllowIntegerConditions` and
   `AllowPointerConditions` options. It also now provides more consistent
-  suggestions when parentheses are added to the return value or expressions. 
-  It also ignores false-positives for comparison containing bool bitfield.
+  suggestions when parentheses are added to the return value or expressions.
+  It also ignores false-positives for comparison containing ``bool`` bitfield.
+  Auto-fix suggestions creating invalid code in certain scenarios have now been
+  fixed.
 
 - Improved :doc:`readability-misleading-indentation
   ` check to ignore
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
index 6f1f29729718875..07e4ca23dbb6bd1 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
@@ -524,3 +524,12 @@ namespace PR71867 {
 // CHECK-FIXES: return (x ? 1 : 0) != 0;
   }
 }
+
+namespace PR71848 {
+  int fun() {
+bool foo = false;
+return( foo );
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicit conversion bool -> 'int' 
[readability-implicit-bool-conversion]
+// CHECK-FIXES: return static_cast( foo );
+  }
+}

>From 0b06b06cd112cdd7aebdd1ea4398afbbf90d8876 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Thu, 18 Jan 2024 19:18:58 +
Subject: [PATCH 2/3] Reworked release notes

---
 clang-tools-extra/docs/ReleaseNotes.rst | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 38befdecd474eb6..29cc5677c0c1ea2 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -501,11 +501,11 @@ Changes in existing checks
 - Improved :doc:`readability-implicit-bool-conversion
   ` check to take
   do-while loops into account for the `AllowIntegerConditions` and
-  

[llvm] [clang] [LoongArch] Add definitions and feature 'frecipe' for FP approximation intrinsics/builtins (PR #78962)

2024-01-22 Thread via cfe-commits

https://github.com/Ami-zhang updated 
https://github.com/llvm/llvm-project/pull/78962

>From ac45bd4b7f9a6f8bae11638ee0b77a4eed64a439 Mon Sep 17 00:00:00 2001
From: zhanglimin 
Date: Mon, 22 Jan 2024 11:10:47 +0800
Subject: [PATCH 1/3] [LoongArch] Add definitions and 'frecipe' feature for FP
 approximation intrinsics

These intrinsics are for floating-point approximate reciprocal
instructions. Enable feature "+frecipe" to constrain FP approximation
instruction patterns. And add some testcases for this implementation.
---
 llvm/include/llvm/IR/IntrinsicsLoongArch.td   | 13 ++
 llvm/lib/Target/LoongArch/LoongArch.td|  7 +
 .../LoongArch/LoongArchFloat32InstrInfo.td|  6 +
 .../LoongArch/LoongArchFloat64InstrInfo.td|  6 +
 .../LoongArch/LoongArchLASXInstrInfo.td   | 10 +++
 .../Target/LoongArch/LoongArchLSXInstrInfo.td | 10 +++
 .../lib/Target/LoongArch/LoongArchSubtarget.h |  2 ++
 .../LoongArch/intrinsic-frecipe-dbl.ll| 26 +++
 .../LoongArch/intrinsic-frecipe-flt.ll| 26 +++
 .../LoongArch/lasx/intrinsic-frecipe.ll   | 26 +++
 .../LoongArch/lasx/intrinsic-frsqrte.ll   | 26 +++
 .../LoongArch/lsx/intrinsic-frecipe.ll| 26 +++
 .../LoongArch/lsx/intrinsic-frsqrte.ll| 26 +++
 13 files changed, 210 insertions(+)
 create mode 100644 llvm/test/CodeGen/LoongArch/intrinsic-frecipe-dbl.ll
 create mode 100644 llvm/test/CodeGen/LoongArch/intrinsic-frecipe-flt.ll
 create mode 100644 llvm/test/CodeGen/LoongArch/lasx/intrinsic-frecipe.ll
 create mode 100644 llvm/test/CodeGen/LoongArch/lasx/intrinsic-frsqrte.ll
 create mode 100644 llvm/test/CodeGen/LoongArch/lsx/intrinsic-frecipe.ll
 create mode 100644 llvm/test/CodeGen/LoongArch/lsx/intrinsic-frsqrte.ll

diff --git a/llvm/include/llvm/IR/IntrinsicsLoongArch.td 
b/llvm/include/llvm/IR/IntrinsicsLoongArch.td
index 685deaec7709bd7..9002076e7aecea6 100644
--- a/llvm/include/llvm/IR/IntrinsicsLoongArch.td
+++ b/llvm/include/llvm/IR/IntrinsicsLoongArch.td
@@ -122,6 +122,15 @@ def int_loongarch_lddir_d : BaseInt<[llvm_i64_ty], 
[llvm_i64_ty, llvm_i64_ty],
 [ImmArg>]>;
 def int_loongarch_ldpte_d : BaseInt<[], [llvm_i64_ty, llvm_i64_ty],
 [ImmArg>]>;
+
+def int_loongarch_frecipe_s : BaseInt<[llvm_float_ty], [llvm_float_ty],
+  [IntrNoMem]>;
+def int_loongarch_frecipe_d : BaseInt<[llvm_double_ty], [llvm_double_ty],
+  [IntrNoMem]>;
+def int_loongarch_frsqrte_s : BaseInt<[llvm_float_ty], [llvm_float_ty],
+  [IntrNoMem]>;
+def int_loongarch_frsqrte_d : BaseInt<[llvm_double_ty], [llvm_double_ty],
+  [IntrNoMem]>;
 } // TargetPrefix = "loongarch"
 
 /// Vector intrinsic
@@ -527,10 +536,12 @@ foreach inst = ["vfmadd_d", "vfmsub_d", "vfnmadd_d", 
"vfnmsub_d"] in
  [IntrNoMem]>;
 
 foreach inst = ["vflogb_s", "vfsqrt_s", "vfrecip_s", "vfrsqrt_s", "vfrint_s",
+"vfrecipe_s", "vfrsqrte_s",
 "vfrintrne_s", "vfrintrz_s", "vfrintrp_s", "vfrintrm_s"] in
   def int_loongarch_lsx_#inst : VecInt<[llvm_v4f32_ty], [llvm_v4f32_ty],
[IntrNoMem]>;
 foreach inst = ["vflogb_d", "vfsqrt_d", "vfrecip_d", "vfrsqrt_d", "vfrint_d",
+"vfrecipe_d", "vfrsqrte_d",
 "vfrintrne_d", "vfrintrz_d", "vfrintrp_d", "vfrintrm_d"] in
   def int_loongarch_lsx_#inst : VecInt<[llvm_v2f64_ty], [llvm_v2f64_ty],
[IntrNoMem]>;
@@ -1044,10 +1055,12 @@ foreach inst = ["xvfmadd_d", "xvfmsub_d", "xvfnmadd_d", 
"xvfnmsub_d"] in
  [IntrNoMem]>;
 
 foreach inst = ["xvflogb_s", "xvfsqrt_s", "xvfrecip_s", "xvfrsqrt_s", 
"xvfrint_s",
+"xvfrecipe_s", "xvfrsqrte_s",
 "xvfrintrne_s", "xvfrintrz_s", "xvfrintrp_s", "xvfrintrm_s"] in
   def int_loongarch_lasx_#inst : VecInt<[llvm_v8f32_ty], [llvm_v8f32_ty],
 [IntrNoMem]>;
 foreach inst = ["xvflogb_d", "xvfsqrt_d", "xvfrecip_d", "xvfrsqrt_d", 
"xvfrint_d",
+"xvfrecipe_d", "xvfrsqrte_d",
 "xvfrintrne_d", "xvfrintrz_d", "xvfrintrp_d", "xvfrintrm_d"] in
   def int_loongarch_lasx_#inst : VecInt<[llvm_v4f64_ty], [llvm_v4f64_ty],
 [IntrNoMem]>;
diff --git a/llvm/lib/Target/LoongArch/LoongArch.td 
b/llvm/lib/Target/LoongArch/LoongArch.td
index 4cffaf573b918ab..c2a669931d78fe7 100644
--- a/llvm/lib/Target/LoongArch/LoongArch.td
+++ b/llvm/lib/Target/LoongArch/LoongArch.td
@@ -111,6 +111,13 @@ def FeatureAutoVec
 : SubtargetFeature<"auto-vec", "HasExpAutoVec", "true",
"Experimental auto vectorization">;
 
+// Floating point approximation operation
+def FeatureFrecipe
+: 

[clang] [llvm] [RISCV] Relax march string order constraint (PR #78120)

2024-01-22 Thread Craig Topper via cfe-commits


@@ -715,6 +815,8 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool 
EnableExperimentalExtension,
 
   unsigned XLen = HasRV64 ? 64 : 32;
   std::unique_ptr ISAInfo(new RISCVISAInfo(XLen));
+  SmallVector SeenExts;

topperc wrote:

Maybe SeenExts should be a SetVector to make it more efficient to check for 
duplicates?

Or maybe a MapVector storing the version as the value so we don't need 
ExtsVersion?

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


[llvm] [clang] [RISCV] Relax march string order constraint (PR #78120)

2024-01-22 Thread Craig Topper via cfe-commits


@@ -695,6 +695,106 @@ RISCVISAInfo::parseNormalizedArchString(StringRef Arch) {
   return std::move(ISAInfo);
 }
 
+static Error splitExtsByUnderscore(StringRef Exts,
+   std::vector ) {

topperc wrote:

`SplitExts`

Splitted has two `t`s but I don't think the `ed` is needed.

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


[llvm] [compiler-rt] [clang] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

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

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


[llvm] [clang] Arm64EC entry/exit thunks, consolidated. (PR #79067)

2024-01-22 Thread Eli Friedman via cfe-commits

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


[compiler-rt] [clang] [llvm] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

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


@@ -173,85 +173,84 @@ X86_FEATURE_COMPAT(AVX512VNNI,  "avx512vnni", 
   34)
 X86_FEATURE_COMPAT(AVX512BITALG,"avx512bitalg",  35)
 X86_FEATURE_COMPAT(AVX512BF16,  "avx512bf16",36)
 X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 37)
-// Features below here are not in libgcc/compiler-rt.
-X86_FEATURE   (3DNOW,   "3dnow")
+X86_FEATURE_COMPAT(3DNOW,   "3dnow",  0)
 X86_FEATURE   (3DNOWA,  "3dnowa")
+X86_FEATURE_COMPAT(ADX, "adx",0)
 X86_FEATURE   (64BIT,   "64bit")
-X86_FEATURE   (ADX, "adx")
-X86_FEATURE   (AMX_BF16,"amx-bf16")
-X86_FEATURE   (AMX_COMPLEX, "amx-complex")
-X86_FEATURE   (AMX_INT8,"amx-int8")
-X86_FEATURE   (AMX_TILE,"amx-tile")
-X86_FEATURE   (CLDEMOTE,"cldemote")
-X86_FEATURE   (CLFLUSHOPT,  "clflushopt")
-X86_FEATURE   (CLWB,"clwb")
-X86_FEATURE_COMPAT(F16C,"f16c",  38)
-X86_FEATURE   (CLZERO,  "clzero")
-X86_FEATURE   (CMPXCHG16B,  "cx16")
-X86_FEATURE   (CMPXCHG8B,   "cx8")
+X86_FEATURE_COMPAT(CLDEMOTE,"cldemote",   0)
+X86_FEATURE_COMPAT(CLFLUSHOPT,  "clflushopt", 0)
+X86_FEATURE_COMPAT(CLWB,"clwb",   0)
+X86_FEATURE_COMPAT(CLZERO,  "clzero", 0)
+X86_FEATURE_COMPAT(CMPXCHG16B,  "cx16",   0)
+X86_FEATURE_COMPAT(CMPXCHG8B,   "cx8",0)
+X86_FEATURE_COMPAT(ENQCMD,  "enqcmd", 0)
+X86_FEATURE_COMPAT(F16C,"f16c",   0)
+X86_FEATURE_COMPAT(FSGSBASE,"fsgsbase",   0)
 X86_FEATURE   (CRC32,   "crc32")
-X86_FEATURE   (ENQCMD,  "enqcmd")
-X86_FEATURE   (FSGSBASE,"fsgsbase")
-X86_FEATURE   (FXSR,"fxsr")
 X86_FEATURE   (INVPCID, "invpcid")
-X86_FEATURE   (KL,  "kl")
-X86_FEATURE   (WIDEKL,  "widekl")
-X86_FEATURE   (LWP, "lwp")
-X86_FEATURE   (LZCNT,   "lzcnt")
-X86_FEATURE   (MOVBE,   "movbe")
-X86_FEATURE   (MOVDIR64B,   "movdir64b")
-X86_FEATURE   (MOVDIRI, "movdiri")
-X86_FEATURE   (MWAITX,  "mwaitx")
-X86_FEATURE   (PCONFIG, "pconfig")
-X86_FEATURE   (PKU, "pku")
-X86_FEATURE   (PREFETCHI,   "prefetchi")
-X86_FEATURE   (PREFETCHWT1, "prefetchwt1")
-X86_FEATURE   (PRFCHW,  "prfchw")
-X86_FEATURE   (PTWRITE, "ptwrite")
-X86_FEATURE   (RDPID,   "rdpid")
 X86_FEATURE   (RDPRU,   "rdpru")
-X86_FEATURE   (RDRND,   "rdrnd")
-X86_FEATURE   (RDSEED,  "rdseed")
-X86_FEATURE   (RTM, "rtm")
 X86_FEATURE   (SAHF,"sahf")
-X86_FEATURE   (SERIALIZE,   "serialize")
-X86_FEATURE   (SGX, "sgx")
-X86_FEATURE   (SHA, "sha")
-X86_FEATURE   (SHSTK,   "shstk")
-X86_FEATURE   (TBM, "tbm")
-X86_FEATURE   (TSXLDTRK,"tsxldtrk")
-X86_FEATURE   (UINTR,   "uintr")
-X86_FEATURE   (VAES,"vaes")
 X86_FEATURE   (VZEROUPPER,  "vzeroupper")
-X86_FEATURE   (WAITPKG, "waitpkg")
-X86_FEATURE   (WBNOINVD,"wbnoinvd")
+X86_FEATURE_COMPAT(LWP, "lwp",0)
+X86_FEATURE_COMPAT(LZCNT,   "lzcnt",  0)
+X86_FEATURE_COMPAT(MOVBE,   "movbe",  0)
+X86_FEATURE_COMPAT(MOVDIR64B,   "movdir64b",  0)
+X86_FEATURE_COMPAT(MOVDIRI, "movdiri",0)
+X86_FEATURE_COMPAT(MWAITX,  "mwaitx", 0)
 X86_FEATURE   (X87, "x87")
-X86_FEATURE   (XSAVE,   "xsave")
-X86_FEATURE   (XSAVEC,  "xsavec")
-X86_FEATURE   (XSAVEOPT,"xsaveopt")
-X86_FEATURE   (XSAVES,  "xsaves")
-X86_FEATURE_COMPAT(AVX512FP16,  "avx512fp16",39)
-X86_FEATURE   (HRESET,  "hreset")
-X86_FEATURE   (RAOINT,  "raoint")
-X86_FEATURE   (AMX_FP16,"amx-fp16")
-X86_FEATURE   (CMPCCXADD,   "cmpccxadd")
-X86_FEATURE   (AVXNECONVERT,"avxneconvert")
-X86_FEATURE   (AVXVNNI, "avxvnni")
-X86_FEATURE   (AVXIFMA, "avxifma")
-X86_FEATURE   (AVXVNNIINT8, "avxvnniint8")
-X86_FEATURE   (SHA512,  "sha512")
-X86_FEATURE   (SM3, "sm3")
-X86_FEATURE   (SM4, "sm4")
-X86_FEATURE   (AVXVNNIINT16,"avxvnniint16")
-X86_FEATURE   (EVEX512, "evex512")
-X86_FEATURE   (AVX10_1, "avx10.1-256")
-X86_FEATURE   (AVX10_1_512, "avx10.1-512")
-X86_FEATURE   (USERMSR, "usermsr")
-X86_FEATURE   

[clang] [llvm] [RISCV] RISCV vector calling convention (1/2) (PR #77560)

2024-01-22 Thread Craig Topper via cfe-commits


@@ -692,8 +692,71 @@ define <16 x i64> @fshr_v16i64(<16 x i64> %a, <16 x i64> 
%b, <16 x i64> %c, <16
 ; CHECK-NEXT:csrr a0, vlenb
 ; CHECK-NEXT:slli a0, a0, 3
 ; CHECK-NEXT:add sp, sp, a0
+; CHECK-NEXT:.cfi_def_cfa sp, 16
 ; CHECK-NEXT:addi sp, sp, 16
 ; CHECK-NEXT:ret
+; RV32-LABEL: fshr_v16i64:

topperc wrote:

There's something weird with the CHECK lines here. How do we have CHECK and 
RV32 and RV64?

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


[llvm] [clang] [RISCV] RISCV vector calling convention (1/2) (PR #77560)

2024-01-22 Thread Craig Topper via cfe-commits


@@ -24,6 +24,19 @@ def CSR_ILP32D_LP64D
 : CalleeSavedRegs<(add CSR_ILP32_LP64,
F8_D, F9_D, (sequence "F%u_D", 18, 27))>;
 
+defvar CSR_V = (add (sequence "V%u", 1, 7), (sequence "V%u", 24, 31),
+ V2M2, V4M2, V6M2, V24M2, V26M2, V28M2, V30M2,

topperc wrote:

Ok thanks

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


[llvm] [clang] [RISCV] RISCV vector calling convention (1/2) (PR #77560)

2024-01-22 Thread Craig Topper via cfe-commits


@@ -0,0 +1,27 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v \
+// RUN:   -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-LLVM %s
+
+#include 
+
+// CHECK-LLVM: call riscv_vector_cc  @bar
+vint32m1_t __attribute__((riscv_vector_cc)) bar(vint32m1_t input);
+vint32m1_t test_vector_cc_attr(vint32m1_t input, int32_t *base, size_t vl) {
+  vint32m1_t ret;
+  vint32m1_t val;
+  val = __riscv_vle32_v_i32m1(base, vl);
+  ret = bar(input);
+  __riscv_vse32_v_i32m1(base, val, vl);
+  return ret;
+}
+
+// CHECK-LLVM: call  @baz
+vint32m1_t baz(vint32m1_t input);
+vint32m1_t test_no_vector_cc_attr(vint32m1_t input, int32_t *base, size_t vl) {
+  vint32m1_t ret;
+  vint32m1_t val;
+  val = __riscv_vle32_v_i32m1(base, vl);

topperc wrote:

Same here

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


[clang] [llvm] [RISCV] RISCV vector calling convention (1/2) (PR #77560)

2024-01-22 Thread Craig Topper via cfe-commits


@@ -1006,15 +1077,24 @@ 
RISCVFrameLowering::assignRVVStackObjectOffsets(MachineFunction ) const {
   MachineFrameInfo  = MF.getFrameInfo();
   // Create a buffer of RVV objects to allocate.
   SmallVector ObjectsToAllocate;
-  for (int I = 0, E = MFI.getObjectIndexEnd(); I != E; ++I) {
-unsigned StackID = MFI.getStackID(I);
-if (StackID != TargetStackID::ScalableVector)
-  continue;
-if (MFI.isDeadObjectIndex(I))
-  continue;
+  auto pushRVVObjects = [&](int FIBegin, int FIEnd) {
+for (int I = FIBegin, E = FIEnd; I != E; ++I) {
+  unsigned StackID = MFI.getStackID(I);
+  if (StackID != TargetStackID::ScalableVector)
+continue;
+  if (MFI.isDeadObjectIndex(I))
+continue;
 
-ObjectsToAllocate.push_back(I);
-  }
+  ObjectsToAllocate.push_back(I);
+}
+  };
+  // First push RVV Callee Saved object, then push RVV stack object
+  std::vector  = MF.getFrameInfo().getCalleeSavedInfo();
+  const auto  = getRVVCalleeSavedInfo(MF, CSI);
+  if (RVVCSI.size())

topperc wrote:

`!RVVCSI.empty()`?

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


[clang] [llvm] [RISCV] RISCV vector calling convention (1/2) (PR #77560)

2024-01-22 Thread Craig Topper via cfe-commits


@@ -0,0 +1,27 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v \
+// RUN:   -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-LLVM %s
+
+#include 
+
+// CHECK-LLVM: call riscv_vector_cc  @bar
+vint32m1_t __attribute__((riscv_vector_cc)) bar(vint32m1_t input);
+vint32m1_t test_vector_cc_attr(vint32m1_t input, int32_t *base, size_t vl) {
+  vint32m1_t ret;
+  vint32m1_t val;
+  val = __riscv_vle32_v_i32m1(base, vl);

topperc wrote:

Can we declare the variables on the same line as the assignment?

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


[clang] [Clang][Sema] fix outline member function template with default align crash (PR #78400)

2024-01-22 Thread Qizhi Hu via cfe-commits


@@ -3063,11 +3064,18 @@ bool Sema::SubstDefaultArgument(
   /*ForDefinition*/ false);
   if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
 return true;
+  if (FD->isOutOfLine()) {
+auto *CurrentTemplateArgumentList = TemplateArgumentList::CreateCopy(
+getASTContext(), TemplateArgs.getInnermost());
+NewTemplateArgs = getTemplateInstantiationArgs(
+FD, FD->getDeclContext(), true, CurrentTemplateArgumentList, true,
+nullptr, false, false);

jcsxky wrote:

All review has been applied.

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


[llvm] [compiler-rt] [clang] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

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


@@ -173,85 +173,84 @@ X86_FEATURE_COMPAT(AVX512VNNI,  "avx512vnni", 
   34)
 X86_FEATURE_COMPAT(AVX512BITALG,"avx512bitalg",  35)
 X86_FEATURE_COMPAT(AVX512BF16,  "avx512bf16",36)
 X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 37)
-// Features below here are not in libgcc/compiler-rt.
-X86_FEATURE   (3DNOW,   "3dnow")
+X86_FEATURE_COMPAT(3DNOW,   "3dnow",  0)
 X86_FEATURE   (3DNOWA,  "3dnowa")
+X86_FEATURE_COMPAT(ADX, "adx",0)
 X86_FEATURE   (64BIT,   "64bit")
-X86_FEATURE   (ADX, "adx")
-X86_FEATURE   (AMX_BF16,"amx-bf16")
-X86_FEATURE   (AMX_COMPLEX, "amx-complex")
-X86_FEATURE   (AMX_INT8,"amx-int8")
-X86_FEATURE   (AMX_TILE,"amx-tile")
-X86_FEATURE   (CLDEMOTE,"cldemote")
-X86_FEATURE   (CLFLUSHOPT,  "clflushopt")
-X86_FEATURE   (CLWB,"clwb")
-X86_FEATURE_COMPAT(F16C,"f16c",  38)
-X86_FEATURE   (CLZERO,  "clzero")
-X86_FEATURE   (CMPXCHG16B,  "cx16")
-X86_FEATURE   (CMPXCHG8B,   "cx8")
+X86_FEATURE_COMPAT(CLDEMOTE,"cldemote",   0)
+X86_FEATURE_COMPAT(CLFLUSHOPT,  "clflushopt", 0)
+X86_FEATURE_COMPAT(CLWB,"clwb",   0)
+X86_FEATURE_COMPAT(CLZERO,  "clzero", 0)
+X86_FEATURE_COMPAT(CMPXCHG16B,  "cx16",   0)
+X86_FEATURE_COMPAT(CMPXCHG8B,   "cx8",0)
+X86_FEATURE_COMPAT(ENQCMD,  "enqcmd", 0)
+X86_FEATURE_COMPAT(F16C,"f16c",   0)

FreddyLeaf wrote:

first `f16c` should not be set higher priority than `avx512f`. higher priority 
means it can imply all the ISAs lower than it.

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


[clang] [llvm] [libunwind] [compiler-rt] [libc] [flang] [lld] [libcxx] [lldb] [libclc] [clang-tools-extra] [libcxxabi] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

2024-01-22 Thread Fangrui Song via cfe-commits

MaskRay wrote:

This PR needs a rebase.. There are quite a few merge commits. Hmm, I don't know 
how to squash the changes to rebase them to latest main branch. `git rebase 
--keep-base -i main` has quite a few merge conflicts.

(My lld change (https://github.com/maskray/llvm-project/tree/rv-tlsdesc) is 
almost complete. I want to rebase it onto the latest revision of this LLVM PR.)

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


[clang] [llvm] [compiler-rt] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

2024-01-22 Thread Phoebe Wang via cfe-commits


@@ -173,85 +173,84 @@ X86_FEATURE_COMPAT(AVX512VNNI,  "avx512vnni", 
   34)
 X86_FEATURE_COMPAT(AVX512BITALG,"avx512bitalg",  35)
 X86_FEATURE_COMPAT(AVX512BF16,  "avx512bf16",36)
 X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 37)
-// Features below here are not in libgcc/compiler-rt.
-X86_FEATURE   (3DNOW,   "3dnow")
+X86_FEATURE_COMPAT(3DNOW,   "3dnow",  0)
 X86_FEATURE   (3DNOWA,  "3dnowa")
+X86_FEATURE_COMPAT(ADX, "adx",0)
 X86_FEATURE   (64BIT,   "64bit")
-X86_FEATURE   (ADX, "adx")
-X86_FEATURE   (AMX_BF16,"amx-bf16")
-X86_FEATURE   (AMX_COMPLEX, "amx-complex")
-X86_FEATURE   (AMX_INT8,"amx-int8")
-X86_FEATURE   (AMX_TILE,"amx-tile")
-X86_FEATURE   (CLDEMOTE,"cldemote")
-X86_FEATURE   (CLFLUSHOPT,  "clflushopt")
-X86_FEATURE   (CLWB,"clwb")
-X86_FEATURE_COMPAT(F16C,"f16c",  38)
-X86_FEATURE   (CLZERO,  "clzero")
-X86_FEATURE   (CMPXCHG16B,  "cx16")
-X86_FEATURE   (CMPXCHG8B,   "cx8")
+X86_FEATURE_COMPAT(CLDEMOTE,"cldemote",   0)
+X86_FEATURE_COMPAT(CLFLUSHOPT,  "clflushopt", 0)
+X86_FEATURE_COMPAT(CLWB,"clwb",   0)
+X86_FEATURE_COMPAT(CLZERO,  "clzero", 0)
+X86_FEATURE_COMPAT(CMPXCHG16B,  "cx16",   0)
+X86_FEATURE_COMPAT(CMPXCHG8B,   "cx8",0)
+X86_FEATURE_COMPAT(ENQCMD,  "enqcmd", 0)
+X86_FEATURE_COMPAT(F16C,"f16c",   0)
+X86_FEATURE_COMPAT(FSGSBASE,"fsgsbase",   0)
 X86_FEATURE   (CRC32,   "crc32")
-X86_FEATURE   (ENQCMD,  "enqcmd")
-X86_FEATURE   (FSGSBASE,"fsgsbase")
-X86_FEATURE   (FXSR,"fxsr")
 X86_FEATURE   (INVPCID, "invpcid")
-X86_FEATURE   (KL,  "kl")
-X86_FEATURE   (WIDEKL,  "widekl")
-X86_FEATURE   (LWP, "lwp")
-X86_FEATURE   (LZCNT,   "lzcnt")
-X86_FEATURE   (MOVBE,   "movbe")
-X86_FEATURE   (MOVDIR64B,   "movdir64b")
-X86_FEATURE   (MOVDIRI, "movdiri")
-X86_FEATURE   (MWAITX,  "mwaitx")
-X86_FEATURE   (PCONFIG, "pconfig")
-X86_FEATURE   (PKU, "pku")
-X86_FEATURE   (PREFETCHI,   "prefetchi")
-X86_FEATURE   (PREFETCHWT1, "prefetchwt1")
-X86_FEATURE   (PRFCHW,  "prfchw")
-X86_FEATURE   (PTWRITE, "ptwrite")
-X86_FEATURE   (RDPID,   "rdpid")
 X86_FEATURE   (RDPRU,   "rdpru")
-X86_FEATURE   (RDRND,   "rdrnd")
-X86_FEATURE   (RDSEED,  "rdseed")
-X86_FEATURE   (RTM, "rtm")
 X86_FEATURE   (SAHF,"sahf")
-X86_FEATURE   (SERIALIZE,   "serialize")
-X86_FEATURE   (SGX, "sgx")
-X86_FEATURE   (SHA, "sha")
-X86_FEATURE   (SHSTK,   "shstk")
-X86_FEATURE   (TBM, "tbm")
-X86_FEATURE   (TSXLDTRK,"tsxldtrk")
-X86_FEATURE   (UINTR,   "uintr")
-X86_FEATURE   (VAES,"vaes")
 X86_FEATURE   (VZEROUPPER,  "vzeroupper")
-X86_FEATURE   (WAITPKG, "waitpkg")
-X86_FEATURE   (WBNOINVD,"wbnoinvd")
+X86_FEATURE_COMPAT(LWP, "lwp",0)
+X86_FEATURE_COMPAT(LZCNT,   "lzcnt",  0)
+X86_FEATURE_COMPAT(MOVBE,   "movbe",  0)
+X86_FEATURE_COMPAT(MOVDIR64B,   "movdir64b",  0)
+X86_FEATURE_COMPAT(MOVDIRI, "movdiri",0)
+X86_FEATURE_COMPAT(MWAITX,  "mwaitx", 0)
 X86_FEATURE   (X87, "x87")
-X86_FEATURE   (XSAVE,   "xsave")
-X86_FEATURE   (XSAVEC,  "xsavec")
-X86_FEATURE   (XSAVEOPT,"xsaveopt")
-X86_FEATURE   (XSAVES,  "xsaves")
-X86_FEATURE_COMPAT(AVX512FP16,  "avx512fp16",39)
-X86_FEATURE   (HRESET,  "hreset")
-X86_FEATURE   (RAOINT,  "raoint")
-X86_FEATURE   (AMX_FP16,"amx-fp16")
-X86_FEATURE   (CMPCCXADD,   "cmpccxadd")
-X86_FEATURE   (AVXNECONVERT,"avxneconvert")
-X86_FEATURE   (AVXVNNI, "avxvnni")
-X86_FEATURE   (AVXIFMA, "avxifma")
-X86_FEATURE   (AVXVNNIINT8, "avxvnniint8")
-X86_FEATURE   (SHA512,  "sha512")
-X86_FEATURE   (SM3, "sm3")
-X86_FEATURE   (SM4, "sm4")
-X86_FEATURE   (AVXVNNIINT16,"avxvnniint16")
-X86_FEATURE   (EVEX512, "evex512")
-X86_FEATURE   (AVX10_1, "avx10.1-256")
-X86_FEATURE   (AVX10_1_512, "avx10.1-512")
-X86_FEATURE   (USERMSR, "usermsr")
-X86_FEATURE   

[clang] [llvm] [compiler-rt] [X86] Support more ISAs to enable __builtin_cpu_supports (PR #79086)

2024-01-22 Thread Phoebe Wang via cfe-commits


@@ -173,85 +173,84 @@ X86_FEATURE_COMPAT(AVX512VNNI,  "avx512vnni", 
   34)
 X86_FEATURE_COMPAT(AVX512BITALG,"avx512bitalg",  35)
 X86_FEATURE_COMPAT(AVX512BF16,  "avx512bf16",36)
 X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 37)
-// Features below here are not in libgcc/compiler-rt.
-X86_FEATURE   (3DNOW,   "3dnow")
+X86_FEATURE_COMPAT(3DNOW,   "3dnow",  0)
 X86_FEATURE   (3DNOWA,  "3dnowa")
+X86_FEATURE_COMPAT(ADX, "adx",0)
 X86_FEATURE   (64BIT,   "64bit")
-X86_FEATURE   (ADX, "adx")
-X86_FEATURE   (AMX_BF16,"amx-bf16")
-X86_FEATURE   (AMX_COMPLEX, "amx-complex")
-X86_FEATURE   (AMX_INT8,"amx-int8")
-X86_FEATURE   (AMX_TILE,"amx-tile")
-X86_FEATURE   (CLDEMOTE,"cldemote")
-X86_FEATURE   (CLFLUSHOPT,  "clflushopt")
-X86_FEATURE   (CLWB,"clwb")
-X86_FEATURE_COMPAT(F16C,"f16c",  38)
-X86_FEATURE   (CLZERO,  "clzero")
-X86_FEATURE   (CMPXCHG16B,  "cx16")
-X86_FEATURE   (CMPXCHG8B,   "cx8")
+X86_FEATURE_COMPAT(CLDEMOTE,"cldemote",   0)
+X86_FEATURE_COMPAT(CLFLUSHOPT,  "clflushopt", 0)
+X86_FEATURE_COMPAT(CLWB,"clwb",   0)
+X86_FEATURE_COMPAT(CLZERO,  "clzero", 0)
+X86_FEATURE_COMPAT(CMPXCHG16B,  "cx16",   0)
+X86_FEATURE_COMPAT(CMPXCHG8B,   "cx8",0)
+X86_FEATURE_COMPAT(ENQCMD,  "enqcmd", 0)
+X86_FEATURE_COMPAT(F16C,"f16c",   0)

phoebewang wrote:

Why clear the previous number?

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


[clang] [clang-format] Add SpacesInParensOption for attributes and filtering for repeated parens (PR #77522)

2024-01-22 Thread Gedare Bloom via cfe-commits

gedare wrote:

* Rebased to resolve conflict in ReleaseNotes.
* Added `ExceptDoubleParentheses` as proposed by @owenca 

This seems to work reasonably well for the cases I care about, as far as I can 
tell.

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


[clang] [clang] Fix behavior of `__is_trivially_relocatable(volatile int)` (PR #77092)

2024-01-22 Thread Amirreza Ashouri via cfe-commits

AMP999 wrote:

> I don't have a good idea here... I don't really know what it means to 
> 'relocate' a volatile.  

This PR doesn't take a position on what it means to relocate a volatile; it 
just makes the type-trait return the correct value on cv-qualified types, for 
consistency with `__is_trivially_copyable` and to implement the current 
Standard proposals.

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


[clang] [llvm] Arm64EC entry/exit thunks, consolidated. (PR #79067)

2024-01-22 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

(I'm going to ignore the indentation issues here, and address in a followup.)

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


[clang] [Clang][Sema] fix outline member function template with default align crash (PR #78400)

2024-01-22 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/78400

>From 852e2d26ee3433e09978da93dfe6303faac92876 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Wed, 17 Jan 2024 14:16:34 +0800
Subject: [PATCH] [Clang][Sema] fix outline member function template with
 default align crash

---
 clang/docs/ReleaseNotes.rst   |  3 ++
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 13 -
 clang/test/SemaTemplate/default-parm-init.cpp | 50 +++
 3 files changed, 64 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/SemaTemplate/default-parm-init.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cb15dfb99bec977..bff8e496cbeed5f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -859,6 +859,9 @@ Bug Fixes in This Version
   Fixes (`#78290 `_)
 - Fixed assertion failure with deleted overloaded unary operators.
   Fixes (`#78314 `_)
+- Fix crash when specialize out-of-line member function with default parameter
+  and issue with incorrect specialization of the initialization of default 
parameter.
+  Fixes (`#68490 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index e12186d7d82f8d0..41e58b91de4e08e 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3049,6 +3049,7 @@ bool Sema::SubstDefaultArgument(
 //   default argument expression appears.
 ContextRAII SavedContext(*this, FD);
 std::unique_ptr LIS;
+MultiLevelTemplateArgumentList NewTemplateArgs = TemplateArgs;
 
 if (ForCallExpr) {
   // When instantiating a default argument due to use in a call expression,
@@ -3061,11 +3062,19 @@ bool Sema::SubstDefaultArgument(
   /*ForDefinition*/ false);
   if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
 return true;
+  if (FD->isOutOfLine()) {
+TemplateArgumentList *CurrentTemplateArgumentList =
+TemplateArgumentList::CreateCopy(getASTContext(),
+ TemplateArgs.getInnermost());
+NewTemplateArgs = getTemplateInstantiationArgs(
+FD, FD->getDeclContext(), /*Final=*/false,
+CurrentTemplateArgumentList, /*RelativeToPrimary=*/true);
+  }
 }
 
 runWithSufficientStackSpace(Loc, [&] {
-  Result = SubstInitializer(PatternExpr, TemplateArgs,
-/*DirectInit*/false);
+  Result = SubstInitializer(PatternExpr, NewTemplateArgs,
+/*DirectInit*/ false);
 });
   }
   if (Result.isInvalid())
diff --git a/clang/test/SemaTemplate/default-parm-init.cpp 
b/clang/test/SemaTemplate/default-parm-init.cpp
new file mode 100644
index 000..4bcea7eaa101763
--- /dev/null
+++ b/clang/test/SemaTemplate/default-parm-init.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+template
+struct Problem{
+  template
+  constexpr int FuncAlign(int param = alignof(FunctionTemplateParam));
+
+  template
+  constexpr int FuncSizeof(int param = sizeof(FunctionTemplateParam));
+
+  template
+  constexpr int FuncAlign2(int param = alignof(TemplateParam));
+
+  template
+  constexpr int FuncSizeof2(int param = sizeof(TemplateParam));
+};
+
+template <>
+template
+constexpr int Problem::FuncAlign(int param) {
+   return param;
+}
+
+template <>
+template
+constexpr int Problem::FuncSizeof(int param) {
+   return param;
+}
+
+template <>
+template
+constexpr int Problem::FuncAlign2(int param) {
+   return param;
+}
+
+template <>
+template
+constexpr int Problem::FuncSizeof2(int param) {
+   return param;
+}
+
+int main(){
+Problem p = {};
+static_assert(p.FuncAlign() == alignof(char));
+static_assert(p.FuncSizeof() == sizeof(char));
+static_assert(p.FuncAlign2() == alignof(int));
+static_assert(p.FuncSizeof2() == sizeof(int));
+}

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


[clang] [Clang][Sema] fix outline member function template with default align crash (PR #78400)

2024-01-22 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/78400

>From b9de8c52a2ffbd03c8a5368f6e62ba6c68ce2125 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Wed, 17 Jan 2024 14:16:34 +0800
Subject: [PATCH] [Clang][Sema] fix outline member function template with
 default align crash

---
 clang/docs/ReleaseNotes.rst   |  3 ++
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 13 -
 clang/test/SemaTemplate/default-parm-init.cpp | 50 +++
 3 files changed, 64 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/SemaTemplate/default-parm-init.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8bb26fcae18d6b..ccdce2c299b022 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -828,6 +828,9 @@ Bug Fixes in This Version
 - Fix an issue with missing symbol definitions when the first coroutine
   statement appears in a discarded ``if constexpr`` branch.
   Fixes (`#78290 `_)
+- Fix crash when specialize out-of-line member function with default parameter
+  and issue with incorrect specialization of the initialization of default 
parameter.
+  Fixes (`#68490 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index fc80515b45e35b..d310dfdd61c600 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3051,6 +3051,7 @@ bool Sema::SubstDefaultArgument(
 //   default argument expression appears.
 ContextRAII SavedContext(*this, FD);
 std::unique_ptr LIS;
+MultiLevelTemplateArgumentList NewTemplateArgs = TemplateArgs;
 
 if (ForCallExpr) {
   // When instantiating a default argument due to use in a call expression,
@@ -3063,11 +3064,19 @@ bool Sema::SubstDefaultArgument(
   /*ForDefinition*/ false);
   if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
 return true;
+  if (FD->isOutOfLine()) {
+TemplateArgumentList *CurrentTemplateArgumentList =
+TemplateArgumentList::CreateCopy(getASTContext(),
+ TemplateArgs.getInnermost());
+NewTemplateArgs = getTemplateInstantiationArgs(
+FD, FD->getDeclContext(), /*Final=*/false,
+CurrentTemplateArgumentList, /*RelativeToPrimary=*/true);
+  }
 }
 
 runWithSufficientStackSpace(Loc, [&] {
-  Result = SubstInitializer(PatternExpr, TemplateArgs,
-/*DirectInit*/false);
+  Result = SubstInitializer(PatternExpr, NewTemplateArgs,
+/*DirectInit*/ false);
 });
   }
   if (Result.isInvalid())
diff --git a/clang/test/SemaTemplate/default-parm-init.cpp 
b/clang/test/SemaTemplate/default-parm-init.cpp
new file mode 100644
index 00..4bcea7eaa10176
--- /dev/null
+++ b/clang/test/SemaTemplate/default-parm-init.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+template
+struct Problem{
+  template
+  constexpr int FuncAlign(int param = alignof(FunctionTemplateParam));
+
+  template
+  constexpr int FuncSizeof(int param = sizeof(FunctionTemplateParam));
+
+  template
+  constexpr int FuncAlign2(int param = alignof(TemplateParam));
+
+  template
+  constexpr int FuncSizeof2(int param = sizeof(TemplateParam));
+};
+
+template <>
+template
+constexpr int Problem::FuncAlign(int param) {
+   return param;
+}
+
+template <>
+template
+constexpr int Problem::FuncSizeof(int param) {
+   return param;
+}
+
+template <>
+template
+constexpr int Problem::FuncAlign2(int param) {
+   return param;
+}
+
+template <>
+template
+constexpr int Problem::FuncSizeof2(int param) {
+   return param;
+}
+
+int main(){
+Problem p = {};
+static_assert(p.FuncAlign() == alignof(char));
+static_assert(p.FuncSizeof() == sizeof(char));
+static_assert(p.FuncAlign2() == alignof(int));
+static_assert(p.FuncSizeof2() == sizeof(int));
+}

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


[clang] [llvm] [RISCV] Add FeatureFastUnalignedAccess to sifive-p450. (PR #79075)

2024-01-22 Thread Craig Topper via cfe-commits

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


[clang] 904b090 - [RISCV] Add FeatureFastUnalignedAccess to sifive-p450. (#79075)

2024-01-22 Thread via cfe-commits

Author: Craig Topper
Date: 2024-01-22T20:17:36-08:00
New Revision: 904b0901ef2d33e6232b7a51fa2525c30fd117e8

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

LOG: [RISCV] Add FeatureFastUnalignedAccess to sifive-p450. (#79075)

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 5fde5ccdbeacfb..39d2c66f14b23f 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -1400,4 +1400,6 @@
 // RUN:   -munaligned-access -o - | FileCheck %s 
--check-prefix=CHECK-MISALIGNED-FAST
 // RUN: %clang --target=riscv64-unknown-linux-gnu -march=rv64i -E -dM %s \
 // RUN:   -munaligned-access -o - | FileCheck %s 
--check-prefix=CHECK-MISALIGNED-FAST
+// RUN: %clang --target=riscv64-unknown-linux-gnu -mcpu=sifive-p450 -E -dM %s \
+// RUN:  -o - | FileCheck %s --check-prefix=CHECK-MISALIGNED-FAST
 // CHECK-MISALIGNED-FAST: __riscv_misaligned_fast 1

diff  --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index db60a5a1dab002..af621de9f802aa 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -238,7 +238,8 @@ def SIFIVE_P450 : RISCVProcessorModel<"sifive-p450", 
SiFiveP400Model,
FeatureStdExtZba,
FeatureStdExtZbb,
FeatureStdExtZbs,
-   FeatureStdExtZfhmin],
+   FeatureStdExtZfhmin,
+   FeatureFastUnalignedAccess],
   [TuneNoDefaultUnroll,
TuneConditionalCompressedMoveFusion,
TuneLUIADDIFusion,



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


[clang] [clang][modules] Print library module manifest path. (PR #76451)

2024-01-22 Thread Kazushi Marukawa via cfe-commits

kaz7 wrote:

Hi @mordante,

Does this test, `Driver/modules-print-library-module-manifest-path.cpp`, work 
on other than x86?  It is failing on VE build bot like below.

https://lab.llvm.org/buildbot/#/builders/91/builds/22189

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


[clang] [clang][ASTImporter] fix assert fail due to offset overflow (PR #79084)

2024-01-22 Thread Qizhi Hu via cfe-commits

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


[clang] [clang][ASTImporter] fix assert fail due to offset overflow (PR #79084)

2024-01-22 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/79084

>From 0b127ff20bc9a6a1d4de7bcbfa2c5ad466cea14c Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Tue, 23 Jan 2024 10:09:44 +0800
Subject: [PATCH] [clang][ASTImporter] fix assert fail due to offset overflow

---
 clang/lib/AST/ASTImporter.cpp | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 12734d62ed9fb76..34f817a098b0fb3 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -9837,6 +9837,13 @@ Expected ASTImporter::Import(SourceRange 
FromRange) {
   return SourceRange(ToBegin, ToEnd);
 }
 
+static bool isBufferSizeOverflow(SourceManager , size_t BufferSize) {
+  unsigned Offset = SM.getNextLocalOffset();
+  unsigned FullSize = Offset + BufferSize + 1;
+  SourceLocation L = SourceLocation().getFromRawEncoding(FullSize);
+  return !L.isFileID() || FullSize <= Offset;
+}
+
 Expected ASTImporter::Import(FileID FromID, bool IsBuiltin) {
   llvm::DenseMap::iterator Pos = ImportedFileIDs.find(FromID);
   if (Pos != ImportedFileIDs.end())
@@ -9896,9 +9903,13 @@ Expected ASTImporter::Import(FileID FromID, bool 
IsBuiltin) {
 // FIXME: The filename may be a virtual name that does probably not
 // point to a valid file and we get no Entry here. In this case try 
with
 // the memory buffer below.
-if (Entry)
+if (Entry) {
+  if (isBufferSizeOverflow(ToSM, Entry->getSize()))
+return llvm::make_error(
+ASTImportError::UnsupportedConstruct);
   ToID = ToSM.createFileID(*Entry, ToIncludeLocOrFakeLoc,
FromSLoc.getFile().getFileCharacteristic());
+}
   }
 }
 
@@ -9913,6 +9924,9 @@ Expected ASTImporter::Import(FileID FromID, bool 
IsBuiltin) {
   std::unique_ptr ToBuf =
   llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
FromBuf->getBufferIdentifier());
+  if (isBufferSizeOverflow(ToSM, ToBuf->getBufferSize()))
+return llvm::make_error(
+ASTImportError::UnsupportedConstruct);
   ToID = ToSM.createFileID(std::move(ToBuf),
FromSLoc.getFile().getFileCharacteristic());
 }

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


[flang] [clang] [lldb] [compiler-rt] [llvm] [clang-tools-extra] [mlir] [libcxxabi] [libc] [libcxx] [lld] [libc++] Fix the behavior of throwing `operator new` under -fno-exceptions (PR #69498)

2024-01-22 Thread Quentin Dian via cfe-commits

DianQK wrote:

Thanks for the fix! I'll merge the blocked patches in a later two days.

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


[openmp] [mlir] [compiler-rt] [libcxx] [llvm] [lld] [clang] [HEXAGON] Inlining Division (PR #79021)

2024-01-22 Thread via cfe-commits

quic-asaravan wrote:

@SundeepKushwaha Can you review ?

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


[llvm] [mlir] [clang] [AMDGPU] Change default AMDHSA Code Object version to 5 (PR #79038)

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

arsenm wrote:

Should get a mention in the release notes 

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


[llvm] [clang] [LoongArch] Add definitions and feature 'frecipe' for FP approximation intrinsics/builtins (PR #78962)

2024-01-22 Thread Lu Weining via cfe-commits

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

LGTM if the conflicting were resolved.

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


[clang] [clang][ASTImporter] fix assert fail due to offset overflow (PR #79084)

2024-01-22 Thread Qizhi Hu via cfe-commits

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


[clang] [clang][ASTImporter] fix assert fail due to offset overflow (PR #79084)

2024-01-22 Thread Qizhi Hu via cfe-commits

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


[clang] [clang-format] Allow decltype in requires clause (PR #78847)

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

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


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


[clang] 4ef646e - [clang-format]: Fix formatting of if statements with BlockIndent (#77699)

2024-01-22 Thread via cfe-commits

Author: Gedare Bloom
Date: 2024-01-22T19:01:16-08:00
New Revision: 4ef646eab3023b52ce8ee529d16605c92caba8ba

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

LOG: [clang-format]: Fix formatting of if statements with BlockIndent  (#77699)

A bug with BlockIndent prevents line breaks within if (and else if)
clauses.

While fixing this bug, it appears that AlignAfterOpenBracket is not
designed to work with loop and if statements, but AlwaysBreak works on
if clauses. The documentation and tests are not clear on whether or not
this behavior is intended.

This PR preserves the `AlwaysBreak` behavior on `if` clauses without
supporting `BlockIndent` on `if` clauses to avoid regressions while
fixing the bug.

It may be reasonable to create an explicit option for alignment of if
(and loop) clauses intentionally for both `AlwaysBreak` and
`BlockIndent`

Fixes #54663.

Migrated from Differential Revision: https://reviews.llvm.org/D154755
See more discussion there. Addressed last open comment from the rev
about refactoring the complex conditional logic involved with the
`AlignAfterOpenBracket` line break behavior.

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index a099813c9100b4..a3eb9138b21833 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -771,15 +771,25 @@ void 
ContinuationIndenter::addTokenOnCurrentLine(LineState , bool DryRun,
   // parenthesis by disallowing any further line breaks if there is no line
   // break after the opening parenthesis. Don't break if it doesn't conserve
   // columns.
+  auto IsOpeningBracket = [&](const FormatToken ) {
+auto IsStartOfBracedList = [&]() {
+  return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
+ Style.Cpp11BracedListStyle;
+};
+if (!Tok.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
+!IsStartOfBracedList()) {
+  return false;
+}
+if (!Tok.Previous)
+  return true;
+if (Tok.Previous->isIf())
+  return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak;
+return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
+  tok::kw_switch);
+  };
   if ((Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) &&
-  (Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) ||
-   (Previous.is(tok::l_brace) && Previous.isNot(BK_Block) &&
-Style.Cpp11BracedListStyle)) &&
-  State.Column > getNewLineColumn(State) &&
-  (!Previous.Previous ||
-   !Previous.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
-   tok::kw_switch)) &&
+  IsOpeningBracket(Previous) && State.Column > getNewLineColumn(State) &&
   // Don't do this for simple (no expressions) one-argument function calls
   // as that feels like needlessly wasting whitespace, e.g.:
   //

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index fa3bea5ae5d755..e5e763edf5b5bf 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -26172,8 +26172,8 @@ TEST_F(FormatTest, 
AlignAfterOpenBracketBlockIndentIfStatement) {
"}",
Style);
 
-  verifyFormat("if (quitelongarg !=\n"
-   "(alsolongarg - 1)) { // ABC is a very long "
+  verifyFormat("if (quiteLongArg !=\n"
+   "(alsoLongArg - 1)) { // ABC is a very long "
"comment\n"
"  return;\n"
"}",
@@ -26186,12 +26186,44 @@ TEST_F(FormatTest, 
AlignAfterOpenBracketBlockIndentIfStatement) {
"}",
Style);
 
-  verifyFormat("if (quitelongarg !=\n"
-   "(alsolongarg - 1)) { // ABC is a very long "
+  verifyFormat("if (quiteLongArg !=\n"
+   "(alsoLongArg - 1)) { // ABC is a very long "
"comment\n"
"  return;\n"
"}",
Style);
+
+  verifyFormat("void foo() {\n"
+   "  if (camelCaseName < alsoLongName ||\n"
+   "  anotherEvenLongerName <=\n"
+   "  thisReallyReallyReallyReallyReallyReallyLongerName 
||"
+   "\n"
+   "  otherName < thisLastName) {\n"
+   "return;\n"
+   "  } else if (quiteLongName < alsoLongName ||\n"
+   " anotherEvenLongerName <=\n"
+ 

[clang] [clang-format]: Fix formatting of if statements with BlockIndent (PR #77699)

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

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


[clang] [Headers][X86] Add macro descriptions to bmiintrin.h (PR #79048)

2024-01-22 Thread Phoebe Wang via cfe-commits

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

LGTM.

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


[clang] [clang-format] Fix a bug in ContinuationIndenter (PR #78921)

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

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


[clang] 3b171cb - [clang-format] Fix a bug in ContinuationIndenter (#78921)

2024-01-22 Thread via cfe-commits

Author: Owen Pan
Date: 2024-01-22T18:59:08-08:00
New Revision: 3b171cb968b3f8495b096139fc57ff6263727e40

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

LOG: [clang-format] Fix a bug in ContinuationIndenter (#78921)

Fixes #76991.

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ddbee15cb159f6..a099813c9100b4 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -740,7 +740,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
, bool DryRun,
 
   if (!DryRun) {
 Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, Spaces,
-  State.Column + Spaces + PPColumnCorrection);
+  State.Column + Spaces + PPColumnCorrection,
+  /*IsAligned=*/false, 
State.Line->InMacroBody);
   }
 
   // If "BreakBeforeInheritanceComma" mode, don't break within the inheritance

diff  --git a/clang/lib/Format/WhitespaceManager.h 
b/clang/lib/Format/WhitespaceManager.h
index dc6f60e5deeedf..8ac73305871ae7 100644
--- a/clang/lib/Format/WhitespaceManager.h
+++ b/clang/lib/Format/WhitespaceManager.h
@@ -55,7 +55,7 @@ class WhitespaceManager {
   /// this replacement. It is needed for determining how \p Spaces is turned
   /// into tabs and spaces for some format styles.
   void replaceWhitespace(FormatToken , unsigned Newlines, unsigned Spaces,
- unsigned StartOfTokenColumn, bool isAligned = false,
+ unsigned StartOfTokenColumn, bool IsAligned = false,
  bool InPPDirective = false);
 
   /// Adds information about an unchangeable token's whitespace.

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index a0825dc2ad4ef1..fa3bea5ae5d755 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -21215,6 +21215,13 @@ TEST_F(FormatTest, 
CatchAlignArrayOfStructuresLeftAlignment) {
"});",
Style);
 
+  Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign;
+  verifyFormat("#define FOO \\\n"
+   "  int foo[][2] = { \\\n"
+   "  {0, 1} \\\n"
+   "  };",
+   Style);
+
   Style.Cpp11BracedListStyle = false;
   verifyFormat("struct test demo[] = {\n"
"  { 56, 23,\"hello\" },\n"



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


[mlir] [clang-tools-extra] [llvm] [mlir][ArithToAMDGPU] Add option for saturating truncation to fp8 (PR #74153)

2024-01-22 Thread Jakub Kuderski via cfe-commits

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

LGTM

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


[clang] [compiler-rt] [NFC] Size and element numbers are often swapped when calling calloc (PR #79081)

2024-01-22 Thread via cfe-commits

https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/79081

>From 1155a5d6cc94a9c0b923487d7653be0cd0484d2d Mon Sep 17 00:00:00 2001
From: Rose <83477269+ataridre...@users.noreply.github.com>
Date: Fri, 21 Apr 2023 16:57:10 -0400
Subject: [PATCH] [NFC] Size and element numbers are often swapped when calling
 calloc

gcc-14 will now throw a warning if size and elements are swapped.
---
 clang/test/Analysis/malloc.mm| 6 +++---
 clang/test/Analysis/uninit-vals.m| 6 +++---
 clang/test/CodeGen/alloc-size.c  | 4 ++--
 compiler-rt/lib/profile/InstrProfilingFile.c | 4 ++--
 compiler-rt/test/tsan/java_finalizer2.cpp| 2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/test/Analysis/malloc.mm b/clang/test/Analysis/malloc.mm
index 9c0f013c4df88a..94a46d731090b3 100644
--- a/clang/test/Analysis/malloc.mm
+++ b/clang/test/Analysis/malloc.mm
@@ -116,17 +116,17 @@ void testUseAfterFree() {
 }
 
 void testNoCopy() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData somethingNoCopy:p]; // no-warning
 }
 
 void testFreeWhenDone() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:1]; // no-warning
 }
 
 void testFreeWhenDonePositive() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:0]; // 
expected-warning{{leak}}
 }
 
diff --git a/clang/test/Analysis/uninit-vals.m 
b/clang/test/Analysis/uninit-vals.m
index 9d18f0ef69b927..a6ec4fb74e128f 100644
--- a/clang/test/Analysis/uninit-vals.m
+++ b/clang/test/Analysis/uninit-vals.m
@@ -158,7 +158,7 @@ Point makePoint(float x, float y) {
 }
 
 void PR14765_test(void) {
-  Circle *testObj = calloc(sizeof(Circle), 1);
+  Circle *testObj = calloc(1, sizeof(Circle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -207,7 +207,7 @@ IntPoint makeIntPoint(int x, int y) {
 }
 
 void PR14765_test_int(void) {
-  IntCircle *testObj = calloc(sizeof(IntCircle), 1);
+  IntCircle *testObj = calloc(1, sizeof(IntCircle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -311,7 +311,7 @@ void testLargeStructsNotCopiedPerField(void) {
 }
 
 void testSmallStructInLargerStruct(void) {
-  IntCircle2D *testObj = calloc(sizeof(IntCircle2D), 1);
+  IntCircle2D *testObj = calloc(1, sizeof(IntCircle2D));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
diff --git a/clang/test/CodeGen/alloc-size.c b/clang/test/CodeGen/alloc-size.c
index 370f61058c4937..bbac7965521b6e 100644
--- a/clang/test/CodeGen/alloc-size.c
+++ b/clang/test/CodeGen/alloc-size.c
@@ -137,7 +137,7 @@ void test5(void) {
   // CHECK: store i32 36
   gi = OBJECT_SIZE_BUILTIN(>t[1], 3);
 
-  struct Data *const arr = my_calloc(sizeof(*data), 2);
+  struct Data *const arr = my_calloc(2, sizeof(*data));
   // CHECK: store i32 96
   gi = OBJECT_SIZE_BUILTIN(arr, 0);
   // CHECK: store i32 96
@@ -171,7 +171,7 @@ void test6(void) {
   // CHECK: store i32 11
   gi = OBJECT_SIZE_BUILTIN(data->end, 3);
 
-  struct Data *const arr = my_calloc(sizeof(*arr) + 5, 3);
+  struct Data *const arr = my_calloc(3, sizeof(*arr) + 5);
   // AFAICT, GCC treats malloc and calloc identically. So, we should do the
   // same.
   //
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index e72a2ba86f5466..867ae73f0d3b27 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -335,10 +335,10 @@ static void initFileWriter(ProfDataWriter *This, FILE 
*File) {
 COMPILER_RT_VISIBILITY ProfBufferIO *
 lprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {
   FreeHook = 
-  DynamicBufferIOBuffer = (uint8_t *)calloc(BufferSz, 1);
+  DynamicBufferIOBuffer = (uint8_t *)calloc(1, BufferSz);
   VPBufferSize = BufferSz;
   ProfDataWriter *fileWriter =
-  (ProfDataWriter *)calloc(sizeof(ProfDataWriter), 1);
+  (ProfDataWriter *)calloc(1, sizeof(ProfDataWriter));
   initFileWriter(fileWriter, File);
   ProfBufferIO *IO = lprofCreateBufferIO(fileWriter);
   IO->OwnFileWriter = 1;
diff --git a/compiler-rt/test/tsan/java_finalizer2.cpp 
b/compiler-rt/test/tsan/java_finalizer2.cpp
index 87528900541a84..0d677be2ba1a0b 100644
--- a/compiler-rt/test/tsan/java_finalizer2.cpp
+++ b/compiler-rt/test/tsan/java_finalizer2.cpp
@@ -51,7 +51,7 @@ void *Ballast(void *p) {
 }
 
 int main() {
-  Heap* heap = (Heap*)calloc(sizeof(Heap), 2) + 1;
+  Heap *heap = (Heap *)calloc(2, sizeof(Heap)) + 1;
   __tsan_java_init((jptr)heap, 

[clang] [Clang][RISCV][RVV Intrinsic] Fix codegen redundant intrinsic names (PR #77889)

2024-01-22 Thread Brandon Wu via cfe-commits

4vtomat wrote:

Since it only reduces about 160 of 54100 intrinsics generated, I have no 
opinion on this, just left the final decision to others~
But if this PR is finally decided to be merged, please add some comments around 
the code you added to explain, thanks!

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


[clang-tools-extra] [libc] [lldb] [compiler-rt] [flang] [libcxxabi] [llvm] [lld] [libcxx] [mlir] [clang] [libc++] Fix the behavior of throwing `operator new` under -fno-exceptions (PR #69498)

2024-01-22 Thread Louis Dionne via cfe-commits

https://github.com/ldionne updated 
https://github.com/llvm/llvm-project/pull/69498

>From 6f89b118ed56ad7a3af1996e19ccd30cc893c51e Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Wed, 14 Jun 2023 17:49:22 -0700
Subject: [PATCH 01/11] [libc++] Fix the behavior of throwing `operator new`
 under -fno-exceptions

In D144319, Clang tried to land a change that would cause some functions
that are not supposed to return nullptr to optimize better. As reported
in https://reviews.llvm.org/D144319#4203982, libc++ started seeing failures
in its CI shortly after this change was landed.

As explained in D146379, the reason for these failures is that libc++'s
throwing `operator new` can in fact return nullptr when compiled with
exceptions disabled. However, this contradicts the Standard, which
clearly says that the throwing version of `operator new(size_t)`
should never return nullptr. This is actually a long standing issue.
I've previously seen a case where LTO would optimize incorrectly based
on the assumption that `operator new` doesn't return nullptr, an
assumption that was violated in that case because libc++.dylib was
compiled with -fno-exceptions.

Unfortunately, fixing this is kind of tricky. The Standard has a few
requirements for the allocation functions, some of which are impossible
to satisfy under -fno-exceptions:
1. `operator new(size_t)` must never return nullptr
2. `operator new(size_t, nothrow_t)` must call the throwing version
 and return nullptr on failure to allocate
3. We can't throw exceptions when compiled with -fno-exceptions

In the case where exceptions are enabled, things work nicely. `new(size_t)`
throws and `new(size_t, nothrow_t)` uses a try-catch to return nullptr.
However, when compiling the library with -fno-exceptions, we can't throw
an exception from `new(size_t)`, and we can't catch anything from
`new(size_t, nothrow_t)`. The only thing we can do from `new(size_t)`
is actually abort the program, which does not make it possible for
`new(size_t, nothrow_t)` to catch something and return nullptr.

This patch makes the following changes:
1. When compiled with -fno-exceptions, the throwing version of
   `operator new` will now abort on failure instead of returning
   nullptr on failure. This resolves the issue that the compiler
   could mis-compile based on the assumption that nullptr is never
   returned. This constitutes an API and ABI breaking change for
   folks compiling the library with -fno-exceptions (which is not
   the general public, who merely uses libc++ headers but use a
   shared library that has already been compiled). This should mostly
   impact vendors and other folks who compile libc++.dylib themselves.

2. When the library is compiled with -fexceptions, the nothrow version
   of `operator new` has no change. When the library is compiled with
   -fno-exceptions, the nothrow version of `operator new` will now check
   whether the throwing version of `operator new` has been overridden.
   If it has not been overridden, then it will use an implementation
   equivalent to that of the throwing `operator new`, except it will
   return nullptr on failure to allocate (instead of terminating).
   However, if the throwing `operator new` has been overridden, it is
   now an error NOT to also override the nothrow `operator new`. Indeed,
   there is no way for us to implement a valid nothrow `operator new`
   without knowing the exact implementation of the throwing version.

rdar://103958777

Differential Revision: https://reviews.llvm.org/D150610
---
 libcxx/docs/ReleaseNotes/18.rst   |  23 +++
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__overridable_function | 119 +
 libcxx/src/new.cpp|  99 ---
 ...new_not_overridden_fno_exceptions.pass.cpp |  59 ++
 .../new_dont_return_nullptr.pass.cpp  |  37 
 libcxx/test/support/check_assertion.h |   6 +
 libcxx/utils/generate_iwyu_mapping.py |   2 +
 libcxxabi/src/stdlib_new_delete.cpp   | 168 +++---
 9 files changed, 426 insertions(+), 88 deletions(-)
 create mode 100644 libcxx/include/__overridable_function
 create mode 100644 
libcxx/test/libcxx/language.support/support.dynamic/assert.nothrow_new_not_overridden_fno_exceptions.pass.cpp
 create mode 100644 
libcxx/test/libcxx/language.support/support.dynamic/new_dont_return_nullptr.pass.cpp

diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 9e509db6359c4aa..405f1e172893bc1 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -142,6 +142,29 @@ LLVM 20
 ABI Affecting Changes
 -
 
+- When the shared/static library is built with ``-fno-exceptions``, the 
behavior of ``operator new`` was changed
+  to make it standards-conforming. In LLVM 17 and before, the throwing 
versions of ``operator new`` would return
+  ``nullptr`` upon failure to allocate, when the 

[compiler-rt] [clang] [NFC] Size and element numbers are often swapped when calling calloc (PR #79081)

2024-01-22 Thread via cfe-commits

https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/79081

>From e10238c4801df03f869db835eac160f5cff66937 Mon Sep 17 00:00:00 2001
From: Rose <83477269+ataridre...@users.noreply.github.com>
Date: Fri, 21 Apr 2023 16:57:10 -0400
Subject: [PATCH] Size and element numbers are often swapped when calling
 calloc

gcc-14 will now throw a warning if size and elements are swapped.
---
 clang/test/Analysis/malloc.mm| 6 +++---
 clang/test/Analysis/uninit-vals.m| 6 +++---
 clang/test/CodeGen/alloc-size.c  | 4 ++--
 compiler-rt/lib/profile/InstrProfilingFile.c | 4 ++--
 compiler-rt/test/tsan/java_finalizer2.cpp| 2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/test/Analysis/malloc.mm b/clang/test/Analysis/malloc.mm
index 9c0f013c4df88a7..94a46d731090b35 100644
--- a/clang/test/Analysis/malloc.mm
+++ b/clang/test/Analysis/malloc.mm
@@ -116,17 +116,17 @@ void testUseAfterFree() {
 }
 
 void testNoCopy() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData somethingNoCopy:p]; // no-warning
 }
 
 void testFreeWhenDone() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:1]; // no-warning
 }
 
 void testFreeWhenDonePositive() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:0]; // 
expected-warning{{leak}}
 }
 
diff --git a/clang/test/Analysis/uninit-vals.m 
b/clang/test/Analysis/uninit-vals.m
index 9d18f0ef69b9270..a6ec4fb74e128f8 100644
--- a/clang/test/Analysis/uninit-vals.m
+++ b/clang/test/Analysis/uninit-vals.m
@@ -158,7 +158,7 @@ Point makePoint(float x, float y) {
 }
 
 void PR14765_test(void) {
-  Circle *testObj = calloc(sizeof(Circle), 1);
+  Circle *testObj = calloc(1, sizeof(Circle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -207,7 +207,7 @@ IntPoint makeIntPoint(int x, int y) {
 }
 
 void PR14765_test_int(void) {
-  IntCircle *testObj = calloc(sizeof(IntCircle), 1);
+  IntCircle *testObj = calloc(1, sizeof(IntCircle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -311,7 +311,7 @@ void testLargeStructsNotCopiedPerField(void) {
 }
 
 void testSmallStructInLargerStruct(void) {
-  IntCircle2D *testObj = calloc(sizeof(IntCircle2D), 1);
+  IntCircle2D *testObj = calloc(1, sizeof(IntCircle2D));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
diff --git a/clang/test/CodeGen/alloc-size.c b/clang/test/CodeGen/alloc-size.c
index 370f61058c49376..bbac7965521b6e3 100644
--- a/clang/test/CodeGen/alloc-size.c
+++ b/clang/test/CodeGen/alloc-size.c
@@ -137,7 +137,7 @@ void test5(void) {
   // CHECK: store i32 36
   gi = OBJECT_SIZE_BUILTIN(>t[1], 3);
 
-  struct Data *const arr = my_calloc(sizeof(*data), 2);
+  struct Data *const arr = my_calloc(2, sizeof(*data));
   // CHECK: store i32 96
   gi = OBJECT_SIZE_BUILTIN(arr, 0);
   // CHECK: store i32 96
@@ -171,7 +171,7 @@ void test6(void) {
   // CHECK: store i32 11
   gi = OBJECT_SIZE_BUILTIN(data->end, 3);
 
-  struct Data *const arr = my_calloc(sizeof(*arr) + 5, 3);
+  struct Data *const arr = my_calloc(3, sizeof(*arr) + 5);
   // AFAICT, GCC treats malloc and calloc identically. So, we should do the
   // same.
   //
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index e72a2ba86f54660..867ae73f0d3b27c 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -335,10 +335,10 @@ static void initFileWriter(ProfDataWriter *This, FILE 
*File) {
 COMPILER_RT_VISIBILITY ProfBufferIO *
 lprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {
   FreeHook = 
-  DynamicBufferIOBuffer = (uint8_t *)calloc(BufferSz, 1);
+  DynamicBufferIOBuffer = (uint8_t *)calloc(1, BufferSz);
   VPBufferSize = BufferSz;
   ProfDataWriter *fileWriter =
-  (ProfDataWriter *)calloc(sizeof(ProfDataWriter), 1);
+  (ProfDataWriter *)calloc(1, sizeof(ProfDataWriter));
   initFileWriter(fileWriter, File);
   ProfBufferIO *IO = lprofCreateBufferIO(fileWriter);
   IO->OwnFileWriter = 1;
diff --git a/compiler-rt/test/tsan/java_finalizer2.cpp 
b/compiler-rt/test/tsan/java_finalizer2.cpp
index 87528900541a84b..0d677be2ba1a0b8 100644
--- a/compiler-rt/test/tsan/java_finalizer2.cpp
+++ b/compiler-rt/test/tsan/java_finalizer2.cpp
@@ -51,7 +51,7 @@ void *Ballast(void *p) {
 }
 
 int main() {
-  Heap* heap = (Heap*)calloc(sizeof(Heap), 2) + 1;
+  Heap *heap = (Heap *)calloc(2, sizeof(Heap)) + 1;
   __tsan_java_init((jptr)heap, 

[compiler-rt] [clang] [NFC] Size and element numbers are often swapped when calling calloc (PR #79081)

2024-01-22 Thread Florian Mayer via cfe-commits

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


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


[clang] [compiler-rt] [NFC] Size and element numbers are often swapped when calling calloc (PR #79081)

2024-01-22 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 d4933b3241f463871cae55bbeec8563e7ffe03a2 
bda35bd77adc4b137a8e9c8dab1f58f233db6c7c -- clang/test/CodeGen/alloc-size.c 
compiler-rt/lib/profile/InstrProfilingFile.c 
compiler-rt/test/tsan/java_finalizer2.cpp
``





View the diff from clang-format here.


``diff
diff --git a/compiler-rt/test/tsan/java_finalizer2.cpp 
b/compiler-rt/test/tsan/java_finalizer2.cpp
index d230c4e2b0..0d677be2ba 100644
--- a/compiler-rt/test/tsan/java_finalizer2.cpp
+++ b/compiler-rt/test/tsan/java_finalizer2.cpp
@@ -51,7 +51,7 @@ void *Ballast(void *p) {
 }
 
 int main() {
-  Heap* heap = (Heap*)calloc(2, sizeof(Heap)) + 1;
+  Heap *heap = (Heap *)calloc(2, sizeof(Heap)) + 1;
   __tsan_java_init((jptr)heap, sizeof(*heap));
   __tsan_java_alloc((jptr)heap, sizeof(*heap));
   // Ballast threads merely make the bug a bit easier to trigger.

``




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


[clang] [compiler-rt] [NFC] Size and element numbers are often swapped when calling calloc (PR #79081)

2024-01-22 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-pgo

Author: AtariDreams (AtariDreams)


Changes

gcc-14 will now throw a warning if size and elements are swapped.

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


5 Files Affected:

- (modified) clang/test/Analysis/malloc.mm (+3-3) 
- (modified) clang/test/Analysis/uninit-vals.m (+3-3) 
- (modified) clang/test/CodeGen/alloc-size.c (+2-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingFile.c (+2-2) 
- (modified) compiler-rt/test/tsan/java_finalizer2.cpp (+1-1) 


``diff
diff --git a/clang/test/Analysis/malloc.mm b/clang/test/Analysis/malloc.mm
index 9c0f013c4df88a7..94a46d731090b35 100644
--- a/clang/test/Analysis/malloc.mm
+++ b/clang/test/Analysis/malloc.mm
@@ -116,17 +116,17 @@ void testUseAfterFree() {
 }
 
 void testNoCopy() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData somethingNoCopy:p]; // no-warning
 }
 
 void testFreeWhenDone() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:1]; // no-warning
 }
 
 void testFreeWhenDonePositive() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:0]; // 
expected-warning{{leak}}
 }
 
diff --git a/clang/test/Analysis/uninit-vals.m 
b/clang/test/Analysis/uninit-vals.m
index 9d18f0ef69b9270..a6ec4fb74e128f8 100644
--- a/clang/test/Analysis/uninit-vals.m
+++ b/clang/test/Analysis/uninit-vals.m
@@ -158,7 +158,7 @@ Point makePoint(float x, float y) {
 }
 
 void PR14765_test(void) {
-  Circle *testObj = calloc(sizeof(Circle), 1);
+  Circle *testObj = calloc(1, sizeof(Circle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -207,7 +207,7 @@ IntPoint makeIntPoint(int x, int y) {
 }
 
 void PR14765_test_int(void) {
-  IntCircle *testObj = calloc(sizeof(IntCircle), 1);
+  IntCircle *testObj = calloc(1, sizeof(IntCircle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -311,7 +311,7 @@ void testLargeStructsNotCopiedPerField(void) {
 }
 
 void testSmallStructInLargerStruct(void) {
-  IntCircle2D *testObj = calloc(sizeof(IntCircle2D), 1);
+  IntCircle2D *testObj = calloc(1, sizeof(IntCircle2D));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
diff --git a/clang/test/CodeGen/alloc-size.c b/clang/test/CodeGen/alloc-size.c
index 370f61058c49376..bbac7965521b6e3 100644
--- a/clang/test/CodeGen/alloc-size.c
+++ b/clang/test/CodeGen/alloc-size.c
@@ -137,7 +137,7 @@ void test5(void) {
   // CHECK: store i32 36
   gi = OBJECT_SIZE_BUILTIN(>t[1], 3);
 
-  struct Data *const arr = my_calloc(sizeof(*data), 2);
+  struct Data *const arr = my_calloc(2, sizeof(*data));
   // CHECK: store i32 96
   gi = OBJECT_SIZE_BUILTIN(arr, 0);
   // CHECK: store i32 96
@@ -171,7 +171,7 @@ void test6(void) {
   // CHECK: store i32 11
   gi = OBJECT_SIZE_BUILTIN(data->end, 3);
 
-  struct Data *const arr = my_calloc(sizeof(*arr) + 5, 3);
+  struct Data *const arr = my_calloc(3, sizeof(*arr) + 5);
   // AFAICT, GCC treats malloc and calloc identically. So, we should do the
   // same.
   //
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index e72a2ba86f54660..867ae73f0d3b27c 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -335,10 +335,10 @@ static void initFileWriter(ProfDataWriter *This, FILE 
*File) {
 COMPILER_RT_VISIBILITY ProfBufferIO *
 lprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {
   FreeHook = 
-  DynamicBufferIOBuffer = (uint8_t *)calloc(BufferSz, 1);
+  DynamicBufferIOBuffer = (uint8_t *)calloc(1, BufferSz);
   VPBufferSize = BufferSz;
   ProfDataWriter *fileWriter =
-  (ProfDataWriter *)calloc(sizeof(ProfDataWriter), 1);
+  (ProfDataWriter *)calloc(1, sizeof(ProfDataWriter));
   initFileWriter(fileWriter, File);
   ProfBufferIO *IO = lprofCreateBufferIO(fileWriter);
   IO->OwnFileWriter = 1;
diff --git a/compiler-rt/test/tsan/java_finalizer2.cpp 
b/compiler-rt/test/tsan/java_finalizer2.cpp
index 87528900541a84b..d230c4e2b0ea23e 100644
--- a/compiler-rt/test/tsan/java_finalizer2.cpp
+++ b/compiler-rt/test/tsan/java_finalizer2.cpp
@@ -51,7 +51,7 @@ void *Ballast(void *p) {
 }
 
 int main() {
-  Heap* heap = (Heap*)calloc(sizeof(Heap), 2) + 1;
+  Heap* heap = (Heap*)calloc(2, sizeof(Heap)) + 1;
   __tsan_java_init((jptr)heap, sizeof(*heap));
   __tsan_java_alloc((jptr)heap, sizeof(*heap));
   // Ballast threads merely make the bug a bit easier to trigger.

``





[clang] [compiler-rt] [NFC] Size and element numbers are often swapped when calling calloc (PR #79081)

2024-01-22 Thread via cfe-commits

https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/79081

>From bda35bd77adc4b137a8e9c8dab1f58f233db6c7c Mon Sep 17 00:00:00 2001
From: Rose <83477269+ataridre...@users.noreply.github.com>
Date: Fri, 21 Apr 2023 16:57:10 -0400
Subject: [PATCH] Size and element numbers are often swapped when calling
 calloc

gcc-14 will now throw a warning if size and elements are swapped.
---
 clang/test/Analysis/malloc.mm| 6 +++---
 clang/test/Analysis/uninit-vals.m| 6 +++---
 clang/test/CodeGen/alloc-size.c  | 4 ++--
 compiler-rt/lib/profile/InstrProfilingFile.c | 4 ++--
 compiler-rt/test/tsan/java_finalizer2.cpp| 2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/test/Analysis/malloc.mm b/clang/test/Analysis/malloc.mm
index 9c0f013c4df88a..94a46d731090b3 100644
--- a/clang/test/Analysis/malloc.mm
+++ b/clang/test/Analysis/malloc.mm
@@ -116,17 +116,17 @@ void testUseAfterFree() {
 }
 
 void testNoCopy() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData somethingNoCopy:p]; // no-warning
 }
 
 void testFreeWhenDone() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:1]; // no-warning
 }
 
 void testFreeWhenDonePositive() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:0]; // 
expected-warning{{leak}}
 }
 
diff --git a/clang/test/Analysis/uninit-vals.m 
b/clang/test/Analysis/uninit-vals.m
index 9d18f0ef69b927..a6ec4fb74e128f 100644
--- a/clang/test/Analysis/uninit-vals.m
+++ b/clang/test/Analysis/uninit-vals.m
@@ -158,7 +158,7 @@ Point makePoint(float x, float y) {
 }
 
 void PR14765_test(void) {
-  Circle *testObj = calloc(sizeof(Circle), 1);
+  Circle *testObj = calloc(1, sizeof(Circle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -207,7 +207,7 @@ IntPoint makeIntPoint(int x, int y) {
 }
 
 void PR14765_test_int(void) {
-  IntCircle *testObj = calloc(sizeof(IntCircle), 1);
+  IntCircle *testObj = calloc(1, sizeof(IntCircle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -311,7 +311,7 @@ void testLargeStructsNotCopiedPerField(void) {
 }
 
 void testSmallStructInLargerStruct(void) {
-  IntCircle2D *testObj = calloc(sizeof(IntCircle2D), 1);
+  IntCircle2D *testObj = calloc(1, sizeof(IntCircle2D));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
diff --git a/clang/test/CodeGen/alloc-size.c b/clang/test/CodeGen/alloc-size.c
index 370f61058c4937..bbac7965521b6e 100644
--- a/clang/test/CodeGen/alloc-size.c
+++ b/clang/test/CodeGen/alloc-size.c
@@ -137,7 +137,7 @@ void test5(void) {
   // CHECK: store i32 36
   gi = OBJECT_SIZE_BUILTIN(>t[1], 3);
 
-  struct Data *const arr = my_calloc(sizeof(*data), 2);
+  struct Data *const arr = my_calloc(2, sizeof(*data));
   // CHECK: store i32 96
   gi = OBJECT_SIZE_BUILTIN(arr, 0);
   // CHECK: store i32 96
@@ -171,7 +171,7 @@ void test6(void) {
   // CHECK: store i32 11
   gi = OBJECT_SIZE_BUILTIN(data->end, 3);
 
-  struct Data *const arr = my_calloc(sizeof(*arr) + 5, 3);
+  struct Data *const arr = my_calloc(3, sizeof(*arr) + 5);
   // AFAICT, GCC treats malloc and calloc identically. So, we should do the
   // same.
   //
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index e72a2ba86f5466..867ae73f0d3b27 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -335,10 +335,10 @@ static void initFileWriter(ProfDataWriter *This, FILE 
*File) {
 COMPILER_RT_VISIBILITY ProfBufferIO *
 lprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {
   FreeHook = 
-  DynamicBufferIOBuffer = (uint8_t *)calloc(BufferSz, 1);
+  DynamicBufferIOBuffer = (uint8_t *)calloc(1, BufferSz);
   VPBufferSize = BufferSz;
   ProfDataWriter *fileWriter =
-  (ProfDataWriter *)calloc(sizeof(ProfDataWriter), 1);
+  (ProfDataWriter *)calloc(1, sizeof(ProfDataWriter));
   initFileWriter(fileWriter, File);
   ProfBufferIO *IO = lprofCreateBufferIO(fileWriter);
   IO->OwnFileWriter = 1;
diff --git a/compiler-rt/test/tsan/java_finalizer2.cpp 
b/compiler-rt/test/tsan/java_finalizer2.cpp
index 87528900541a84..d230c4e2b0ea23 100644
--- a/compiler-rt/test/tsan/java_finalizer2.cpp
+++ b/compiler-rt/test/tsan/java_finalizer2.cpp
@@ -51,7 +51,7 @@ void *Ballast(void *p) {
 }
 
 int main() {
-  Heap* heap = (Heap*)calloc(sizeof(Heap), 2) + 1;
+  Heap* heap = (Heap*)calloc(2, sizeof(Heap)) + 1;
   __tsan_java_init((jptr)heap, 

[clang] [compiler-rt] [NFC] Size and element numbers are often swapped when calling calloc (PR #79081)

2024-01-22 Thread via cfe-commits

https://github.com/AtariDreams created 
https://github.com/llvm/llvm-project/pull/79081

gcc-14 will now throw a warning if size and elements are swapped.

>From 104cef5e78448fd0a15a077f4cc1b9be9f340aad Mon Sep 17 00:00:00 2001
From: Rose <83477269+ataridre...@users.noreply.github.com>
Date: Fri, 21 Apr 2023 16:57:10 -0400
Subject: [PATCH] Size and element numbers are often swapped when calling
 calloc

---
 clang/test/Analysis/malloc.mm| 6 +++---
 clang/test/Analysis/uninit-vals.m| 6 +++---
 clang/test/CodeGen/alloc-size.c  | 4 ++--
 compiler-rt/lib/profile/InstrProfilingFile.c | 4 ++--
 compiler-rt/test/tsan/java_finalizer2.cpp| 2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/test/Analysis/malloc.mm b/clang/test/Analysis/malloc.mm
index 9c0f013c4df88a7..94a46d731090b35 100644
--- a/clang/test/Analysis/malloc.mm
+++ b/clang/test/Analysis/malloc.mm
@@ -116,17 +116,17 @@ void testUseAfterFree() {
 }
 
 void testNoCopy() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData somethingNoCopy:p]; // no-warning
 }
 
 void testFreeWhenDone() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:1]; // no-warning
 }
 
 void testFreeWhenDonePositive() {
-  char *p = (char *)calloc(sizeof(int), 1);
+  char *p = (char *)calloc(1, sizeof(int));
   CustomData *w = [CustomData something:p freeWhenDone:0]; // 
expected-warning{{leak}}
 }
 
diff --git a/clang/test/Analysis/uninit-vals.m 
b/clang/test/Analysis/uninit-vals.m
index 9d18f0ef69b9270..a6ec4fb74e128f8 100644
--- a/clang/test/Analysis/uninit-vals.m
+++ b/clang/test/Analysis/uninit-vals.m
@@ -158,7 +158,7 @@ Point makePoint(float x, float y) {
 }
 
 void PR14765_test(void) {
-  Circle *testObj = calloc(sizeof(Circle), 1);
+  Circle *testObj = calloc(1, sizeof(Circle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -207,7 +207,7 @@ IntPoint makeIntPoint(int x, int y) {
 }
 
 void PR14765_test_int(void) {
-  IntCircle *testObj = calloc(sizeof(IntCircle), 1);
+  IntCircle *testObj = calloc(1, sizeof(IntCircle));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
@@ -311,7 +311,7 @@ void testLargeStructsNotCopiedPerField(void) {
 }
 
 void testSmallStructInLargerStruct(void) {
-  IntCircle2D *testObj = calloc(sizeof(IntCircle2D), 1);
+  IntCircle2D *testObj = calloc(1, sizeof(IntCircle2D));
 
   clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
diff --git a/clang/test/CodeGen/alloc-size.c b/clang/test/CodeGen/alloc-size.c
index 370f61058c49376..bbac7965521b6e3 100644
--- a/clang/test/CodeGen/alloc-size.c
+++ b/clang/test/CodeGen/alloc-size.c
@@ -137,7 +137,7 @@ void test5(void) {
   // CHECK: store i32 36
   gi = OBJECT_SIZE_BUILTIN(>t[1], 3);
 
-  struct Data *const arr = my_calloc(sizeof(*data), 2);
+  struct Data *const arr = my_calloc(2, sizeof(*data));
   // CHECK: store i32 96
   gi = OBJECT_SIZE_BUILTIN(arr, 0);
   // CHECK: store i32 96
@@ -171,7 +171,7 @@ void test6(void) {
   // CHECK: store i32 11
   gi = OBJECT_SIZE_BUILTIN(data->end, 3);
 
-  struct Data *const arr = my_calloc(sizeof(*arr) + 5, 3);
+  struct Data *const arr = my_calloc(3, sizeof(*arr) + 5);
   // AFAICT, GCC treats malloc and calloc identically. So, we should do the
   // same.
   //
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index e72a2ba86f54660..867ae73f0d3b27c 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -335,10 +335,10 @@ static void initFileWriter(ProfDataWriter *This, FILE 
*File) {
 COMPILER_RT_VISIBILITY ProfBufferIO *
 lprofCreateBufferIOInternal(void *File, uint32_t BufferSz) {
   FreeHook = 
-  DynamicBufferIOBuffer = (uint8_t *)calloc(BufferSz, 1);
+  DynamicBufferIOBuffer = (uint8_t *)calloc(1, BufferSz);
   VPBufferSize = BufferSz;
   ProfDataWriter *fileWriter =
-  (ProfDataWriter *)calloc(sizeof(ProfDataWriter), 1);
+  (ProfDataWriter *)calloc(1, sizeof(ProfDataWriter));
   initFileWriter(fileWriter, File);
   ProfBufferIO *IO = lprofCreateBufferIO(fileWriter);
   IO->OwnFileWriter = 1;
diff --git a/compiler-rt/test/tsan/java_finalizer2.cpp 
b/compiler-rt/test/tsan/java_finalizer2.cpp
index 87528900541a84b..d230c4e2b0ea23e 100644
--- a/compiler-rt/test/tsan/java_finalizer2.cpp
+++ b/compiler-rt/test/tsan/java_finalizer2.cpp
@@ -51,7 +51,7 @@ void *Ballast(void *p) {
 }
 
 int main() {
-  Heap* heap = (Heap*)calloc(sizeof(Heap), 2) + 1;
+  Heap* heap = (Heap*)calloc(2, sizeof(Heap)) + 1;
   __tsan_java_init((jptr)heap, 

[clang] [Clang][AST] fix crash in mangle lambda expression (PR #78896)

2024-01-22 Thread Qizhi Hu via cfe-commits


@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s

jcsxky wrote:

Sorry, I am afraid that I misunderstand root cause of this issue and still need 
more working on it.

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


[clang] [HIP][Driver] Automatically include `hipstdpar` forwarding header (PR #78915)

2024-01-22 Thread Alex Voicu via cfe-commits

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


[clang] 907f2a0 - [HIP][Driver] Automatically include `hipstdpar` forwarding header (#78915)

2024-01-22 Thread via cfe-commits

Author: Alex Voicu
Date: 2024-01-23T00:55:59Z
New Revision: 907f2a0927d94d72d59f27e411c595b95aa673e9

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

LOG: [HIP][Driver] Automatically include `hipstdpar` forwarding header (#78915)

The forwarding header used by `hipstdpar` on AMDGPU targets is now
pacakged with `rocThrust`. This change augments the ROCm Driver
component so that it can automatically pick up the packaged header iff
the user hasn't overridden it via the dedicated flag.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/test/Driver/hipstdpar.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 56f06fc5fccb7eb..b3c9d5908654f6a 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -545,26 +545,35 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const 
ArgList ,
   }
 
   const auto HandleHipStdPar = [=, , ]() {
-if (!hasHIPStdParLibrary()) {
-  D.Diag(diag::err_drv_no_hipstdpar_lib);
-  return;
-}
-if (!HasRocThrustLibrary &&
-!D.getVFS().exists(getIncludePath() + "/thrust")) {
+StringRef Inc = getIncludePath();
+auto  = D.getVFS();
+
+if (!hasHIPStdParLibrary())
+  if (!HIPStdParPathArg.empty() ||
+  !FS.exists(Inc + "/thrust/system/hip/hipstdpar/hipstdpar_lib.hpp")) {
+D.Diag(diag::err_drv_no_hipstdpar_lib);
+return;
+  }
+if (!HasRocThrustLibrary && !FS.exists(Inc + "/thrust")) {
   D.Diag(diag::err_drv_no_hipstdpar_thrust_lib);
   return;
 }
-if (!HasRocPrimLibrary &&
-!D.getVFS().exists(getIncludePath() + "/rocprim")) {
+if (!HasRocPrimLibrary && !FS.exists(Inc + "/rocprim")) {
   D.Diag(diag::err_drv_no_hipstdpar_prim_lib);
   return;
 }
-
 const char *ThrustPath;
 if (HasRocThrustLibrary)
   ThrustPath = DriverArgs.MakeArgString(HIPRocThrustPathArg);
 else
-  ThrustPath = DriverArgs.MakeArgString(getIncludePath() + "/thrust");
+  ThrustPath = DriverArgs.MakeArgString(Inc + "/thrust");
+
+const char *HIPStdParPath;
+if (hasHIPStdParLibrary())
+  HIPStdParPath = DriverArgs.MakeArgString(HIPStdParPathArg);
+else
+  HIPStdParPath = DriverArgs.MakeArgString(StringRef(ThrustPath) +
+   "/system/hip/hipstdpar");
 
 const char *PrimPath;
 if (HasRocPrimLibrary)
@@ -573,8 +582,8 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const 
ArgList ,
   PrimPath = DriverArgs.MakeArgString(getIncludePath() + "/rocprim");
 
 CC1Args.append({"-idirafter", ThrustPath, "-idirafter", PrimPath,
-"-idirafter", DriverArgs.MakeArgString(HIPStdParPathArg),
-"-include", "hipstdpar_lib.hpp"});
+"-idirafter", HIPStdParPath, "-include",
+"hipstdpar_lib.hpp"});
   };
 
   if (DriverArgs.hasArg(options::OPT_nogpuinc)) {

diff  --git a/clang/test/Driver/hipstdpar.c b/clang/test/Driver/hipstdpar.c
index 69c5b177d170cd8..2f48bf6b5cf1ebd 100644
--- a/clang/test/Driver/hipstdpar.c
+++ b/clang/test/Driver/hipstdpar.c
@@ -5,7 +5,8 @@
 // XFAIL: target={{.*}}-scei{{.*}}
 // XFAIL: target={{.*}}-sie{{.*}}
 
-// RUN: not %clang -### --hipstdpar -nogpulib -nogpuinc --compile %s 2>&1 | \
+// RUN: not %clang -### --hipstdpar --hipstdpar-path=/does/not/exist -nogpulib 
\
+// RUN:   -nogpuinc --compile %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=HIPSTDPAR-MISSING-LIB %s
 // RUN: %clang -### --hipstdpar --hipstdpar-path=%S/Inputs/hipstdpar \
 // RUN:   --hipstdpar-thrust-path=%S/Inputs/hipstdpar/thrust \



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


[clang] [WIP] Turn 'counted_by' into a type attribute and parse it into 'CountAttributedType' (PR #78000)

2024-01-22 Thread Yeoul Na via cfe-commits

https://github.com/rapidsna updated 
https://github.com/llvm/llvm-project/pull/78000

>From 1a17c254ddf09cd4faf5217b2f72da3f44622f8a Mon Sep 17 00:00:00 2001
From: Yeoul Na 
Date: Mon, 18 Dec 2023 10:58:16 +0900
Subject: [PATCH 1/5] [BoundsSafety] Introduce CountAttributedType

CountAttributedType is a sugar type to represent a type with
a 'counted_by' attribute and the likes, which provides bounds
information to the underlying type. The type contains an
the argument of attribute as an expression. Additionally, the type
holds metadata about declarations referenced by the expression in
order to make it easier for Sema to access declarations on which
the type depends.
---
 clang/include/clang/AST/ASTContext.h  |   7 +
 clang/include/clang/AST/PropertiesBase.td |   1 +
 clang/include/clang/AST/RecursiveASTVisitor.h |   9 ++
 clang/include/clang/AST/Type.h| 152 ++
 clang/include/clang/AST/TypeLoc.h |  26 +++
 clang/include/clang/AST/TypeProperties.td |  19 +++
 clang/include/clang/Basic/TypeNodes.td|   2 +
 .../clang/Serialization/ASTRecordReader.h |   2 +
 .../clang/Serialization/ASTRecordWriter.h |   5 +
 .../clang/Serialization/TypeBitCodes.def  |   1 +
 clang/lib/AST/ASTContext.cpp  |  56 +++
 clang/lib/AST/ASTImporter.cpp |  12 ++
 clang/lib/AST/ASTStructuralEquivalence.cpp|   7 +
 clang/lib/AST/ItaniumMangle.cpp   |   1 +
 clang/lib/AST/Type.cpp|  57 +++
 clang/lib/AST/TypeLoc.cpp |   4 +
 clang/lib/AST/TypePrinter.cpp |  23 +++
 clang/lib/CodeGen/CGDebugInfo.cpp |   1 +
 clang/lib/CodeGen/CodeGenFunction.cpp |   1 +
 clang/lib/Sema/SemaExpr.cpp   |   1 +
 clang/lib/Sema/TreeTransform.h|   7 +
 clang/lib/Serialization/ASTReader.cpp |   8 +
 clang/lib/Serialization/ASTWriter.cpp |   4 +
 clang/tools/libclang/CIndex.cpp   |   4 +
 24 files changed, 410 insertions(+)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 3e46a5da3fc043f..c8354fbb108a27d 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -247,6 +247,8 @@ class ASTContext : public RefCountedBase {
   DependentBitIntTypes;
   llvm::FoldingSet BTFTagAttributedTypes;
 
+  mutable llvm::FoldingSet CountAttributedTypes;
+
   mutable llvm::FoldingSet QualifiedTemplateNames;
   mutable llvm::FoldingSet DependentTemplateNames;
   mutable llvm::FoldingSet
@@ -1338,6 +1340,11 @@ class ASTContext : public RefCountedBase {
 return CanQualType::CreateUnsafe(getPointerType((QualType) T));
   }
 
+  QualType
+  getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes,
+ bool OrNull,
+ ArrayRef DependentDecls) 
const;
+
   /// Return the uniqued reference to a type adjusted from the original
   /// type to a new type.
   QualType getAdjustedType(QualType Orig, QualType New) const;
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index d86c4eba6a22511..25ddfd105ab8776 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -143,6 +143,7 @@ def UInt32 : CountPropertyType<"uint32_t">;
 def UInt64 : CountPropertyType<"uint64_t">;
 def UnaryTypeTransformKind : EnumPropertyType<"UnaryTransformType::UTTKind">;
 def VectorKind : EnumPropertyType<"VectorKind">;
+def TypeCoupledDeclRefInfo : PropertyType;
 
 def ExceptionSpecInfo : PropertyType<"FunctionProtoType::ExceptionSpecInfo"> {
   let BufferElementTypes = [ QualType ];
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 8f2714e142bbe3e..b57ab36939d07c0 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1099,6 +1099,12 @@ DEF_TRAVERSE_TYPE(InjectedClassNameType, {})
 DEF_TRAVERSE_TYPE(AttributedType,
   { TRY_TO(TraverseType(T->getModifiedType())); })
 
+DEF_TRAVERSE_TYPE(CountAttributedType, {
+  if (T->getCountExpr())
+TRY_TO(TraverseStmt(T->getCountExpr()));
+  TRY_TO(TraverseType(T->desugar()));
+})
+
 DEF_TRAVERSE_TYPE(BTFTagAttributedType,
   { TRY_TO(TraverseType(T->getWrappedType())); })
 
@@ -1385,6 +1391,9 @@ DEF_TRAVERSE_TYPELOC(MacroQualifiedType,
 DEF_TRAVERSE_TYPELOC(AttributedType,
  { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
 
+DEF_TRAVERSE_TYPELOC(CountAttributedType,
+ { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
+
 DEF_TRAVERSE_TYPELOC(BTFTagAttributedType,
  { TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index d4e5310fb3abc60..489644ca5acf869 100644
--- 

[clang-tools-extra] [libclc] [compiler-rt] [lldb] [libcxxabi] [libunwind] [llvm] [libcxx] [lld] [flang] [libc] [clang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

2024-01-22 Thread Fangrui Song via cfe-commits


@@ -89,8 +89,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine 
,
   if ((ABI == RISCVABI::ABI_ILP32F || ABI == RISCVABI::ABI_LP64F) &&
   !Subtarget.hasStdExtF()) {
 errs() << "Hard-float 'f' ABI can't be used for a target that "
-"doesn't support the F instruction set extension (ignoring "
-  "target-abi)\n";
+  "doesn't support the F instruction set extension (ignoring "

MaskRay wrote:

Ah, I only use `git diff -U0 --no-color --relative main... -- | 
path/to/clang/tools/clang-format/clang-format-diff.py -p1  -i` :)

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


[clang] [WIP] Turn 'counted_by' into a type attribute and parse it into 'CountAttributedType' (PR #78000)

2024-01-22 Thread Yeoul Na via cfe-commits

https://github.com/rapidsna updated 
https://github.com/llvm/llvm-project/pull/78000

>From 1a17c254ddf09cd4faf5217b2f72da3f44622f8a Mon Sep 17 00:00:00 2001
From: Yeoul Na 
Date: Mon, 18 Dec 2023 10:58:16 +0900
Subject: [PATCH 1/4] [BoundsSafety] Introduce CountAttributedType

CountAttributedType is a sugar type to represent a type with
a 'counted_by' attribute and the likes, which provides bounds
information to the underlying type. The type contains an
the argument of attribute as an expression. Additionally, the type
holds metadata about declarations referenced by the expression in
order to make it easier for Sema to access declarations on which
the type depends.
---
 clang/include/clang/AST/ASTContext.h  |   7 +
 clang/include/clang/AST/PropertiesBase.td |   1 +
 clang/include/clang/AST/RecursiveASTVisitor.h |   9 ++
 clang/include/clang/AST/Type.h| 152 ++
 clang/include/clang/AST/TypeLoc.h |  26 +++
 clang/include/clang/AST/TypeProperties.td |  19 +++
 clang/include/clang/Basic/TypeNodes.td|   2 +
 .../clang/Serialization/ASTRecordReader.h |   2 +
 .../clang/Serialization/ASTRecordWriter.h |   5 +
 .../clang/Serialization/TypeBitCodes.def  |   1 +
 clang/lib/AST/ASTContext.cpp  |  56 +++
 clang/lib/AST/ASTImporter.cpp |  12 ++
 clang/lib/AST/ASTStructuralEquivalence.cpp|   7 +
 clang/lib/AST/ItaniumMangle.cpp   |   1 +
 clang/lib/AST/Type.cpp|  57 +++
 clang/lib/AST/TypeLoc.cpp |   4 +
 clang/lib/AST/TypePrinter.cpp |  23 +++
 clang/lib/CodeGen/CGDebugInfo.cpp |   1 +
 clang/lib/CodeGen/CodeGenFunction.cpp |   1 +
 clang/lib/Sema/SemaExpr.cpp   |   1 +
 clang/lib/Sema/TreeTransform.h|   7 +
 clang/lib/Serialization/ASTReader.cpp |   8 +
 clang/lib/Serialization/ASTWriter.cpp |   4 +
 clang/tools/libclang/CIndex.cpp   |   4 +
 24 files changed, 410 insertions(+)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 3e46a5da3fc043f..c8354fbb108a27d 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -247,6 +247,8 @@ class ASTContext : public RefCountedBase {
   DependentBitIntTypes;
   llvm::FoldingSet BTFTagAttributedTypes;
 
+  mutable llvm::FoldingSet CountAttributedTypes;
+
   mutable llvm::FoldingSet QualifiedTemplateNames;
   mutable llvm::FoldingSet DependentTemplateNames;
   mutable llvm::FoldingSet
@@ -1338,6 +1340,11 @@ class ASTContext : public RefCountedBase {
 return CanQualType::CreateUnsafe(getPointerType((QualType) T));
   }
 
+  QualType
+  getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes,
+ bool OrNull,
+ ArrayRef DependentDecls) 
const;
+
   /// Return the uniqued reference to a type adjusted from the original
   /// type to a new type.
   QualType getAdjustedType(QualType Orig, QualType New) const;
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index d86c4eba6a22511..25ddfd105ab8776 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -143,6 +143,7 @@ def UInt32 : CountPropertyType<"uint32_t">;
 def UInt64 : CountPropertyType<"uint64_t">;
 def UnaryTypeTransformKind : EnumPropertyType<"UnaryTransformType::UTTKind">;
 def VectorKind : EnumPropertyType<"VectorKind">;
+def TypeCoupledDeclRefInfo : PropertyType;
 
 def ExceptionSpecInfo : PropertyType<"FunctionProtoType::ExceptionSpecInfo"> {
   let BufferElementTypes = [ QualType ];
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 8f2714e142bbe3e..b57ab36939d07c0 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1099,6 +1099,12 @@ DEF_TRAVERSE_TYPE(InjectedClassNameType, {})
 DEF_TRAVERSE_TYPE(AttributedType,
   { TRY_TO(TraverseType(T->getModifiedType())); })
 
+DEF_TRAVERSE_TYPE(CountAttributedType, {
+  if (T->getCountExpr())
+TRY_TO(TraverseStmt(T->getCountExpr()));
+  TRY_TO(TraverseType(T->desugar()));
+})
+
 DEF_TRAVERSE_TYPE(BTFTagAttributedType,
   { TRY_TO(TraverseType(T->getWrappedType())); })
 
@@ -1385,6 +1391,9 @@ DEF_TRAVERSE_TYPELOC(MacroQualifiedType,
 DEF_TRAVERSE_TYPELOC(AttributedType,
  { TRY_TO(TraverseTypeLoc(TL.getModifiedLoc())); })
 
+DEF_TRAVERSE_TYPELOC(CountAttributedType,
+ { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })
+
 DEF_TRAVERSE_TYPELOC(BTFTagAttributedType,
  { TRY_TO(TraverseTypeLoc(TL.getWrappedLoc())); })
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index d4e5310fb3abc60..489644ca5acf869 100644
--- 

[clang] [-Wunsafe-buffer-usage] Add a new warning for uses of std::span two-parameter constructors (PR #77148)

2024-01-22 Thread Ziqing Luo via cfe-commits

https://github.com/ziqingluo-90 updated 
https://github.com/llvm/llvm-project/pull/77148

>From 6ba957670ca593094b4545c35801585da2ee02a8 Mon Sep 17 00:00:00 2001
From: ziqingluo-90 
Date: Fri, 5 Jan 2024 13:39:39 -0800
Subject: [PATCH 1/2] [-Wunsafe-buffer-usage] Add a new warning for use of
 two-parameter std::span constructors

Constructing `std::span` objects with the two parameter constructors
could introduce mismatched bounds information, which defeats the
purpose of using `std::span`.  Therefore, we warn every use of such
constructors.

We also plan to incrementally teach `-Wunsafe-buffer-usage` about benign
usages of those constructors.

rdar://115817781
---
 .../Analysis/Analyses/UnsafeBufferUsage.h |   8 +-
 .../Analyses/UnsafeBufferUsageGadgets.def |   8 ++
 .../clang/Basic/DiagnosticSemaKinds.td|   3 +
 clang/lib/Analysis/UnsafeBufferUsage.cpp  |  46 ++
 clang/lib/Sema/AnalysisBasedWarnings.cpp  |  16 ++-
 ...ffer-usage-in-container-span-construct.cpp | 136 ++
 ...e-buffer-usage-warning-data-invocation.cpp |   2 +-
 7 files changed, 215 insertions(+), 4 deletions(-)
 create mode 100644 
clang/test/SemaCXX/warn-unsafe-buffer-usage-in-container-span-construct.cpp

diff --git a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
index b28f2c6b99c50ec..aca1ad998822c58 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
@@ -16,6 +16,7 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
+#include "clang/Basic/SourceLocation.h"
 #include "llvm/Support/Debug.h"
 
 namespace clang {
@@ -98,9 +99,14 @@ class UnsafeBufferUsageHandler {
 #endif
 
 public:
-  /// Returns a reference to the `Preprocessor`:
+  /// \return true iff buffer safety is opt-out at `Loc`; false otherwise.
   virtual bool isSafeBufferOptOut(const SourceLocation ) const = 0;
 
+  /// \return true iff unsafe uses in containers should NOT be reported at
+  /// `Loc`; false otherwise.
+  virtual bool
+  ignoreUnsafeBufferInContainer(const SourceLocation ) const = 0;
+
   virtual std::string
   getUnsafeBufferUsageAttributeTextAt(SourceLocation Loc,
   StringRef WSSuffix = "") const = 0;
diff --git a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def 
b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
index c97661688365102..07f805ebb110132 100644
--- a/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
+++ b/clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
@@ -18,6 +18,12 @@
 #define WARNING_GADGET(name) GADGET(name)
 #endif
 
+/// A `WARNING_GADGET` subset, where the code pattern of each gadget
+/// corresponds uses of a (possibly hardened) contatiner (e.g., `std::span`).
+#ifndef WARNING_CONTAINER_GADGET
+#define WARNING_CONTAINER_GADGET(name) WARNING_GADGET(name)
+#endif
+
 /// Safe gadgets correspond to code patterns that aren't unsafe but need to be
 /// properly recognized in order to emit correct warnings and fixes over unsafe
 /// gadgets.
@@ -31,6 +37,7 @@ WARNING_GADGET(ArraySubscript)
 WARNING_GADGET(PointerArithmetic)
 WARNING_GADGET(UnsafeBufferUsageAttr)
 WARNING_GADGET(DataInvocation)
+WARNING_CONTAINER_GADGET(SpanTwoParamConstructor) // Uses of `std::span(arg0, 
arg1)`
 FIXABLE_GADGET(ULCArraySubscript)  // `DRE[any]` in an Unspecified 
Lvalue Context
 FIXABLE_GADGET(DerefSimplePtrArithFixable)
 FIXABLE_GADGET(PointerDereference)
@@ -43,4 +50,5 @@ FIXABLE_GADGET(PointerInit)
 
 #undef FIXABLE_GADGET
 #undef WARNING_GADGET
+#undef WARNING_CONTAINER_GADGET
 #undef GADGET
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e54f969c19039dd..940de9629d79862 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12075,6 +12075,9 @@ def note_unsafe_buffer_variable_fixit_together : Note<
   "%select{|, and change %2 to safe types to make function %4 bounds-safe}3">;
 def note_safe_buffer_usage_suggestions_disabled : Note<
   "pass -fsafe-buffer-usage-suggestions to receive code hardening 
suggestions">;
+def warn_unsafe_buffer_usage_in_container : Warning<
+  "%select{the two-parameter std::span construction is unsafe as it can 
introduce mismatch between buffer size and the bound information}0">,
+  InGroup, DefaultIgnore;
 #ifndef NDEBUG
 // Not a user-facing diagnostic. Useful for debugging false negatives in
 // -fsafe-buffer-usage-suggestions (i.e. lack of -Wunsafe-buffer-usage fixits).
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 724c4304a072420..3b6d69cac1afd86 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -232,6 +232,11 @@ AST_MATCHER_P(Stmt, notInSafeBufferOptOut, 

[clang] [llvm] [WIP] Correct lowering of `fp128` intrinsics (PR #76558)

2024-01-22 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Putting a function in TargetMachine seems reasonable.

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


[clang-tools-extra] [clangd] Make sure ninja can clean "ClangdXPC.framework" (PR #75669)

2024-01-22 Thread via cfe-commits

https://github.com/jkorous-apple approved this pull request.

LGTM

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


[clang] [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT options (PR #69133)

2024-01-22 Thread Amir Ayupov via cfe-commits

aaupov wrote:

Reverted. Strangely I couldn't repro from 
https://lab.llvm.org/buildbot/#/builders/225/builds/29950/ the failure locally. 
But will get to the bottom of it.

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


[clang] 6953b36 - Revert "Reland [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT options (#69133)"

2024-01-22 Thread Amir Ayupov via cfe-commits

Author: Amir Ayupov
Date: 2024-01-22T14:56:43-08:00
New Revision: 6953b367027e4234607a6718a0a1d57eb52ef57e

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

LOG: Revert "Reland [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT 
options (#69133)"

This reverts commit b83b8d3fd17885438b0ea154e07088d877d293a8.

Breaks buildbots e.g.
https://lab.llvm.org/buildbot/#/builders/225/builds/29950

Added: 


Modified: 
clang/CMakeLists.txt
clang/cmake/caches/BOLT.cmake
clang/utils/perf-training/CMakeLists.txt
clang/utils/perf-training/bolt.lit.cfg
clang/utils/perf-training/bolt.lit.site.cfg.in
clang/utils/perf-training/perf-helper.py

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 47fc2e4886cfc28..5f2b7f064da4377 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -876,38 +876,23 @@ if (CLANG_ENABLE_BOOTSTRAP)
   endforeach()
 endif()
 
-set(CLANG_BOLT OFF CACHE STRING "Apply BOLT optimization to Clang. \
-  May be specified as Instrument or Perf or LBR to use a particular profiling \
-  mechanism.")
-string(TOUPPER "${CLANG_BOLT}" CLANG_BOLT)
-
-if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
+if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
-  set(CLANG_INSTRUMENTED 
${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_BOLT_INSTRUMENTED})
+  set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst)
   set(BOLT_FDATA ${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/prof.fdata)
 
-  # Pass extra flag in no-LBR mode
-  if (CLANG_BOLT STREQUAL "PERF")
-set(BOLT_NO_LBR "-nl")
-  endif()
-
-  if (CLANG_BOLT STREQUAL "INSTRUMENT")
-# Instrument clang with BOLT
-add_custom_target(clang-instrumented
-  DEPENDS ${CLANG_INSTRUMENTED}
-)
-add_custom_command(OUTPUT ${CLANG_INSTRUMENTED}
-  DEPENDS clang llvm-bolt
-  COMMAND llvm-bolt ${CLANG_PATH} -o ${CLANG_INSTRUMENTED}
--instrument --instrumentation-file-append-pid
---instrumentation-file=${BOLT_FDATA}
-  COMMENT "Instrumenting clang binary with BOLT"
-  VERBATIM
-)
-add_custom_target(clang-bolt-training-deps DEPENDS clang-instrumented)
-  else() # perf or LBR
-add_custom_target(clang-bolt-training-deps DEPENDS clang)
-  endif()
+  # Instrument clang with BOLT
+  add_custom_target(clang-instrumented
+DEPENDS ${CLANG_INSTRUMENTED}
+  )
+  add_custom_command(OUTPUT ${CLANG_INSTRUMENTED}
+DEPENDS clang llvm-bolt
+COMMAND llvm-bolt ${CLANG_PATH} -o ${CLANG_INSTRUMENTED}
+  -instrument --instrumentation-file-append-pid
+  --instrumentation-file=${BOLT_FDATA}
+COMMENT "Instrumenting clang binary with BOLT"
+VERBATIM
+  )
 
   # Optimize original (pre-bolt) Clang using the collected profile
   set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt)
@@ -921,7 +906,6 @@ if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
   -data ${BOLT_FDATA}
   -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions
   -split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack
-  ${BOLT_NO_LBR}
 COMMAND ${CMAKE_COMMAND} -E rename ${CLANG_OPTIMIZED} $
 COMMENT "Optimizing Clang with BOLT"
 VERBATIM

diff  --git a/clang/cmake/caches/BOLT.cmake b/clang/cmake/caches/BOLT.cmake
index eba2346b2f4ca12..0442f73e5426ac7 100644
--- a/clang/cmake/caches/BOLT.cmake
+++ b/clang/cmake/caches/BOLT.cmake
@@ -1,5 +1,5 @@
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
-set(CLANG_BOLT "INSTRUMENT" CACHE STRING "")
+set(CLANG_BOLT_INSTRUMENT ON CACHE BOOL "")
 set(CMAKE_EXE_LINKER_FLAGS "-Wl,--emit-relocs,-znow" CACHE STRING "")
 
 set(LLVM_ENABLE_PROJECTS "bolt;clang" CACHE STRING "")

diff  --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index 601f40902fa34ea..c6d51863fb1b5c2 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -62,9 +62,7 @@ if(APPLE AND DTRACE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
 DEPENDS generate-dtrace-logs)
 endif()
 
-if(CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
-  set(CLANG_BOLT_INSTRUMENTED "clang-bolt.inst" CACHE STRING
-"Name of BOLT-instrumented Clang binary")
+if(CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/bolt.lit.site.cfg.in
 ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/lit.site.cfg
@@ -73,37 +71,16 @@ if(CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
   add_lit_testsuite(generate-bolt-fdata "Generating BOLT profile for Clang"
 ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/
 EXCLUDE_FROM_CHECK_ALL
-DEPENDS clang-bolt-training-deps clear-bolt-fdata clear-perf-data
+DEPENDS clang-instrumented clear-bolt-fdata
 )
 
   

[clang-tools-extra] [clang-tidy] Ignore user-defined literals in google-runtime-int (PR #78859)

2024-01-22 Thread FĂ©lix-Antoine Constantin via cfe-commits

felix642 wrote:

@PiotrZSL would you be able to commit those changes for me please  ? 

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


  1   2   3   4   5   6   7   >