[clang] [lld] [llvm] Deprecate the `-fbasic-block-sections=labels` option. (PR #107494)

2024-09-13 Thread James Henderson via cfe-commits

jh7370 wrote:

Just chiming in that I happened to spot the pre-merge check failure looks 
possibly related.

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


[clang] Reland "[clang] Add nuw attribute to GEPs (#105496)" (PR #107257)

2024-09-13 Thread Nikita Popov via cfe-commits

nikic wrote:

Should be fixed by 
https://github.com/llvm/llvm-project/commit/940f89255e4a3982d94dad57837e8e658092af78.

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


[clang] [llvm] [SPIRV][RFC] Rework / extend support for memory scopes (PR #106429)

2024-09-13 Thread Matt Arsenault via cfe-commits


@@ -251,6 +251,24 @@ SPIRV::MemorySemantics::MemorySemantics 
getMemSemantics(AtomicOrdering Ord) {
   llvm_unreachable(nullptr);
 }
 
+SPIRV::Scope::Scope getMemScope(const LLVMContext &Ctx, SyncScope::ID ID) {
+  SmallVector SSNs;
+  Ctx.getSyncScopeNames(SSNs);
+
+  StringRef MemScope = SSNs[ID];
+  if (MemScope.empty() || MemScope == "all_svm_devices")

arsenm wrote:

Hard disagree, we do not want aliases. System = "" = all_svm_devices 

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-SATCVT-DS new instructions. (PR #102592)

2024-09-13 Thread Malay Sanghi via cfe-commits


@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-unknown-unknown -target-feature +avx10.2-512 -emit-llvm -Wall 
-Werror -verify

MalaySanghi wrote:

Hi,
Thanks for bringing this to my notice. I'll send a patch next week

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


[clang] [clang-format] Reimplement InsertNewlineAtEOF (PR #108513)

2024-09-13 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/108513

Fixes #108333.

>From c85d8cdd44ad577bbc2a29e45058b0c972c6fa9e Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Fri, 13 Sep 2024 01:21:29 -0700
Subject: [PATCH] [clang-format] Reimplement InsertNewlineAtEOF

Fixes #108333.
---
 clang/lib/Format/FormatTokenLexer.cpp | 7 +++
 clang/lib/Format/TokenAnnotator.cpp   | 5 -
 clang/unittests/Format/FormatTest.cpp | 6 ++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index e21b5a882b7773..63949b2e26bdc1 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -100,6 +100,13 @@ ArrayRef FormatTokenLexer::lex() {
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
   } while (Tokens.back()->isNot(tok::eof));
+  if (Style.InsertNewlineAtEOF) {
+auto &TokEOF = *Tokens.back();
+if (TokEOF.NewlinesBefore == 0) {
+  TokEOF.NewlinesBefore = 1;
+  TokEOF.OriginalColumn = 0;
+}
+  }
   return Tokens;
 }
 
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index dfa703aed0d34d..aa0d310a355ff6 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3704,11 +3704,6 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
   auto *First = Line.First;
   First->SpacesRequiredBefore = 1;
   First->CanBreakBefore = First->MustBreakBefore;
-
-  if (First->is(tok::eof) && First->NewlinesBefore == 0 &&
-  Style.InsertNewlineAtEOF) {
-First->NewlinesBefore = 1;
-  }
 }
 
 // This function heuristically determines whether 'Current' starts the name of 
a
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 5ebf0d7068dd6c..033daa3645db0d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -27577,6 +27577,12 @@ TEST_F(FormatTest, InsertNewlineAtEOF) {
 
   verifyNoChange("int i;\n", Style);
   verifyFormat("int i;\n", "int i;", Style);
+
+  constexpr StringRef Code{"namespace {\n"
+   "int i;\n"
+   "} // namespace"};
+  verifyFormat(Code.str() + '\n', Code, Style,
+   {tooling::Range(19, 13)}); // line 3
 }
 
 TEST_F(FormatTest, KeepEmptyLinesAtEOF) {

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


[clang] [clang-format] Reimplement InsertNewlineAtEOF (PR #108513)

2024-09-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fixes #108333.

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


3 Files Affected:

- (modified) clang/lib/Format/FormatTokenLexer.cpp (+7) 
- (modified) clang/lib/Format/TokenAnnotator.cpp (-5) 
- (modified) clang/unittests/Format/FormatTest.cpp (+6) 


``diff
diff --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index e21b5a882b7773..63949b2e26bdc1 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -100,6 +100,13 @@ ArrayRef FormatTokenLexer::lex() {
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
   } while (Tokens.back()->isNot(tok::eof));
+  if (Style.InsertNewlineAtEOF) {
+auto &TokEOF = *Tokens.back();
+if (TokEOF.NewlinesBefore == 0) {
+  TokEOF.NewlinesBefore = 1;
+  TokEOF.OriginalColumn = 0;
+}
+  }
   return Tokens;
 }
 
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index dfa703aed0d34d..aa0d310a355ff6 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3704,11 +3704,6 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
   auto *First = Line.First;
   First->SpacesRequiredBefore = 1;
   First->CanBreakBefore = First->MustBreakBefore;
-
-  if (First->is(tok::eof) && First->NewlinesBefore == 0 &&
-  Style.InsertNewlineAtEOF) {
-First->NewlinesBefore = 1;
-  }
 }
 
 // This function heuristically determines whether 'Current' starts the name of 
a
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 5ebf0d7068dd6c..033daa3645db0d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -27577,6 +27577,12 @@ TEST_F(FormatTest, InsertNewlineAtEOF) {
 
   verifyNoChange("int i;\n", Style);
   verifyFormat("int i;\n", "int i;", Style);
+
+  constexpr StringRef Code{"namespace {\n"
+   "int i;\n"
+   "} // namespace"};
+  verifyFormat(Code.str() + '\n', Code, Style,
+   {tooling::Range(19, 13)}); // line 3
 }
 
 TEST_F(FormatTest, KeepEmptyLinesAtEOF) {

``




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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2-SATCVT-DS new instructions. (PR #102592)

2024-09-13 Thread Malay Sanghi via cfe-commits

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


[clang] [perf-training] Fix dependencies when using -DCLANG_PGO_TRAINING_DATA_SOURCE_DIR (PR #108488)

2024-09-13 Thread Konrad Kleine via cfe-commits

kwk wrote:

I'm trying this patch locally now.

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


[clang] 5d1d2f0 - [clang][ExprConst] Allow comparisons with string literals (#106733)

2024-09-13 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-13T10:30:02+02:00
New Revision: 5d1d2f08c4a92580e7f6b3b6b77b2b6f6184e126

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

LOG: [clang][ExprConst] Allow comparisons with string literals (#106733)

Don't diagnose them, but literals still have distinct addresses.

Fixes https://github.com/llvm/llvm-project/issues/58754

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/AST/ByteCode/cxx20.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 6387e375dda79c..4af7752d3b238b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2146,7 +2146,7 @@ static bool IsLiteralLValue(const LValue &Value) {
   if (Value.getLValueCallIndex())
 return false;
   const Expr *E = Value.Base.dyn_cast();
-  return E && !isa(E);
+  return E && !isa(E);
 }
 
 static bool IsWeakLValue(const LValue &Value) {

diff  --git a/clang/test/AST/ByteCode/cxx20.cpp 
b/clang/test/AST/ByteCode/cxx20.cpp
index 9bbc3dbe0073d3..b47a4b47d09644 100644
--- a/clang/test/AST/ByteCode/cxx20.cpp
+++ b/clang/test/AST/ByteCode/cxx20.cpp
@@ -108,22 +108,16 @@ constexpr auto p2 = "test2";
 constexpr bool b1 = foo(p1) == foo(p1);
 static_assert(b1);
 
-constexpr bool b2 = foo(p1) == foo(p2); // ref-error {{must be initialized by 
a constant expression}} \
-// ref-note {{comparison of addresses 
of literals}} \
-// ref-note {{declared here}}
-static_assert(!b2); // ref-error {{not an integral constant expression}} \
-// ref-note {{not a constant expression}}
+constexpr bool b2 = foo(p1) == foo(p2);
+static_assert(!b2);
 
 constexpr auto name1() { return "name1"; }
 constexpr auto name2() { return "name2"; }
 
 constexpr auto b3 = name1() == name1();
 static_assert(b3);
-constexpr auto b4 = name1() == name2(); // ref-error {{must be initialized by 
a constant expression}} \
-// ref-note {{has unspecified value}} \
-// ref-note {{declared here}}
-static_assert(!b4); // ref-error {{not an integral constant expression}} \
-// ref-note {{not a constant expression}}
+constexpr auto b4 = name1() == name2();
+static_assert(!b4);
 
 namespace UninitializedFields {
   class A {

diff  --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp 
b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index 44ef540f41fa8c..d2d2f1a127eaeb 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -358,11 +358,9 @@ struct Str {
 
 extern char externalvar[];
 constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // 
expected-error {{must be initialized by a constant expression}} expected-note 
{{reinterpret_cast}}
-constexpr bool litaddress = "foo" == "foo"; // expected-error {{must be 
initialized by a constant expression}}
-// expected-note@-1 {{comparison of addresses of literals has unspecified 
value}}
-// cxx20_23-warning@-2 {{comparison between two arrays is deprecated}}
+constexpr bool litaddress = "foo" == "foo"; // cxx20_23-warning {{comparison 
between two arrays is deprecated}}
 static_assert(0 != "foo", "");
-
+static_assert("foo" != "foo", "");// cxx20_23-warning {{comparison between two 
arrays is deprecated}}
 }
 
 namespace MaterializeTemporary {



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


[clang] [clang][ExprConst] Allow comparisons with string literals (PR #106733)

2024-09-13 Thread Timm Baeder via cfe-commits

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


[clang] Fix the behavior of __COUNT__ macros when PCH is enabled (PR #105591)

2024-09-13 Thread via cfe-commits


@@ -1243,12 +1247,19 @@ bool 
ASTUnit::Parse(std::shared_ptr PCHContainerOps,
   }
 
   std::unique_ptr Act(
-  new TopLevelDeclTrackerAction(*this));
+  new TopLevelDeclTrackerAction(*this, true));

cor3ntin wrote:

Moreover, can you explain the "reuse  preprocessor" logic, which seems 
orthogonal to the goal of preserving `__COUNT__`? (ie, i would expect count to 
be preserved, not the whole preprocessor).
Unless I am missing something, I think this would simplify the patch a bit.

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


[clang] [compiler-rt] [llvm] [FMV][AArch64] Remove feature sha1 from FMV. (PR #108383)

2024-09-13 Thread Alexandros Lamprineas via cfe-commits

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


[clang] [Clang][ARM] Make CRC and DSP intrinsics always available. (PR #107417)

2024-09-13 Thread Daniel Kiss via cfe-commits

DanielKristofKiss wrote:

> I think this is OK but do you know if the dsp side works with cortex-m? 
> Target attributes are less likely to be used there, but it's worth testing if 
> the command line args are still all happy.

This seems works fine:
```c
#include 
int dsp() {
return __smlabb(1,3,4);
}
```
cat dpp.c | bin/clang dpp.c -O2 -target thumb-none-gnueabi -mcpu=cortex-m4 -c 
-o - | llvm-objdump -d -
```
:file format elf32-littlearm

Disassembly of section .text:

 :
   0: 2004  movsr0, #0x4
   2: 2103  movsr1, #0x3
   4: 2201  movsr2, #0x1
   6: fb12 0001 smlabb  r0, r2, r1, r0
   a: 4770  bx  lr
```

could be added to the clang/test/Codegen/acle_test.c too. but we seem don't 
have too many M class test for these things...
```
// RUN: %clang_cc1 -ffreestanding -triple thumbv7em-unknown-none-gnueabi 
-target-feature -crc -target-feature +dsp -O0 -disable-O0-optnone -emit-llvm -o 
- %s | opt -S -passes=mem2reg | FileCheck %s -check-prefixes=ARM,AArch32`
``

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


[clang] [llvm] [RISCV] Add Syntacore SCR7 processor definition (PR #108406)

2024-09-13 Thread Anton Sidorenko via cfe-commits


@@ -502,3 +502,28 @@
 
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr5-rv64 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR5-RV64 %s
 // MTUNE-SYNTACORE-SCR5-RV64: "-tune-cpu" "syntacore-scr5-rv64"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=syntacore-scr7 | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR7 %s
+// MCPU-SYNTACORE-SCR7: "-target-cpu" "syntacore-scr7"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+m"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+a"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+f"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+d"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zicsr"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zifencei"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zba"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbb"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbc"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbkb"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbkc"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbkx"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbs"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zkn"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zknd"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zkne"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zknh"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-abi" "lp64d"

asi-sc wrote:

Thanks for catching this! Addressed.

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


[clang] [llvm] [RISCV] Add Syntacore SCR7 processor definition (PR #108406)

2024-09-13 Thread Anton Sidorenko via cfe-commits

https://github.com/asi-sc updated 
https://github.com/llvm/llvm-project/pull/108406

>From 0c2925d18e8e4312a16d081c1c97d3298b85e8d4 Mon Sep 17 00:00:00 2001
From: Anton Sidorenko 
Date: Mon, 2 Sep 2024 13:25:39 +0300
Subject: [PATCH 1/2] [RISCV] Add Syntacore SCR7 processor definition

Syntacore SCR7 is a high-performance Linux-capable RISC-V processor core.
The core has rv64imafdcv_zba_zbb_zbc_zbs_zkn march.
Overview: https://syntacore.com/products/scr7

Scheduling model will be added in a subsequent PR.

Co-authored-by: Dmitrii Petrov 
Co-authored-by: Anton Afanasyev 
Co-authored-by: Elena Lepilkina 
---
 clang/test/Driver/riscv-cpus.c| 25 +++
 .../test/Misc/target-invalid-cpu-note/riscv.c |  2 ++
 llvm/docs/ReleaseNotes.rst|  1 +
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 19 ++
 4 files changed, 47 insertions(+)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 481eaae9153e86..79256e402c0b74 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -502,3 +502,28 @@
 
 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr5-rv64 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR5-RV64 %s
 // MTUNE-SYNTACORE-SCR5-RV64: "-tune-cpu" "syntacore-scr5-rv64"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=syntacore-scr7 | 
FileCheck -check-prefix=MCPU-SYNTACORE-SCR7 %s
+// MCPU-SYNTACORE-SCR7: "-target-cpu" "syntacore-scr7"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+m"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+a"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+f"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+d"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+c"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zicsr"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zifencei"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zba"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbb"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbc"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbkb"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbkc"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbkx"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zbs"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zkn"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zknd"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zkne"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-feature" "+zknh"
+// MCPU-SYNTACORE-SCR7-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr7 | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR7 %s
+// MTUNE-SYNTACORE-SCR7: "-tune-cpu" "syntacore-scr7"
diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c 
b/clang/test/Misc/target-invalid-cpu-note/riscv.c
index 96d3cefd434d78..7bbf3574af3c35 100644
--- a/clang/test/Misc/target-invalid-cpu-note/riscv.c
+++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c
@@ -40,6 +40,7 @@
 // RISCV64-SAME: {{^}}, syntacore-scr3-rv64
 // RISCV64-SAME: {{^}}, syntacore-scr4-rv64
 // RISCV64-SAME: {{^}}, syntacore-scr5-rv64
+// RISCV64-SAME: {{^}}, syntacore-scr7
 // RISCV64-SAME: {{^}}, veyron-v1
 // RISCV64-SAME: {{^}}, xiangshan-nanhu
 // RISCV64-SAME: {{$}}
@@ -85,6 +86,7 @@
 // TUNE-RISCV64-SAME: {{^}}, syntacore-scr3-rv64
 // TUNE-RISCV64-SAME: {{^}}, syntacore-scr4-rv64
 // TUNE-RISCV64-SAME: {{^}}, syntacore-scr5-rv64
+// TUNE-RISCV64-SAME: {{^}}, syntacore-scr7
 // TUNE-RISCV64-SAME: {{^}}, veyron-v1
 // TUNE-RISCV64-SAME: {{^}}, xiangshan-nanhu
 // TUNE-RISCV64-SAME: {{^}}, generic
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 52456896f2fc6c..6df4c37b092432 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -123,6 +123,7 @@ Changes to the RISC-V Backend
   largely untested.
 * The ``Zvbc32e`` and ``Zvkgs`` extensions are now supported experimentally.
 * Added ``Smctr`` and ``Ssctr`` extensions.
+* ``-mcpu=syntacore-scr7`` was added.
 
 Changes to the WebAssembly Backend
 --
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index d4ec5ecc6489c1..c4e1a1457e8d30 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -383,6 +383,25 @@ def SYNTACORE_SCR5_RV64 : 
RISCVProcessorModel<"syntacore-scr5-rv64",
FeatureStdExtC],
   [TuneNoDefaultUnroll, 
FeaturePostRAScheduler]>;
 
+def SYNTACORE_SCR7 : RISCVProcessorModel<"syntacore-scr7",
+  NoSchedModel,
+  [Feature64Bit,
+   FeatureStdExtI,
+   FeatureStdExtZicsr,
+   FeatureStdExtZifencei,
+  

[clang] [compiler-rt] [llvm] [FMV][AArch64] Remove feature sha1 from FMV. (PR #108383)

2024-09-13 Thread Alexandros Lamprineas via cfe-commits


@@ -33,7 +33,6 @@ enum CPUFeatures {
   FEAT_FP,
   FEAT_SIMD,
   FEAT_CRC,
-  FEAT_SHA1,

labrinea wrote:

It was raised on another pr, so perhaps it is.

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


[clang] [C++20] [Modules] Warn for importing implementation partition unit in interface units (PR #108493)

2024-09-13 Thread via cfe-commits


@@ -439,6 +439,9 @@ def warn_deprecated_literal_operator_id: Warning<
   "is deprecated">, InGroup, DefaultIgnore;
 def warn_reserved_module_name : Warning<
   "%0 is a reserved name for a module">, InGroup;
+def warn_import_implementation_partition_unit_in_interface_unit : Warning<
+  "it is not suggested to import implementation partition unit in interface 
unit">,

cor3ntin wrote:

```suggestion
  "importing an implementation partition unit in a module interface is not 
recommended. Symbols exported by %0 may not be reachable">,
```
Maybe something like that ?

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

@tru This patch at the very least needs to make it for 19.x but I was hoping 
we'd get some of the tuning improvements in as well - should we wait for those 
PRs or just get this committed and cherry picked straight away?

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


[clang] [C++20] [Modules] Warn for importing implementation partition unit in interface units (PR #108493)

2024-09-13 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/108493

>From b109ea29ee6d1c290766e141ce75317fbf450767 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Fri, 13 Sep 2024 13:18:43 +0800
Subject: [PATCH 1/2] [C++20] [Modules] Warn for importing implementation
 partition unit in interface units

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 +++
 clang/lib/Sema/SemaModule.cpp| 7 +++
 clang/test/CXX/module/module.import/p2.cpp   | 3 +--
 clang/test/Modules/cxx20-10-3-ex1.cpp| 1 +
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index efdc058edca56d..7545a06123789d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -439,6 +439,9 @@ def warn_deprecated_literal_operator_id: Warning<
   "is deprecated">, InGroup, DefaultIgnore;
 def warn_reserved_module_name : Warning<
   "%0 is a reserved name for a module">, InGroup;
+def warn_import_implementation_partition_unit_in_interface_unit : Warning<
+  "it is not suggested to import implementation partition unit in interface 
unit">,
+  InGroup>;
 
 def warn_parameter_size: Warning<
   "%0 is a large (%1 bytes) pass-by-value argument; "
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 3b84e7bd4277fd..9a80adbde60d19 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -650,6 +650,13 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
   else
 VisibleModules.setVisible(Mod, ImportLoc);
 
+  assert((!Mod->isModulePartitionImplementation() || getCurrentModule()) &&
+ "We can only import a partition unit in a named module.");
+  if (Mod->isModulePartitionImplementation() &&
+  getCurrentModule()->isModuleInterfaceUnit())
+Diag(ImportLoc,
+ diag::warn_import_implementation_partition_unit_in_interface_unit);
+
   checkModuleImportContext(*this, Mod, ImportLoc, CurContext);
 
   // FIXME: we should support importing a submodule within a different 
submodule
diff --git a/clang/test/CXX/module/module.import/p2.cpp 
b/clang/test/CXX/module/module.import/p2.cpp
index ef6006811e7763..3ac76856c7cfc3 100644
--- a/clang/test/CXX/module/module.import/p2.cpp
+++ b/clang/test/CXX/module/module.import/p2.cpp
@@ -30,9 +30,8 @@ void test() {
 }
 
 //--- UseInPartA.cppm
-// expected-no-diagnostics
 export module M:partA;
-import :impl;
+import :impl; // expected-warning {{it is not suggested to import 
implementation partition unit in interface unit}}
 void test() {
   A a;
 }
diff --git a/clang/test/Modules/cxx20-10-3-ex1.cpp 
b/clang/test/Modules/cxx20-10-3-ex1.cpp
index 99b88c7e442ffd..dcdc92340366ae 100644
--- a/clang/test/Modules/cxx20-10-3-ex1.cpp
+++ b/clang/test/Modules/cxx20-10-3-ex1.cpp
@@ -37,6 +37,7 @@ module M:PartImpl;
 export module M;
  // error: exported partition :Part is an implementation 
unit
 export import :PartImpl; // expected-error {{module partition implementations 
cannot be exported}}
+ // expected-warning@-1 {{it is not suggested to 
import implementation partition unit in interface unit}}
 
 //--- std10-3-ex1-tu3.cpp
 export module M:Part;

>From c3d3f78ce81a7a1b5f589624a9a792b46f3ff811 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Fri, 13 Sep 2024 17:09:30 +0800
Subject: [PATCH 2/2] address comments

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 ++-
 clang/lib/Sema/SemaModule.cpp| 3 ++-
 clang/test/CXX/module/module.import/p2.cpp   | 2 +-
 clang/test/Modules/cxx20-10-3-ex1.cpp| 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7545a06123789d..10bb91564c2afa 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -440,7 +440,8 @@ def warn_deprecated_literal_operator_id: Warning<
 def warn_reserved_module_name : Warning<
   "%0 is a reserved name for a module">, InGroup;
 def warn_import_implementation_partition_unit_in_interface_unit : Warning<
-  "it is not suggested to import implementation partition unit in interface 
unit">,
+  "importing an implementation partition unit in a module interface is not 
recommended. "
+  "Names in by %0 may not be reachable">,
   InGroup>;
 
 def warn_parameter_size: Warning<
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 9a80adbde60d19..4b3a480a2f8f4a 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -655,7 +655,8 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
   if (Mod->isModulePartitionImplementation() &&
   getCurrentModule()->isModuleInterfaceUnit())
 Diag(ImportLoc,
- diag::warn_impo

[clang] [C++20] [Modules] Warn for importing implementation partition unit in interface units (PR #108493)

2024-09-13 Thread Chuanqi Xu via cfe-commits


@@ -439,6 +439,9 @@ def warn_deprecated_literal_operator_id: Warning<
   "is deprecated">, InGroup, DefaultIgnore;
 def warn_reserved_module_name : Warning<
   "%0 is a reserved name for a module">, InGroup;
+def warn_import_implementation_partition_unit_in_interface_unit : Warning<
+  "it is not suggested to import implementation partition unit in interface 
unit">,

ChuanqiXu9 wrote:

Done. But I changed `Symbols exported ` to `Names in ` since the term `name` is 
more precise and we won't export things in implementation partition unit.

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


[clang] a0f8890 - [clang][C23] Support N3029 Improved Normal Enumerations (#103917)

2024-09-13 Thread via cfe-commits

Author: Mariya Podchishchaeva
Date: 2024-09-13T11:11:34+02:00
New Revision: a0f88901a4e6a6618c3ec02108103d0415e28834

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

LOG: [clang][C23] Support N3029 Improved Normal Enumerations (#103917)

Basically clang already implemented 90% of the feature as an extension.
This commit disables warnings for C23 and aligns types of enumerators
according to the recent wording.

Added: 
clang/test/C/C23/n3029.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/test/Misc/warning-flags.c
clang/test/Sema/enum.c
clang/www/c_status.html

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c4fa017b982bbd..3929a9fb599259 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -179,6 +179,8 @@ C2y Feature Support
 C23 Feature Support
 ^^^
 
+- Clang now supports `N3029 
`_ Improved Normal 
Enumerations.
+
 Non-comprehensive list of changes in this release
 -
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index efdc058edca56d..3a465464bc5b47 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1039,7 +1039,6 @@ def err_opencl_invalid_param : Error<
   "declaring function parameter of type %0 is not allowed%select{; did you 
forget * ?|}1">;
 def err_opencl_invalid_return : Error<
   "declaring function return value of type %0 is not allowed %select{; did you 
forget * ?|}1">;
-def warn_enum_value_overflow : Warning<"overflow in enumeration value">;
 def warn_pragma_options_align_reset_failed : Warning<
   "#pragma options align=reset failed: %0">,
   InGroup;
@@ -6194,9 +6193,13 @@ def err_misplaced_ivar : Error<
 def warn_ivars_in_interface : Warning<
   "declaration of instance variables in the interface is deprecated">,
   InGroup>, DefaultIgnore;
-def ext_enum_value_not_int : Extension<
-  "ISO C restricts enumerator values to range of 'int' (%0 is too "
-  "%select{small|large}1)">;
+def ext_c23_enum_value_not_int : Extension<
+  "%select{|incremented }0enumerator value which exceeds the range of 'int' is 
"
+  "a C23 extension (%1 is too %select{small|large}2)">, InGroup;
+def warn_c17_compat_enum_value_not_int : Warning<
+  "%select{|incremented }0enumerator value which exceeds the range of 'int' is 
"
+  "incompatible with C standards before C23 (%1 is too 
%select{small|large}2)">,
+  DefaultIgnore, InGroup;
 def ext_enum_too_large : ExtWarn<
   "enumeration values exceed range of largest integer">, InGroup;
 def ext_enumerator_increment_too_large : ExtWarn<

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3c6a0dff798ff6..8557c25b93a8da 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -19479,11 +19479,13 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl 
*Enum,
   //   representable as an int.
 
   // Complain if the value is not representable in an int.
-  if (!isRepresentableIntegerValue(Context, EnumVal, Context.IntTy))
-Diag(IdLoc, diag::ext_enum_value_not_int)
-  << toString(EnumVal, 10) << Val->getSourceRange()
-  << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
-  else if (!Context.hasSameType(Val->getType(), Context.IntTy)) {
+  if (!isRepresentableIntegerValue(Context, EnumVal, Context.IntTy)) {
+Diag(IdLoc, getLangOpts().C23
+? diag::warn_c17_compat_enum_value_not_int
+: diag::ext_c23_enum_value_not_int)
+<< 0 << toString(EnumVal, 10) << Val->getSourceRange()
+<< (EnumVal.isUnsigned() || EnumVal.isNonNegative());
+  } else if (!Context.hasSameType(Val->getType(), Context.IntTy)) {
 // Force the type of the expression to 'int'.
 Val = ImpCastExprToType(Val, Context.IntTy, CK_IntegralCast).get();
   }
@@ -19558,17 +19560,22 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl 
*Enum,
 
 // If we're not in C++, diagnose the overflow of enumerator values,
 // which in C99 means that the enumerator value is not representable in
-// an int (C99 6.7.2.2p2). However, we support GCC's extension that
-// permits enumerator values that are representable in some larger
-// integral type.
-if (!getLangOpts().CPlusPlus && !T.isNull())
-  Diag(IdLoc, diag::warn_enum_value_overflow);
-  } else if (!getL

[clang] [clang][C23] Support N3029 Improved Normal Enumerations (PR #103917)

2024-09-13 Thread Mariya Podchishchaeva via cfe-commits

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


[clang] [llvm] [RISCV] Add Syntacore SCR7 processor definition (PR #108406)

2024-09-13 Thread Yingwei Zheng via cfe-commits

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

LG

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


[clang] 1c298c9 - [InstCombine] Preserve nuw flags when merging geps

2024-09-13 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2024-09-13T11:15:22+02:00
New Revision: 1c298c927498983dee29037ed1d3e71b72ca0082

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

LOG: [InstCombine] Preserve nuw flags when merging geps

These transforms all perform a variant of (gep (gep p, x), y)
to (gep p, (x + y)). We can preserve both inbounds and nuw
during such transforms (https://alive2.llvm.org/ce/z/Stu4cN), but
not nusw, which would require proving that the new add is nsw.

For the constant offset case, I've conservatively retained the
logic that checks for negative intermediate offsets, though I'm
not sure it's still reachable nowadays.

Added: 


Modified: 
clang/test/CodeGen/attr-counted-by.c
clang/test/OpenMP/bug57757.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/getelementptr.ll

Removed: 




diff  --git a/clang/test/CodeGen/attr-counted-by.c 
b/clang/test/CodeGen/attr-counted-by.c
index a06e815737f4e6..2e2d9cdd4da20e 100644
--- a/clang/test/CodeGen/attr-counted-by.c
+++ b/clang/test/CodeGen/attr-counted-by.c
@@ -686,7 +686,7 @@ size_t test6_bdos(struct anon_struct *p) {
 // SANITIZE-WITH-ATTR-NEXT:tail call void 
@__ubsan_handle_out_of_bounds_abort(ptr nonnull @[[GLOB11:[0-9]+]], i64 
[[IDXPROM]]) #[[ATTR10]], !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR-NEXT:unreachable, !nosanitize [[META2]]
 // SANITIZE-WITH-ATTR:   cont7:
-// SANITIZE-WITH-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds i8, ptr 
[[P]], i64 9
+// SANITIZE-WITH-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds nuw i8, 
ptr [[P]], i64 9
 // SANITIZE-WITH-ATTR-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [0 x 
i8], ptr [[INTS]], i64 0, i64 [[IDXPROM]]
 // SANITIZE-WITH-ATTR-NEXT:store i8 -1, ptr [[ARRAYIDX]], align 1, !tbaa 
[[TBAA8:![0-9]+]]
 // SANITIZE-WITH-ATTR-NEXT:ret void
@@ -694,7 +694,7 @@ size_t test6_bdos(struct anon_struct *p) {
 // NO-SANITIZE-WITH-ATTR-LABEL: define dso_local void @test7(
 // NO-SANITIZE-WITH-ATTR-SAME: ptr noundef [[P:%.*]], i32 noundef 
[[INDEX:%.*]]) local_unnamed_addr #[[ATTR0]] {
 // NO-SANITIZE-WITH-ATTR-NEXT:  entry:
-// NO-SANITIZE-WITH-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds i8, 
ptr [[P]], i64 9
+// NO-SANITIZE-WITH-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds nuw 
i8, ptr [[P]], i64 9
 // NO-SANITIZE-WITH-ATTR-NEXT:[[IDXPROM:%.*]] = sext i32 [[INDEX]] to i64
 // NO-SANITIZE-WITH-ATTR-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [0 
x i8], ptr [[INTS]], i64 0, i64 [[IDXPROM]]
 // NO-SANITIZE-WITH-ATTR-NEXT:store i8 -1, ptr [[ARRAYIDX]], align 1, 
!tbaa [[TBAA6:![0-9]+]]
@@ -703,7 +703,7 @@ size_t test6_bdos(struct anon_struct *p) {
 // SANITIZE-WITHOUT-ATTR-LABEL: define dso_local void @test7(
 // SANITIZE-WITHOUT-ATTR-SAME: ptr noundef [[P:%.*]], i32 noundef 
[[INDEX:%.*]]) local_unnamed_addr #[[ATTR0]] {
 // SANITIZE-WITHOUT-ATTR-NEXT:  entry:
-// SANITIZE-WITHOUT-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds i8, 
ptr [[P]], i64 9
+// SANITIZE-WITHOUT-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds nuw 
i8, ptr [[P]], i64 9
 // SANITIZE-WITHOUT-ATTR-NEXT:[[IDXPROM:%.*]] = sext i32 [[INDEX]] to i64
 // SANITIZE-WITHOUT-ATTR-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [0 
x i8], ptr [[INTS]], i64 0, i64 [[IDXPROM]]
 // SANITIZE-WITHOUT-ATTR-NEXT:store i8 -1, ptr [[ARRAYIDX]], align 1, 
!tbaa [[TBAA6:![0-9]+]]
@@ -712,7 +712,7 @@ size_t test6_bdos(struct anon_struct *p) {
 // NO-SANITIZE-WITHOUT-ATTR-LABEL: define dso_local void @test7(
 // NO-SANITIZE-WITHOUT-ATTR-SAME: ptr noundef [[P:%.*]], i32 noundef 
[[INDEX:%.*]]) local_unnamed_addr #[[ATTR0]] {
 // NO-SANITIZE-WITHOUT-ATTR-NEXT:  entry:
-// NO-SANITIZE-WITHOUT-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds i8, 
ptr [[P]], i64 9
+// NO-SANITIZE-WITHOUT-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds nuw 
i8, ptr [[P]], i64 9
 // NO-SANITIZE-WITHOUT-ATTR-NEXT:[[IDXPROM:%.*]] = sext i32 [[INDEX]] to 
i64
 // NO-SANITIZE-WITHOUT-ATTR-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds 
[0 x i8], ptr [[INTS]], i64 0, i64 [[IDXPROM]]
 // NO-SANITIZE-WITHOUT-ATTR-NEXT:store i8 -1, ptr [[ARRAYIDX]], align 1, 
!tbaa [[TBAA6:![0-9]+]]
@@ -778,7 +778,7 @@ size_t test7_bdos(struct union_of_fams *p) {
 // SANITIZE-WITHOUT-ATTR-LABEL: define dso_local void @test8(
 // SANITIZE-WITHOUT-ATTR-SAME: ptr noundef [[P:%.*]], i32 noundef 
[[INDEX:%.*]]) local_unnamed_addr #[[ATTR0]] {
 // SANITIZE-WITHOUT-ATTR-NEXT:  entry:
-// SANITIZE-WITHOUT-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds i8, 
ptr [[P]], i64 9
+// SANITIZE-WITHOUT-ATTR-NEXT:[[INTS:%.*]] = getelementptr inbounds nuw 
i8, ptr [[P]], i64 9
 // SANITIZE-WITHOUT-ATTR-NEXT:[[IDXPROM:%.*]] = sext i32 [[I

[clang] [RecursiveASTVisitor] Do not inline TraverseStmt (NFC) (PR #107601)

2024-09-13 Thread Nikita Popov via cfe-commits

nikic wrote:

ping

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


[clang] [clang-tools-extra] [clangd] Collect comments from function definitions into the index (PR #67802)

2024-09-13 Thread Christian Kandeler via cfe-commits

https://github.com/ckandeler updated 
https://github.com/llvm/llvm-project/pull/67802

>From f441c0bd52add3d5b63bc0f19a3d38cb12477359 Mon Sep 17 00:00:00 2001
From: Christian Kandeler 
Date: Fri, 29 Sep 2023 15:01:58 +0200
Subject: [PATCH] [clangd] Collect comments from function definitions into the
 index

This is useful with projects that put their (doxygen) comments at the
implementation site, rather than the header.
---
 clang-tools-extra/clangd/index/Symbol.h   |  4 +-
 .../clangd/index/SymbolCollector.cpp  | 57 +++
 .../clangd/index/SymbolCollector.h|  3 +-
 .../clangd/unittests/SymbolCollectorTests.cpp | 52 +
 clang/lib/AST/ASTContext.cpp  | 11 +++-
 5 files changed, 114 insertions(+), 13 deletions(-)

diff --git a/clang-tools-extra/clangd/index/Symbol.h 
b/clang-tools-extra/clangd/index/Symbol.h
index 1aa5265299231b..62c47ddfc5758d 100644
--- a/clang-tools-extra/clangd/index/Symbol.h
+++ b/clang-tools-extra/clangd/index/Symbol.h
@@ -145,9 +145,11 @@ struct Symbol {
 ImplementationDetail = 1 << 2,
 /// Symbol is visible to other files (not e.g. a static helper function).
 VisibleOutsideFile = 1 << 3,
+/// Symbol has an attached documentation comment.
+HasDocComment = 1 << 4
   };
-
   SymbolFlag Flags = SymbolFlag::None;
+
   /// FIXME: also add deprecation message and fixit?
 };
 
diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 5c4e2150cf3123..a76894cf0855f3 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -635,17 +635,21 @@ bool SymbolCollector::handleDeclOccurrence(
 return true;
 
   const Symbol *BasicSymbol = Symbols.find(ID);
-  if (isPreferredDeclaration(*OriginalDecl, Roles))
+  bool SkipDocCheckInDef = false;
+  if (isPreferredDeclaration(*OriginalDecl, Roles)) {
 // If OriginalDecl is preferred, replace/create the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
 BasicSymbol = addDeclaration(*OriginalDecl, std::move(ID), IsMainFileOnly);
-  else if (!BasicSymbol || DeclIsCanonical)
+SkipDocCheckInDef = true;
+  } else if (!BasicSymbol || DeclIsCanonical) {
 BasicSymbol = addDeclaration(*ND, std::move(ID), IsMainFileOnly);
+SkipDocCheckInDef = true;
+  }
 
   if (Roles & static_cast(index::SymbolRole::Definition))
-addDefinition(*OriginalDecl, *BasicSymbol);
+addDefinition(*OriginalDecl, *BasicSymbol, SkipDocCheckInDef);
 
   return true;
 }
@@ -1025,16 +1029,28 @@ const Symbol *SymbolCollector::addDeclaration(const 
NamedDecl &ND, SymbolID ID,
   *ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
   *CompletionTUInfo,
   /*IncludeBriefComments*/ false);
-  std::string Documentation =
-  formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
-  /*CommentsFromHeaders=*/true));
+  std::string DocComment;
+  std::string Documentation;
+  bool AlreadyHasDoc = S.Flags & Symbol::HasDocComment;
+  if (!AlreadyHasDoc) {
+DocComment = getDocComment(Ctx, SymbolCompletion,
+   /*CommentsFromHeaders=*/true);
+Documentation = formatDocumentation(*CCS, DocComment);
+  }
+  const auto UpdateDoc = [&] {
+if (!AlreadyHasDoc) {
+  if (!DocComment.empty())
+S.Flags |= Symbol::HasDocComment;
+  S.Documentation = Documentation;
+}
+  };
   if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
 if (Opts.StoreAllDocumentation)
-  S.Documentation = Documentation;
+  UpdateDoc();
 Symbols.insert(S);
 return Symbols.find(S.ID);
   }
-  S.Documentation = Documentation;
+  UpdateDoc();
   std::string Signature;
   std::string SnippetSuffix;
   getSignature(*CCS, &Signature, &SnippetSuffix, SymbolCompletion.Kind,
@@ -1058,8 +1074,8 @@ const Symbol *SymbolCollector::addDeclaration(const 
NamedDecl &ND, SymbolID ID,
   return Symbols.find(S.ID);
 }
 
-void SymbolCollector::addDefinition(const NamedDecl &ND,
-const Symbol &DeclSym) {
+void SymbolCollector::addDefinition(const NamedDecl &ND, const Symbol &DeclSym,
+bool SkipDocCheck) {
   if (DeclSym.Definition)
 return;
   const auto &SM = ND.getASTContext().getSourceManager();
@@ -1074,6 +1090,27 @@ void SymbolCollector::addDefinition(const NamedDecl &ND,
   Symbol S = DeclSym;
   // FIXME: use the result to filter out symbols.
   S.Definition = *DefLoc;
+
+  std::string DocComment;
+  std::string Documentation;
+  if (!SkipDocCheck && !(S.Flags & Symbol::HasDocComment) &&
+  (llvm::isa(ND) || llvm::isa(ND))) {
+CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0)

[clang] [clang-tools-extra] [clangd] Collect comments from function definitions into the index (PR #67802)

2024-09-13 Thread Christian Kandeler via cfe-commits

ckandeler wrote:

> Meanwhile, I thought of a fix for #108145 and submitted it as #108475.
> If that's accepted, you should be able to drop the `ASTContext.cpp` changes 
> from this patch.

Nice, will do.



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


[clang] [clang][bytecode] Fix two-pointer-style std::initializer_lists (PR #107565)

2024-09-13 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Apparently I've already pushed this.

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


[clang] fbf0a80 - [clang][bytecode] Implement HLSLVectorTruncation casts (#108499)

2024-09-13 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-13T11:32:12+02:00
New Revision: fbf0a8015389bccab80bba00be49955079913152

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

LOG: [clang][bytecode] Implement HLSLVectorTruncation casts (#108499)

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/hlsl.hlsl

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 265350e44d95b9..5247b8cadf8d4f 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -644,6 +644,31 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
 return true;
   }
 
+  case CK_HLSLVectorTruncation: {
+assert(SubExpr->getType()->isVectorType());
+if (std::optional ResultT = classify(CE)) {
+  assert(!DiscardResult);
+  // Result must be either a float or integer. Take the first element.
+  if (!this->visit(SubExpr))
+return false;
+  return this->emitArrayElemPop(*ResultT, 0, CE);
+}
+// Otherwise, this truncates from one vector type to another.
+assert(CE->getType()->isVectorType());
+
+if (!Initializing) {
+  unsigned LocalIndex = allocateTemporary(CE);
+  if (!this->emitGetPtrLocal(LocalIndex, CE))
+return false;
+}
+unsigned ToSize = CE->getType()->getAs()->getNumElements();
+assert(SubExpr->getType()->getAs()->getNumElements() > ToSize);
+if (!this->visit(SubExpr))
+  return false;
+return this->emitCopyArray(classifyVectorElementType(CE->getType()), 0, 0,
+   ToSize, CE);
+  };
+
   case CK_ToVoid:
 return discard(SubExpr);
 

diff  --git a/clang/test/AST/ByteCode/hlsl.hlsl 
b/clang/test/AST/ByteCode/hlsl.hlsl
index cb14662c11f394..073e4301919914 100644
--- a/clang/test/AST/ByteCode/hlsl.hlsl
+++ b/clang/test/AST/ByteCode/hlsl.hlsl
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl 
-std=hlsl202x -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - | FileCheck %s
 
-// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl 
-std=hlsl202x -triple \
 // RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
 // RUN:   -o - -fexperimental-new-constant-interpreter | FileCheck %s
 
@@ -16,4 +16,16 @@ int2 ToTwoInts(int V){
   return V.xx;
 }
 
+export void fn() {
+  // This compiling successfully verifies that the vector constant expression
+  // gets truncated to an integer at compile time for instantiation.
+  _Static_assert(((int)1.) + 0 == 1, "Woo!");
 
+  // This compiling successfully verifies that the vector constant expression
+  // gets truncated to a float at compile time for instantiation.
+  _Static_assert(((float)1.0.) + 0.0 == 1.0, "Woo!");
+
+  // This compiling successfully verifies that a vector can be truncated to a
+  // smaller vector, then truncated to a float as a constant expression.
+  _Static_assert(((float2)float4(6, 5, 4, 3)).x == 6, "Woo!");
+}



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


[clang] [clang][bytecode] Implement HLSLVectorTruncation casts (PR #108499)

2024-09-13 Thread Timm Baeder via cfe-commits

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


[clang] e7f782e - Reapply "[clang] Extend diagnose_if to accept more detailed warning information (#70976)" (#108453)

2024-09-13 Thread via cfe-commits

Author: Nikolas Klauser
Date: 2024-09-13T11:34:20+02:00
New Revision: e7f782e7481cea23ef452a75607d3d61f5bd0d22

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

LOG: Reapply "[clang] Extend diagnose_if to accept more detailed warning 
information (#70976)" (#108453)

This reverts commit e0cd11eba526234ca14a0b91f5598ca3363b6aca.

Update the use of `getWarningOptionForDiag` in flang to use the
DiagnosticIDs.

Added: 
clang/test/SemaCXX/diagnose_if-warning-group.cpp

Modified: 
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Diagnostics.h
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Basic/DiagnosticCategories.h
clang/include/clang/Basic/DiagnosticIDs.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Basic/Diagnostic.cpp
clang/lib/Basic/DiagnosticIDs.cpp
clang/lib/Frontend/LogDiagnosticPrinter.cpp
clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
clang/lib/Frontend/TextDiagnosticPrinter.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
clang/test/Sema/diagnose_if.c
clang/tools/diagtool/ListWarnings.cpp
clang/tools/diagtool/ShowEnabledWarnings.cpp
clang/tools/libclang/CXStoredDiagnostic.cpp
flang/lib/Frontend/TextDiagnosticPrinter.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index d5eca083eb6512..552dd36b6900bf 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -579,7 +579,17 @@ std::vector StoreDiags::take(const 
clang::tidy::ClangTidyContext *Tidy) {
   for (auto &Diag : Output) {
 if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) {
   // Warnings controlled by -Wfoo are better recognized by that name.
-  StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(Diag.ID);
+  const StringRef Warning = [&] {
+if (OrigSrcMgr) {
+  return OrigSrcMgr->getDiagnostics()
+  .getDiagnosticIDs()
+  ->getWarningOptionForDiag(Diag.ID);
+}
+if (!DiagnosticIDs::IsCustomDiag(Diag.ID))
+  return DiagnosticIDs{}.getWarningOptionForDiag(Diag.ID);
+return StringRef{};
+  }();
+
   if (!Warning.empty()) {
 Diag.Name = ("-W" + Warning).str();
   } else {
@@ -896,20 +906,23 @@ void StoreDiags::flushLastDiag() {
   Output.push_back(std::move(*LastDiag));
 }
 
-bool isBuiltinDiagnosticSuppressed(unsigned ID,
-   const llvm::StringSet<> &Suppress,
-   const LangOptions &LangOpts) {
+bool isDiagnosticSuppressed(const clang::Diagnostic &Diag,
+const llvm::StringSet<> &Suppress,
+const LangOptions &LangOpts) {
   // Don't complain about header-only stuff in mainfiles if it's a header.
   // FIXME: would be cleaner to suppress in clang, once we decide whether the
   //behavior should be to silently-ignore or respect the pragma.
-  if (ID == diag::pp_pragma_sysheader_in_main_file && LangOpts.IsHeaderFile)
+  if (Diag.getID() == diag::pp_pragma_sysheader_in_main_file &&
+  LangOpts.IsHeaderFile)
 return true;
 
-  if (const char *CodePtr = getDiagnosticCode(ID)) {
+  if (const char *CodePtr = getDiagnosticCode(Diag.getID())) {
 if (Suppress.contains(normalizeSuppressedCode(CodePtr)))
   return true;
   }
-  StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(ID);
+  StringRef Warning =
+  Diag.getDiags()->getDiagnosticIDs()->getWarningOptionForDiag(
+  Diag.getID());
   if (!Warning.empty() && Suppress.contains(Warning))
 return true;
   return false;

diff  --git a/clang-tools-extra/clangd/Diagnostics.h 
b/clang-tools-extra/clangd/Diagnostics.h
index d4c0478c63a5cf..c45d8dc3aa6ce6 100644
--- a/clang-tools-extra/clangd/Diagnostics.h
+++ b/clang-tools-extra/clangd/Diagnostics.h
@@ -181,11 +181,11 @@ class StoreDiags : public DiagnosticConsumer {
 };
 
 /// Determine whether a (non-clang-tidy) diagnostic is suppressed by config.
-bool isBuiltinDiagnosticSuppressed(unsigned ID,
-   const llvm::StringSet<> &Suppressed,
-   const LangOptions &);
+bool isDiagnosticSuppressed(const clang::Diagnostic &D

[clang] [clang-tools-extra] [flang] Reapply "[clang] Extend diagnose_if to accept more detailed warning information (#70976)" (PR #108453)

2024-09-13 Thread Nikolas Klauser via cfe-commits

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


[clang] [clang][bytecode] Fix two-pointer-style std::initializer_lists (PR #107565)

2024-09-13 Thread Timm Baeder via cfe-commits

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


[clang] [clang][Sema] Fix assertion in `tryDiagnoseOverloadedCast` (PR #108021)

2024-09-13 Thread Alejandro Álvarez Ayllón via cfe-commits


@@ -446,7 +446,12 @@ static bool tryDiagnoseOverloadedCast(Sema &S, CastType CT,
 : InitializationKind::CreateCast(/*type range?*/ range);
   InitializationSequence sequence(S, entity, initKind, src);
 
-  assert(sequence.Failed() && "initialization succeeded on second try?");
+  // It could happen that a constructor failed to be used because
+  // it requires a temporary of a broken type. Still, it will be found when
+  // looking for a match.
+  if (!sequence.Failed())

alejandro-alvarez-sonarsource wrote:

I have checked, and the destination type has no errors. I guess because the 
type itself is ok, the problem is that the constructor from `const char*` 
failed to be instantiated.

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


[clang] [clang][Sema] Fix assertion in `tryDiagnoseOverloadedCast` (PR #108021)

2024-09-13 Thread Alejandro Álvarez Ayllón via cfe-commits

https://github.com/alejandro-alvarez-sonarsource edited 
https://github.com/llvm/llvm-project/pull/108021
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [FMV][AArch64] Unify ls64, ls64_v and ls64_accdata. (PR #108024)

2024-09-13 Thread Alexandros Lamprineas via cfe-commits


@@ -73,8 +73,6 @@ enum CPUFeatures {
   FEAT_SSBS,
   FEAT_SSBS2,
   FEAT_BTI,
-  FEAT_LS64,
-  FEAT_LS64_V,

labrinea wrote:

Thanks for flagging this up. I am puzzled though since I was under the 
impression that FMV is still not production ready. When did the enum become 
part of the ABI? I guess a workaround is to keep a reserved position in the 
enum when removing a feature.

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

@ganeshgit Ignore what I said earlier about waiting for the tuning patches :) 
Please can we get this committed to trunk, we'll let it brew for a few days and 
then cherry pick for 19.x - if you can create PRs for the tuning changes as 
soon as possible we can review them for 19.x on a case by case basis.

https://github.com/llvm/llvm-project/pull/107964
___
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 annotating StartOfName (PR #99791)

2024-09-13 Thread Alexander Lohnau via cfe-commits

alex1701c wrote:

Can we expect this to be backported and released with clang-format-18?

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


[clang] [llvm] Introduce -defer-thinlto-prelink-coro-split that skips Coro passes in ThinLTO pre-link pipeline (PR #107153)

2024-09-13 Thread Adrian Vogelsgesang via cfe-commits

vogelsgesang wrote:

My 2cts:

I think it would be best for clang-users, if HALO / coroutine optimizations 
work out-of-the-box in as many cases as possible.

Unfortunately, it seems we have an "either-or" decision here. Either, the 
"thin-lto + HALO" work out-of-the-box or the llc-code-generation works 
out-of-the-box. Afaict, thin-lto is the more common use case compared to 
calling llc directly. At least there seems to be documentation for 
[thin-lto](https://clang.llvm.org/docs/ThinLTO.html) but not for the llc use 
case?

As a normal C++ programmer and clang user, I doubt that I would ever find the 
`-defer-thinlto-prelink-coro-split` setting, in particular given that this 
commit does not add any documentation for it. As such, I would be stuck without 
cross-TU link-time HALO optimizations. At the same time, I would expect people 
which use custom llc-based compilation to be more experienced with setting up 
an LLVM toolchain, and more enabled to figure out about the existince of the 
flag.

All of this is to say: I think the default should be flipped. **By default, 
coro-split should be deferred to post-link** (such that the more common 
thin-lto setup can apply HALO out-of-the-box). More advanced users, who call 
llc directly, can still use a flag to defer coro-split.

In addition, some documentation would be great (e.g. mentioning the newly 
introduced flag in https://clang.llvm.org/docs/ThinLTO.html and 
https://llvm.org/docs/Coroutines.html

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


[clang] 9cd9377 - [RISCV][FMV] Support target_clones (#85786)

2024-09-13 Thread via cfe-commits

Author: Piyou Chen
Date: 2024-09-13T18:04:53+08:00
New Revision: 9cd93774098c861c260090a690f428b7ae031c65

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

LOG: [RISCV][FMV] Support target_clones (#85786)

This patch enable the function multiversion(FMV) and `target_clones`
attribute for RISC-V target.

The proposal of `target_clones` syntax can be found at the
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/48 (which has
landed), as modified by the proposed
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/85 (which adds the
priority syntax).

It supports the `target_clones` function attribute and function
multiversioning feature for RISC-V target. It will generate the ifunc
resolver function for the function that declared with target_clones
attribute.

The resolver function will check the version support by runtime object
`__riscv_feature_bits`.

For example:

```
__attribute__((target_clones("default", "arch=+ver1", "arch=+ver2"))) int bar() 
{
return 1;
}
```

the corresponding resolver will be like:

```
bar.resolver() {
__init_riscv_feature_bits();
// Check arch=+ver1
if ((__riscv_feature_bits.features[0] & BITMASK_OF_VERSION1) == 
BITMASK_OF_VERSION1) {
return bar.arch=+ver1;
} else {
// Check arch=+ver2
if ((__riscv_feature_bits.features[0] & BITMASK_OF_VERSION2) == 
BITMASK_OF_VERSION2) {
return bar.arch=+ver2;
} else {
// Default
return bar.default;
}
}
}
```

Added: 
clang/test/CodeGen/attr-target-clones-riscv-invalid.c
clang/test/CodeGen/attr-target-clones-riscv.c
clang/test/CodeGenCXX/attr-target-clones-riscv.cpp
clang/test/SemaCXX/attr-target-clones-riscv.cpp

Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Sema/SemaRISCV.h
clang/lib/AST/ASTContext.cpp
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/Targets/RISCV.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaRISCV.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 8a1462c670d68f..a85b72a3981578 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -378,4 +378,8 @@ def warn_missing_symbol_graph_dir : Warning<
 def err_ast_action_on_llvm_ir : Error<
   "cannot apply AST actions to LLVM IR file '%0'">,
   DefaultFatal;
+
+def err_os_unsupport_riscv_fmv : Error<
+  "function multiversioning is currently only supported on Linux">;
+
 }

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index a58fb5f9792720..f31d88a354ea28 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1496,7 +1496,8 @@ class TargetInfo : public TransferrableTargetInfo,
   /// Identify whether this target supports multiversioning of functions,
   /// which requires support for cpu_supports and cpu_is functionality.
   bool supportsMultiVersioning() const {
-return getTriple().isX86() || getTriple().isAArch64();
+return getTriple().isX86() || getTriple().isAArch64() ||
+   getTriple().isRISCV();
   }
 
   /// Identify whether this target supports IFuncs.

diff  --git a/clang/include/clang/Sema/SemaRISCV.h 
b/clang/include/clang/Sema/SemaRISCV.h
index d62fca8128b2a3..d7f17797283b86 100644
--- a/clang/include/clang/Sema/SemaRISCV.h
+++ b/clang/include/clang/Sema/SemaRISCV.h
@@ -43,6 +43,7 @@ class SemaRISCV : public SemaBase {
 
   void handleInterruptAttr(Decl *D, const ParsedAttr &AL);
   bool isAliasValid(unsigned BuiltinID, llvm::StringRef AliasName);
+  bool isValidFMVExtension(StringRef Ext);
 
   /// Indicate RISC-V vector builtin functions enabled or not.
   bool DeclareRVVBuiltins = false;

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 8ece39a3830468..7cc69ca4a8a814 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14248,6 +14248,18 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   Target->getTargetOpts().FeaturesAsWritten.begin(),
   Target->getTargetOpts().FeaturesAsWritten.end());
   Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, 
Features);
+} else if (Target->getTriple().isRISCV()) {
+  StringRef VersionStr = TC->getFeatureStr(GD.getMultiVersionIndex());
+  std::vector Features;
+  if (VersionStr != "default") {
+ParsedTargetAttr ParsedA

[clang] [RISCV][FMV] Support target_clones (PR #85786)

2024-09-13 Thread Piyou Chen via cfe-commits

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


[clang] [llvm] Introduce -defer-thinlto-prelink-coro-split that skips Coro passes in ThinLTO pre-link pipeline (PR #107153)

2024-09-13 Thread Adrian Vogelsgesang via cfe-commits

vogelsgesang wrote:

> Unfortunately, it seems we have an "either-or" decision here

Although... Is this even an either-or decision?

Could we add coro-split to the llc unconditionally, also for non-thin-lto 
pipelines? Afaict, coro-split is a no-op pass if coroutines were already split 
previously. Hence, codegen would simply work, even if a thin-lto-prelink 
pipeline is combined with a non-thin-lto post-link step.

Doing so, I think we wouldn't need to introduce a flag at all?

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread Nikita Popov via cfe-commits

nikic wrote:

Zen 5 support in GCC was upstreamed more than half a year ago -- why is the 
LLVM support being upstreamed only now, after missing the 19.x window? What 
steps are being taken to ensure this does not happen again?

The change to X86TargetParser.h looks ABI breaking to me.

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


[clang] [RISCV][FMV] Support target_version (PR #99040)

2024-09-13 Thread Piyou Chen via cfe-commits

https://github.com/BeMg updated https://github.com/llvm/llvm-project/pull/99040

>From 54b5d6833a52271dfd1ca3912d5d9e886b1970c2 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Tue, 19 Mar 2024 02:02:35 -0700
Subject: [PATCH] [RISCV][FMV] Support target_version

---
 clang/lib/AST/ASTContext.cpp  |  13 +-
 clang/lib/CodeGen/CodeGenModule.cpp   |   6 +-
 clang/lib/Sema/SemaDecl.cpp   |  43 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  39 ++
 .../attr-target-version-riscv-invalid.c   |  13 +
 .../test/CodeGen/attr-target-version-riscv.c  | 443 ++
 .../CodeGenCXX/attr-target-version-riscv.cpp  | 432 +
 .../SemaCXX/attr-target-version-riscv.cpp |  53 +++
 8 files changed, 1026 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/CodeGen/attr-target-version-riscv-invalid.c
 create mode 100644 clang/test/CodeGen/attr-target-version-riscv.c
 create mode 100644 clang/test/CodeGenCXX/attr-target-version-riscv.cpp
 create mode 100644 clang/test/SemaCXX/attr-target-version-riscv.cpp

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7cc69ca4a8a814..4f20ccd67c9493 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14270,9 +14270,16 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, 
Features);
 }
   } else if (const auto *TV = FD->getAttr()) {
-llvm::SmallVector Feats;
-TV->getFeatures(Feats);
-std::vector Features = getFMVBackendFeaturesFor(Feats);
+std::vector Features;
+if (Target->getTriple().isRISCV()) {
+  ParsedTargetAttr ParsedAttr = Target->parseTargetAttr(TV->getName());
+  Features.insert(Features.begin(), ParsedAttr.Features.begin(),
+  ParsedAttr.Features.end());
+} else {
+  llvm::SmallVector Feats;
+  TV->getFeatures(Feats);
+  Features = getFMVBackendFeaturesFor(Feats);
+}
 Features.insert(Features.begin(),
 Target->getTargetOpts().FeaturesAsWritten.begin(),
 Target->getTargetOpts().FeaturesAsWritten.end());
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index ba2d6588900a11..618b3ac75a9c4a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4268,8 +4268,12 @@ void CodeGenModule::emitMultiVersionFunctions() {
   } else if (const auto *TVA = CurFD->getAttr()) {
 if (TVA->isDefaultVersion() && IsDefined)
   ShouldEmitResolver = true;
-TVA->getFeatures(Feats);
 llvm::Function *Func = createFunction(CurFD);
+if (getTarget().getTriple().isRISCV()) {
+  Feats.push_back(TVA->getName());
+} else {
+  TVA->getFeatures(Feats);
+}
 Options.emplace_back(Func, /*Architecture*/ "", Feats);
   } else if (const auto *TC = CurFD->getAttr()) {
 if (IsDefined)
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 8557c25b93a8da..b2b2417b47b8d8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10319,8 +10319,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   // Handle attributes.
   ProcessDeclAttributes(S, NewFD, D);
   const auto *NewTVA = NewFD->getAttr();
-  if (NewTVA && !NewTVA->isDefaultVersion() &&
-  !Context.getTargetInfo().hasFeature("fmv")) {
+  if (Context.getTargetInfo().getTriple().isRISCV()) {
+// Go thought anyway.
+  } else if (NewTVA && !NewTVA->isDefaultVersion() &&
+ !Context.getTargetInfo().hasFeature("fmv")) {
 // Don't add to scope fmv functions declarations if fmv disabled
 AddToScope = false;
 return NewFD;
@@ -11027,13 +11029,27 @@ static bool CheckMultiVersionValue(Sema &S, const 
FunctionDecl *FD) {
   }
 
   if (TVA) {
-llvm::SmallVector Feats;
-TVA->getFeatures(Feats);
-for (const auto &Feat : Feats) {
-  if (!TargetInfo.validateCpuSupports(Feat)) {
-S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
-<< Feature << Feat;
-return true;
+if (S.getASTContext().getTargetInfo().getTriple().isRISCV()) {
+  ParsedTargetAttr ParseInfo =
+  S.getASTContext().getTargetInfo().parseTargetAttr(TVA->getName());
+  for (const auto &Feat : ParseInfo.Features) {
+StringRef BareFeat = StringRef{Feat}.substr(1);
+
+if (!TargetInfo.isValidFeatureName(BareFeat)) {
+  S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+  << Feature << BareFeat;
+  return true;
+}
+  }
+} else {
+  llvm::SmallVector Feats;
+  TVA->getFeatures(Feats);
+  for (const auto &Feat : Feats) {
+if (!TargetInfo.validateCpuSupports(Feat)) {
+  S.Diag(FD->getLocation(), diag:

[clang] [RISCV][FMV] Support target_version (PR #99040)

2024-09-13 Thread Piyou Chen via cfe-commits

BeMg wrote:

Rebase to main

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


[clang] [RISCV][FMV] Support target_version (PR #99040)

2024-09-13 Thread Piyou Chen via cfe-commits

https://github.com/BeMg updated https://github.com/llvm/llvm-project/pull/99040

>From 54b5d6833a52271dfd1ca3912d5d9e886b1970c2 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Tue, 19 Mar 2024 02:02:35 -0700
Subject: [PATCH 1/2] [RISCV][FMV] Support target_version

---
 clang/lib/AST/ASTContext.cpp  |  13 +-
 clang/lib/CodeGen/CodeGenModule.cpp   |   6 +-
 clang/lib/Sema/SemaDecl.cpp   |  43 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  39 ++
 .../attr-target-version-riscv-invalid.c   |  13 +
 .../test/CodeGen/attr-target-version-riscv.c  | 443 ++
 .../CodeGenCXX/attr-target-version-riscv.cpp  | 432 +
 .../SemaCXX/attr-target-version-riscv.cpp |  53 +++
 8 files changed, 1026 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/CodeGen/attr-target-version-riscv-invalid.c
 create mode 100644 clang/test/CodeGen/attr-target-version-riscv.c
 create mode 100644 clang/test/CodeGenCXX/attr-target-version-riscv.cpp
 create mode 100644 clang/test/SemaCXX/attr-target-version-riscv.cpp

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7cc69ca4a8a814..4f20ccd67c9493 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14270,9 +14270,16 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, 
Features);
 }
   } else if (const auto *TV = FD->getAttr()) {
-llvm::SmallVector Feats;
-TV->getFeatures(Feats);
-std::vector Features = getFMVBackendFeaturesFor(Feats);
+std::vector Features;
+if (Target->getTriple().isRISCV()) {
+  ParsedTargetAttr ParsedAttr = Target->parseTargetAttr(TV->getName());
+  Features.insert(Features.begin(), ParsedAttr.Features.begin(),
+  ParsedAttr.Features.end());
+} else {
+  llvm::SmallVector Feats;
+  TV->getFeatures(Feats);
+  Features = getFMVBackendFeaturesFor(Feats);
+}
 Features.insert(Features.begin(),
 Target->getTargetOpts().FeaturesAsWritten.begin(),
 Target->getTargetOpts().FeaturesAsWritten.end());
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index ba2d6588900a11..618b3ac75a9c4a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4268,8 +4268,12 @@ void CodeGenModule::emitMultiVersionFunctions() {
   } else if (const auto *TVA = CurFD->getAttr()) {
 if (TVA->isDefaultVersion() && IsDefined)
   ShouldEmitResolver = true;
-TVA->getFeatures(Feats);
 llvm::Function *Func = createFunction(CurFD);
+if (getTarget().getTriple().isRISCV()) {
+  Feats.push_back(TVA->getName());
+} else {
+  TVA->getFeatures(Feats);
+}
 Options.emplace_back(Func, /*Architecture*/ "", Feats);
   } else if (const auto *TC = CurFD->getAttr()) {
 if (IsDefined)
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 8557c25b93a8da..b2b2417b47b8d8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10319,8 +10319,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   // Handle attributes.
   ProcessDeclAttributes(S, NewFD, D);
   const auto *NewTVA = NewFD->getAttr();
-  if (NewTVA && !NewTVA->isDefaultVersion() &&
-  !Context.getTargetInfo().hasFeature("fmv")) {
+  if (Context.getTargetInfo().getTriple().isRISCV()) {
+// Go thought anyway.
+  } else if (NewTVA && !NewTVA->isDefaultVersion() &&
+ !Context.getTargetInfo().hasFeature("fmv")) {
 // Don't add to scope fmv functions declarations if fmv disabled
 AddToScope = false;
 return NewFD;
@@ -11027,13 +11029,27 @@ static bool CheckMultiVersionValue(Sema &S, const 
FunctionDecl *FD) {
   }
 
   if (TVA) {
-llvm::SmallVector Feats;
-TVA->getFeatures(Feats);
-for (const auto &Feat : Feats) {
-  if (!TargetInfo.validateCpuSupports(Feat)) {
-S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
-<< Feature << Feat;
-return true;
+if (S.getASTContext().getTargetInfo().getTriple().isRISCV()) {
+  ParsedTargetAttr ParseInfo =
+  S.getASTContext().getTargetInfo().parseTargetAttr(TVA->getName());
+  for (const auto &Feat : ParseInfo.Features) {
+StringRef BareFeat = StringRef{Feat}.substr(1);
+
+if (!TargetInfo.isValidFeatureName(BareFeat)) {
+  S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+  << Feature << BareFeat;
+  return true;
+}
+  }
+} else {
+  llvm::SmallVector Feats;
+  TVA->getFeatures(Feats);
+  for (const auto &Feat : Feats) {
+if (!TargetInfo.validateCpuSupports(Feat)) {
+  S.Diag(FD->getLocation(), d

[clang] [RISCV][FMV] Support target_version (PR #99040)

2024-09-13 Thread Piyou Chen via cfe-commits

https://github.com/BeMg updated https://github.com/llvm/llvm-project/pull/99040

>From 54b5d6833a52271dfd1ca3912d5d9e886b1970c2 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Tue, 19 Mar 2024 02:02:35 -0700
Subject: [PATCH 1/3] [RISCV][FMV] Support target_version

---
 clang/lib/AST/ASTContext.cpp  |  13 +-
 clang/lib/CodeGen/CodeGenModule.cpp   |   6 +-
 clang/lib/Sema/SemaDecl.cpp   |  43 +-
 clang/lib/Sema/SemaDeclAttr.cpp   |  39 ++
 .../attr-target-version-riscv-invalid.c   |  13 +
 .../test/CodeGen/attr-target-version-riscv.c  | 443 ++
 .../CodeGenCXX/attr-target-version-riscv.cpp  | 432 +
 .../SemaCXX/attr-target-version-riscv.cpp |  53 +++
 8 files changed, 1026 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/CodeGen/attr-target-version-riscv-invalid.c
 create mode 100644 clang/test/CodeGen/attr-target-version-riscv.c
 create mode 100644 clang/test/CodeGenCXX/attr-target-version-riscv.cpp
 create mode 100644 clang/test/SemaCXX/attr-target-version-riscv.cpp

diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7cc69ca4a8a814..4f20ccd67c9493 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14270,9 +14270,16 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, 
Features);
 }
   } else if (const auto *TV = FD->getAttr()) {
-llvm::SmallVector Feats;
-TV->getFeatures(Feats);
-std::vector Features = getFMVBackendFeaturesFor(Feats);
+std::vector Features;
+if (Target->getTriple().isRISCV()) {
+  ParsedTargetAttr ParsedAttr = Target->parseTargetAttr(TV->getName());
+  Features.insert(Features.begin(), ParsedAttr.Features.begin(),
+  ParsedAttr.Features.end());
+} else {
+  llvm::SmallVector Feats;
+  TV->getFeatures(Feats);
+  Features = getFMVBackendFeaturesFor(Feats);
+}
 Features.insert(Features.begin(),
 Target->getTargetOpts().FeaturesAsWritten.begin(),
 Target->getTargetOpts().FeaturesAsWritten.end());
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index ba2d6588900a11..618b3ac75a9c4a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4268,8 +4268,12 @@ void CodeGenModule::emitMultiVersionFunctions() {
   } else if (const auto *TVA = CurFD->getAttr()) {
 if (TVA->isDefaultVersion() && IsDefined)
   ShouldEmitResolver = true;
-TVA->getFeatures(Feats);
 llvm::Function *Func = createFunction(CurFD);
+if (getTarget().getTriple().isRISCV()) {
+  Feats.push_back(TVA->getName());
+} else {
+  TVA->getFeatures(Feats);
+}
 Options.emplace_back(Func, /*Architecture*/ "", Feats);
   } else if (const auto *TC = CurFD->getAttr()) {
 if (IsDefined)
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 8557c25b93a8da..b2b2417b47b8d8 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10319,8 +10319,10 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   // Handle attributes.
   ProcessDeclAttributes(S, NewFD, D);
   const auto *NewTVA = NewFD->getAttr();
-  if (NewTVA && !NewTVA->isDefaultVersion() &&
-  !Context.getTargetInfo().hasFeature("fmv")) {
+  if (Context.getTargetInfo().getTriple().isRISCV()) {
+// Go thought anyway.
+  } else if (NewTVA && !NewTVA->isDefaultVersion() &&
+ !Context.getTargetInfo().hasFeature("fmv")) {
 // Don't add to scope fmv functions declarations if fmv disabled
 AddToScope = false;
 return NewFD;
@@ -11027,13 +11029,27 @@ static bool CheckMultiVersionValue(Sema &S, const 
FunctionDecl *FD) {
   }
 
   if (TVA) {
-llvm::SmallVector Feats;
-TVA->getFeatures(Feats);
-for (const auto &Feat : Feats) {
-  if (!TargetInfo.validateCpuSupports(Feat)) {
-S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
-<< Feature << Feat;
-return true;
+if (S.getASTContext().getTargetInfo().getTriple().isRISCV()) {
+  ParsedTargetAttr ParseInfo =
+  S.getASTContext().getTargetInfo().parseTargetAttr(TVA->getName());
+  for (const auto &Feat : ParseInfo.Features) {
+StringRef BareFeat = StringRef{Feat}.substr(1);
+
+if (!TargetInfo.isValidFeatureName(BareFeat)) {
+  S.Diag(FD->getLocation(), diag::err_bad_multiversion_option)
+  << Feature << BareFeat;
+  return true;
+}
+  }
+} else {
+  llvm::SmallVector Feats;
+  TVA->getFeatures(Feats);
+  for (const auto &Feat : Feats) {
+if (!TargetInfo.validateCpuSupports(Feat)) {
+  S.Diag(FD->getLocation(), d

[clang] [clang] Fix various typos and whitespace in HelpText. (PR #108527)

2024-09-13 Thread Ryan Mansfield via cfe-commits

https://github.com/rjmansfield created 
https://github.com/llvm/llvm-project/pull/108527

None

>From 8bea5472c6be19664b4c044f510b757b88ec441f Mon Sep 17 00:00:00 2001
From: Ryan Mansfield 
Date: Fri, 13 Sep 2024 06:31:50 -0400
Subject: [PATCH] [clang] Fix various typos and whitespace in HelpText.

---
 clang/include/clang/Driver/Options.td | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f78032255f036f..c5e0aca4da0bc4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1055,7 +1055,7 @@ def Xlinker : Separate<["-"], "Xlinker">, 
Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass  to the linker">, MetaVarName<"">,
   Group;
 def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
-  HelpText<"Pass  to the offload linkers or the ones idenfied by 
-">,
+  HelpText<"Pass  to the offload linkers or the ones identified by 
-">,
   MetaVarName<" ">, Group;
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, 
Group,
   HelpText<"Pass  to the preprocessor">, MetaVarName<"">;
@@ -2576,7 +2576,7 @@ defm sanitize_stats : BoolOption<"f", "sanitize-stats",
   BothFlags<[], [ClangOption], " sanitizer statistics gathering.">>,
   Group;
 def fsanitize_undefined_ignore_overflow_pattern_EQ : CommaJoined<["-"], 
"fsanitize-undefined-ignore-overflow-pattern=">,
-  HelpText<"Specify the overflow patterns to exclude from artihmetic sanitizer 
instrumentation">,
+  HelpText<"Specify the overflow patterns to exclude from arithmetic sanitizer 
instrumentation">,
   Visibility<[ClangOption, CC1Option]>,
   
Values<"none,all,add-unsigned-overflow-test,add-signed-overflow-test,negated-unsigned-const,unsigned-post-decr-while">,
   MarshallingInfoStringVector>;
@@ -3216,7 +3216,7 @@ def fno_modules_prune_non_affecting_module_map_files :
 def fincremental_extensions :
   Flag<["-"], "fincremental-extensions">,
   Group, Visibility<[ClangOption, CC1Option]>,
-  HelpText<"Enable incremental processing extensions such as processing"
+  HelpText<"Enable incremental processing extensions such as processing "
"statements on the global scope.">,
   MarshallingInfoFlag>;
 
@@ -3669,7 +3669,7 @@ def fopenmp_offload_mandatory : Flag<["-"], 
"fopenmp-offload-mandatory">, Group<
   MarshallingInfoFlag>;
 def fopenmp_force_usm : Flag<["-"], "fopenmp-force-usm">, Group,
   Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CC1Option, FlangOption, 
FC1Option]>,
-  HelpText<"Force behvaior as if the user specified pragma omp requires 
unified_shared_memory.">,
+  HelpText<"Force behavior as if the user specified pragma omp requires 
unified_shared_memory.">,
   MarshallingInfoFlag>;
 def fopenmp_target_jit : Flag<["-"], "fopenmp-target-jit">, Group,
   Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CLOption]>,
@@ -3776,20 +3776,20 @@ defm tocdata : BoolOption<"m","tocdata",
   PosFlag,
   NegFlag,
   BothFlags<[TargetSpecific], [ClangOption, CLOption]>>, Group;
 def mtocdata_EQ : CommaJoined<["-"], "mtocdata=">,
   Visibility<[ClangOption, CC1Option]>,
   Flags<[TargetSpecific]>, Group,
-  HelpText<"Specifies a list of variables to which the TOC data transformation"
+  HelpText<"Specifies a list of variables to which the TOC data transformation 
"
"will be applied.">,
   MarshallingInfoStringVector>;
 def mno_tocdata_EQ : CommaJoined<["-"], "mno-tocdata=">,
   Visibility<[ClangOption, CC1Option]>,
   Flags<[TargetSpecific]>, Group,
-  HelpText<"Specifies a list of variables to be exempt from the TOC data"
+  HelpText<"Specifies a list of variables to be exempt from the TOC data "
"transformation.">,
   MarshallingInfoStringVector>;
 defm preserve_as_comments : BoolFOption<"preserve-as-comments",
@@ -4373,7 +4373,7 @@ def femit_dwarf_unwind_EQ : Joined<["-"], 
"femit-dwarf-unwind=">,
 defm emit_compact_unwind_non_canonical : 
BoolFOption<"emit-compact-unwind-non-canonical",
   CodeGenOpts<"EmitCompactUnwindNonCanonical">, DefaultFalse,
   PosFlag,
+  "Try emitting Compact-Unwind for non-canonical entries. Maybe 
overridden by other constraints">,
   NegFlag>;
 def g_Flag : Flag<["-"], "g">, Group,
 Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
@@ -5573,7 +5573,7 @@ def noseglinkedit : Flag<["-"], "noseglinkedit">;
 def nostartfiles : Flag<["-"], "nostartfiles">, Group;
 def nostdinc : Flag<["-"], "nostdinc">,
   Visibility<[ClangOption, CLOption, DXCOption]>, Group,
-  HelpText<"Disable both standard system #include directories and builtin 
#include directores">;
+  HelpText<"Disable both standard system #include directories and builtin 
#include directories">;
 def nostdlibinc : Flag<["-"], "nostdlibinc">, Group,
   HelpText<"Disable standard system #include directories only">;
 def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, 
CC1Option]>,

_

[clang] [clang] Fix various typos and whitespace in HelpText. (PR #108527)

2024-09-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ryan Mansfield (rjmansfield)


Changes



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


1 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+10-10) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f78032255f036f..c5e0aca4da0bc4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1055,7 +1055,7 @@ def Xlinker : Separate<["-"], "Xlinker">, 
Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass  to the linker">, MetaVarName<"">,
   Group;
 def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
-  HelpText<"Pass  to the offload linkers or the ones idenfied by 
-">,
+  HelpText<"Pass  to the offload linkers or the ones identified by 
-">,
   MetaVarName<" ">, Group;
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, 
Group,
   HelpText<"Pass  to the preprocessor">, MetaVarName<"">;
@@ -2576,7 +2576,7 @@ defm sanitize_stats : BoolOption<"f", "sanitize-stats",
   BothFlags<[], [ClangOption], " sanitizer statistics gathering.">>,
   Group;
 def fsanitize_undefined_ignore_overflow_pattern_EQ : CommaJoined<["-"], 
"fsanitize-undefined-ignore-overflow-pattern=">,
-  HelpText<"Specify the overflow patterns to exclude from artihmetic sanitizer 
instrumentation">,
+  HelpText<"Specify the overflow patterns to exclude from arithmetic sanitizer 
instrumentation">,
   Visibility<[ClangOption, CC1Option]>,
   
Values<"none,all,add-unsigned-overflow-test,add-signed-overflow-test,negated-unsigned-const,unsigned-post-decr-while">,
   MarshallingInfoStringVector>;
@@ -3216,7 +3216,7 @@ def fno_modules_prune_non_affecting_module_map_files :
 def fincremental_extensions :
   Flag<["-"], "fincremental-extensions">,
   Group, Visibility<[ClangOption, CC1Option]>,
-  HelpText<"Enable incremental processing extensions such as processing"
+  HelpText<"Enable incremental processing extensions such as processing "
"statements on the global scope.">,
   MarshallingInfoFlag>;
 
@@ -3669,7 +3669,7 @@ def fopenmp_offload_mandatory : Flag<["-"], 
"fopenmp-offload-mandatory">, Group<
   MarshallingInfoFlag>;
 def fopenmp_force_usm : Flag<["-"], "fopenmp-force-usm">, Group,
   Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CC1Option, FlangOption, 
FC1Option]>,
-  HelpText<"Force behvaior as if the user specified pragma omp requires 
unified_shared_memory.">,
+  HelpText<"Force behavior as if the user specified pragma omp requires 
unified_shared_memory.">,
   MarshallingInfoFlag>;
 def fopenmp_target_jit : Flag<["-"], "fopenmp-target-jit">, Group,
   Flags<[NoArgumentUnused]>, Visibility<[ClangOption, CLOption]>,
@@ -3776,20 +3776,20 @@ defm tocdata : BoolOption<"m","tocdata",
   PosFlag,
   NegFlag,
   BothFlags<[TargetSpecific], [ClangOption, CLOption]>>, Group;
 def mtocdata_EQ : CommaJoined<["-"], "mtocdata=">,
   Visibility<[ClangOption, CC1Option]>,
   Flags<[TargetSpecific]>, Group,
-  HelpText<"Specifies a list of variables to which the TOC data transformation"
+  HelpText<"Specifies a list of variables to which the TOC data transformation 
"
"will be applied.">,
   MarshallingInfoStringVector>;
 def mno_tocdata_EQ : CommaJoined<["-"], "mno-tocdata=">,
   Visibility<[ClangOption, CC1Option]>,
   Flags<[TargetSpecific]>, Group,
-  HelpText<"Specifies a list of variables to be exempt from the TOC data"
+  HelpText<"Specifies a list of variables to be exempt from the TOC data "
"transformation.">,
   MarshallingInfoStringVector>;
 defm preserve_as_comments : BoolFOption<"preserve-as-comments",
@@ -4373,7 +4373,7 @@ def femit_dwarf_unwind_EQ : Joined<["-"], 
"femit-dwarf-unwind=">,
 defm emit_compact_unwind_non_canonical : 
BoolFOption<"emit-compact-unwind-non-canonical",
   CodeGenOpts<"EmitCompactUnwindNonCanonical">, DefaultFalse,
   PosFlag,
+  "Try emitting Compact-Unwind for non-canonical entries. Maybe 
overridden by other constraints">,
   NegFlag>;
 def g_Flag : Flag<["-"], "g">, Group,
 Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
@@ -5573,7 +5573,7 @@ def noseglinkedit : Flag<["-"], "noseglinkedit">;
 def nostartfiles : Flag<["-"], "nostartfiles">, Group;
 def nostdinc : Flag<["-"], "nostdinc">,
   Visibility<[ClangOption, CLOption, DXCOption]>, Group,
-  HelpText<"Disable both standard system #include directories and builtin 
#include directores">;
+  HelpText<"Disable both standard system #include directories and builtin 
#include directories">;
 def nostdlibinc : Flag<["-"], "nostdlibinc">, Group,
   HelpText<"Disable standard system #include directories only">;
 def nostdincxx : Flag<["-"], "nostdinc++">, Visibility<[ClangOption, 
CC1Option]>,

``




https://github.com/llvm/llvm-project/pull/108527
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cg

[clang] [llvm] [SPIRV][RFC] Rework / extend support for memory scopes (PR #106429)

2024-09-13 Thread Vyacheslav Levytskyy via cfe-commits


@@ -58,7 +58,35 @@ class SPIRVTargetCodeGenInfo : public 
CommonSPIRTargetCodeGenInfo {
   SPIRVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
   : CommonSPIRTargetCodeGenInfo(std::make_unique(CGT)) {}
   void setCUDAKernelCallingConvention(const FunctionType *&FT) const override;
+  llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
+ SyncScope Scope,
+ llvm::AtomicOrdering Ordering,
+ llvm::LLVMContext &Ctx) const 
override;
 };
+
+inline StringRef mapClangSyncScopeToLLVM(SyncScope Scope) {
+  switch (Scope) {
+  case SyncScope::HIPSingleThread:
+  case SyncScope::SingleScope:
+return "singlethread";
+  case SyncScope::HIPWavefront:
+  case SyncScope::OpenCLSubGroup:
+  case SyncScope::WavefrontScope:
+return "subgroup";
+  case SyncScope::HIPWorkgroup:
+  case SyncScope::OpenCLWorkGroup:
+  case SyncScope::WorkgroupScope:
+return "workgroup";
+  case SyncScope::HIPAgent:
+  case SyncScope::OpenCLDevice:
+  case SyncScope::DeviceScope:
+return "device";
+  case SyncScope::SystemScope:
+  case SyncScope::HIPSystem:
+  case SyncScope::OpenCLAllSVMDevices:
+return "all_svm_devices";

VyacheslavLevytskyy wrote:

Should we return "" instead of "all_svm_devices" here as already existing name 
denoting the System sync scope?

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


[clang] [llvm] Prefer std::getenv to ::getenv (PR #108529)

2024-09-13 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev created 
https://github.com/llvm/llvm-project/pull/108529

Posix call to ::getenv is not guarenteed to be thread safe while C++11 made 
std::getenv thread safe.

This resolves bugs when using llvm in multithreaded environment similar to 
cms-sw/cmssw#44659

>From 4ae2832068848ea84bae0dd16e6ad40cb5207f4f Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Fri, 13 Sep 2024 10:37:36 +
Subject: [PATCH] Prefer std::getenv to ::getenv

Posix call to ::getenv is not guarenteed to be thread safe while C++11 made
std::getenv thread safe.

This resolves bugs when using llvm in multithreaded environment similar to
cms-sw/cmssw#44659
---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp |  2 +-
 clang/lib/Driver/Driver.cpp |  2 +-
 clang/lib/Driver/ToolChains/CommonArgs.cpp  |  2 +-
 clang/lib/Driver/ToolChains/Darwin.cpp  |  8 
 clang/lib/Frontend/PrecompiledPreamble.cpp  |  2 +-
 clang/tools/clang-installapi/Options.cpp|  6 +++---
 clang/tools/driver/driver.cpp   | 12 ++--
 clang/tools/libclang/ARCMigrate.cpp |  4 ++--
 clang/tools/libclang/CLog.h |  2 +-
 llvm/lib/Support/Unix/Path.inc  |  2 +-
 llvm/lib/Support/Unix/Process.inc   |  2 +-
 llvm/unittests/Support/Path.cpp |  4 ++--
 12 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index a36cb41a63dfb1..8d6590fab281c2 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -522,7 +522,7 @@ class HTMLLogger : public Logger {
 // Nothing interesting here, just subprocess/temp-file plumbing.
 llvm::Expected renderSVG(llvm::StringRef DotGraph) {
   std::string DotPath;
-  if (const auto *FromEnv = ::getenv("GRAPHVIZ_DOT"))
+  if (const auto *FromEnv = std::getenv("GRAPHVIZ_DOT"))
 DotPath = FromEnv;
   else {
 auto FromPath = llvm::sys::findProgramByName("dot");
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e12416e51f8d24..4b65bff86393cd 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1124,7 +1124,7 @@ bool Driver::loadConfigFiles() {
 bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) {
   // Disable default config if CLANG_NO_DEFAULT_CONFIG is set to a non-empty
   // value.
-  if (const char *NoConfigEnv = ::getenv("CLANG_NO_DEFAULT_CONFIG")) {
+  if (const char *NoConfigEnv = std::getenv("CLANG_NO_DEFAULT_CONFIG")) {
 if (*NoConfigEnv)
   return false;
   }
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 320d2901da06ed..8c65c7d2d3d3e5 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -390,7 +390,7 @@ tools::unifyTargetFeatures(ArrayRef Features) {
 
 void tools::addDirectoryList(const ArgList &Args, ArgStringList &CmdArgs,
  const char *ArgName, const char *EnvVar) {
-  const char *DirList = ::getenv(EnvVar);
+  const char *DirList = std::getenv(EnvVar);
   bool CombinedArg = false;
 
   if (!DirList)
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 2550541a438481..0c7fcd54fb7d21 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1936,7 +1936,7 @@ getDeploymentTargetFromEnvironmentVariables(const Driver 
&TheDriver,
   static_assert(std::size(EnvVars) == Darwin::LastDarwinPlatform + 1,
 "Missing platform");
   for (const auto &I : llvm::enumerate(llvm::ArrayRef(EnvVars))) {
-if (char *Env = ::getenv(I.value()))
+if (char *Env = std::getenv(I.value()))
   Targets[I.index()] = Env;
   }
 
@@ -2217,7 +2217,7 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) 
const {
 if (!getVFS().exists(A->getValue()))
   getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
   } else {
-if (char *env = ::getenv("SDKROOT")) {
+if (char *env = std::getenv("SDKROOT")) {
   // We only use this value as the default if it is an absolute path,
   // exists, and it is not the root path.
   if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) &&
@@ -3217,13 +3217,13 @@ ToolChain::UnwindTableLevel 
MachO::getDefaultUnwindTableLevel(const ArgList &Arg
 }
 
 bool MachO::UseDwarfDebugFlags() const {
-  if (const char *S = ::getenv("RC_DEBUG_OPTIONS"))
+  if (const char *S = std::getenv("RC_DEBUG_OPTIONS"))
 return S[0] != '\0';
   return false;
 }
 
 std::string MachO::GetGlobalDebugPathRemapping() const {
-  if (const char *S = ::getenv("RC_DEBUG_PREFIX_MAP"))
+  if (const char *S = std::getenv("RC_DEBUG_PREFIX_MAP"))
 return S;
   return {};
 }
diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp 
b

[clang] [llvm] Prefer std::getenv to ::getenv (PR #108529)

2024-09-13 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-support

@llvm/pr-subscribers-clang-driver

Author: Vassil Vassilev (vgvassilev)


Changes

Posix call to ::getenv is not guarenteed to be thread safe while C++11 made 
std::getenv thread safe.

This resolves bugs when using llvm in multithreaded environment similar to 
cms-sw/cmssw#44659

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


12 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp (+1-1) 
- (modified) clang/lib/Driver/Driver.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+4-4) 
- (modified) clang/lib/Frontend/PrecompiledPreamble.cpp (+1-1) 
- (modified) clang/tools/clang-installapi/Options.cpp (+3-3) 
- (modified) clang/tools/driver/driver.cpp (+6-6) 
- (modified) clang/tools/libclang/ARCMigrate.cpp (+2-2) 
- (modified) clang/tools/libclang/CLog.h (+1-1) 
- (modified) llvm/lib/Support/Unix/Path.inc (+1-1) 
- (modified) llvm/lib/Support/Unix/Process.inc (+1-1) 
- (modified) llvm/unittests/Support/Path.cpp (+2-2) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index a36cb41a63dfb1..8d6590fab281c2 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -522,7 +522,7 @@ class HTMLLogger : public Logger {
 // Nothing interesting here, just subprocess/temp-file plumbing.
 llvm::Expected renderSVG(llvm::StringRef DotGraph) {
   std::string DotPath;
-  if (const auto *FromEnv = ::getenv("GRAPHVIZ_DOT"))
+  if (const auto *FromEnv = std::getenv("GRAPHVIZ_DOT"))
 DotPath = FromEnv;
   else {
 auto FromPath = llvm::sys::findProgramByName("dot");
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e12416e51f8d24..4b65bff86393cd 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1124,7 +1124,7 @@ bool Driver::loadConfigFiles() {
 bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) {
   // Disable default config if CLANG_NO_DEFAULT_CONFIG is set to a non-empty
   // value.
-  if (const char *NoConfigEnv = ::getenv("CLANG_NO_DEFAULT_CONFIG")) {
+  if (const char *NoConfigEnv = std::getenv("CLANG_NO_DEFAULT_CONFIG")) {
 if (*NoConfigEnv)
   return false;
   }
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 320d2901da06ed..8c65c7d2d3d3e5 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -390,7 +390,7 @@ tools::unifyTargetFeatures(ArrayRef Features) {
 
 void tools::addDirectoryList(const ArgList &Args, ArgStringList &CmdArgs,
  const char *ArgName, const char *EnvVar) {
-  const char *DirList = ::getenv(EnvVar);
+  const char *DirList = std::getenv(EnvVar);
   bool CombinedArg = false;
 
   if (!DirList)
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 2550541a438481..0c7fcd54fb7d21 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1936,7 +1936,7 @@ getDeploymentTargetFromEnvironmentVariables(const Driver 
&TheDriver,
   static_assert(std::size(EnvVars) == Darwin::LastDarwinPlatform + 1,
 "Missing platform");
   for (const auto &I : llvm::enumerate(llvm::ArrayRef(EnvVars))) {
-if (char *Env = ::getenv(I.value()))
+if (char *Env = std::getenv(I.value()))
   Targets[I.index()] = Env;
   }
 
@@ -2217,7 +2217,7 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) 
const {
 if (!getVFS().exists(A->getValue()))
   getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
   } else {
-if (char *env = ::getenv("SDKROOT")) {
+if (char *env = std::getenv("SDKROOT")) {
   // We only use this value as the default if it is an absolute path,
   // exists, and it is not the root path.
   if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) &&
@@ -3217,13 +3217,13 @@ ToolChain::UnwindTableLevel 
MachO::getDefaultUnwindTableLevel(const ArgList &Arg
 }
 
 bool MachO::UseDwarfDebugFlags() const {
-  if (const char *S = ::getenv("RC_DEBUG_OPTIONS"))
+  if (const char *S = std::getenv("RC_DEBUG_OPTIONS"))
 return S[0] != '\0';
   return false;
 }
 
 std::string MachO::GetGlobalDebugPathRemapping() const {
-  if (const char *S = ::getenv("RC_DEBUG_PREFIX_MAP"))
+  if (const char *S = std::getenv("RC_DEBUG_PREFIX_MAP"))
 return S;
   return {};
 }
diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp 
b/clang/lib/Frontend/PrecompiledPreamble.cpp
index cab5838fceb24d..cf3999341dc2d4 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -203,7 +203,7 @@ class TempPCHFile {
 // FIXME: This is a hack so that we can override the preamble file during

[clang] [llvm] [SPIRV][RFC] Rework / extend support for memory scopes (PR #106429)

2024-09-13 Thread Vyacheslav Levytskyy via cfe-commits

VyacheslavLevytskyy wrote:

With the full respect to @AlexVlx work I created 
https://github.com/llvm/llvm-project/pull/108528 just as an utility to discuss 
and agree about memory scoped issues.

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread via cfe-commits

ganeshgit wrote:

> @ganeshgit Ignore what I said earlier about waiting for the tuning patches :) 
> Please can we get this committed to trunk, we'll let it brew for a few days 
> and then cherry pick for 19.x - if you can create PRs for the tuning changes 
> as soon as possible we can review them for 19.x on a case by case basis.

I will upload the rebased code addressing the format errors shortly. Yes PRs 
will work for tuning changes. I think it will take some time. 

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread via cfe-commits

ganeshgit wrote:

> Zen 5 support in GCC was upstreamed more than half a year ago -- why is the 
> LLVM support being upstreamed only now, after missing the 19.x window? What 
> steps are being taken to ensure this does not happen again?
> 
> The change to X86TargetParser.h looks ABI breaking to me.

We have a dependency in libpfm for llvm which requires legal clearances. In 
future, we will make sure this gets addressed in advance and will try to upload 
our patches in sync with GCC patches. Apologies for the inconvenience.

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


[clang] [llvm] [Instrumentation] Move out to Utils (NFC) (PR #108532)

2024-09-13 Thread Antonio Frighetto via cfe-commits

https://github.com/antoniofrighetto created 
https://github.com/llvm/llvm-project/pull/108532

Utility functions have been moved out to Utils. Minor opportunity to drop the 
header where not needed.

>From 42fef89fcc75d7f1f869c70d5357fcf3a0d410e1 Mon Sep 17 00:00:00 2001
From: Antonio Frighetto 
Date: Fri, 13 Sep 2024 11:43:30 +0200
Subject: [PATCH] [Instrumentation] Move out to Utils (NFC)

Utility functions have been moved out to Utils.
---
 clang/lib/CodeGen/BackendUtil.cpp   | 1 -
 llvm/include/llvm/Passes/PassBuilder.h  | 1 -
 llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h | 2 +-
 llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h   | 2 +-
 .../llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h   | 2 +-
 .../include/llvm/Transforms/Instrumentation/SanitizerCoverage.h | 2 +-
 llvm/include/llvm/Transforms/{ => Utils}/Instrumentation.h  | 0
 llvm/lib/Passes/PassBuilder.cpp | 2 +-
 llvm/lib/Transforms/IPO/SampleProfile.cpp   | 2 +-
 llvm/lib/Transforms/IPO/SampleProfileProbe.cpp  | 2 +-
 llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp| 2 +-
 llvm/lib/Transforms/Instrumentation/CGProfile.cpp   | 2 +-
 llvm/lib/Transforms/Instrumentation/CMakeLists.txt  | 1 -
 llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp   | 2 +-
 llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp   | 2 +-
 llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp  | 2 +-
 llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp   | 2 +-
 llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp  | 2 +-
 llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp  | 2 +-
 llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | 2 +-
 .../Transforms/Instrumentation/NumericalStabilitySanitizer.cpp  | 2 +-
 llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp  | 2 +-
 llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp | 2 +-
 llvm/lib/Transforms/Utils/CMakeLists.txt| 1 +
 .../Transforms/{Instrumentation => Utils}/Instrumentation.cpp   | 2 +-
 llvm/tools/lli/lli.cpp  | 1 -
 26 files changed, 21 insertions(+), 24 deletions(-)
 rename llvm/include/llvm/Transforms/{ => Utils}/Instrumentation.h (100%)
 rename llvm/lib/Transforms/{Instrumentation => Utils}/Instrumentation.cpp (98%)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7fa69420298160..d6fdd79db1b5af 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -64,7 +64,6 @@
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
diff --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index e1d78a8685aed2..e6ced0cccb9b3c 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -25,7 +25,6 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/IPO/Inliner.h"
 #include "llvm/Transforms/IPO/ModuleInliner.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h 
b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
index e5b4520f36a2fd..f92cee0cf1 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
@@ -13,7 +13,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_GCOVPROFILER_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 /// The gcov-style instrumentation pass
diff --git a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
index 0dd37c9ca58b7e..2042700ad6b6ad 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -14,7 +14,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_INSTRPROFILING_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 
diff --git 
a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h 
b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
index 800a1d583f8015..9efa23108d6a38 100644
--- a/llvm/include/llv

[clang] [llvm] [Instrumentation] Move out to Utils (NFC) (PR #108532)

2024-09-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Antonio Frighetto (antoniofrighetto)


Changes

Utility functions have been moved out to Utils. Minor opportunity to drop the 
header where not needed.

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


26 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (-1) 
- (modified) llvm/include/llvm/Passes/PassBuilder.h (-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
(+1-1) 
- (modified) 
llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h 
(+1-1) 
- (renamed) llvm/include/llvm/Transforms/Utils/Instrumentation.h () 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/SampleProfileProbe.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/CGProfile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (-1) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp 
(+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Utils/CMakeLists.txt (+1) 
- (renamed) llvm/lib/Transforms/Utils/Instrumentation.cpp (+1-1) 
- (modified) llvm/tools/lli/lli.cpp (-1) 


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7fa69420298160..d6fdd79db1b5af 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -64,7 +64,6 @@
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
diff --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index e1d78a8685aed2..e6ced0cccb9b3c 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -25,7 +25,6 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/IPO/Inliner.h"
 #include "llvm/Transforms/IPO/ModuleInliner.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h 
b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
index e5b4520f36a2fd..f92cee0cf1 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
@@ -13,7 +13,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_GCOVPROFILER_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 /// The gcov-style instrumentation pass
diff --git a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
index 0dd37c9ca58b7e..2042700ad6b6ad 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -14,7 +14,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_INSTRPROFILING_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 
diff --git 
a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h 
b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
index 800a1d583f8015..9efa23108d6a38 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
@@ -16,7 +16,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transfor

[clang] [llvm] [Instrumentation] Move out to Utils (NFC) (PR #108532)

2024-09-13 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-clang-codegen

Author: Antonio Frighetto (antoniofrighetto)


Changes

Utility functions have been moved out to Utils. Minor opportunity to drop the 
header where not needed.

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


26 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (-1) 
- (modified) llvm/include/llvm/Passes/PassBuilder.h (-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
(+1-1) 
- (modified) 
llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h 
(+1-1) 
- (renamed) llvm/include/llvm/Transforms/Utils/Instrumentation.h () 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/SampleProfileProbe.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/CGProfile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (-1) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp 
(+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Utils/CMakeLists.txt (+1) 
- (renamed) llvm/lib/Transforms/Utils/Instrumentation.cpp (+1-1) 
- (modified) llvm/tools/lli/lli.cpp (-1) 


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7fa69420298160..d6fdd79db1b5af 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -64,7 +64,6 @@
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
diff --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index e1d78a8685aed2..e6ced0cccb9b3c 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -25,7 +25,6 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/IPO/Inliner.h"
 #include "llvm/Transforms/IPO/ModuleInliner.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h 
b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
index e5b4520f36a2fd..f92cee0cf1 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
@@ -13,7 +13,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_GCOVPROFILER_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 /// The gcov-style instrumentation pass
diff --git a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
index 0dd37c9ca58b7e..2042700ad6b6ad 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -14,7 +14,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_INSTRPROFILING_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 
diff --git 
a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h 
b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
index 800a1d583f8015..9efa23108d6a38 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
@@ -16,7 +16,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transform

[clang] [llvm] [Instrumentation] Move out to Utils (NFC) (PR #108532)

2024-09-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Antonio Frighetto (antoniofrighetto)


Changes

Utility functions have been moved out to Utils. Minor opportunity to drop the 
header where not needed.

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


26 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (-1) 
- (modified) llvm/include/llvm/Passes/PassBuilder.h (-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
(+1-1) 
- (modified) 
llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h (+1-1) 
- (modified) llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h 
(+1-1) 
- (renamed) llvm/include/llvm/Transforms/Utils/Instrumentation.h () 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/SampleProfileProbe.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/CGProfile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (-1) 
- (modified) llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp 
(+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+1-1) 
- (modified) 
llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Utils/CMakeLists.txt (+1) 
- (renamed) llvm/lib/Transforms/Utils/Instrumentation.cpp (+1-1) 
- (modified) llvm/tools/lli/lli.cpp (-1) 


``diff
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7fa69420298160..d6fdd79db1b5af 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -64,7 +64,6 @@
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
diff --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index e1d78a8685aed2..e6ced0cccb9b3c 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -25,7 +25,6 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/IPO/Inliner.h"
 #include "llvm/Transforms/IPO/ModuleInliner.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h 
b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
index e5b4520f36a2fd..f92cee0cf1 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
@@ -13,7 +13,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_GCOVPROFILER_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 /// The gcov-style instrumentation pass
diff --git a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
index 0dd37c9ca58b7e..2042700ad6b6ad 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -14,7 +14,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_INSTRPROFILING_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 
diff --git 
a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h 
b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
index 800a1d583f8015..9efa23108d6a38 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
@@ -16,7 +16,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#includ

[clang] [llvm] [X86][AVX10.2] Support AVX10.2-SATCVT-DS new instructions. (PR #102592)

2024-09-13 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lld-x86_64-win` running on 
`as-worker-93` while building `clang,llvm` at step 7 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/146/builds/1139


Here is the relevant piece of the build log for the reference

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM-Unit :: Support/./SupportTests.exe/36/87' 
FAILED 
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-16844-36-87.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=36 
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe 
--gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): 
error: Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): 
error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied







```



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


[clang] [llvm] [Instrumentation] Move out to Utils (NFC) (PR #108532)

2024-09-13 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 c0e308ba3d8ac252b8118d94a17b1351ca92b813 
42fef89fcc75d7f1f869c70d5357fcf3a0d410e1 --extensions cpp,h -- 
clang/lib/CodeGen/BackendUtil.cpp llvm/include/llvm/Passes/PassBuilder.h 
llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h 
llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h 
llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h 
llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/SampleProfile.cpp 
llvm/lib/Transforms/IPO/SampleProfileProbe.cpp 
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
llvm/lib/Transforms/Instrumentation/CGProfile.cpp 
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp 
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp 
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp 
llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp 
llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp 
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp 
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp 
llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp 
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp 
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp llvm/tools/lli/lli.cpp 
llvm/include/llvm/Transforms/Utils/Instrumentation.h 
llvm/lib/Transforms/Utils/Instrumentation.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp 
b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 2954c5bea2..5d1ec7248a 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -73,9 +73,9 @@
 #include "llvm/Transforms/IPO/SampleContextTracker.h"
 #include "llvm/Transforms/IPO/SampleProfileMatcher.h"
 #include "llvm/Transforms/IPO/SampleProfileProbe.h"
-#include "llvm/Transforms/Utils/Instrumentation.h"
 #include "llvm/Transforms/Utils/CallPromotionUtils.h"
 #include "llvm/Transforms/Utils/Cloning.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 #include "llvm/Transforms/Utils/MisExpect.h"
 #include "llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h"
 #include "llvm/Transforms/Utils/SampleProfileLoaderBaseUtil.h"
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index d0b0a6a6ad..16e43bef15 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -71,11 +71,11 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
-#include "llvm/Transforms/Utils/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerCommon.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include "llvm/Transforms/Utils/ASanStackFrameLayout.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 #include "llvm/Transforms/Utils/PromoteMemToReg.h"
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index b9bc6e5f70..20fdf28011 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -104,8 +104,8 @@
 #include "llvm/Support/SpecialCaseList.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/Triple.h"
-#include "llvm/Transforms/Utils/Instrumentation.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 #include "llvm/Transforms/Utils/Local.h"
 #include 
 #include 
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp 
b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 254dc29cee..1d4f85ab1e 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -36,9 +36,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Transforms/Utils/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/CFGMST.h"
 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 #include 
 #include 
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index b80f4145f0..da7dc180de 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/In

[clang] [llvm] [Instrumentation] Move out to Utils (NFC) (PR #108532)

2024-09-13 Thread Antonio Frighetto via cfe-commits

https://github.com/antoniofrighetto updated 
https://github.com/llvm/llvm-project/pull/108532

>From 4518980e2698b76825d9650373df7414f61062d9 Mon Sep 17 00:00:00 2001
From: Antonio Frighetto 
Date: Fri, 13 Sep 2024 11:43:30 +0200
Subject: [PATCH] [Instrumentation] Move out to Utils (NFC)

Utility functions have been moved out to Utils.
---
 clang/lib/CodeGen/BackendUtil.cpp | 1 -
 llvm/include/llvm/Passes/PassBuilder.h| 1 -
 .../llvm/Transforms/Instrumentation/GCOVProfiler.h| 2 +-
 .../llvm/Transforms/Instrumentation/InstrProfiling.h  | 2 +-
 .../Transforms/Instrumentation/SanitizerBinaryMetadata.h  | 2 +-
 .../llvm/Transforms/Instrumentation/SanitizerCoverage.h   | 2 +-
 .../include/llvm/Transforms/{ => Utils}/Instrumentation.h | 0
 llvm/lib/Passes/PassBuilder.cpp   | 2 +-
 llvm/lib/Transforms/IPO/SampleProfile.cpp | 2 +-
 llvm/lib/Transforms/IPO/SampleProfileProbe.cpp| 2 +-
 llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp  | 2 +-
 llvm/lib/Transforms/Instrumentation/CGProfile.cpp | 2 +-
 llvm/lib/Transforms/Instrumentation/CMakeLists.txt| 1 -
 llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp | 2 +-
 llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp | 2 +-
 .../lib/Transforms/Instrumentation/HWAddressSanitizer.cpp | 2 +-
 .../Transforms/Instrumentation/IndirectCallPromotion.cpp  | 2 +-
 llvm/lib/Transforms/Instrumentation/InstrOrderFile.cpp| 2 +-
 llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp| 2 +-
 llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp   | 2 +-
 .../Instrumentation/NumericalStabilitySanitizer.cpp   | 2 +-
 .../lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 2 +-
 llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp   | 2 +-
 llvm/lib/Transforms/Utils/CMakeLists.txt  | 1 +
 .../{Instrumentation => Utils}/Instrumentation.cpp| 8 +---
 llvm/tools/lli/lli.cpp| 1 -
 26 files changed, 25 insertions(+), 26 deletions(-)
 rename llvm/include/llvm/Transforms/{ => Utils}/Instrumentation.h (100%)
 rename llvm/lib/Transforms/{Instrumentation => Utils}/Instrumentation.cpp (95%)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7fa69420298160..d6fdd79db1b5af 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -64,7 +64,6 @@
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
diff --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index e1d78a8685aed2..e6ced0cccb9b3c 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -25,7 +25,6 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/IPO/Inliner.h"
 #include "llvm/Transforms/IPO/ModuleInliner.h"
-#include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include 
 #include 
diff --git a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h 
b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
index e5b4520f36a2fd..f92cee0cf1 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/GCOVProfiler.h
@@ -13,7 +13,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_GCOVPROFILER_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 /// The gcov-style instrumentation pass
diff --git a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h 
b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
index 0dd37c9ca58b7e..2042700ad6b6ad 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -14,7 +14,7 @@
 #define LLVM_TRANSFORMS_INSTRUMENTATION_INSTRPROFILING_H
 
 #include "llvm/IR/PassManager.h"
-#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Utils/Instrumentation.h"
 
 namespace llvm {
 
diff --git 
a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h 
b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
index 800a1d583f8015..9efa23108d6a38 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
@@ -16,7 +16,7 @@
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
-#include "

[clang] [X86][test] Avoid writing to a potentially write-protected dir (PR #108525)

2024-09-13 Thread Mikhail Goncharov via cfe-commits

metaflow wrote:

there is also `avx10_2satcvtds-builtins-errors.c` that calls emit

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


[clang] [X86][test] Avoid writing to a potentially write-protected dir (PR #108525)

2024-09-13 Thread Mikhail Goncharov via cfe-commits

metaflow wrote:

thank you for the fix @MalaySanghi !

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


[clang] [llvm] [X86][AVX10.2] Support AVX10.2 MOVZXC new Instructions. (PR #108537)

2024-09-13 Thread via cfe-commits

https://github.com/mahesh-attarde created 
https://github.com/llvm/llvm-project/pull/108537

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965

Chapter 14 INTEL® AVX10 ZERO-EXTENDING PARTIAL VECTOR COPY INSTRUCTIONS

>From d8e76ea27679df40d0c796a5e8e5bc31433b6bff Mon Sep 17 00:00:00 2001
From: mattarde 
Date: Fri, 13 Sep 2024 03:26:14 -0700
Subject: [PATCH] update clr

---
 clang/lib/Headers/CMakeLists.txt  |  1 +
 clang/lib/Headers/avx10_2copyintrin.h | 34 ++
 clang/lib/Headers/immintrin.h |  1 +
 clang/test/CodeGen/X86/avx512copy-builtins.c  | 17 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   |  5 +-
 llvm/lib/Target/X86/X86InstrAVX10.td  | 64 +++
 .../test/CodeGen/X86/avx512copy-intrinsics.ll | 35 ++
 .../MC/Disassembler/X86/avx10.2-copy-32.txt   | 34 ++
 .../MC/Disassembler/X86/avx10.2-copy-64.txt   | 34 ++
 llvm/test/MC/X86/avx10.2-copy-32-att.s| 17 +
 llvm/test/MC/X86/avx10.2-copy-32-intel.s  | 17 +
 llvm/test/MC/X86/avx10.2-copy-64-att.s| 17 +
 llvm/test/MC/X86/avx10.2-copy-64-intel.s  | 17 +
 llvm/test/TableGen/x86-fold-tables.inc|  2 +
 llvm/utils/TableGen/X86ManualInstrMapping.def |  1 +
 15 files changed, 294 insertions(+), 2 deletions(-)
 create mode 100644 clang/lib/Headers/avx10_2copyintrin.h
 create mode 100644 clang/test/CodeGen/X86/avx512copy-builtins.c
 create mode 100644 llvm/test/CodeGen/X86/avx512copy-intrinsics.ll
 create mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-copy-32.txt
 create mode 100644 llvm/test/MC/Disassembler/X86/avx10.2-copy-64.txt
 create mode 100644 llvm/test/MC/X86/avx10.2-copy-32-att.s
 create mode 100644 llvm/test/MC/X86/avx10.2-copy-32-intel.s
 create mode 100644 llvm/test/MC/X86/avx10.2-copy-64-att.s
 create mode 100644 llvm/test/MC/X86/avx10.2-copy-64-intel.s

diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index a21e3901f63fea..fb55dca0fda405 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -155,6 +155,7 @@ set(x86_files
   avx10_2_512satcvtintrin.h
   avx10_2bf16intrin.h
   avx10_2convertintrin.h
+  avx10_2copyintrin.h
   avx10_2minmaxintrin.h
   avx10_2niintrin.h
   avx10_2satcvtdsintrin.h
diff --git a/clang/lib/Headers/avx10_2copyintrin.h 
b/clang/lib/Headers/avx10_2copyintrin.h
new file mode 100644
index 00..13e76c6abe8993
--- /dev/null
+++ b/clang/lib/Headers/avx10_2copyintrin.h
@@ -0,0 +1,34 @@
+/*=== avx10_2copyintrin.h - AVX10.2 Copy intrinsics ---===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error 
\
+"Never use  directly; include  instead."
+#endif // __IMMINTRIN_H
+
+#ifndef __AVX10_2COPYINTRIN_H
+#define __AVX10_2COPYINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS128  
\
+  __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"),
\
+ __min_vector_width__(128)))
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_move_epi32(__m128i __A) {
+  return (__m128i)__builtin_shufflevector(
+  (__v4si)__A, (__v4si)_mm_setzero_si128(), 0, 4, 4, 4);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_move_epi16(__m128i __A) {
+  return (__m128i)__builtin_shufflevector(
+  (__v8hi)__A, (__v8hi)_mm_setzero_si128(), 0, 8, 8, 8, 8, 8, 8, 8);
+}
+
+#undef __DEFAULT_FN_ATTRS128
+
+#endif // __AVX10_2COPYINTRIN_H
\ No newline at end of file
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 280154f3c1026e..3fbabffa98df20 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -651,6 +651,7 @@ _storebe_i64(void * __P, long long __D) {
 #if !defined(__SCE__) || __has_feature(modules) || defined(__AVX10_2__)
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/clang/test/CodeGen/X86/avx512copy-builtins.c 
b/clang/test/CodeGen/X86/avx512copy-builtins.c
new file mode 100644
index 00..06f7507bde53ed
--- /dev/null
+++ b/clang/test/CodeGen/X86/avx512copy-builtins.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -flax-vector-conversions=none -ffreestanding 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-512 \
+// RUN: -emit-llvm -o - -Wall -Werror -pedantic -Wno-gnu-statement-expression 
| FileCheck %s
+
+#include 
+#include 
+
+__m128i test_mm_move_epi32(__m128i A) {
+  // CHECK-LABEL: test_mm_move_epi32
+  // CHECK: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> 
+  return _mm_move_epi32(A);
+}
+
+__

[clang] [llvm] [X86][AVX10.2] Support AVX10.2 MOVZXC new Instructions. (PR #108537)

2024-09-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mahesh-Attarde (mahesh-attarde)


Changes

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965

Chapter 14 INTEL® AVX10 ZERO-EXTENDING PARTIAL VECTOR COPY INSTRUCTIONS

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


15 Files Affected:

- (modified) clang/lib/Headers/CMakeLists.txt (+1) 
- (added) clang/lib/Headers/avx10_2copyintrin.h (+34) 
- (modified) clang/lib/Headers/immintrin.h (+1) 
- (added) clang/test/CodeGen/X86/avx512copy-builtins.c (+17) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+3-2) 
- (modified) llvm/lib/Target/X86/X86InstrAVX10.td (+64) 
- (added) llvm/test/CodeGen/X86/avx512copy-intrinsics.ll (+35) 
- (added) llvm/test/MC/Disassembler/X86/avx10.2-copy-32.txt (+34) 
- (added) llvm/test/MC/Disassembler/X86/avx10.2-copy-64.txt (+34) 
- (added) llvm/test/MC/X86/avx10.2-copy-32-att.s (+17) 
- (added) llvm/test/MC/X86/avx10.2-copy-32-intel.s (+17) 
- (added) llvm/test/MC/X86/avx10.2-copy-64-att.s (+17) 
- (added) llvm/test/MC/X86/avx10.2-copy-64-intel.s (+17) 
- (modified) llvm/test/TableGen/x86-fold-tables.inc (+2) 
- (modified) llvm/utils/TableGen/X86ManualInstrMapping.def (+1) 


``diff
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index a21e3901f63fea..fb55dca0fda405 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -155,6 +155,7 @@ set(x86_files
   avx10_2_512satcvtintrin.h
   avx10_2bf16intrin.h
   avx10_2convertintrin.h
+  avx10_2copyintrin.h
   avx10_2minmaxintrin.h
   avx10_2niintrin.h
   avx10_2satcvtdsintrin.h
diff --git a/clang/lib/Headers/avx10_2copyintrin.h 
b/clang/lib/Headers/avx10_2copyintrin.h
new file mode 100644
index 00..13e76c6abe8993
--- /dev/null
+++ b/clang/lib/Headers/avx10_2copyintrin.h
@@ -0,0 +1,34 @@
+/*=== avx10_2copyintrin.h - AVX10.2 Copy intrinsics ---===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error 
\
+"Never use  directly; include  instead."
+#endif // __IMMINTRIN_H
+
+#ifndef __AVX10_2COPYINTRIN_H
+#define __AVX10_2COPYINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS128  
\
+  __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"),
\
+ __min_vector_width__(128)))
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_move_epi32(__m128i __A) {
+  return (__m128i)__builtin_shufflevector(
+  (__v4si)__A, (__v4si)_mm_setzero_si128(), 0, 4, 4, 4);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_move_epi16(__m128i __A) {
+  return (__m128i)__builtin_shufflevector(
+  (__v8hi)__A, (__v8hi)_mm_setzero_si128(), 0, 8, 8, 8, 8, 8, 8, 8);
+}
+
+#undef __DEFAULT_FN_ATTRS128
+
+#endif // __AVX10_2COPYINTRIN_H
\ No newline at end of file
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 280154f3c1026e..3fbabffa98df20 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -651,6 +651,7 @@ _storebe_i64(void * __P, long long __D) {
 #if !defined(__SCE__) || __has_feature(modules) || defined(__AVX10_2__)
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/clang/test/CodeGen/X86/avx512copy-builtins.c 
b/clang/test/CodeGen/X86/avx512copy-builtins.c
new file mode 100644
index 00..06f7507bde53ed
--- /dev/null
+++ b/clang/test/CodeGen/X86/avx512copy-builtins.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -flax-vector-conversions=none -ffreestanding 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-512 \
+// RUN: -emit-llvm -o - -Wall -Werror -pedantic -Wno-gnu-statement-expression 
| FileCheck %s
+
+#include 
+#include 
+
+__m128i test_mm_move_epi32(__m128i A) {
+  // CHECK-LABEL: test_mm_move_epi32
+  // CHECK: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> 
+  return _mm_move_epi32(A);
+}
+
+__m128i test_mm_move_epi16(__m128i A) {
+  // CHECK-LABEL: test_mm_move_epi16
+  // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <8 x i32> 
+  return _mm_move_epi16(A);
+}
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 3c5b952ff62e24..38999de669c013 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -12319,7 +12319,7 @@ static SDValue lowerShuffleAsElementInsertion(
 }
 V2 = DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, ExtVT, V2S);
   } else if (Mask[V2Index] != (int)Mask.size() || EltVT == MVT::i8 ||
- EltVT == MVT::i16) {
+   

[clang] [llvm] [X86][AVX10.2] Support AVX10.2 MOVZXC new Instructions. (PR #108537)

2024-09-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: Mahesh-Attarde (mahesh-attarde)


Changes

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/828965

Chapter 14 INTEL® AVX10 ZERO-EXTENDING PARTIAL VECTOR COPY INSTRUCTIONS

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


15 Files Affected:

- (modified) clang/lib/Headers/CMakeLists.txt (+1) 
- (added) clang/lib/Headers/avx10_2copyintrin.h (+34) 
- (modified) clang/lib/Headers/immintrin.h (+1) 
- (added) clang/test/CodeGen/X86/avx512copy-builtins.c (+17) 
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+3-2) 
- (modified) llvm/lib/Target/X86/X86InstrAVX10.td (+64) 
- (added) llvm/test/CodeGen/X86/avx512copy-intrinsics.ll (+35) 
- (added) llvm/test/MC/Disassembler/X86/avx10.2-copy-32.txt (+34) 
- (added) llvm/test/MC/Disassembler/X86/avx10.2-copy-64.txt (+34) 
- (added) llvm/test/MC/X86/avx10.2-copy-32-att.s (+17) 
- (added) llvm/test/MC/X86/avx10.2-copy-32-intel.s (+17) 
- (added) llvm/test/MC/X86/avx10.2-copy-64-att.s (+17) 
- (added) llvm/test/MC/X86/avx10.2-copy-64-intel.s (+17) 
- (modified) llvm/test/TableGen/x86-fold-tables.inc (+2) 
- (modified) llvm/utils/TableGen/X86ManualInstrMapping.def (+1) 


``diff
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index a21e3901f63fea..fb55dca0fda405 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -155,6 +155,7 @@ set(x86_files
   avx10_2_512satcvtintrin.h
   avx10_2bf16intrin.h
   avx10_2convertintrin.h
+  avx10_2copyintrin.h
   avx10_2minmaxintrin.h
   avx10_2niintrin.h
   avx10_2satcvtdsintrin.h
diff --git a/clang/lib/Headers/avx10_2copyintrin.h 
b/clang/lib/Headers/avx10_2copyintrin.h
new file mode 100644
index 00..13e76c6abe8993
--- /dev/null
+++ b/clang/lib/Headers/avx10_2copyintrin.h
@@ -0,0 +1,34 @@
+/*=== avx10_2copyintrin.h - AVX10.2 Copy intrinsics ---===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error 
\
+"Never use  directly; include  instead."
+#endif // __IMMINTRIN_H
+
+#ifndef __AVX10_2COPYINTRIN_H
+#define __AVX10_2COPYINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS128  
\
+  __attribute__((__always_inline__, __nodebug__, __target__("avx10.2-256"),
\
+ __min_vector_width__(128)))
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_move_epi32(__m128i __A) {
+  return (__m128i)__builtin_shufflevector(
+  (__v4si)__A, (__v4si)_mm_setzero_si128(), 0, 4, 4, 4);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS128 _mm_move_epi16(__m128i __A) {
+  return (__m128i)__builtin_shufflevector(
+  (__v8hi)__A, (__v8hi)_mm_setzero_si128(), 0, 8, 8, 8, 8, 8, 8, 8);
+}
+
+#undef __DEFAULT_FN_ATTRS128
+
+#endif // __AVX10_2COPYINTRIN_H
\ No newline at end of file
diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 280154f3c1026e..3fbabffa98df20 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -651,6 +651,7 @@ _storebe_i64(void * __P, long long __D) {
 #if !defined(__SCE__) || __has_feature(modules) || defined(__AVX10_2__)
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/clang/test/CodeGen/X86/avx512copy-builtins.c 
b/clang/test/CodeGen/X86/avx512copy-builtins.c
new file mode 100644
index 00..06f7507bde53ed
--- /dev/null
+++ b/clang/test/CodeGen/X86/avx512copy-builtins.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -flax-vector-conversions=none -ffreestanding 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-512 \
+// RUN: -emit-llvm -o - -Wall -Werror -pedantic -Wno-gnu-statement-expression 
| FileCheck %s
+
+#include 
+#include 
+
+__m128i test_mm_move_epi32(__m128i A) {
+  // CHECK-LABEL: test_mm_move_epi32
+  // CHECK: shufflevector <4 x i32> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> 
+  return _mm_move_epi32(A);
+}
+
+__m128i test_mm_move_epi16(__m128i A) {
+  // CHECK-LABEL: test_mm_move_epi16
+  // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <8 x i32> 
+  return _mm_move_epi16(A);
+}
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 3c5b952ff62e24..38999de669c013 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -12319,7 +12319,7 @@ static SDValue lowerShuffleAsElementInsertion(
 }
 V2 = DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, ExtVT, V2S);
   } else if (Mask[V2Index] != (int)Mask.size() || EltVT == MVT::i8 ||
- EltVT == MVT::i16) {
+  

[clang] [llvm] [X86][AVX10.2] Support AVX10.2 MOVZXC new Instructions. (PR #108537)

2024-09-13 Thread via cfe-commits

mahesh-attarde wrote:

@phoebewang @FreddyLeaf @KanRobert Can you review please?

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


[clang] [clang] Fix various typos and whitespace in HelpText. (PR #108527)

2024-09-13 Thread via cfe-commits

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

LGTM, thanks!

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


[clang] [clang-scan-deps] Infer the tool locations from PATH (PR #108539)

2024-09-13 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo created 
https://github.com/llvm/llvm-project/pull/108539

This allows the clang driver to know which tool is meant to be executed, which 
allows the clang driver to load the right clang config files, and allows clang 
to find colocated sysroots.

This makes sure that doing `clang-scan-deps --  ...` looks up things in 
the same way as if one just would execute ` ...`, when `` isn't an 
absolute or relative path.

From 4119204e2da13d00bd6ac5d23e05a4f269b2b75c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Fri, 13 Sep 2024 13:57:49 +0300
Subject: [PATCH] [clang-scan-deps] Infer the tool locations from PATH

This allows the clang driver to know which tool is meant to be
executed, which allows the clang driver to load the right clang
config files, and allows clang to find colocated sysroots.

This makes sure that doing `clang-scan-deps --  ...`
looks up things in the same way as if one just would execute
` ...`, when `` isn't an absolute or relative path.
---
 .../clang/Tooling/CompilationDatabase.h   |  6 ++
 clang/lib/Tooling/CMakeLists.txt  |  1 +
 .../Tooling/LocateToolCompilationDatabase.cpp | 71 +++
 .../ClangScanDeps/modules-extern-submodule.c  |  2 +-
 .../modules-full-output-tu-order.c|  4 +-
 .../modules-has-include-umbrella-header.c |  2 +-
 .../ClangScanDeps/modules-header-sharing.m|  2 +-
 .../modules-implementation-module-map.c   |  2 +-
 .../modules-implementation-private.m  |  2 +-
 .../ClangScanDeps/modules-priv-fw-from-pub.m  |  2 +-
 .../ClangScanDeps/resolve-executable-path.c   | 32 +
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  2 +
 12 files changed, 120 insertions(+), 8 deletions(-)
 create mode 100644 clang/lib/Tooling/LocateToolCompilationDatabase.cpp
 create mode 100644 clang/test/ClangScanDeps/resolve-executable-path.c

diff --git a/clang/include/clang/Tooling/CompilationDatabase.h 
b/clang/include/clang/Tooling/CompilationDatabase.h
index fee584acb48623..36fe0812ebe974 100644
--- a/clang/include/clang/Tooling/CompilationDatabase.h
+++ b/clang/include/clang/Tooling/CompilationDatabase.h
@@ -234,6 +234,12 @@ std::unique_ptr
 std::unique_ptr
 inferTargetAndDriverMode(std::unique_ptr Base);
 
+/// Returns a wrapped CompilationDatabase that will transform argv[0] to an
+/// absolute path, if it currently is a plain tool name, looking it up in
+/// PATH.
+std::unique_ptr
+inferToolLocation(std::unique_ptr Base);
+
 /// Returns a wrapped CompilationDatabase that will expand all rsp(response)
 /// files on commandline returned by underlying database.
 std::unique_ptr
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index 93a9e707a134cf..fc1f1f9f9d367e 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -25,6 +25,7 @@ add_clang_library(clangTooling
   GuessTargetAndModeCompilationDatabase.cpp
   InterpolatingCompilationDatabase.cpp
   JSONCompilationDatabase.cpp
+  LocateToolCompilationDatabase.cpp
   Refactoring.cpp
   RefactoringCallbacks.cpp
   StandaloneExecution.cpp
diff --git a/clang/lib/Tooling/LocateToolCompilationDatabase.cpp 
b/clang/lib/Tooling/LocateToolCompilationDatabase.cpp
new file mode 100644
index 00..033f69f3760c6d
--- /dev/null
+++ b/clang/lib/Tooling/LocateToolCompilationDatabase.cpp
@@ -0,0 +1,71 @@
+//===- GuessTargetAndModeCompilationDatabase.cpp 
--===//
+//
+// 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 "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include 
+
+namespace clang {
+namespace tooling {
+
+namespace {
+class LocationAdderDatabase : public CompilationDatabase {
+public:
+  LocationAdderDatabase(std::unique_ptr Base)
+  : Base(std::move(Base)) {
+assert(this->Base != nullptr);
+  }
+
+  std::vector getAllFiles() const override {
+return Base->getAllFiles();
+  }
+
+  std::vector getAllCompileCommands() const override {
+return addLocation(Base->getAllCompileCommands());
+  }
+
+  std::vector
+  getCompileCommands(StringRef FilePath) const override {
+return addLocation(Base->getCompileCommands(FilePath));
+  }
+
+private:
+  std::vector
+  addLocation(std::vector Cmds) const {
+for (auto &Cmd : Cmds) {
+  if (Cmd.CommandLine.empty())
+continue;
+  std::string &Driver = Cmd.CommandLine.front();
+  // If the driver name already is absolute, we don't need to do anything.
+  if (llvm::sys::path::is_absolute(Driver))
+continue;
+  // If the name is a relative path, like bin/clang, we assume it's
+  // possible to resolve i

[clang] [clang-scan-deps] Infer the tool locations from PATH (PR #108539)

2024-09-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Martin Storsjö (mstorsjo)


Changes

This allows the clang driver to know which tool is meant to be executed, which 
allows the clang driver to load the right clang config files, and allows clang 
to find colocated sysroots.

This makes sure that doing `clang-scan-deps --  ...` looks up 
things in the same way as if one just would execute ` ...`, when 
`` isn't an absolute or relative path.

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


12 Files Affected:

- (modified) clang/include/clang/Tooling/CompilationDatabase.h (+6) 
- (modified) clang/lib/Tooling/CMakeLists.txt (+1) 
- (added) clang/lib/Tooling/LocateToolCompilationDatabase.cpp (+71) 
- (modified) clang/test/ClangScanDeps/modules-extern-submodule.c (+1-1) 
- (modified) clang/test/ClangScanDeps/modules-full-output-tu-order.c (+2-2) 
- (modified) clang/test/ClangScanDeps/modules-has-include-umbrella-header.c 
(+1-1) 
- (modified) clang/test/ClangScanDeps/modules-header-sharing.m (+1-1) 
- (modified) clang/test/ClangScanDeps/modules-implementation-module-map.c 
(+1-1) 
- (modified) clang/test/ClangScanDeps/modules-implementation-private.m (+1-1) 
- (modified) clang/test/ClangScanDeps/modules-priv-fw-from-pub.m (+1-1) 
- (added) clang/test/ClangScanDeps/resolve-executable-path.c (+32) 
- (modified) clang/tools/clang-scan-deps/ClangScanDeps.cpp (+2) 


``diff
diff --git a/clang/include/clang/Tooling/CompilationDatabase.h 
b/clang/include/clang/Tooling/CompilationDatabase.h
index fee584acb48623..36fe0812ebe974 100644
--- a/clang/include/clang/Tooling/CompilationDatabase.h
+++ b/clang/include/clang/Tooling/CompilationDatabase.h
@@ -234,6 +234,12 @@ std::unique_ptr
 std::unique_ptr
 inferTargetAndDriverMode(std::unique_ptr Base);
 
+/// Returns a wrapped CompilationDatabase that will transform argv[0] to an
+/// absolute path, if it currently is a plain tool name, looking it up in
+/// PATH.
+std::unique_ptr
+inferToolLocation(std::unique_ptr Base);
+
 /// Returns a wrapped CompilationDatabase that will expand all rsp(response)
 /// files on commandline returned by underlying database.
 std::unique_ptr
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index 93a9e707a134cf..fc1f1f9f9d367e 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -25,6 +25,7 @@ add_clang_library(clangTooling
   GuessTargetAndModeCompilationDatabase.cpp
   InterpolatingCompilationDatabase.cpp
   JSONCompilationDatabase.cpp
+  LocateToolCompilationDatabase.cpp
   Refactoring.cpp
   RefactoringCallbacks.cpp
   StandaloneExecution.cpp
diff --git a/clang/lib/Tooling/LocateToolCompilationDatabase.cpp 
b/clang/lib/Tooling/LocateToolCompilationDatabase.cpp
new file mode 100644
index 00..033f69f3760c6d
--- /dev/null
+++ b/clang/lib/Tooling/LocateToolCompilationDatabase.cpp
@@ -0,0 +1,71 @@
+//===- GuessTargetAndModeCompilationDatabase.cpp 
--===//
+//
+// 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 "clang/Tooling/CompilationDatabase.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include 
+
+namespace clang {
+namespace tooling {
+
+namespace {
+class LocationAdderDatabase : public CompilationDatabase {
+public:
+  LocationAdderDatabase(std::unique_ptr Base)
+  : Base(std::move(Base)) {
+assert(this->Base != nullptr);
+  }
+
+  std::vector getAllFiles() const override {
+return Base->getAllFiles();
+  }
+
+  std::vector getAllCompileCommands() const override {
+return addLocation(Base->getAllCompileCommands());
+  }
+
+  std::vector
+  getCompileCommands(StringRef FilePath) const override {
+return addLocation(Base->getCompileCommands(FilePath));
+  }
+
+private:
+  std::vector
+  addLocation(std::vector Cmds) const {
+for (auto &Cmd : Cmds) {
+  if (Cmd.CommandLine.empty())
+continue;
+  std::string &Driver = Cmd.CommandLine.front();
+  // If the driver name already is absolute, we don't need to do anything.
+  if (llvm::sys::path::is_absolute(Driver))
+continue;
+  // If the name is a relative path, like bin/clang, we assume it's
+  // possible to resolve it and don't do anything about it either.
+  if (llvm::any_of(Driver,
+   [](char C) { return llvm::sys::path::is_separator(C); 
}))
+continue;
+  auto Absolute = llvm::sys::findProgramByName(Driver);
+  // If we found it in path, update the entry in Cmd.CommandLine
+  if (Absolute && llvm::sys::path::is_absolute(*Absolute))
+Driver = std::move(*Absolute);
+}
+return Cmds;
+  }
+  std::unique_ptr Bas

[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread Tobias Hieta via cfe-commits

tru wrote:

> The change to X86TargetParser.h looks ABI breaking to me.

This seems unfortunate to me. But I don't think it would be good to insert the 
enum at the end of the list and changing the sorting order.

How big of a problem would it be with a ABI break now? I know you have 
requested that we try to avoid those, even if it's strictly within the policy 
to still do that before the final release.

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


[clang] [Clang][SVE] Change LLVM representation of ACLE tuple types to be struct based. (PR #108008)

2024-09-13 Thread Paul Walker via cfe-commits

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


[clang] [llvm] [AMDGPU] Change CF intrinsics lowering to reconverge on predecessors. (PR #92809)

2024-09-13 Thread via cfe-commits

alex-t wrote:

> @alex-t Just curious about the status of this PR. Both this PR and the 
> register-allocation PR by CD will have significant impact to the generated 
> code. If we decide this is the right direction, then I feel it would be 
> better to get it in earlier, so we can access its impact in our downstream 
> work.

I am sorry but I haven't updated this PR for too long time. We recently decided 
that it worth trying to upstream.
I am going to close this one and create the new one. My apologies for the 
inconvenience. 

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

It would be messy, but could we not place the CK_ZNVER5 enum entry at the end 
of the enum list just for 19.x and then fix the sorting in trunk?

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> It would be messy, but could we not place the CK_ZNVER5 enum entry at the end 
> of the enum list just for 19.x and then fix the sorting in trunk?

Seems better than an ABI break this late in the cycle, but I don't have *super* 
strong feelings.

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


[clang] [clang][TableGen] Change SyntaxEmitter to use const RecordKeeper (PR #108478)

2024-09-13 Thread Aaron Ballman via cfe-commits

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

LGTM!

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


[clang] [clang][TableGen] Change SACheckersEmitter to use const RecordKeeper (PR #108477)

2024-09-13 Thread Aaron Ballman via cfe-commits

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

LGTM!

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


[clang] [clang][TableGen] Change TypeNodesEmitter to use const RecordKeeper (PR #108476)

2024-09-13 Thread Aaron Ballman via cfe-commits

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

LGTM!

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread Tobias Hieta via cfe-commits

tru wrote:

> It would be messy, but could we not place the CK_ZNVER5 enum entry at the end 
> of the enum list just for 19.x and then fix the sorting in trunk?

I would be fine with that. WDYT @nikic ?

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov commented:

See my comment about `VerifyOnly` and duplicate diagnostics.
The rest are small NITs.

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits


@@ -119,6 +119,14 @@ FIELD(HasInitMethod, 1, NO_MERGE)
 /// within anonymous unions or structs.
 FIELD(HasInClassInitializer, 1, NO_MERGE)
 
+/// Custom attribute that is True if any field is marked as explicit in a type

ilya-biryukov wrote:

Suggestion: could we mention the attribute name?
E.g. "marked as requiring init with [[]]"

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits


@@ -2148,6 +2158,19 @@ void 
CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
   for (conversion_iterator I = conversion_begin(), E = conversion_end();
I != E; ++I)
 I.setAccess((*I)->getAccess());
+
+  ASTContext &Context = getASTContext();
+  if (!Context.getLangOpts().CPlusPlus20 && hasUserDeclaredConstructor()) {

ilya-biryukov wrote:

We should probably complaint only if the type is aggregate in the first place, 
right?
See https://gcc.godbolt.org/z/sa94xa9or for an example code.



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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits


@@ -743,6 +743,12 @@ void InitListChecker::FillInEmptyInitForField(unsigned 
Init, FieldDecl *Field,
 ILE->updateInit(SemaRef.Context, Init, Filler);
   return;
 }
+
+if (Field->hasAttr()) {
+  SemaRef.Diag(ILE->getExprLoc(), diag::warn_field_requires_explicit_init)
+  << Field;

ilya-biryukov wrote:

Maybe we could also add the `note_entity_declared_at` pointing at field's 
location?

It will mostly be redundant, but can sometimes really come in handy if the 
field names happen to clash with base classes, e.g. 
https://gcc.godbolt.org/z/Pzx9PE3Mh

However, this also adds noise.


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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits


@@ -1472,3 +1472,49 @@ template struct Outer {
   };
 };
 Outer::Inner outerinner;
+
+void aggregate() {
+  struct S {
+[[clang::requires_explicit_initialization]] int x;
+int y;
+int z = 12;
+[[clang::requires_explicit_initialization]] int q = 100;
+static void foo(S) { }
+  };
+
+  struct D : S { // expected-warning {{not explicitly initialized}}
+int f1;
+int f2 [[clang::requires_explicit_initialization]];
+  };
+
+  struct C {
+[[clang::requires_explicit_initialization]] int w;
+C() = default;  // Test pre-C++20 aggregates
+  };
+
+  S::foo(S{1, 2, 3, 4});
+  S::foo(S{.x = 100, .q = 100});
+  S::foo(S{.x = 100}); // expected-warning {{'q' is not explicitly 
initialized}} expected-warning {{'q' is not explicitly initialized}}
+  S s{.x = 100, .q = 100};
+  (void)s;
+  S t{.q = 100}; // expected-warning {{'x' is not explicitly initialized}} 
expected-warning {{'x' is not explicitly initialized}}
+  (void)t;
+  S *ptr1 = new S; // expected-warning {{not explicitly initialized}}
+  delete ptr1;
+  S *ptr2 = new S{.x = 100, .q = 100};
+  delete ptr2;
+#if __cplusplus >= 202002L
+  D a({}, 0); // expected-warning {{'x' is not explicitly initialized}} 
expected-warning {{'f2' is not explicitly initialized}}
+  (void)a;
+#else
+  C a; // expected-warning {{not explicitly initialized}}
+  (void)a;
+#endif
+  D b{.f2 = 1}; // expected-warning {{'x' is not explicitly initialized}} 
expected-warning {{'q' is not explicitly initialized}}

ilya-biryukov wrote:

As an idea for future improvements: we could also collect all unitialized 
fields and emit a single diagnostic that lists them all (with notes to the 
locations of the fields).

However, I think this is good enough for the first version, I don't necessarily 
feel we should do it right away.

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits


@@ -743,6 +743,12 @@ void InitListChecker::FillInEmptyInitForField(unsigned 
Init, FieldDecl *Field,
 ILE->updateInit(SemaRef.Context, Init, Filler);
   return;
 }
+
+if (Field->hasAttr()) {
+  SemaRef.Diag(ILE->getExprLoc(), diag::warn_field_requires_explicit_init)

ilya-biryukov wrote:

Your other comment seems right.

`InitListChecker` should not produce any diagnostics when `VerifyOnly == true`, 
so we should only report the warning when the flag is false.

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


[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

2024-09-13 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

@AaronBallman @cor3ntin I believe we are getting close to finalizing this PR.
Would you be okay with this feature landing and myself approving this when it's 
ready?

There was some discussion here and in the RFC, but I don't think there was 
explicit approval (or objection) to land this, so I wanted to clarify this.

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


[clang] [clang][TableGen] Change MVE Emitter to use const RecordKeeper (PR #108500)

2024-09-13 Thread Rahul Joshi via cfe-commits

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


[clang] a41bb71 - [X86][test] Avoid writing to a potentially write-protected dir

2024-09-13 Thread Mikhail Goncharov via cfe-commits

Author: Mikhail Goncharov
Date: 2024-09-13T14:24:09+02:00
New Revision: a41bb71f2216cef08ab04f1d730ae1701c145f3c

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

LOG: [X86][test] Avoid writing to a potentially write-protected dir

see https://github.com/llvm/llvm-project/pull/108525 (#108525)

for a409ebc1fc136be4004073a12cd7f847a5f3a588

Added: 


Modified: 
clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-errors.c
clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-x64-error.c
clang/test/CodeGen/X86/avx10_2satcvtds-builtins-errors.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-errors.c 
b/clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-errors.c
index c2e891217fbbcf..46d47648440723 100644
--- a/clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-errors.c
+++ b/clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-errors.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-unknown-unknown -target-feature +avx10.2-512 -emit-llvm -Wall 
-Werror -verify
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-unknown-unknown -target-feature +avx10.2-512 -Wall -Werror -verify
 
 #include 
 #include 

diff  --git a/clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-x64-error.c 
b/clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-x64-error.c
index 2900256914570c..334edfb501e2f0 100755
--- a/clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-x64-error.c
+++ b/clang/test/CodeGen/X86/avx10_2_512satcvtds-builtins-x64-error.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-512 -emit-llvm -Wall 
-Werror -verify
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +avx10.2-512 -Wall -Werror 
-verify
 
 #include 
 #include 

diff  --git a/clang/test/CodeGen/X86/avx10_2satcvtds-builtins-errors.c 
b/clang/test/CodeGen/X86/avx10_2satcvtds-builtins-errors.c
index 72d2769dc21067..f32dfba60132d4 100644
--- a/clang/test/CodeGen/X86/avx10_2satcvtds-builtins-errors.c
+++ b/clang/test/CodeGen/X86/avx10_2satcvtds-builtins-errors.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-unknown-unknown -target-feature +avx10.2-256 -emit-llvm -Wall 
-Werror -verify
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=i386-unknown-unknown -target-feature +avx10.2-256 -Wall -Werror -verify
 
 unsigned long long test_mm_cvttssd(unsigned long long __A) {
   return _mm_cvttssd(__A); // expected-error {{call to undeclared function 
'_mm_cvttssd'}}



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


[clang] [clang][TableGen] Change NeonEmitter to use const RecordKeeper (PR #108501)

2024-09-13 Thread Rahul Joshi via cfe-commits

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


[clang] [clang][TableGen] Change MVE Emitter to use const RecordKeeper (PR #108500)

2024-09-13 Thread Rahul Joshi via cfe-commits

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


[clang] [clang][TableGen] Change RISCVVEmitter to use const RecordKeeper (PR #108502)

2024-09-13 Thread Rahul Joshi via cfe-commits

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


[clang] [X86][test] Avoid writing to a potentially write-protected dir (PR #108525)

2024-09-13 Thread Mikhail Goncharov via cfe-commits

metaflow wrote:

I have submitted it as a41bb71f2216cef08ab04f1d730ae1701c145f3c (with 3 files). 
Sorry for the race, but I want it working :)

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


[clang] [clang][TableGen] Change SVE Emitter to use const RecordKeeper (PR #108503)

2024-09-13 Thread Rahul Joshi via cfe-commits

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


[clang] [compiler-rt] [llvm] [X86] AMD Zen 5 Initial enablement (PR #107964)

2024-09-13 Thread via cfe-commits

ganeshgit wrote:

> It would be messy, but could we not place the CK_ZNVER5 enum entry at the end 
> of the enum list just for 19.x and then fix the sorting in trunk?

> > It would be messy, but could we not place the CK_ZNVER5 enum entry at the 
> > end of the enum list just for 19.x and then fix the sorting in trunk?
> 
> I would be fine with that. WDYT @nikic ?

I will do the change placing the enum at the end of the list after CK_Geode and 
submit for this branch instead of rebasing then.

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


[clang] [clang][TableGen] Change MVE Emitter to use const RecordKeeper (PR #108500)

2024-09-13 Thread Rahul Joshi via cfe-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/108500

>From e07fa2170e4a9699e89f54442a730d1c14702fa5 Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Thu, 12 Sep 2024 19:50:11 -0700
Subject: [PATCH] [clang][TableGen] Change MVE Emitter to use const
 RecordKeeper

---
 clang/utils/TableGen/MveEmitter.cpp | 71 +
 clang/utils/TableGen/TableGenBackends.h | 26 +
 2 files changed, 52 insertions(+), 45 deletions(-)

diff --git a/clang/utils/TableGen/MveEmitter.cpp 
b/clang/utils/TableGen/MveEmitter.cpp
index bb4f091604f5e4..6cfaa891241fa9 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -958,7 +958,7 @@ class ACLEIntrinsic {
";\n";
   }
 
-  ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param);
+  ACLEIntrinsic(EmitterBase &ME, const Record *R, const Type *Param);
 };
 
 // 
-
@@ -988,7 +988,7 @@ class EmitterBase {
   const ScalarType *getScalarType(StringRef Name) {
 return ScalarTypes[std::string(Name)].get();
   }
-  const ScalarType *getScalarType(Record *R) {
+  const ScalarType *getScalarType(const Record *R) {
 return getScalarType(R->getName());
   }
   const VectorType *getVectorType(const ScalarType *ST, unsigned Lanes) {
@@ -1028,7 +1028,7 @@ class EmitterBase {
   // the Params list in the Tablegen record for the intrinsic), which is used
   // to expand Tablegen classes like 'Vector' which mean something different in
   // each member of a parametric family.
-  const Type *getType(Record *R, const Type *Param);
+  const Type *getType(const Record *R, const Type *Param);
   const Type *getType(DagInit *D, const Type *Param);
   const Type *getType(Init *I, const Type *Param);
 
@@ -1046,7 +1046,7 @@ class EmitterBase {
 
   // Constructor and top-level functions.
 
-  EmitterBase(RecordKeeper &Records);
+  EmitterBase(const RecordKeeper &Records);
   virtual ~EmitterBase() = default;
 
   virtual void EmitHeader(raw_ostream &OS) = 0;
@@ -1065,7 +1065,7 @@ const Type *EmitterBase::getType(Init *I, const Type 
*Param) {
   PrintFatalError("Could not convert this value into a type");
 }
 
-const Type *EmitterBase::getType(Record *R, const Type *Param) {
+const Type *EmitterBase::getType(const Record *R, const Type *Param) {
   // Pass to a subfield of any wrapper records. We don't expect more than one
   // of these: immediate operands are used as plain numbers rather than as
   // llvm::Value, so it's meaningless to promote their type anyway.
@@ -1088,7 +1088,7 @@ const Type *EmitterBase::getType(DagInit *D, const Type 
*Param) {
   // The meat of the getType system: types in the Tablegen are represented by a
   // dag whose operators select sub-cases of this function.
 
-  Record *Op = cast(D->getOperator())->getDef();
+  const Record *Op = cast(D->getOperator())->getDef();
   if (!Op->isSubClassOf("ComplexTypeOp"))
 PrintFatalError(
 "Expected ComplexTypeOp as dag operator in type expression");
@@ -1154,7 +1154,7 @@ const Type *EmitterBase::getType(DagInit *D, const Type 
*Param) {
 
 Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
const Type *Param) {
-  Record *Op = cast(D->getOperator())->getDef();
+  const Record *Op = cast(D->getOperator())->getDef();
 
   if (Op->getName() == "seq") {
 Result::Scope SubScope = Scope;
@@ -1211,7 +1211,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const 
Result::Scope &Scope,
   } else if (Op->getName() == "unsignedflag") {
 if (D->getNumArgs() != 1)
   PrintFatalError("unsignedflag should have exactly one argument");
-Record *TypeRec = cast(D->getArg(0))->getDef();
+const Record *TypeRec = cast(D->getArg(0))->getDef();
 if (!TypeRec->isSubClassOf("Type"))
   PrintFatalError("unsignedflag's argument should be a type");
 if (const auto *ST = dyn_cast(getType(TypeRec, Param))) {
@@ -1223,7 +1223,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const 
Result::Scope &Scope,
   } else if (Op->getName() == "bitsize") {
 if (D->getNumArgs() != 1)
   PrintFatalError("bitsize should have exactly one argument");
-Record *TypeRec = cast(D->getArg(0))->getDef();
+const Record *TypeRec = cast(D->getArg(0))->getDef();
 if (!TypeRec->isSubClassOf("Type"))
   PrintFatalError("bitsize's argument should be a type");
 if (const auto *ST = dyn_cast(getType(TypeRec, Param))) {
@@ -1239,7 +1239,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const 
Result::Scope &Scope,
 if (Op->isSubClassOf("IRBuilderBase")) {
   std::set AddressArgs;
   std::map IntegerArgs;
-  for (Record *sp : Op->getValueAsListOfDefs("special_params")) {
+  for (const Record *sp : Op->getValueAsListOfDefs("special_params")) {
 unsigned Index = sp->getValueAsInt("index");
 if (sp->isSubClassOf("IRBu

[clang] [clang][TableGen] Change NeonEmitter to use const RecordKeeper (PR #108501)

2024-09-13 Thread Rahul Joshi via cfe-commits

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


[clang] [clang][TableGen] Change NeonEmitter to use const RecordKeeper (PR #108501)

2024-09-13 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Rahul Joshi (jurahul)


Changes

Change NeonEmitter to use const RecordKeeper.

This is a part of effort to have better const correctness in TableGen backends:

https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089

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


2 Files Affected:

- (modified) clang/utils/TableGen/NeonEmitter.cpp (+28-33) 
- (modified) clang/utils/TableGen/TableGenBackends.h (+6-6) 


``diff
diff --git a/clang/utils/TableGen/NeonEmitter.cpp 
b/clang/utils/TableGen/NeonEmitter.cpp
index 4707ce1ea3b792..9e5480be20adac 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -59,7 +59,7 @@ namespace {
 // While globals are generally bad, this one allows us to perform assertions
 // liberally and somehow still trace them back to the def they indirectly
 // came from.
-static Record *CurrentRecord = nullptr;
+static const Record *CurrentRecord = nullptr;
 static void assert_with_loc(bool Assertion, const std::string &Str) {
   if (!Assertion) {
 if (CurrentRecord)
@@ -308,7 +308,7 @@ class Variable {
 /// a particular typespec and prototype.
 class Intrinsic {
   /// The Record this intrinsic was created from.
-  Record *R;
+  const Record *R;
   /// The unmangled name.
   std::string Name;
   /// The input and output typespecs. InTS == OutTS except when
@@ -371,7 +371,7 @@ class Intrinsic {
   }
 
 public:
-  Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
+  Intrinsic(const Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
 TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter,
 StringRef ArchGuard, StringRef TargetGuard, bool IsUnavailable,
 bool BigEndianSafe)
@@ -442,7 +442,7 @@ class Intrinsic {
   }
 
   /// Get the Record that this intrinsic is based off.
-  Record *getRecord() const { return R; }
+  const Record *getRecord() const { return R; }
   /// Get the set of Intrinsics that this intrinsic calls.
   /// this is the set of immediate dependencies, NOT the
   /// transitive closure.
@@ -576,12 +576,12 @@ class Intrinsic {
 
//===--===//
 
 class NeonEmitter {
-  RecordKeeper &Records;
-  DenseMap ClassMap;
+  const RecordKeeper &Records;
+  DenseMap ClassMap;
   std::map> IntrinsicMap;
   unsigned UniqueNumber;
 
-  void createIntrinsic(Record *R, SmallVectorImpl &Out);
+  void createIntrinsic(const Record *R, SmallVectorImpl &Out);
   void genBuiltinsDef(raw_ostream &OS, SmallVectorImpl &Defs);
   void genStreamingSVECompatibleList(raw_ostream &OS,
  SmallVectorImpl &Defs);
@@ -601,15 +601,15 @@ class NeonEmitter {
   /// Called by Intrinsic - returns a globally-unique number.
   unsigned getUniqueNumber() { return UniqueNumber++; }
 
-  NeonEmitter(RecordKeeper &R) : Records(R), UniqueNumber(0) {
-Record *SI = R.getClass("SInst");
-Record *II = R.getClass("IInst");
-Record *WI = R.getClass("WInst");
-Record *SOpI = R.getClass("SOpInst");
-Record *IOpI = R.getClass("IOpInst");
-Record *WOpI = R.getClass("WOpInst");
-Record *LOpI = R.getClass("LOpInst");
-Record *NoTestOpI = R.getClass("NoTestOpInst");
+  NeonEmitter(const RecordKeeper &R) : Records(R), UniqueNumber(0) {
+const Record *SI = R.getClass("SInst");
+const Record *II = R.getClass("IInst");
+const Record *WI = R.getClass("WInst");
+const Record *SOpI = R.getClass("SOpInst");
+const Record *IOpI = R.getClass("IOpInst");
+const Record *WOpI = R.getClass("WOpInst");
+const Record *LOpI = R.getClass("LOpInst");
+const Record *NoTestOpI = R.getClass("NoTestOpInst");
 
 ClassMap[SI] = ClassS;
 ClassMap[II] = ClassI;
@@ -1979,12 +1979,12 @@ Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, 
ArrayRef Types,
   return *GoodVec.front();
 }
 
-void NeonEmitter::createIntrinsic(Record *R,
+void NeonEmitter::createIntrinsic(const Record *R,
   SmallVectorImpl &Out) {
   std::string Name = std::string(R->getValueAsString("Name"));
   std::string Proto = std::string(R->getValueAsString("Prototype"));
   std::string Types = std::string(R->getValueAsString("Types"));
-  Record *OperationRec = R->getValueAsDef("Operation");
+  const Record *OperationRec = R->getValueAsDef("Operation");
   bool BigEndianSafe  = R->getValueAsBit("BigEndianSafe");
   std::string ArchGuard = std::string(R->getValueAsString("ArchGuard"));
   std::string TargetGuard = std::string(R->getValueAsString("TargetGuard"));
@@ -2240,10 +2240,8 @@ void NeonEmitter::genIntrinsicRangeCheckCode(
 /// 2. the SemaChecking code for the type overload checking.
 /// 3. the SemaChecking code for validation of intrinsic immediate arguments.
 void NeonEmitter::runHeader(raw_ostream &OS) {
-  std

[clang] [clang][TableGen] Change RISCVVEmitter to use const RecordKeeper (PR #108502)

2024-09-13 Thread Rahul Joshi via cfe-commits

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


  1   2   3   4   5   >