[llvm-branch-commits] [llvm] WebAssembly: Stop directly using RuntimeLibcalls.def (PR #143054)

2025-06-12 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/143054

>From 7a49ea288ef1105ca28548ea1d7dced536cb8de2 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Fri, 6 Jun 2025 10:01:59 +0900
Subject: [PATCH] WebAssembly: Stop directly using RuntimeLibcalls.def

Construct RuntimeLibcallsInfo instead of manually creating a map.
This was repeating the setting of the RETURN_ADDRESS. This removes
an obstacle to generating libcall information with tablegen.

This is also not great, since it's setting a static map which
would be broken if there were ever a triple with a different libcall
configuration.
---
 .../WebAssemblyRuntimeLibcallSignatures.cpp   | 27 +--
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git 
a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
index ce795d3dedc6a..9622b5a54dc62 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
@@ -528,23 +528,20 @@ RuntimeLibcallSignatureTable 
&getRuntimeLibcallSignatures() {
 // constructor for use with a static variable
 struct StaticLibcallNameMap {
   StringMap Map;
-  StaticLibcallNameMap() {
-static const std::pair NameLibcalls[] = {
-#define HANDLE_LIBCALL(code, name) {(const char *)name, RTLIB::code},
-#include "llvm/IR/RuntimeLibcalls.def"
-#undef HANDLE_LIBCALL
-};
-for (const auto &NameLibcall : NameLibcalls) {
-  if (NameLibcall.first != nullptr &&
-  getRuntimeLibcallSignatures().Table[NameLibcall.second] !=
-  unsupported) {
-assert(!Map.contains(NameLibcall.first) &&
+  StaticLibcallNameMap(const Triple &TT) {
+// FIXME: This is broken if there are ever different triples compiled with
+// different libcalls.
+RTLIB::RuntimeLibcallsInfo RTCI(TT);
+for (int I = 0; I < RTLIB::UNKNOWN_LIBCALL; ++I) {
+  RTLIB::Libcall LC = static_cast(I);
+  const char *NameLibcall = RTCI.getLibcallName(LC);
+  if (NameLibcall != nullptr &&
+  getRuntimeLibcallSignatures().Table[LC] != unsupported) {
+assert(!Map.contains(NameLibcall) &&
"duplicate libcall names in name map");
-Map[NameLibcall.first] = NameLibcall.second;
+Map[NameLibcall] = LC;
   }
 }
-
-Map["emscripten_return_address"] = RTLIB::RETURN_ADDRESS;
   }
 };
 
@@ -940,7 +937,7 @@ void WebAssembly::getLibcallSignature(const 
WebAssemblySubtarget &Subtarget,
   StringRef Name,
   SmallVectorImpl &Rets,
   SmallVectorImpl &Params) {
-  static StaticLibcallNameMap LibcallNameMap;
+  static StaticLibcallNameMap LibcallNameMap(Subtarget.getTargetTriple());
   auto &Map = LibcallNameMap.Map;
   auto Val = Map.find(Name);
 #ifndef NDEBUG

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


[llvm-branch-commits] [llvm] WebAssembly: Stop directly using RuntimeLibcalls.def (PR #143054)

2025-06-12 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/143054

>From 7a49ea288ef1105ca28548ea1d7dced536cb8de2 Mon Sep 17 00:00:00 2001
From: Matt Arsenault 
Date: Fri, 6 Jun 2025 10:01:59 +0900
Subject: [PATCH] WebAssembly: Stop directly using RuntimeLibcalls.def

Construct RuntimeLibcallsInfo instead of manually creating a map.
This was repeating the setting of the RETURN_ADDRESS. This removes
an obstacle to generating libcall information with tablegen.

This is also not great, since it's setting a static map which
would be broken if there were ever a triple with a different libcall
configuration.
---
 .../WebAssemblyRuntimeLibcallSignatures.cpp   | 27 +--
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git 
a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
index ce795d3dedc6a..9622b5a54dc62 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
@@ -528,23 +528,20 @@ RuntimeLibcallSignatureTable 
&getRuntimeLibcallSignatures() {
 // constructor for use with a static variable
 struct StaticLibcallNameMap {
   StringMap Map;
-  StaticLibcallNameMap() {
-static const std::pair NameLibcalls[] = {
-#define HANDLE_LIBCALL(code, name) {(const char *)name, RTLIB::code},
-#include "llvm/IR/RuntimeLibcalls.def"
-#undef HANDLE_LIBCALL
-};
-for (const auto &NameLibcall : NameLibcalls) {
-  if (NameLibcall.first != nullptr &&
-  getRuntimeLibcallSignatures().Table[NameLibcall.second] !=
-  unsupported) {
-assert(!Map.contains(NameLibcall.first) &&
+  StaticLibcallNameMap(const Triple &TT) {
+// FIXME: This is broken if there are ever different triples compiled with
+// different libcalls.
+RTLIB::RuntimeLibcallsInfo RTCI(TT);
+for (int I = 0; I < RTLIB::UNKNOWN_LIBCALL; ++I) {
+  RTLIB::Libcall LC = static_cast(I);
+  const char *NameLibcall = RTCI.getLibcallName(LC);
+  if (NameLibcall != nullptr &&
+  getRuntimeLibcallSignatures().Table[LC] != unsupported) {
+assert(!Map.contains(NameLibcall) &&
"duplicate libcall names in name map");
-Map[NameLibcall.first] = NameLibcall.second;
+Map[NameLibcall] = LC;
   }
 }
-
-Map["emscripten_return_address"] = RTLIB::RETURN_ADDRESS;
   }
 };
 
@@ -940,7 +937,7 @@ void WebAssembly::getLibcallSignature(const 
WebAssemblySubtarget &Subtarget,
   StringRef Name,
   SmallVectorImpl &Rets,
   SmallVectorImpl &Params) {
-  static StaticLibcallNameMap LibcallNameMap;
+  static StaticLibcallNameMap LibcallNameMap(Subtarget.getTargetTriple());
   auto &Map = LibcallNameMap.Map;
   auto Val = Map.find(Name);
 #ifndef NDEBUG

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


[llvm-branch-commits] [llvm] [RISCV] Support memcmp expansion for vectors (PR #114517)

2025-06-12 Thread Pengcheng Wang via llvm-branch-commits

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


[llvm-branch-commits] [clang-tools-extra] Release/20.x clangd modules (PR #143647)

2025-06-12 Thread Chuanqi Xu via llvm-branch-commits

ChuanqiXu9 wrote:

Fixed a crash for clangd with modules.

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


[llvm-branch-commits] [flang] [flang][OpenMP] Add symbol table scopes for `teams` and `parallel` (PR #144015)

2025-06-12 Thread Kareem Ergawy via llvm-branch-commits

https://github.com/ergawy created 
https://github.com/llvm/llvm-project/pull/144015

Adds symbol map scopes for standalone `teams` and `parallel` constructs. This 
is required to properly bind the privatized symbols in both constructs so that 
nested constructs can find them.

Resolves https://github.com/llvm/llvm-project/issues/116428.

>From 8b3544902163e060d423777e259cbea7c176847e Mon Sep 17 00:00:00 2001
From: ergawy 
Date: Thu, 12 Jun 2025 23:46:14 -0500
Subject: [PATCH] [flang][OpenMP] Add symbol table scopes for `teams` and
 `parallel`

Adds symbol map scopes for standalone `teams` and `parallel` constructs.
This is required to properly bind the privatized symbols in both
constructs so that nested constructs can find them.

Resolves https://github.com/llvm/llvm-project/issues/116428.
---
 flang/lib/Lower/OpenMP/OpenMP.cpp |  9 ++--
 .../OpenMP/Todo/target-parallel-private.f90   | 13 
 .../OpenMP/Todo/target-teams-private.f90  | 13 
 .../Lower/OpenMP/target-parallel-private.f90  | 21 +++
 .../Lower/OpenMP/target-teams-private.f90 | 20 ++
 5 files changed, 43 insertions(+), 33 deletions(-)
 delete mode 100644 flang/test/Lower/OpenMP/Todo/target-parallel-private.f90
 delete mode 100644 flang/test/Lower/OpenMP/Todo/target-teams-private.f90
 create mode 100644 flang/test/Lower/OpenMP/target-parallel-private.f90
 create mode 100644 flang/test/Lower/OpenMP/target-teams-private.f90

diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 060eba1b906e3..3e865a1ee7185 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -2674,6 +2674,7 @@ genTeamsOp(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
mlir::Location loc, const ConstructQueue &queue,
ConstructQueue::const_iterator item) {
+  lower::SymMapScope scope(symTable);
   mlir::omp::TeamsOperands clauseOps;
   llvm::SmallVector reductionSyms;
   genTeamsClauses(converter, semaCtx, stmtCtx, item->clauses, loc, clauseOps,
@@ -2981,6 +2982,7 @@ static mlir::omp::ParallelOp genStandaloneParallel(
 lower::StatementContext &stmtCtx, semantics::SemanticsContext &semaCtx,
 lower::pft::Evaluation &eval, mlir::Location loc,
 const ConstructQueue &queue, ConstructQueue::const_iterator item) {
+  lower::SymMapScope scope(symTable);
   mlir::omp::ParallelOperands parallelClauseOps;
   llvm::SmallVector parallelReductionSyms;
   genParallelClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
@@ -4027,13 +4029,6 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
   
parser::ToUpperCaseLetters(llvm::omp::getOpenMPClauseName(clause.id));
   TODO(clauseLocation, name + " clause is not implemented yet");
 }
-
-if (std::holds_alternative(clause.u) &&
-origDirective == llvm::omp::Directive::OMPD_target_teams)
-  TODO(clauseLocation, "TARGET TEAMS PRIVATE is not implemented yet");
-if (std::holds_alternative(clause.u) &&
-origDirective == llvm::omp::Directive::OMPD_target_parallel)
-  TODO(clauseLocation, "TARGET PARALLEL PRIVATE is not implemented yet");
   }
 
   llvm::omp::Directive directive =
diff --git a/flang/test/Lower/OpenMP/Todo/target-parallel-private.f90 
b/flang/test/Lower/OpenMP/Todo/target-parallel-private.f90
deleted file mode 100644
index e820143021f9a..0
--- a/flang/test/Lower/OpenMP/Todo/target-parallel-private.f90
+++ /dev/null
@@ -1,13 +0,0 @@
-! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | 
FileCheck %s
-! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=50 -o - %s 
2>&1 | FileCheck %s
-
-!===
-! `private` clause on `target parallel`
-!===
-
-! CHECK: not yet implemented: TARGET PARALLEL PRIVATE is not implemented yet
-subroutine target_teams_private()
-integer, dimension(3) :: i
-!$omp target parallel private(i)
-!$omp end target parallel
-end subroutine
diff --git a/flang/test/Lower/OpenMP/Todo/target-teams-private.f90 
b/flang/test/Lower/OpenMP/Todo/target-teams-private.f90
deleted file mode 100644
index c8d998a5cbf94..0
--- a/flang/test/Lower/OpenMP/Todo/target-teams-private.f90
+++ /dev/null
@@ -1,13 +0,0 @@
-! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | 
FileCheck %s
-! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=50 -o - %s 
2>&1 | FileCheck %s
-
-!===
-! `private` clause on `target teams`
-!===
-
-! CHECK: not yet implemented: TARGET TEAMS PRIVATE is not implemente

[llvm-branch-commits] [flang] [flang][OpenMP] Add symbol table scopes for `teams` and `parallel` (PR #144015)

2025-06-12 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-flang-fir-hlfir

Author: Kareem Ergawy (ergawy)


Changes

Adds symbol map scopes for standalone `teams` and `parallel` constructs. This 
is required to properly bind the privatized symbols in both constructs so that 
nested constructs can find them.

Resolves https://github.com/llvm/llvm-project/issues/116428.

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


5 Files Affected:

- (modified) flang/lib/Lower/OpenMP/OpenMP.cpp (+2-7) 
- (removed) flang/test/Lower/OpenMP/Todo/target-parallel-private.f90 (-13) 
- (removed) flang/test/Lower/OpenMP/Todo/target-teams-private.f90 (-13) 
- (added) flang/test/Lower/OpenMP/target-parallel-private.f90 (+21) 
- (added) flang/test/Lower/OpenMP/target-teams-private.f90 (+20) 


``diff
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp 
b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 060eba1b906e3..3e865a1ee7185 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -2674,6 +2674,7 @@ genTeamsOp(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
mlir::Location loc, const ConstructQueue &queue,
ConstructQueue::const_iterator item) {
+  lower::SymMapScope scope(symTable);
   mlir::omp::TeamsOperands clauseOps;
   llvm::SmallVector reductionSyms;
   genTeamsClauses(converter, semaCtx, stmtCtx, item->clauses, loc, clauseOps,
@@ -2981,6 +2982,7 @@ static mlir::omp::ParallelOp genStandaloneParallel(
 lower::StatementContext &stmtCtx, semantics::SemanticsContext &semaCtx,
 lower::pft::Evaluation &eval, mlir::Location loc,
 const ConstructQueue &queue, ConstructQueue::const_iterator item) {
+  lower::SymMapScope scope(symTable);
   mlir::omp::ParallelOperands parallelClauseOps;
   llvm::SmallVector parallelReductionSyms;
   genParallelClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
@@ -4027,13 +4029,6 @@ static void genOMP(lower::AbstractConverter &converter, 
lower::SymMap &symTable,
   
parser::ToUpperCaseLetters(llvm::omp::getOpenMPClauseName(clause.id));
   TODO(clauseLocation, name + " clause is not implemented yet");
 }
-
-if (std::holds_alternative(clause.u) &&
-origDirective == llvm::omp::Directive::OMPD_target_teams)
-  TODO(clauseLocation, "TARGET TEAMS PRIVATE is not implemented yet");
-if (std::holds_alternative(clause.u) &&
-origDirective == llvm::omp::Directive::OMPD_target_parallel)
-  TODO(clauseLocation, "TARGET PARALLEL PRIVATE is not implemented yet");
   }
 
   llvm::omp::Directive directive =
diff --git a/flang/test/Lower/OpenMP/Todo/target-parallel-private.f90 
b/flang/test/Lower/OpenMP/Todo/target-parallel-private.f90
deleted file mode 100644
index e820143021f9a..0
--- a/flang/test/Lower/OpenMP/Todo/target-parallel-private.f90
+++ /dev/null
@@ -1,13 +0,0 @@
-! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | 
FileCheck %s
-! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=50 -o - %s 
2>&1 | FileCheck %s
-
-!===
-! `private` clause on `target parallel`
-!===
-
-! CHECK: not yet implemented: TARGET PARALLEL PRIVATE is not implemented yet
-subroutine target_teams_private()
-integer, dimension(3) :: i
-!$omp target parallel private(i)
-!$omp end target parallel
-end subroutine
diff --git a/flang/test/Lower/OpenMP/Todo/target-teams-private.f90 
b/flang/test/Lower/OpenMP/Todo/target-teams-private.f90
deleted file mode 100644
index c8d998a5cbf94..0
--- a/flang/test/Lower/OpenMP/Todo/target-teams-private.f90
+++ /dev/null
@@ -1,13 +0,0 @@
-! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | 
FileCheck %s
-! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=50 -o - %s 
2>&1 | FileCheck %s
-
-!===
-! `private` clause on `target teams`
-!===
-
-! CHECK: not yet implemented: TARGET TEAMS PRIVATE is not implemented yet
-subroutine target_teams_private()
-integer, dimension(3) :: i
-!$omp target teams private(i)
-!$omp end target teams
-end subroutine
diff --git a/flang/test/Lower/OpenMP/target-parallel-private.f90 
b/flang/test/Lower/OpenMP/target-parallel-private.f90
new file mode 100644
index 0..cc04b77e4a527
--- /dev/null
+++ b/flang/test/Lower/OpenMP/target-parallel-private.f90
@@ -0,0 +1,21 @@
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --enable-delayed-privatization \
+! RUN:   -o - %s 2>&1 | FileCheck %s
+! RUN: bbc -emit-hlfir -fopenmp --enable-delayed-privatization -o - %s 2>&1 |\
+! RUN:   FileCheck %s
+
+!===

[llvm-branch-commits] [clang] release/20.x: [LoongArch] Fix '-mno-lsx' option not disabling LASX feature (#143821) (PR #143882)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/143882
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [LoongArch] Fix '-mno-lsx' option not disabling LASX feature (#143821) (PR #143882)

2025-06-12 Thread via llvm-branch-commits

github-actions[bot] wrote:

@Ami-zhang (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

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


[llvm-branch-commits] [clang] release/20.x: [LoongArch] Fix '-mno-lsx' option not disabling LASX feature (#143821) (PR #143882)

2025-06-12 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/143882

>From 6146a88f60492b520a36f8f8f3231e15f3cc6082 Mon Sep 17 00:00:00 2001
From: Ami-zhang 
Date: Thu, 12 Jun 2025 20:11:14 +0800
Subject: [PATCH] [LoongArch] Fix '-mno-lsx' option not disabling LASX feature
 (#143821)

When '-march' with LASX feature and '-mno-lsx' options are used
together, '-mno-lsx' fails to disable LASX, leaving
'HasFeatureLASX=true' and causing incorrect '__loongarch_sx/asx=1' macro
definition.

Fixes https://github.com/loongson-community/discussions/issues/95

(cherry picked from commit 2ecbfc0beb42abbbd2c3d28bfd576b38c44a5b46)
---
 clang/lib/Driver/ToolChains/Arch/LoongArch.cpp | 1 +
 clang/test/Preprocessor/init-loongarch.c   | 4 
 2 files changed, 5 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp 
b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index 0575a1ebef3a6..1666253db54cb 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -253,6 +253,7 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
 Features.push_back("+lsx");
 } else /*-mno-lsx*/ {
   Features.push_back("-lsx");
+  Features.push_back("-lasx");
 }
   }
 
diff --git a/clang/test/Preprocessor/init-loongarch.c 
b/clang/test/Preprocessor/init-loongarch.c
index ac461b371162f..71a266b8a9157 100644
--- a/clang/test/Preprocessor/init-loongarch.c
+++ b/clang/test/Preprocessor/init-loongarch.c
@@ -946,6 +946,10 @@
 // RUN:   | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
 // RUN: %clang --target=loongarch64 -mno-lasx -mno-lsx -x c -E -dM %s -o - \
 // RUN:   | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
+// RUN: %clang --target=loongarch64 -march=la464 -mno-lsx -x c -E -dM %s -o - \
+// RUN:   | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
+// RUN: %clang --target=loongarch64 -mno-lsx -march=la464 -x c -E -dM %s -o - \
+// RUN:   | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
 // MNO-LSX-NOT: #define __loongarch_asx
 // MNO-LSX-NOT: #define __loongarch_simd_width
 // MNO-LSX-NOT: #define __loongarch_sx

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


[llvm-branch-commits] [clang] 6146a88 - [LoongArch] Fix '-mno-lsx' option not disabling LASX feature (#143821)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

Author: Ami-zhang
Date: 2025-06-12T21:54:32-07:00
New Revision: 6146a88f60492b520a36f8f8f3231e15f3cc6082

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

LOG: [LoongArch] Fix '-mno-lsx' option not disabling LASX feature (#143821)

When '-march' with LASX feature and '-mno-lsx' options are used
together, '-mno-lsx' fails to disable LASX, leaving
'HasFeatureLASX=true' and causing incorrect '__loongarch_sx/asx=1' macro
definition.

Fixes https://github.com/loongson-community/discussions/issues/95

(cherry picked from commit 2ecbfc0beb42abbbd2c3d28bfd576b38c44a5b46)

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
clang/test/Preprocessor/init-loongarch.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp 
b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index 0575a1ebef3a6..1666253db54cb 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -253,6 +253,7 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
 Features.push_back("+lsx");
 } else /*-mno-lsx*/ {
   Features.push_back("-lsx");
+  Features.push_back("-lasx");
 }
   }
 

diff  --git a/clang/test/Preprocessor/init-loongarch.c 
b/clang/test/Preprocessor/init-loongarch.c
index ac461b371162f..71a266b8a9157 100644
--- a/clang/test/Preprocessor/init-loongarch.c
+++ b/clang/test/Preprocessor/init-loongarch.c
@@ -946,6 +946,10 @@
 // RUN:   | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
 // RUN: %clang --target=loongarch64 -mno-lasx -mno-lsx -x c -E -dM %s -o - \
 // RUN:   | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
+// RUN: %clang --target=loongarch64 -march=la464 -mno-lsx -x c -E -dM %s -o - \
+// RUN:   | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
+// RUN: %clang --target=loongarch64 -mno-lsx -march=la464 -x c -E -dM %s -o - \
+// RUN:   | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
 // MNO-LSX-NOT: #define __loongarch_asx
 // MNO-LSX-NOT: #define __loongarch_simd_width
 // MNO-LSX-NOT: #define __loongarch_sx



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


[llvm-branch-commits] [llvm] [DLCov] Origin-Tracking: Enable collecting and symbolizing stack traces (PR #143591)

2025-06-12 Thread Stephen Tozer via llvm-branch-commits


@@ -253,6 +253,122 @@ static bool printSymbolizedStackTrace(StringRef Argv0, 
void **StackTrace,
   return true;
 }
 
+#if LLVM_ENABLE_DEBUGLOC_ORIGIN_TRACKING
+void sys::symbolizeAddresses(AddressSet &Addresses,
+ SymbolizedAddressMap &SymbolizedAddresses) {
+  assert(!DisableSymbolicationFlag && !getenv(DisableSymbolizationEnv) &&
+ "Debugify origin stacktraces require symbolization to be enabled.");
+
+  // Convert Set of Addresses to ordered list.
+  SmallVector AddressList(Addresses.begin(), Addresses.end());
+  if (AddressList.empty())
+return;
+  int NumAddresses = AddressList.size();
+  llvm::sort(AddressList);
+
+  // Use llvm-symbolizer tool to symbolize the stack traces. First look for it
+  // alongside our binary, then in $PATH.
+  ErrorOr LLVMSymbolizerPathOrErr = std::error_code();
+  if (const char *Path = getenv(LLVMSymbolizerPathEnv)) {
+LLVMSymbolizerPathOrErr = sys::findProgramByName(Path);
+  }
+  if (!LLVMSymbolizerPathOrErr)
+LLVMSymbolizerPathOrErr = sys::findProgramByName("llvm-symbolizer");
+  assert(!!LLVMSymbolizerPathOrErr &&
+ "Debugify origin stacktraces require llvm-symbolizer.");
+  const std::string &LLVMSymbolizerPath = *LLVMSymbolizerPathOrErr;
+
+  // Try to guess the main executable name, since we don't have argv0 available
+  // here.
+  std::string MainExecutableName = sys::fs::getMainExecutable(nullptr, 
nullptr);
+
+  BumpPtrAllocator Allocator;
+  StringSaver StrPool(Allocator);
+  std::vector Modules(NumAddresses, nullptr);
+  std::vector Offsets(NumAddresses, 0);
+  if (!findModulesAndOffsets(AddressList.data(), NumAddresses, Modules.data(),
+ Offsets.data(), MainExecutableName.c_str(),
+ StrPool))
+return;
+  int InputFD;
+  SmallString<32> InputFile, OutputFile;
+  sys::fs::createTemporaryFile("symbolizer-input", "", InputFD, InputFile);
+  sys::fs::createTemporaryFile("symbolizer-output", "", OutputFile);
+  FileRemover InputRemover(InputFile.c_str());
+  FileRemover OutputRemover(OutputFile.c_str());
+
+  {
+raw_fd_ostream Input(InputFD, true);
+for (int i = 0; i < NumAddresses; i++) {
+  if (Modules[i])
+Input << Modules[i] << " " << (void *)Offsets[i] << "\n";
+}
+  }
+
+  std::optional Redirects[] = {InputFile.str(), OutputFile.str(),
+  StringRef("")};
+  StringRef Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",
+#ifdef _WIN32
+  // Pass --relative-address on Windows so that we don't
+  // have to add ImageBase from PE file.
+  // FIXME: Make this the default for llvm-symbolizer.
+  "--relative-address",
+#endif

SLTozer wrote:

We don't need it for now, but since this is copied from the existing invocation 
of the symbolizer (and I'm currently looking at extracting this and a few other 
parts out), it's more effort to remove support for Windows than to keep it; I 
do intend to add Windows support later on, it's just trickier than using 
`backtrace()` and not an urgent feature.

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


[llvm-branch-commits] [clang] [clan-reply] Backport PTU error recovery to 20.x (PR #143893)

2025-06-12 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: David Spickett (DavidSpickett)


Changes

This cherry-picks 3b4c51bb3243a02526313c51207a674139b67a00 and 
beffd1509af7b12eeab0d5ae85b2f8322e039287 to 20.x.

Which are:
[clang-repl] Fix error recovery while PTU cleanup (#127467) 
[clang][Interpreter] Disable part of lambda test on Windows

The latter commit avoids a test failure seen in Windows builds. On main, I 
turned off one of the RUN lines for Windows, but reviewers on the cherry-pick 
preferred UNSUPPORTED to disable the whole test.

So I have used UNSUPPORTED in this version for 20.x.

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


2 Files Affected:

- (modified) clang/lib/Interpreter/IncrementalParser.cpp (+1-1) 
- (modified) clang/test/Interpreter/lambda.cpp (+16-2) 


``diff
diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index e43cea1baf43a..1d223e230669c 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -175,7 +175,7 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
   // FIXME: We should de-allocate MostRecentTU
   for (Decl *D : MostRecentTU->decls()) {
 auto *ND = dyn_cast(D);
-if (!ND)
+if (!ND || ND->getDeclName().isEmpty())
   continue;
 // Check if we need to clean up the IdResolver chain.
 if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
diff --git a/clang/test/Interpreter/lambda.cpp 
b/clang/test/Interpreter/lambda.cpp
index df75274a050b2..fee6c73bf95cb 100644
--- a/clang/test/Interpreter/lambda.cpp
+++ b/clang/test/Interpreter/lambda.cpp
@@ -1,7 +1,11 @@
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// At -O2, somehow "x = 42" appears first when piped into FileCheck,
+// see https://github.com/llvm/llvm-project/issues/143547.
+// UNSUPPORTED: system-windows
 // RUN: cat %s | clang-repl | FileCheck %s
-// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc -verify -Xcc -O2 | FileCheck %s
+
 extern "C" int printf(const char *, ...);
 
 auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +18,14 @@ auto r2 = l2();
 auto r3 = l2();
 // CHECK: TWO
 
-%quit
+// Verify non-local lambda capture error is correctly reported
+int x = 42;
+
+// expected-error {{non-local lambda expression cannot have a capture-default}}
+auto capture = [&]() { return x * 2; };
+
+// Ensure interpreter continues and x is still valid
+printf("x = %d\n", x);
+// CHECK: x = 42
+
+%quit
\ No newline at end of file

``




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


[llvm-branch-commits] [clang] release/20.x: [clang][Interpreter] Disable part of lambda test on Windows (PR #143851)

2025-06-12 Thread David Spickett via llvm-branch-commits


@@ -1,7 +1,10 @@
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
 // RUN: cat %s | clang-repl | FileCheck %s
-// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+// At -O2, somehow "x = 42" appears first when piped into FileCheck,
+// see https://github.com/llvm/llvm-project/issues/143547.
+// RUN: %if !system-windows %{ cat %s | clang-repl -Xcc -Xclang -Xcc -verify 
-Xcc -O2 | FileCheck %s %}

DavidSpickett wrote:

Sure, had to make my own branch to do that: 
https://github.com/llvm/llvm-project/pull/143893

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


[llvm-branch-commits] [clang] release/20.x: [clang][Interpreter] Disable part of lambda test on Windows (PR #143851)

2025-06-12 Thread David Spickett via llvm-branch-commits

DavidSpickett wrote:

Closing this in favour of https://github.com/llvm/llvm-project/pull/143893, 
where I am able to address the reviewer feedback.

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


[llvm-branch-commits] [clang] release/20.x: [clang][Interpreter] Disable part of lambda test on Windows (PR #143851)

2025-06-12 Thread David Spickett via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [DLCov] Origin-Tracking: Enable collecting and symbolizing stack traces (PR #143591)

2025-06-12 Thread Stephen Tozer via llvm-branch-commits

SLTozer wrote:

> A bigger question though is whether this can be tested.

That's a good question - in theory yes, but it sounds brittle. Assuming we're 
testing the output of backtrace/symbolize, we'd have a test that could fail if 
any of a variety of function names changed. Another argument against testing is 
that this code exists to generate formatted, human readable output - most of 
the complicated parts are in `llvm-symbolizer` and `libbacktrace`, while these 
functions are essentially just invoking them and formatting the output.

All the same, testing is generally good; I'll consider how would be best to 
test this, but I will also happily take suggestions if you/others have any.

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


[llvm-branch-commits] [clang] [clan-reply] Backport PTU error recovery to 20.x (PR #143893)

2025-06-12 Thread David Spickett via llvm-branch-commits

https://github.com/DavidSpickett edited 
https://github.com/llvm/llvm-project/pull/143893
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clan-reply] Backport PTU error recovery to 20.x (PR #143893)

2025-06-12 Thread David Spickett via llvm-branch-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/143893

This cherry-picks 3b4c51bb3243a02526313c51207a674139b67a00 and 
beffd1509af7b12eeab0d5ae85b2f8322e039287 to 20.x.

Which are:
[clang-repl] Fix error recovery while PTU cleanup (#127467) 
[clang][Interpreter] Disable part of lambda test on Windows

The latter commit avoids a test failure seen in Windows builds. On main, I 
turned off one of the RUN lines for Windows, but reviewers on the cherry-pick 
preferred UNSUPPORTED to disable the whole test.

So I have used UNSUPPORTED in this version for 20.x.

>From c8f6fda8e223e39fafb5670c466bfc95f753d714 Mon Sep 17 00:00:00 2001
From: Anutosh Bhat 
Date: Mon, 2 Jun 2025 20:14:28 +0530
Subject: [PATCH] [clan-reply] Backport PTU error recovery to 20.x

This cherry-picks 3b4c51bb3243a02526313c51207a674139b67a00 and
beffd1509af7b12eeab0d5ae85b2f8322e039287 to 20.x.

Which are:
[clang-repl] Fix error recovery while PTU cleanup (#127467)
[clang][Interpreter] Disable part of lambda test on Windows

The latter commit avoids a test failure seen in Windows builds.
On main, I turned off one of the RUN lines for Windows, but reviewers
on the cherry-pick preferred UNSUPPORTED to disable the whole test.

So I have used UNSUPPORTED in this version for 20.x.
---
 clang/lib/Interpreter/IncrementalParser.cpp |  2 +-
 clang/test/Interpreter/lambda.cpp   | 18 --
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index e43cea1baf43a..1d223e230669c 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -175,7 +175,7 @@ void IncrementalParser::CleanUpPTU(TranslationUnitDecl 
*MostRecentTU) {
   // FIXME: We should de-allocate MostRecentTU
   for (Decl *D : MostRecentTU->decls()) {
 auto *ND = dyn_cast(D);
-if (!ND)
+if (!ND || ND->getDeclName().isEmpty())
   continue;
 // Check if we need to clean up the IdResolver chain.
 if (ND->getDeclName().getFETokenInfo() && !D->getLangOpts().ObjC &&
diff --git a/clang/test/Interpreter/lambda.cpp 
b/clang/test/Interpreter/lambda.cpp
index df75274a050b2..fee6c73bf95cb 100644
--- a/clang/test/Interpreter/lambda.cpp
+++ b/clang/test/Interpreter/lambda.cpp
@@ -1,7 +1,11 @@
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// At -O2, somehow "x = 42" appears first when piped into FileCheck,
+// see https://github.com/llvm/llvm-project/issues/143547.
+// UNSUPPORTED: system-windows
 // RUN: cat %s | clang-repl | FileCheck %s
-// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
+// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc -verify -Xcc -O2 | FileCheck %s
+
 extern "C" int printf(const char *, ...);
 
 auto l1 = []() { printf("ONE\n"); return 42; };
@@ -14,4 +18,14 @@ auto r2 = l2();
 auto r3 = l2();
 // CHECK: TWO
 
-%quit
+// Verify non-local lambda capture error is correctly reported
+int x = 42;
+
+// expected-error {{non-local lambda expression cannot have a capture-default}}
+auto capture = [&]() { return x * 2; };
+
+// Ensure interpreter continues and x is still valid
+printf("x = %d\n", x);
+// CHECK: x = 42
+
+%quit
\ No newline at end of file

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


[llvm-branch-commits] [clang] [clan-reply] Backport PTU error recovery to 20.x (PR #143893)

2025-06-12 Thread David Spickett via llvm-branch-commits

https://github.com/DavidSpickett milestoned 
https://github.com/llvm/llvm-project/pull/143893
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clan-reply] Backport PTU error recovery to 20.x (PR #143893)

2025-06-12 Thread Anutosh Bhat via llvm-branch-commits

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


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


[llvm-branch-commits] [llvm] [RISCV] Support memcmp expansion for vectors (PR #114517)

2025-06-12 Thread Pengcheng Wang via llvm-branch-commits


@@ -2952,5 +2952,22 @@ RISCVTTIImpl::enableMemCmpExpansion(bool OptSize, bool 
IsZeroCmp) const {
 Options.LoadSizes = {4, 2, 1};
 Options.AllowedTailExpansions = {3};
   }
+
+  if (IsZeroCmp && ST->hasVInstructions() && ST->enableUnalignedVectorMem()) {

wangpc-pp wrote:

Yeah, we don't need this check at all. I just forgot to remove this part. :D

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


[llvm-branch-commits] [llvm] [RISCV] Support non-power-of-2 types when expanding memcmp (PR #114971)

2025-06-12 Thread Pengcheng Wang via llvm-branch-commits

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

>From 3fd27bd1405a8b2c068786a200d610b9cacb65ef Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Tue, 5 Nov 2024 20:38:44 +0800
Subject: [PATCH] Set max bytes

Created using spr 1.3.6-beta.1
---
 llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp 
b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index c65feb9755633..a1c5f76bae009 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -2508,7 +2508,10 @@ RISCVTTIImpl::enableMemCmpExpansion(bool OptSize, bool 
IsZeroCmp) const {
 Options.LoadSizes = {4, 2, 1};
   if (IsZeroCmp && ST->hasVInstructions()) {
 unsigned VLenB = ST->getRealMinVLen() / 8;
-for (unsigned Size = ST->getXLen() / 8 + 1;
+// The minimum size should be the maximum bytes between `VLen * LMUL_MF8`
+// and `XLen + 8`.
+unsigned MinSize = std::max(VLenB / 8, ST->getXLen() / 8 + 1);
+for (unsigned Size = MinSize;
  Size <= VLenB * ST->getMaxLMULForFixedLengthVectors(); Size++)
   Options.LoadSizes.insert(Options.LoadSizes.begin(), Size);
   }

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


[llvm-branch-commits] [llvm] [RISCV] Support non-power-of-2 types when expanding memcmp (PR #114971)

2025-06-12 Thread Pengcheng Wang via llvm-branch-commits


@@ -16190,13 +16186,20 @@ combineVectorSizedSetCCEquality(EVT VT, SDValue X, 
SDValue Y, ISD::CondCode CC,
 return SDValue();
 
   unsigned VecSize = OpSize / 8;
-  EVT VecVT = MVT::getVectorVT(MVT::i8, VecSize);
-  EVT CmpVT = MVT::getVectorVT(MVT::i1, VecSize);
+  EVT VecVT = EVT::getVectorVT(*DAG.getContext(), MVT::i8, VecSize);
+  EVT CmpVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1, VecSize);
 
   SDValue VecX = DAG.getBitcast(VecVT, X);
   SDValue VecY = DAG.getBitcast(VecVT, Y);
-  SDValue Cmp = DAG.getSetCC(DL, CmpVT, VecX, VecY, ISD::SETNE);
-  return DAG.getSetCC(DL, VT, DAG.getNode(ISD::VECREDUCE_OR, DL, XLenVT, Cmp),
+  SDValue Mask = DAG.getAllOnesConstant(DL, CmpVT);
+  SDValue VL = DAG.getConstant(VecSize, DL, XLenVT);
+
+  SDValue Cmp = DAG.getNode(ISD::VP_SETCC, DL, CmpVT, VecX, VecY,
+DAG.getCondCode(ISD::SETNE), Mask, VL);
+  return DAG.getSetCC(DL, VT,
+  DAG.getNode(ISD::VP_REDUCE_OR, DL, XLenVT,
+  DAG.getConstant(0, DL, XLenVT), Cmp, Mask,
+  VL),

wangpc-pp wrote:

I think so, because this PR was done several months later after that commit. 

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


[llvm-branch-commits] [llvm] ARM: Avoid repeating hardcoded windows division libcall names (PR #143834)

2025-06-12 Thread Matt Arsenault via llvm-branch-commits

arsenm wrote:

### Merge activity

* **Jun 12, 12:07 PM UTC**: A user started a stack merge that includes this 
pull request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/143834).


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


[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Handle ISD::PTRADD in VOP3 patterns (PR #143881)

2025-06-12 Thread Fabian Ritter via llvm-branch-commits

ritter-x2a wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/143881?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#143881** https://app.graphite.dev/github/pr/llvm/llvm-project/143881?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/143881?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#143880** https://app.graphite.dev/github/pr/llvm/llvm-project/143880?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143673** https://app.graphite.dev/github/pr/llvm/llvm-project/143673?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143672** https://app.graphite.dev/github/pr/llvm/llvm-project/143672?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#142778** https://app.graphite.dev/github/pr/llvm/llvm-project/142778?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#142777** https://app.graphite.dev/github/pr/llvm/llvm-project/142777?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#142739** https://app.graphite.dev/github/pr/llvm/llvm-project/142739?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#142738** https://app.graphite.dev/github/pr/llvm/llvm-project/142738?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#141725** https://app.graphite.dev/github/pr/llvm/llvm-project/141725?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


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


[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Test ISD::PTRADD handling in VOP3 patterns (PR #143880)

2025-06-12 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a created 
https://github.com/llvm/llvm-project/pull/143880

Pre-committing tests to show improvements in a follow-up PR.

>From d4f77f6692b2bf892dc33023219cd1bc402db546 Mon Sep 17 00:00:00 2001
From: Fabian Ritter 
Date: Thu, 12 Jun 2025 06:13:26 -0400
Subject: [PATCH] [AMDGPU][SDAG] Test ISD::PTRADD handling in VOP3 patterns

Pre-committing tests to show improvements in a follow-up PR.
---
 .../AMDGPU/ptradd-sdag-optimizations.ll   | 45 +++
 1 file changed, 45 insertions(+)

diff --git a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll 
b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
index c00bccdbce6b7..d48bfe0bb7f21 100644
--- a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
+++ b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
@@ -263,3 +263,48 @@ define amdgpu_kernel void @fold_mad64(ptr addrspace(1) %p) 
{
   store float 1.0, ptr addrspace(1) %p1
   ret void
 }
+
+; Use non-zero shift amounts in v_lshl_add_u64.
+define ptr @select_v_lshl_add_u64(ptr %base, i64 %voffset) {
+; GFX942_PTRADD-LABEL: select_v_lshl_add_u64:
+; GFX942_PTRADD:   ; %bb.0:
+; GFX942_PTRADD-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX942_PTRADD-NEXT:v_lshlrev_b64 v[2:3], 3, v[2:3]
+; GFX942_PTRADD-NEXT:v_lshl_add_u64 v[0:1], v[0:1], 0, v[2:3]
+; GFX942_PTRADD-NEXT:s_setpc_b64 s[30:31]
+;
+; GFX942_LEGACY-LABEL: select_v_lshl_add_u64:
+; GFX942_LEGACY:   ; %bb.0:
+; GFX942_LEGACY-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX942_LEGACY-NEXT:v_lshl_add_u64 v[0:1], v[2:3], 3, v[0:1]
+; GFX942_LEGACY-NEXT:s_setpc_b64 s[30:31]
+  %gep = getelementptr inbounds i64, ptr %base, i64 %voffset
+  ret ptr %gep
+}
+
+; Fold mul and add into v_mad, even if amdgpu-codegenprepare-mul24 turned the
+; mul into a mul24.
+define ptr @fold_mul24_into_mad(ptr %base, i64 %a, i64 %b) {
+; GFX942_PTRADD-LABEL: fold_mul24_into_mad:
+; GFX942_PTRADD:   ; %bb.0:
+; GFX942_PTRADD-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX942_PTRADD-NEXT:v_and_b32_e32 v2, 0xf, v2
+; GFX942_PTRADD-NEXT:v_and_b32_e32 v4, 0xf, v4
+; GFX942_PTRADD-NEXT:v_mul_hi_u32_u24_e32 v3, v2, v4
+; GFX942_PTRADD-NEXT:v_mul_u32_u24_e32 v2, v2, v4
+; GFX942_PTRADD-NEXT:v_lshl_add_u64 v[0:1], v[0:1], 0, v[2:3]
+; GFX942_PTRADD-NEXT:s_setpc_b64 s[30:31]
+;
+; GFX942_LEGACY-LABEL: fold_mul24_into_mad:
+; GFX942_LEGACY:   ; %bb.0:
+; GFX942_LEGACY-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; GFX942_LEGACY-NEXT:v_and_b32_e32 v2, 0xf, v2
+; GFX942_LEGACY-NEXT:v_and_b32_e32 v3, 0xf, v4
+; GFX942_LEGACY-NEXT:v_mad_u64_u32 v[0:1], s[0:1], v2, v3, v[0:1]
+; GFX942_LEGACY-NEXT:s_setpc_b64 s[30:31]
+  %a_masked = and i64 %a, u0xf
+  %b_masked = and i64 %b, u0xf
+  %mul = mul i64 %a_masked, %b_masked
+  %gep = getelementptr inbounds i8, ptr %base, i64 %mul
+  ret ptr %gep
+}

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


[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Test ISD::PTRADD handling in VOP3 patterns (PR #143880)

2025-06-12 Thread Fabian Ritter via llvm-branch-commits

ritter-x2a wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/143880?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#143881** https://app.graphite.dev/github/pr/llvm/llvm-project/143881?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143880** https://app.graphite.dev/github/pr/llvm/llvm-project/143880?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/143880?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#143673** https://app.graphite.dev/github/pr/llvm/llvm-project/143673?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143672** https://app.graphite.dev/github/pr/llvm/llvm-project/143672?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#142778** https://app.graphite.dev/github/pr/llvm/llvm-project/142778?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#142777** https://app.graphite.dev/github/pr/llvm/llvm-project/142777?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#142739** https://app.graphite.dev/github/pr/llvm/llvm-project/142739?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#142738** https://app.graphite.dev/github/pr/llvm/llvm-project/142738?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#141725** https://app.graphite.dev/github/pr/llvm/llvm-project/141725?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


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


[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Handle ISD::PTRADD in VOP3 patterns (PR #143881)

2025-06-12 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Fabian Ritter (ritter-x2a)


Changes

This patch mirrors similar patterns for ISD::ADD. The main difference is
that ISD::ADD is commutative, so that a pattern definition for, e.g.,
(add (mul x, y), z), automatically also handles (add z, (mul x, y)).
ISD::PTRADD is not commutative, so we would need to handle these cases
explicitly. This patch only implements (ptradd z, (op x, y)) patterns,
where the nested operation (shift or multiply) is the offset of the
ptradd (i.e., the right operand), since base pointers that are the
result of a shift or multiply seem less likely.

For SWDEV-516125.

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


3 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/VOP3Instructions.td (+26-10) 
- (modified) llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll (+12-29) 
- (modified) llvm/test/CodeGen/AMDGPU/ptradd-sdag.ll (+14-28) 


``diff
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td 
b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index 594b37bb6e21a..c3088d6bb1dca 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -484,12 +484,13 @@ let OtherPredicates = [isGFX10Plus, Has16BitInsts], 
True16Predicate = NotHasTrue
   defm: Ternary_i16_Pats_gfx9;
 } // End OtherPredicates = [isGFX10Plus, Has16BitInsts], True16Predicate = 
NotHasTrue16BitInsts
 
-class ThreeOpFragSDAG : PatFrag<
+class ThreeOpFragSDAG : PatFrag<
   (ops node:$x, node:$y, node:$z),
   // When the inner operation is used multiple times, selecting 3-op
   // instructions may still be beneficial -- if the other users can be
   // combined similarly. Let's be conservative for now.
-  (op2 (HasOneUseBinOp node:$x, node:$y), node:$z),
+  !if(op1IsRight, (op2 node:$z, (HasOneUseBinOp node:$x, node:$y)),
+  (op2 (HasOneUseBinOp node:$x, node:$y), node:$z)),
   [{
 // Only use VALU ops when the result is divergent.
 if (!N->isDivergent())
@@ -516,7 +517,10 @@ class ThreeOpFragSDAG : PatFrag<
   let PredicateCodeUsesOperands = 1;
 }
 
-class ThreeOpFrag : 
ThreeOpFragSDAG {
+// Matches (op2 (op1 x, y), z) if op1IsRight = 0 and
+// matches (op2 z, (op1, x, y)) if op1IsRight = 1.
+class ThreeOpFrag : ThreeOpFragSDAG {
   // The divergence predicate is irrelevant in GlobalISel, as we have
   // proper register bank checks. We just need to verify the constant
   // bus restriction when all the sources are considered.
@@ -748,12 +752,19 @@ def : GCNPat<
  (DivergentBinFrag i32:$src0, IsPow2Plus1:$src1),
  (V_LSHL_ADD_U32_e64 i32:$src0, (i32 (Log2_32 imm:$src1)), i32:$src0)>;
 
-let SubtargetPredicate = isGFX940Plus in
+let SubtargetPredicate = isGFX940Plus in {
 def : GCNPat<
   (ThreeOpFrag i64:$src0, i32:$src1, i64:$src2),
   (V_LSHL_ADD_U64_e64 VSrc_b64:$src0, VSrc_b32:$src1, VSrc_b64:$src2)
 >;
 
+def : GCNPat <
+  // (ptradd z, (shl x, y)) -> ((x << y) + z)
+  (ThreeOpFrag i64:$src0, i32:$src1, 
i64:$src2),
+  (V_LSHL_ADD_U64_e64 VSrc_b64:$src0, VSrc_b32:$src1, VSrc_b64:$src2)
+>;
+} // End SubtargetPredicate = isGFX940Plus
+
 def : VOPBinOpClampPat;
 def : VOPBinOpClampPat;
 
@@ -822,19 +833,24 @@ multiclass IMAD32_Pats  {
 
 // Handle cases where amdgpu-codegenprepare-mul24 made a mul24 instead of a 
normal mul.
 // We need to separate this because otherwise OtherPredicates would be 
overriden.
-class IMAD32_Mul24_Pat: GCNPat <
-(i64 (add (i64 (AMDGPUmul_u24 i32:$src0, i32:$src1)), i64:$src2)),
-(inst $src0, $src1, $src2, 0 /* clamp */)
->;
+class IMAD32_Mul24_Pats_Impl : GCNPat <
+!if(mulIsRight, (i64 (AddOp i64:$src2, (i64 (AMDGPUmul_u24 i32:$src0, 
i32:$src1,
+(i64 (AddOp (i64 (AMDGPUmul_u24 i32:$src0, i32:$src1)), 
i64:$src2))),
+(inst $src0, $src1, $src2, 0 /* clamp */)>;
+
+multiclass IMAD32_Mul24_Pats {
+  def : IMAD32_Mul24_Pats_Impl;
+  def : IMAD32_Mul24_Pats_Impl;
+}
 
 // exclude pre-GFX9 where it was slow
 let OtherPredicates = [HasNotMADIntraFwdBug], SubtargetPredicate = isGFX9Plus 
in {
   defm : IMAD32_Pats;
-  def : IMAD32_Mul24_Pat;
+  defm : IMAD32_Mul24_Pats;
 }
 let OtherPredicates = [HasMADIntraFwdBug], SubtargetPredicate = isGFX11Only in 
{
   defm : IMAD32_Pats;
-  def : IMAD32_Mul24_Pat;
+  defm : IMAD32_Mul24_Pats;
 }
 
 def VOP3_PERMLANE_Profile : VOP3_Profile, 
VOP3_OPSEL> {
diff --git a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll 
b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
index d48bfe0bb7f21..34bb98550de04 100644
--- a/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
+++ b/llvm/test/CodeGen/AMDGPU/ptradd-sdag-optimizations.ll
@@ -266,18 +266,11 @@ define amdgpu_kernel void @fold_mad64(ptr addrspace(1) 
%p) {
 
 ; Use non-zero shift amounts in v_lshl_add_u64.
 define ptr @select_v_lshl_add_u64(ptr %base, i64 %voffset) {
-; GFX942_PTRADD-LABEL: select_v_lshl_add_u64:
-; GFX942_PTRADD:   ; %bb.0:
-; GFX942_PTRADD-NEXT:s_waitcnt vmcnt(0) e

[llvm-branch-commits] [llvm] [AMDGPU][SDAG] Test ISD::PTRADD handling in VOP3 patterns (PR #143880)

2025-06-12 Thread Fabian Ritter via llvm-branch-commits

https://github.com/ritter-x2a ready_for_review 
https://github.com/llvm/llvm-project/pull/143880
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [RISCV] Fix assertion failure when using -fstack-clash-protection (#135248) (PR #139388)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

@topperc You should be able to push to this branch.

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature (PR #143422)

2025-06-12 Thread via llvm-branch-commits

https://github.com/joaosaffran edited 
https://github.com/llvm/llvm-project/pull/143422
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature (PR #143422)

2025-06-12 Thread via llvm-branch-commits

https://github.com/joaosaffran edited 
https://github.com/llvm/llvm-project/pull/143422
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [MLGO][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits


@@ -20,33 +21,102 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Transforms/Utils/Cloning.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 
 using namespace llvm;
+using namespace testing;
 
 namespace llvm {
 LLVM_ABI extern cl::opt EnableDetailedFunctionProperties;
 LLVM_ABI extern cl::opt BigBasicBlockInstructionThreshold;
 LLVM_ABI extern cl::opt MediumBasicBlockInstrutionThreshold;
+LLVM_ABI extern cl::opt ir2vec::OpcWeight;
+LLVM_ABI extern cl::opt ir2vec::TypeWeight;
+LLVM_ABI extern cl::opt ir2vec::ArgWeight;
 } // namespace llvm
 
 namespace {
 
 class FunctionPropertiesAnalysisTest : public testing::Test {
 public:
   FunctionPropertiesAnalysisTest() {
+createTestVocabulary(1);
+MAM.registerPass([&] { return IR2VecVocabAnalysis(Vocabulary); });
+MAM.registerPass([&] { return PassInstrumentationAnalysis(); });
+FAM.registerPass([&] { return ModuleAnalysisManagerFunctionProxy(MAM); });
 FAM.registerPass([&] { return DominatorTreeAnalysis(); });
 FAM.registerPass([&] { return LoopAnalysis(); });
 FAM.registerPass([&] { return PassInstrumentationAnalysis(); });
+
+ir2vec::OpcWeight = 1.0;
+ir2vec::TypeWeight = 1.0;
+ir2vec::ArgWeight = 1.0;
+  }
+
+private:
+  float OriginalOpcWeight = ir2vec::OpcWeight;
+  float OriginalTypeWeight = ir2vec::TypeWeight;
+  float OriginalArgWeight = ir2vec::ArgWeight;
+
+  void createTestVocabulary(unsigned Dim) {
+Vocabulary["add"] = ir2vec::Embedding(Dim, 0.1);

svkeerthy wrote:

Simplified it using lambda. Please let me know if this is better. (Just thought 
this would reduce the number of lines)

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


[llvm-branch-commits] [llvm] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-12 Thread Thurston Dang via llvm-branch-commits


@@ -4187,6 +4187,29 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
 setShadow(&I, IRB.CreateBitCast(CI, getShadowTy(&I)));
 setOriginForNaryOp(I);
   }
+  // Instrument AVX permutation intrinsic.
+  // We apply the same permutation (argument index 1) to the shadows.
+  void handleAVXVpermil2var(IntrinsicInst &I) {
+assert(I.arg_size() == 3);
+assert(I.getArgOperand(0)->getType() == I.getArgOperand(2)->getType());
+assert(I.getType() == I.getArgOperand(0)->getType());

thurstond wrote:

Please also check that I.getType() is a vector type, and that 
`I.getArgOperand(0)` has the same number of elements as `I.getArgOperand(1)`

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


[llvm-branch-commits] [llvm] [MLGO][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143479

>From b7ec65230c731c77dea1f4a484df6731819729b5 Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Tue, 10 Jun 2025 05:40:38 +
Subject: [PATCH] [MLIniner][IR2Vec] Integrating IR2Vec with MLInliner

---
 .../Analysis/FunctionPropertiesAnalysis.h |  26 +++-
 llvm/include/llvm/Analysis/InlineAdvisor.h|   4 +
 .../llvm/Analysis/InlineModelFeatureMaps.h|   8 +-
 llvm/include/llvm/Analysis/MLInlineAdvisor.h  |   1 +
 .../Analysis/FunctionPropertiesAnalysis.cpp   | 115 +-
 llvm/lib/Analysis/InlineAdvisor.cpp   |  29 
 llvm/lib/Analysis/MLInlineAdvisor.cpp |  34 +++-
 .../FunctionPropertiesAnalysisTest.cpp| 145 --
 8 files changed, 338 insertions(+), 24 deletions(-)

diff --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h 
b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index babb6d9d6cf0c..06dbfc35a5294 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -15,6 +15,7 @@
 #define LLVM_ANALYSIS_FUNCTIONPROPERTIESANALYSIS_H
 
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Analysis/IR2Vec.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Compiler.h"
@@ -32,17 +33,19 @@ class FunctionPropertiesInfo {
   void updateAggregateStats(const Function &F, const LoopInfo &LI);
   void reIncludeBB(const BasicBlock &BB);
 
+  ir2vec::Embedding FunctionEmbedding = ir2vec::Embedding(0.0);
+  std::optional IR2VecVocab;
+
 public:
   LLVM_ABI static FunctionPropertiesInfo
   getFunctionPropertiesInfo(const Function &F, const DominatorTree &DT,
-const LoopInfo &LI);
+const LoopInfo &LI,
+const IR2VecVocabResult *VocabResult);
 
   LLVM_ABI static FunctionPropertiesInfo
   getFunctionPropertiesInfo(Function &F, FunctionAnalysisManager &FAM);
 
-  bool operator==(const FunctionPropertiesInfo &FPI) const {
-return std::memcmp(this, &FPI, sizeof(FunctionPropertiesInfo)) == 0;
-  }
+  bool operator==(const FunctionPropertiesInfo &FPI) const;
 
   bool operator!=(const FunctionPropertiesInfo &FPI) const {
 return !(*this == FPI);
@@ -137,6 +140,19 @@ class FunctionPropertiesInfo {
   int64_t CallReturnsVectorPointerCount = 0;
   int64_t CallWithManyArgumentsCount = 0;
   int64_t CallWithPointerArgumentCount = 0;
+
+  const ir2vec::Embedding &getFunctionEmbedding() const {
+return FunctionEmbedding;
+  }
+
+  const std::optional &getIR2VecVocab() const {
+return IR2VecVocab;
+  }
+
+  // Helper intended to be useful for unittests
+  void setFunctionEmbeddingForTest(const ir2vec::Embedding &Embedding) {
+FunctionEmbedding = Embedding;
+  }
 };
 
 // Analysis pass
@@ -192,7 +208,7 @@ class FunctionPropertiesUpdater {
 
   DominatorTree &getUpdatedDominatorTree(FunctionAnalysisManager &FAM) const;
 
-  DenseSet Successors;
+  DenseSet Successors, CallUsers;
 
   // Edges we might potentially need to remove from the dominator tree.
   SmallVector DomTreeUpdates;
diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h 
b/llvm/include/llvm/Analysis/InlineAdvisor.h
index 9d15136e81d10..50ba3c13da70f 100644
--- a/llvm/include/llvm/Analysis/InlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -331,6 +331,10 @@ class InlineAdvisorAnalysis : public 
AnalysisInfoMixin {
   };
 
   Result run(Module &M, ModuleAnalysisManager &MAM) { return Result(M, MAM); }
+
+private:
+  static bool initializeIR2VecVocabIfRequested(Module &M,
+   ModuleAnalysisManager &MAM);
 };
 
 /// Printer pass for the InlineAdvisorAnalysis results.
diff --git a/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h 
b/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
index 961d5091bf9f3..a166621243cad 100644
--- a/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
+++ b/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
@@ -142,6 +142,12 @@ enum class FeatureIndex : size_t {
   INLINE_FEATURE_ITERATOR(POPULATE_INDICES)
 #undef POPULATE_INDICES
 
+// IR2Vec embeddings
+// Dimensions of embeddings are not known in the compile time (until vocab is 
+// read). Hence macros cannot be used here.
+  callee_embedding,
+  caller_embedding,
+
   NumberOfFeatures
 };
 // clang-format on
@@ -154,7 +160,7 @@ inlineCostFeatureToMlFeature(InlineCostFeatureIndex 
Feature) {
 constexpr size_t NumberOfFeatures =
 static_cast(FeatureIndex::NumberOfFeatures);
 
-LLVM_ABI extern const std::vector FeatureMap;
+LLVM_ABI extern std::vector FeatureMap;
 
 LLVM_ABI extern const char *const DecisionName;
 LLVM_ABI extern const TensorSpec InlineDecisionSpec;
diff --git a/llvm/include/llvm/Analysis/MLInlineAdvisor.h 
b/llvm/include/llvm/Analysis/MLInlineAdvisor.h
index 580dd5e95d760..8262dd0846ede 100644
--- a/llvm/include/llvm/Analysis/MLInlin

[llvm-branch-commits] [llvm] [IR2Vec] Consider only reachable BBs and non-debug instructions (PR #143476)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143476

>From 6e44bb095fa214a5146af383de0ffeb89606607b Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Tue, 10 Jun 2025 04:49:59 +
Subject: [PATCH] reachable BB

---
 llvm/lib/Analysis/IR2Vec.cpp | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 0f7303c1b0917..fa38c35796a0e 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -13,7 +13,9 @@
 
 #include "llvm/Analysis/IR2Vec.h"
 
+#include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/IR/CFG.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Debug.h"
@@ -190,7 +192,8 @@ Embedding SymbolicEmbedder::getOperandEmbedding(const Value 
*Op) const {
 void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
   Embedding BBVector(Dimension, 0);
 
-  for (const auto &I : BB) {
+  // We consider only the non-debug and non-pseudo instructions
+  for (const auto &I : BB.instructionsWithoutDebug()) {
 Embedding InstVector(Dimension, 0);
 
 const auto OpcVec = lookupVocab(I.getOpcodeName());
@@ -215,9 +218,11 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock 
&BB) const {
 void SymbolicEmbedder::computeEmbeddings() const {
   if (F.isDeclaration())
 return;
-  for (const auto &BB : F) {
-computeEmbeddings(BB);
-FuncVector += BBVecMap[&BB];
+
+  // Consider only the basic blocks that are reachable from entry
+  for (const BasicBlock *BB : depth_first(&F)) {
+computeEmbeddings(*BB);
+FuncVector += BBVecMap[BB];
   }
 }
 

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


[llvm-branch-commits] [llvm] [IR2Vec] Consider only reachable BBs and non-debug instructions (PR #143476)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143476

>From 6e44bb095fa214a5146af383de0ffeb89606607b Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Tue, 10 Jun 2025 04:49:59 +
Subject: [PATCH] reachable BB

---
 llvm/lib/Analysis/IR2Vec.cpp | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 0f7303c1b0917..fa38c35796a0e 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -13,7 +13,9 @@
 
 #include "llvm/Analysis/IR2Vec.h"
 
+#include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/IR/CFG.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Debug.h"
@@ -190,7 +192,8 @@ Embedding SymbolicEmbedder::getOperandEmbedding(const Value 
*Op) const {
 void SymbolicEmbedder::computeEmbeddings(const BasicBlock &BB) const {
   Embedding BBVector(Dimension, 0);
 
-  for (const auto &I : BB) {
+  // We consider only the non-debug and non-pseudo instructions
+  for (const auto &I : BB.instructionsWithoutDebug()) {
 Embedding InstVector(Dimension, 0);
 
 const auto OpcVec = lookupVocab(I.getOpcodeName());
@@ -215,9 +218,11 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock 
&BB) const {
 void SymbolicEmbedder::computeEmbeddings() const {
   if (F.isDeclaration())
 return;
-  for (const auto &BB : F) {
-computeEmbeddings(BB);
-FuncVector += BBVecMap[&BB];
+
+  // Consider only the basic blocks that are reachable from entry
+  for (const BasicBlock *BB : depth_first(&F)) {
+computeEmbeddings(*BB);
+FuncVector += BBVecMap[BB];
   }
 }
 

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


[llvm-branch-commits] [llvm] [MLGO][IR2Vec] Integrating IR2Vec with MLInliner (PR #143479)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy updated 
https://github.com/llvm/llvm-project/pull/143479

>From b7ec65230c731c77dea1f4a484df6731819729b5 Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Tue, 10 Jun 2025 05:40:38 +
Subject: [PATCH] [MLIniner][IR2Vec] Integrating IR2Vec with MLInliner

---
 .../Analysis/FunctionPropertiesAnalysis.h |  26 +++-
 llvm/include/llvm/Analysis/InlineAdvisor.h|   4 +
 .../llvm/Analysis/InlineModelFeatureMaps.h|   8 +-
 llvm/include/llvm/Analysis/MLInlineAdvisor.h  |   1 +
 .../Analysis/FunctionPropertiesAnalysis.cpp   | 115 +-
 llvm/lib/Analysis/InlineAdvisor.cpp   |  29 
 llvm/lib/Analysis/MLInlineAdvisor.cpp |  34 +++-
 .../FunctionPropertiesAnalysisTest.cpp| 145 --
 8 files changed, 338 insertions(+), 24 deletions(-)

diff --git a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h 
b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index babb6d9d6cf0c..06dbfc35a5294 100644
--- a/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -15,6 +15,7 @@
 #define LLVM_ANALYSIS_FUNCTIONPROPERTIESANALYSIS_H
 
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Analysis/IR2Vec.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Compiler.h"
@@ -32,17 +33,19 @@ class FunctionPropertiesInfo {
   void updateAggregateStats(const Function &F, const LoopInfo &LI);
   void reIncludeBB(const BasicBlock &BB);
 
+  ir2vec::Embedding FunctionEmbedding = ir2vec::Embedding(0.0);
+  std::optional IR2VecVocab;
+
 public:
   LLVM_ABI static FunctionPropertiesInfo
   getFunctionPropertiesInfo(const Function &F, const DominatorTree &DT,
-const LoopInfo &LI);
+const LoopInfo &LI,
+const IR2VecVocabResult *VocabResult);
 
   LLVM_ABI static FunctionPropertiesInfo
   getFunctionPropertiesInfo(Function &F, FunctionAnalysisManager &FAM);
 
-  bool operator==(const FunctionPropertiesInfo &FPI) const {
-return std::memcmp(this, &FPI, sizeof(FunctionPropertiesInfo)) == 0;
-  }
+  bool operator==(const FunctionPropertiesInfo &FPI) const;
 
   bool operator!=(const FunctionPropertiesInfo &FPI) const {
 return !(*this == FPI);
@@ -137,6 +140,19 @@ class FunctionPropertiesInfo {
   int64_t CallReturnsVectorPointerCount = 0;
   int64_t CallWithManyArgumentsCount = 0;
   int64_t CallWithPointerArgumentCount = 0;
+
+  const ir2vec::Embedding &getFunctionEmbedding() const {
+return FunctionEmbedding;
+  }
+
+  const std::optional &getIR2VecVocab() const {
+return IR2VecVocab;
+  }
+
+  // Helper intended to be useful for unittests
+  void setFunctionEmbeddingForTest(const ir2vec::Embedding &Embedding) {
+FunctionEmbedding = Embedding;
+  }
 };
 
 // Analysis pass
@@ -192,7 +208,7 @@ class FunctionPropertiesUpdater {
 
   DominatorTree &getUpdatedDominatorTree(FunctionAnalysisManager &FAM) const;
 
-  DenseSet Successors;
+  DenseSet Successors, CallUsers;
 
   // Edges we might potentially need to remove from the dominator tree.
   SmallVector DomTreeUpdates;
diff --git a/llvm/include/llvm/Analysis/InlineAdvisor.h 
b/llvm/include/llvm/Analysis/InlineAdvisor.h
index 9d15136e81d10..50ba3c13da70f 100644
--- a/llvm/include/llvm/Analysis/InlineAdvisor.h
+++ b/llvm/include/llvm/Analysis/InlineAdvisor.h
@@ -331,6 +331,10 @@ class InlineAdvisorAnalysis : public 
AnalysisInfoMixin {
   };
 
   Result run(Module &M, ModuleAnalysisManager &MAM) { return Result(M, MAM); }
+
+private:
+  static bool initializeIR2VecVocabIfRequested(Module &M,
+   ModuleAnalysisManager &MAM);
 };
 
 /// Printer pass for the InlineAdvisorAnalysis results.
diff --git a/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h 
b/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
index 961d5091bf9f3..a166621243cad 100644
--- a/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
+++ b/llvm/include/llvm/Analysis/InlineModelFeatureMaps.h
@@ -142,6 +142,12 @@ enum class FeatureIndex : size_t {
   INLINE_FEATURE_ITERATOR(POPULATE_INDICES)
 #undef POPULATE_INDICES
 
+// IR2Vec embeddings
+// Dimensions of embeddings are not known in the compile time (until vocab is 
+// read). Hence macros cannot be used here.
+  callee_embedding,
+  caller_embedding,
+
   NumberOfFeatures
 };
 // clang-format on
@@ -154,7 +160,7 @@ inlineCostFeatureToMlFeature(InlineCostFeatureIndex 
Feature) {
 constexpr size_t NumberOfFeatures =
 static_cast(FeatureIndex::NumberOfFeatures);
 
-LLVM_ABI extern const std::vector FeatureMap;
+LLVM_ABI extern std::vector FeatureMap;
 
 LLVM_ABI extern const char *const DecisionName;
 LLVM_ABI extern const TensorSpec InlineDecisionSpec;
diff --git a/llvm/include/llvm/Analysis/MLInlineAdvisor.h 
b/llvm/include/llvm/Analysis/MLInlineAdvisor.h
index 580dd5e95d760..8262dd0846ede 100644
--- a/llvm/include/llvm/Analysis/MLInlin

[llvm-branch-commits] [llvm] [IR2Vec] Scale embeddings once in vocab analysis instead of repetitive scaling (PR #143986)

2025-06-12 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-analysis

Author: S. VenkataKeerthy (svkeerthy)


Changes

Changes to scale opcodes, types and args once in `IR2VecVocabAnalysis` so that 
we can avoid scaling each time while computing embeddings. This PR refactors 
the vocabulary to explicitly define 3 sections---Opcodes, Types, and 
Arguments---used for computing Embeddings. 

(Tracking issue - #141817 ; partly fixes - #141832)


---

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


16 Files Affected:

- (modified) llvm/include/llvm/Analysis/IR2Vec.h (+15-1) 
- (modified) llvm/lib/Analysis/IR2Vec.cpp (+102-39) 
- (modified) llvm/lib/Analysis/models/seedEmbeddingVocab75D.json (+70-63) 
- (modified) llvm/lib/Passes/PassRegistry.def (+24-17) 
- (added) llvm/test/Analysis/IR2Vec/Inputs/dummy_2D_vocab.json (+11) 
- (modified) llvm/test/Analysis/IR2Vec/Inputs/dummy_3D_vocab.json (+13-5) 
- (modified) llvm/test/Analysis/IR2Vec/Inputs/dummy_5D_vocab.json (+15-9) 
- (added) llvm/test/Analysis/IR2Vec/Inputs/incorrect_vocab1.json (+11) 
- (added) llvm/test/Analysis/IR2Vec/Inputs/incorrect_vocab2.json (+12) 
- (added) llvm/test/Analysis/IR2Vec/Inputs/incorrect_vocab3.json (+12) 
- (added) llvm/test/Analysis/IR2Vec/Inputs/incorrect_vocab4.json (+16) 
- (modified) llvm/test/Analysis/IR2Vec/basic.ll (+13-1) 
- (added) llvm/test/Analysis/IR2Vec/dbg-inst.ll (+13) 
- (added) llvm/test/Analysis/IR2Vec/unreachable.ll (+42) 
- (added) llvm/test/Analysis/IR2Vec/vocab-test.ll (+20) 
- (modified) llvm/unittests/Analysis/IR2VecTest.cpp (+6) 


``diff
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index de67955d85d7c..f1aaf4cd2e013 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -108,6 +108,7 @@ struct Embedding {
   /// Arithmetic operators
   Embedding &operator+=(const Embedding &RHS);
   Embedding &operator-=(const Embedding &RHS);
+  Embedding &operator*=(double Factor);
 
   /// Adds Src Embedding scaled by Factor with the called Embedding.
   /// Called_Embedding += Src * Factor
@@ -116,6 +117,8 @@ struct Embedding {
   /// Returns true if the embedding is approximately equal to the RHS embedding
   /// within the specified tolerance.
   bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-6) 
const;
+
+  void print(raw_ostream &OS) const;
 };
 
 using InstEmbeddingsMap = DenseMap;
@@ -234,6 +237,8 @@ class IR2VecVocabResult {
 class IR2VecVocabAnalysis : public AnalysisInfoMixin {
   ir2vec::Vocab Vocabulary;
   Error readVocabulary();
+  Error parseVocabSection(const char *Key, const json::Value ParsedVocabValue,
+  ir2vec::Vocab &TargetVocab, unsigned &Dim);
   void emitError(Error Err, LLVMContext &Ctx);
 
 public:
@@ -249,7 +254,6 @@ class IR2VecVocabAnalysis : public 
AnalysisInfoMixin {
 /// functions.
 class IR2VecPrinterPass : public PassInfoMixin {
   raw_ostream &OS;
-  void printVector(const ir2vec::Embedding &Vec) const;
 
 public:
   explicit IR2VecPrinterPass(raw_ostream &OS) : OS(OS) {}
@@ -257,6 +261,16 @@ class IR2VecPrinterPass : public 
PassInfoMixin {
   static bool isRequired() { return true; }
 };
 
+/// This pass prints the embeddings in the vocabulary
+class IR2VecVocabPrinterPass : public PassInfoMixin {
+  raw_ostream &OS;
+
+public:
+  explicit IR2VecVocabPrinterPass(raw_ostream &OS) : OS(OS) {}
+  PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
+  static bool isRequired() { return true; }
+};
+
 } // namespace llvm
 
 #endif // LLVM_ANALYSIS_IR2VEC_H
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index fa38c35796a0e..f51d3252d6606 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -85,6 +85,12 @@ Embedding &Embedding::operator-=(const Embedding &RHS) {
   return *this;
 }
 
+Embedding &Embedding::operator*=(double Factor) {
+  std::transform(this->begin(), this->end(), this->begin(),
+ [Factor](double Elem) { return Elem * Factor; });
+  return *this;
+}
+
 Embedding &Embedding::scaleAndAdd(const Embedding &Src, float Factor) {
   assert(this->size() == Src.size() && "Vectors must have the same dimension");
   for (size_t Itr = 0; Itr < this->size(); ++Itr)
@@ -101,6 +107,13 @@ bool Embedding::approximatelyEquals(const Embedding &RHS,
   return true;
 }
 
+void Embedding::print(raw_ostream &OS) const {
+  OS << " [";
+  for (const auto &Elem : Data)
+OS << " " << format("%.2f", Elem) << " ";
+  OS << "]\n";
+}
+
 // 
==--===//
 // Embedder and its subclasses
 
//===--===//
@@ -196,18 +209,12 @@ void SymbolicEmbedder::computeEmbeddings(const BasicBlock 
&BB) const {
   for (const auto &I : BB.instructionsWithoutDebug()) {
 Embedding InstVector(Dimension, 0);
 
-const

[llvm-branch-commits] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-12 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc created https://github.com/llvm/llvm-project/pull/143992

This is useful for debugging ThinLTO issues.



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


[llvm-branch-commits] [llvm] llvm-lto2: Add print-guid subcommand. (PR #143992)

2025-06-12 Thread Peter Collingbourne via llvm-branch-commits

https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/143992

>From f11d7d544cc61dce582de538608bfd512147f90a Mon Sep 17 00:00:00 2001
From: Peter Collingbourne 
Date: Thu, 12 Jun 2025 16:06:14 -0700
Subject: [PATCH] Upload correct patch

Created using spr 1.3.6-beta.1
---
 llvm/tools/llvm-lto2/llvm-lto2.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp 
b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index 5f5c954c6a57d..d35868ffafe1e 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -610,7 +610,9 @@ int main(int argc, char **argv) {
 return dumpSymtab(argc - 1, argv + 1);
   if (Subcommand == "run")
 return run(argc - 1, argv + 1);
-  if (Subcommand == "print-guid" && argc > 2)
-outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]);
+  if (Subcommand == "print-guid" && argc > 2) {
+outs() << GlobalValue::getGUIDAssumingExternalLinkage(argv[2]) << '\n';
+return 0;
+  }
   return usage();
 }

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


[llvm-branch-commits] [llvm] [IR2Vec] Scale embeddings once in vocab analysis instead of repetitive scaling (PR #143986)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy edited 
https://github.com/llvm/llvm-project/pull/143986
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [IR2Vec] Scale embeddings once in vocab analysis instead of repetitive scaling (PR #143986)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy commented:

@albertcohen - Please have a look. I am not able to add you as reviewer.

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature (PR #143422)

2025-06-12 Thread via llvm-branch-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/143422

>From 9f51858f2050720c50c09ddd18108d3bcde5a68b Mon Sep 17 00:00:00 2001
From: joaosaffran 
Date: Wed, 4 Jun 2025 21:42:20 +
Subject: [PATCH 1/6] adding metadata support for static samplers

---
 llvm/lib/MC/DXContainerRootSignature.cpp  | 42 +
 llvm/lib/Target/DirectX/DXILRootSignature.cpp | 89 +++
 llvm/lib/Target/DirectX/DXILRootSignature.h   |  1 +
 .../RootSignature-StaticSamplers.ll   | 42 +
 4 files changed, 157 insertions(+), 17 deletions(-)
 create mode 100644 
llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll

diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp 
b/llvm/lib/MC/DXContainerRootSignature.cpp
index 6c71823a51f85..d67babf13a432 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -9,6 +9,7 @@
 #include "llvm/MC/DXContainerRootSignature.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/EndianStream.h"
+#include 
 
 using namespace llvm;
 using namespace llvm::mcdxbc;
@@ -71,12 +72,16 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
   BOS.reserveExtraSpace(getSize());
 
   const uint32_t NumParameters = ParametersContainer.size();
-
+  const uint32_t NumSamplers = StaticSamplers.size();
   support::endian::write(BOS, Version, llvm::endianness::little);
   support::endian::write(BOS, NumParameters, llvm::endianness::little);
   support::endian::write(BOS, RootParameterOffset, llvm::endianness::little);
-  support::endian::write(BOS, NumStaticSamplers, llvm::endianness::little);
-  support::endian::write(BOS, StaticSamplersOffset, llvm::endianness::little);
+  support::endian::write(BOS, NumSamplers, llvm::endianness::little);
+  uint32_t SSO = StaticSamplersOffset;
+  if (NumSamplers > 0)
+SSO = writePlaceholder(BOS);
+  else
+support::endian::write(BOS, SSO, llvm::endianness::little);
   support::endian::write(BOS, Flags, llvm::endianness::little);
 
   SmallVector ParamsOffsets;
@@ -142,20 +147,23 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
 }
 }
   }
-  for (const auto &S : StaticSamplers) {
-support::endian::write(BOS, S.Filter, llvm::endianness::little);
-support::endian::write(BOS, S.AddressU, llvm::endianness::little);
-support::endian::write(BOS, S.AddressV, llvm::endianness::little);
-support::endian::write(BOS, S.AddressW, llvm::endianness::little);
-support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
-support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
-support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
-support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
-support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
-support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
-support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
-support::endian::write(BOS, S.ShaderVisibility, llvm::endianness::little);
+  if (NumSamplers > 0) {
+rewriteOffsetToCurrentByte(BOS, SSO);
+for (const auto &S : StaticSamplers) {
+  support::endian::write(BOS, S.Filter, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressU, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressV, llvm::endianness::little);
+  support::endian::write(BOS, S.AddressW, llvm::endianness::little);
+  support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
+  support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
+  support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
+  support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
+  support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
+  support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
+  support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
+  support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
+  support::endian::write(BOS, S.ShaderVisibility, 
llvm::endianness::little);
+}
   }
   assert(Storage.size() == getSize());
   OS.write(Storage.data(), Storage.size());
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp 
b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index e51bd6796fb84..dfe9900b21df2 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -12,6 +12,7 @@
 
//===--===//
 #include "DXILRootSignature.h"
 #include "DirectX.h"
+#include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/DXILMetadataAnalysis.h"
@@ -55,6 +56,13 @@ static std::optional extractMdIntValue(MDNode 
*

[llvm-branch-commits] [llvm] Simplifying creation of Embedder (PR #143999)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy created 
https://github.com/llvm/llvm-project/pull/143999

None

>From cc133a17f78f9ed2082930617ed4d94dbbf9bf97 Mon Sep 17 00:00:00 2001
From: svkeerthy 
Date: Thu, 12 Jun 2025 23:54:10 +
Subject: [PATCH] Simplifying creation of Embedder

---
 llvm/docs/MLGO.rst|  7 +--
 llvm/include/llvm/Analysis/IR2Vec.h   |  4 +-
 .../Analysis/FunctionPropertiesAnalysis.cpp   | 10 ++---
 llvm/lib/Analysis/IR2Vec.cpp  | 19 
 .../FunctionPropertiesAnalysisTest.cpp|  7 ++-
 llvm/unittests/Analysis/IR2VecTest.cpp| 44 +++
 6 files changed, 34 insertions(+), 57 deletions(-)

diff --git a/llvm/docs/MLGO.rst b/llvm/docs/MLGO.rst
index 4f8fb3f59ca19..e7bba9995b75b 100644
--- a/llvm/docs/MLGO.rst
+++ b/llvm/docs/MLGO.rst
@@ -479,14 +479,9 @@ embeddings can be computed and accessed via an 
``ir2vec::Embedder`` instance.
 
   // Assuming F is an llvm::Function&
   // For example, using IR2VecKind::Symbolic:
-  Expected> EmbOrErr =
+  std::unique_ptr Emb =
   ir2vec::Embedder::create(IR2VecKind::Symbolic, F, Vocabulary);
 
-  if (auto Err = EmbOrErr.takeError()) {
-// Handle error in embedder creation
-return;
-  }
-  std::unique_ptr Emb = std::move(*EmbOrErr);
 
 3. **Compute and Access Embeddings**:
Call ``getFunctionVector()`` to get the embedding for the function. 
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index f1aaf4cd2e013..6efa6eac56af9 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -170,8 +170,8 @@ class Embedder {
   virtual ~Embedder() = default;
 
   /// Factory method to create an Embedder object.
-  static Expected>
-  create(IR2VecKind Mode, const Function &F, const Vocab &Vocabulary);
+  static std::unique_ptr create(IR2VecKind Mode, const Function &F,
+  const Vocab &Vocabulary);
 
   /// Returns a map containing instructions and the corresponding embeddings 
for
   /// the function F if it has been computed. If not, it computes the 
embeddings
diff --git a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp 
b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
index 29d3aaf46dc06..dd4eb7f0df053 100644
--- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
+++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
@@ -204,16 +204,12 @@ void FunctionPropertiesInfo::updateForBB(const BasicBlock 
&BB,
 // We instantiate the IR2Vec embedder each time, as having an unique
 // pointer to the embedder as member of the class would make it
 // non-copyable. Instantiating the embedder in itself is not costly.
-auto EmbOrErr = ir2vec::Embedder::create(IR2VecKind::Symbolic,
+auto Embedder = ir2vec::Embedder::create(IR2VecKind::Symbolic,
  *BB.getParent(), *IR2VecVocab);
-if (Error Err = EmbOrErr.takeError()) {
-  handleAllErrors(std::move(Err), [&](const ErrorInfoBase &EI) {
-BB.getContext().emitError("Error creating IR2Vec embeddings: " +
-  EI.message());
-  });
+if (!Embedder) {
+  BB.getContext().emitError("Error creating IR2Vec embeddings");
   return;
 }
-auto Embedder = std::move(*EmbOrErr);
 const auto &BBEmbedding = Embedder->getBBVector(BB);
 // Subtract BBEmbedding from Function embedding if the direction is -1,
 // and add it if the direction is +1.
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index f51d3252d6606..68026618449d8 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -123,13 +123,14 @@ Embedder::Embedder(const Function &F, const Vocab 
&Vocabulary)
   Dimension(Vocabulary.begin()->second.size()), OpcWeight(::OpcWeight),
   TypeWeight(::TypeWeight), ArgWeight(::ArgWeight) {}
 
-Expected>
-Embedder::create(IR2VecKind Mode, const Function &F, const Vocab &Vocabulary) {
+std::unique_ptr Embedder::create(IR2VecKind Mode, const Function &F,
+   const Vocab &Vocabulary) {
   switch (Mode) {
   case IR2VecKind::Symbolic:
 return std::make_unique(F, Vocabulary);
   }
-  return make_error("Unknown IR2VecKind", errc::invalid_argument);
+  llvm_unreachable("Unknown IR2Vec kind");
+  return nullptr;
 }
 
 // FIXME: Currently lookups are string based. Use numeric Keys
@@ -389,17 +390,13 @@ PreservedAnalyses IR2VecPrinterPass::run(Module &M,
 
   auto Vocab = IR2VecVocabResult.getVocabulary();
   for (Function &F : M) {
-Expected> EmbOrErr =
+std::unique_ptr Emb =
 Embedder::create(IR2VecKind::Symbolic, F, Vocab);
-if (auto Err = EmbOrErr.takeError()) {
-  handleAllErrors(std::move(Err), [&](const ErrorInfoBase &EI) {
-OS << "Error creating IR2Vec embeddings: " << EI.message() << "\n";
-  });
+if (!Emb) {
+  OS << "Error cre

[llvm-branch-commits] [llvm] Simplifying creation of Embedder (PR #143999)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

svkeerthy wrote:

> [!WARNING]
> This pull request is not mergeable via GitHub because a downstack PR is 
> open. Once all requirements are satisfied, merge this PR as a stack  href="https://app.graphite.dev/github/pr/llvm/llvm-project/143999?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#143999** https://app.graphite.dev/github/pr/llvm/llvm-project/143999?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/143999?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#143986** https://app.graphite.dev/github/pr/llvm/llvm-project/143986?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143479** https://app.graphite.dev/github/pr/llvm/llvm-project/143479?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143476** https://app.graphite.dev/github/pr/llvm/llvm-project/143476?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143200** https://app.graphite.dev/github/pr/llvm/llvm-project/143200?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#143197** https://app.graphite.dev/github/pr/llvm/llvm-project/143197?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* `main`




This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


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


[llvm-branch-commits] [llvm] [IR2Vec] Simplifying creation of Embedder (PR #143999)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy edited 
https://github.com/llvm/llvm-project/pull/143999
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [IR2Vec] Simplifying creation of Embedder (PR #143999)

2025-06-12 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-analysis

Author: S. VenkataKeerthy (svkeerthy)


Changes

This change simplifies the API by removing the error handling complexity. 

- Changed `Embedder::create()` to return `std::unique_ptr` 
directly instead of `Expected>`
- Updated documentation and tests to reflect the new API
- Added death test for invalid IR2Vec kind in debug mode
- In release mode, simply returns nullptr for invalid kinds instead of creating 
an error

(Tracking issue - #141817)



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


6 Files Affected:

- (modified) llvm/docs/MLGO.rst (+1-6) 
- (modified) llvm/include/llvm/Analysis/IR2Vec.h (+2-2) 
- (modified) llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp (+3-7) 
- (modified) llvm/lib/Analysis/IR2Vec.cpp (+8-11) 
- (modified) llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp (+3-4) 
- (modified) llvm/unittests/Analysis/IR2VecTest.cpp (+17-27) 


``diff
diff --git a/llvm/docs/MLGO.rst b/llvm/docs/MLGO.rst
index 4f8fb3f59ca19..e7bba9995b75b 100644
--- a/llvm/docs/MLGO.rst
+++ b/llvm/docs/MLGO.rst
@@ -479,14 +479,9 @@ embeddings can be computed and accessed via an 
``ir2vec::Embedder`` instance.
 
   // Assuming F is an llvm::Function&
   // For example, using IR2VecKind::Symbolic:
-  Expected> EmbOrErr =
+  std::unique_ptr Emb =
   ir2vec::Embedder::create(IR2VecKind::Symbolic, F, Vocabulary);
 
-  if (auto Err = EmbOrErr.takeError()) {
-// Handle error in embedder creation
-return;
-  }
-  std::unique_ptr Emb = std::move(*EmbOrErr);
 
 3. **Compute and Access Embeddings**:
Call ``getFunctionVector()`` to get the embedding for the function. 
diff --git a/llvm/include/llvm/Analysis/IR2Vec.h 
b/llvm/include/llvm/Analysis/IR2Vec.h
index f1aaf4cd2e013..6efa6eac56af9 100644
--- a/llvm/include/llvm/Analysis/IR2Vec.h
+++ b/llvm/include/llvm/Analysis/IR2Vec.h
@@ -170,8 +170,8 @@ class Embedder {
   virtual ~Embedder() = default;
 
   /// Factory method to create an Embedder object.
-  static Expected>
-  create(IR2VecKind Mode, const Function &F, const Vocab &Vocabulary);
+  static std::unique_ptr create(IR2VecKind Mode, const Function &F,
+  const Vocab &Vocabulary);
 
   /// Returns a map containing instructions and the corresponding embeddings 
for
   /// the function F if it has been computed. If not, it computes the 
embeddings
diff --git a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp 
b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
index 29d3aaf46dc06..dd4eb7f0df053 100644
--- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
+++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
@@ -204,16 +204,12 @@ void FunctionPropertiesInfo::updateForBB(const BasicBlock 
&BB,
 // We instantiate the IR2Vec embedder each time, as having an unique
 // pointer to the embedder as member of the class would make it
 // non-copyable. Instantiating the embedder in itself is not costly.
-auto EmbOrErr = ir2vec::Embedder::create(IR2VecKind::Symbolic,
+auto Embedder = ir2vec::Embedder::create(IR2VecKind::Symbolic,
  *BB.getParent(), *IR2VecVocab);
-if (Error Err = EmbOrErr.takeError()) {
-  handleAllErrors(std::move(Err), [&](const ErrorInfoBase &EI) {
-BB.getContext().emitError("Error creating IR2Vec embeddings: " +
-  EI.message());
-  });
+if (!Embedder) {
+  BB.getContext().emitError("Error creating IR2Vec embeddings");
   return;
 }
-auto Embedder = std::move(*EmbOrErr);
 const auto &BBEmbedding = Embedder->getBBVector(BB);
 // Subtract BBEmbedding from Function embedding if the direction is -1,
 // and add it if the direction is +1.
diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index f51d3252d6606..68026618449d8 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -123,13 +123,14 @@ Embedder::Embedder(const Function &F, const Vocab 
&Vocabulary)
   Dimension(Vocabulary.begin()->second.size()), OpcWeight(::OpcWeight),
   TypeWeight(::TypeWeight), ArgWeight(::ArgWeight) {}
 
-Expected>
-Embedder::create(IR2VecKind Mode, const Function &F, const Vocab &Vocabulary) {
+std::unique_ptr Embedder::create(IR2VecKind Mode, const Function &F,
+   const Vocab &Vocabulary) {
   switch (Mode) {
   case IR2VecKind::Symbolic:
 return std::make_unique(F, Vocabulary);
   }
-  return make_error("Unknown IR2VecKind", errc::invalid_argument);
+  llvm_unreachable("Unknown IR2Vec kind");
+  return nullptr;
 }
 
 // FIXME: Currently lookups are string based. Use numeric Keys
@@ -389,17 +390,13 @@ PreservedAnalyses IR2VecPrinterPass::run(Module &M,
 
   auto Vocab = IR2VecVocabResult.getVocabulary();
   for (Function &F : M) {
-Expected> EmbOrErr =
+

[llvm-branch-commits] [llvm] [IR2Vec] Simplifying creation of Embedder (PR #143999)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

svkeerthy wrote:

@albertcohen

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


[llvm-branch-commits] [llvm] [IR2Vec] Simplifying creation of Embedder (PR #143999)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy edited 
https://github.com/llvm/llvm-project/pull/143999
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [IR2Vec] Simplifying creation of Embedder (PR #143999)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy ready_for_review 
https://github.com/llvm/llvm-project/pull/143999
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [IR2Vec] Simplifying creation of Embedder (PR #143999)

2025-06-12 Thread S. VenkataKeerthy via llvm-branch-commits

https://github.com/svkeerthy edited 
https://github.com/llvm/llvm-project/pull/143999
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (PR #121830)

2025-06-12 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/121830

>From 23a48f34439d3f84487dc36541fe99c3d9a8cad7 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 04:58:57 -0700
Subject: [PATCH] [Driver] Add support for crtbegin.o, crtend.o and libgloss
 lib to BareMetal toolchain object

This patch conditionalise the addition of crt{begin,end}.o object files along
with addition of -lgloss lib based on whether libc selected is newlib or llvm
libc. Since there is no way a user can specify which libc it wants to link
against, currently passing valid GCCInstallation to driver will select newlib
otherwise it will default to llvm libc.

Moreover, this patch makes gnuld the default linker for baremetal toolchain
object. User need to pass `-fuse-ld=lld` explicitly to driver to select lld

This is the 2nd patch in the series of patches of merging RISCVToolchain into
BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ie06dc976c306cf04ec2733bbb2d271c57d201f86
---
 clang/lib/Driver/ToolChains/BareMetal.cpp   | 38 +++-
 clang/lib/Driver/ToolChains/BareMetal.h |  3 +-
 clang/test/Driver/aarch64-toolchain-extra.c | 13 ++-
 clang/test/Driver/aarch64-toolchain.c   | 95 
 clang/test/Driver/arm-toolchain-extra.c |  7 ++
 clang/test/Driver/arm-toolchain.c   | 99 -
 clang/test/Driver/baremetal.cpp |  3 +-
 clang/test/Driver/sanitizer-ld.c|  2 +-
 8 files changed, 247 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index a39da21e9ebcd..c4e10ccf1a7bd 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -586,9 +586,31 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_r)) {
-CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+  bool NeedCRTs =
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
+
+  const char *CRTBegin, *CRTEnd;
+  if (NeedCRTs) {
+if (!Args.hasArg(options::OPT_r))
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) {
+  auto RuntimeLib = TC.GetRuntimeLibType(Args);
+  switch (RuntimeLib) {
+  case (ToolChain::RLT_Libgcc): {
+CRTBegin = "crtbegin.o";
+CRTEnd = "crtend.o";
+break;
+  }
+  case (ToolChain::RLT_CompilerRT): {
+CRTBegin =
+TC.getCompilerRTArgString(Args, "crtbegin", ToolChain::FT_Object);
+CRTEnd =
+TC.getCompilerRTArgString(Args, "crtend", ToolChain::FT_Object);
+break;
+  }
+  }
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTBegin)));
+}
   }
 
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
@@ -611,9 +633,12 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+CmdArgs.push_back("--start-group");
 AddRunTimeLibs(TC, D, CmdArgs, Args);
-
 CmdArgs.push_back("-lc");
+if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D))
+  CmdArgs.push_back("-lgloss");
+CmdArgs.push_back("--end-group");
   }
 
   if (D.isUsingLTO()) {
@@ -629,6 +654,11 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 addLTOOptions(TC, Args, CmdArgs, Output, *Input,
   D.getLTOMode() == LTOK_Thin);
   }
+
+  if ((TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) &&
+  NeedCRTs)
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTEnd)));
+
   if (TC.getTriple().isRISCV())
 CmdArgs.push_back("-X");
 
diff --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index 930f8584e6435..54805530bae82 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -38,6 +38,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
 public:
   bool initGCCInstallation(const llvm::Triple &Triple,
const llvm::opt::ArgList &Args);
+  bool hasValidGCCInstallation() const { return IsGCCInstallationValid; }
   bool isBareMetal() const override { return true; }
   bool isCrossCompiling() const override { return true; }
   bool HasNativeLLVMSupport() const override { return true; }
@@ -63,8 +64,6 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
 return ToolChain::CST_Libcxx;
   }
 
-  const char *getDefaultLinker() const override { return "ld.lld"; }
-
   void
   AddClangSystemIncludeArgs(

[llvm-branch-commits] [clang] [Driver] Fix link order of BareMetal toolchain object (PR #132806)

2025-06-12 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/132806

>From 9a1f1f7352751deab1786a922a70f1e6fe79d736 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 06:17:42 -0700
Subject: [PATCH] [Driver] Fix link order of BareMetal toolchain object

The linker job in BareMetal toolchain object will be used by gnuld and lld both.
However, gnuld process the arguments in the order in which they appear on 
command
line, whereas there is no such restriction with lld.

The previous order was:
LibraryPaths -> Libraries -> LTOOptions -> LinkerInputs
The new iorder is:
LibraryPaths -> LTOOptions -> LinkerInputs -> Libraries

LTO options need to be added before adding any linker inputs because file format
after compile stage during LTO is bitcode which gnuld natively cannot process.
Hence iwill need to pass appropriate plugins before adding any bitcode file on 
the
command line.

Object files that are getting linked need to be passed before processing any
libraries so that gnuld can appropriately do symbol resolution for the symbols
for which no definition is provided through user code.

Similar link order is also followed by other linker jobs for gnuld such as in
gnutools::Linker in Gnu.cpp

This is the 3rd patch in the series of patches of merging RISCVToolchain into
BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: I0e68e403c08b5687cc3346e833981f7b9f3819c4
---
 clang/lib/Driver/ToolChains/BareMetal.cpp   | 32 -
 clang/test/Driver/aarch64-toolchain-extra.c |  2 +-
 clang/test/Driver/aarch64-toolchain.c   | 28 
 clang/test/Driver/arm-toolchain-extra.c |  2 +-
 clang/test/Driver/arm-toolchain.c   | 28 
 clang/test/Driver/baremetal-multilib.yaml   |  3 +-
 clang/test/Driver/baremetal-sysroot.cpp |  8 ++-
 clang/test/Driver/baremetal.cpp | 79 +
 8 files changed, 102 insertions(+), 80 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index c4e10ccf1a7bd..3abfb7efe6bfc 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -570,8 +570,6 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
-  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
-
   CmdArgs.push_back("-Bstatic");
 
   if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
@@ -621,6 +619,22 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   for (const auto &LibPath : TC.getLibraryPaths())
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-L", LibPath)));
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+// Find the first filename InputInfo object.
+auto Input = llvm::find_if(
+Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
+if (Input == Inputs.end())
+  // For a very rare case, all of the inputs to the linker are
+  // InputArg. If that happens, just use the first InputInfo.
+  Input = Inputs.begin();
+
+addLTOOptions(TC, Args, CmdArgs, Output, *Input,
+  D.getLTOMode() == LTOK_Thin);
+  }
+
+  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
+
   if (TC.ShouldLinkCXXStdlib(Args)) {
 bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
!Args.hasArg(options::OPT_static);
@@ -641,20 +655,6 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("--end-group");
   }
 
-  if (D.isUsingLTO()) {
-assert(!Inputs.empty() && "Must have at least one input.");
-// Find the first filename InputInfo object.
-auto Input = llvm::find_if(
-Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
-if (Input == Inputs.end())
-  // For a very rare case, all of the inputs to the linker are
-  // InputArg. If that happens, just use the first InputInfo.
-  Input = Inputs.begin();
-
-addLTOOptions(TC, Args, CmdArgs, Output, *Input,
-  D.getLTOMode() == LTOK_Thin);
-  }
-
   if ((TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) &&
   NeedCRTs)
 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(CRTEnd)));
diff --git a/clang/test/Driver/aarch64-toolchain-extra.c 
b/clang/test/Driver/aarch64-toolchain-extra.c
index 2a930e35acd45..a0b5f2902962f 100644
--- a/clang/test/Driver/aarch64-toolchain-extra.c
+++ b/clang/test/Driver/aarch64-toolchain-extra.c
@@ -31,5 +31,5 @@
 // C-AARCH64-BAREMETAL-NOGCC: 
"{{.*}}/aarch64-nogcc/bin/../aarch64-none-elf/lib/crt0.o"
 // C-AARCH64-BAREMETAL-NOGCC: 
"{{.*}}/aarch64-nogcc/{{.*}}/aarch64-none-elf/lib/crtbegin.o"
 // C-AARCH64-BAREMETAL-NOGCC: 

[llvm-branch-commits] [clang] [Driver] Forward sysroot from Driver to linker in BareMetal ToolChain Object (PR #132808)

2025-06-12 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/132808

>From a12635427fbd2cf42d5174dd86f5a5a064f61ca4 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 07:04:59 -0700
Subject: [PATCH] [Driver] Forward sysroot from Driver to linker in BareMetal
 ToolChain Object

RISCVToolChain object passes `--sysroot` option from clang to gnuld. Adding
the supprt for the same in BareMetal toolchain object.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 5th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ie830bf6d126fea46dc225e5ef97e14349765ba07
---
 clang/lib/Driver/ToolChains/BareMetal.cpp |  3 +
 clang/test/Driver/aarch64-toolchain.c |  5 +-
 clang/test/Driver/arm-toolchain.c |  3 +
 clang/test/Driver/baremetal.cpp   | 96 +--
 4 files changed, 82 insertions(+), 25 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index d70d39c3c5ca6..65f3d0a8eefb1 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -570,6 +570,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
 
+  if (!D.SysRoot.empty())
+CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
+
   CmdArgs.push_back("-Bstatic");
 
   if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
diff --git a/clang/test/Driver/aarch64-toolchain.c 
b/clang/test/Driver/aarch64-toolchain.c
index e12107fa2c506..d6628aa3e2e36 100644
--- a/clang/test/Driver/aarch64-toolchain.c
+++ b/clang/test/Driver/aarch64-toolchain.c
@@ -29,6 +29,7 @@
 // C-AARCH64-BAREMETAL: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// C-AARCH64-BAREMETAL: 
"--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // C-AARCH64-BAREMETAL: "-Bstatic" "-EL"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // C-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
@@ -65,6 +66,7 @@
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1"
 // CXX-AARCH64-BAREMETAL: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// CXX-AARCH64-BAREMETAL: 
"--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL: "-Bstatic" "-EL"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // CXX-AARCH64-BAREMETAL: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
@@ -101,7 +103,8 @@
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-isysroot" 
"{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/v1"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
-// CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld
+// CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../bin/aarch64-none-elf-ld"
+// CXX-AARCH64-BAREMETAL-LIBCXX: 
"--sysroot={{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
 // CXX-AARCH64-BAREMETAL-LIBCXX: "-Bstatic" "-EL"
 // CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o"
 // CXX-AARCH64-BAREMETAL-LIBCXX: 
"{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o"
diff --git a/clang/test/Driver/arm-toolchain.c 
b/clang/test/Driver/arm-toolchain.c
index d4f9bf2aaf3d5..3e507be44a8dd 100644
--- a/clang/test/Driver/arm-toolchain.c
+++ b/clang/test/Driver/arm-toolchain.c
@@ -28,6 +28,7 @@
 // C-ARM-BAREMETAL: "-isysroot" 
"{{.*}}Inputs/basic_arm_gcc_tree/armv6m-none-eabi"
 // C-ARM-BAREMETAL: "-internal-isystem" 
"{{.*}}Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include"
 // C-ARM-BAREMETAL: 
"{{.*}}/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/../../../../bin/armv6m-none-eabi-ld"
+// C-ARM-BAREMETAL: 
"--sysroot={{.*}}/Inputs/basic_arm_

[llvm-branch-commits] [clang] [Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (PR #132807)

2025-06-12 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/132807

>From ab8d90fc9f03a182295cb79c766ddeb0455c2f94 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 24 Mar 2025 06:49:09 -0700
Subject: [PATCH] [Driver] Add option to force udnefined symbols during linking
 in BareMetal toolchain object.

Add support for `-u` option to force defined symbols. This option is supported
by both lld and gnuld.

This is done as a part of the effort to merge RISCVToolchain object into
BareMetal toolchain object.

This is the 4th patch in the series of patches for merging RISCVToolchain object
into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524

Change-Id: Ia6597c756923a77fd9c7cb9a6ae8e52a56f5457d
---
 clang/lib/Driver/ToolChains/BareMetal.cpp   |  5 +++--
 clang/test/Driver/baremetal-undefined-symbols.c | 14 ++
 clang/test/Driver/riscv-args.c  |  6 --
 3 files changed, 17 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/Driver/baremetal-undefined-symbols.c
 delete mode 100644 clang/test/Driver/riscv-args.c

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 3abfb7efe6bfc..d70d39c3c5ca6 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -611,8 +611,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 }
   }
 
-  Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
-options::OPT_s, options::OPT_t, options::OPT_r});
+  Args.addAllArgs(CmdArgs,
+  {options::OPT_L, options::OPT_u, options::OPT_T_Group,
+   options::OPT_s, options::OPT_t, options::OPT_r});
 
   TC.AddFilePathLibArgs(Args, CmdArgs);
 
diff --git a/clang/test/Driver/baremetal-undefined-symbols.c 
b/clang/test/Driver/baremetal-undefined-symbols.c
new file mode 100644
index 0..bff58c7c54c33
--- /dev/null
+++ b/clang/test/Driver/baremetal-undefined-symbols.c
@@ -0,0 +1,14 @@
+// Check the arguments are correctly passed
+
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 
-T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD %s
+// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
+
+// TODO: Merge this test with the above in the last patch when finally 
integrating riscv
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### --target=aarch64-none-elf --gcc-toolchain= -Xlinker 
--defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-LD %s
+// RUN: %clang -### --target=armv6m-none-eabi --gcc-toolchain= -Xlinker 
--defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-LD %s
+// CHECK-ARM-LD: {{.*}} "-T" "a.lds" "-u" "foo" {{.*}} "--defsym=FOO=10"
diff --git a/clang/test/Driver/riscv-args.c b/clang/test/Driver/riscv-args.c
deleted file mode 100644
index cab08e5b0f811..0
--- a/clang/test/Driver/riscv-args.c
+++ /dev/null
@@ -1,6 +0,0 @@
-// Check the arguments are correctly passed
-
-// Make sure -T is the last with gcc-toolchain option
-// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 
-T a.lds -u foo %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-LD %s
-// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"

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


[llvm-branch-commits] [clang] [RISCV][Driver] Add riscv emulation mode to linker job of BareMetal toolchain (PR #134442)

2025-06-12 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/134442

>From e9cc265c4f8eeb1d678144b5de7f25a2e9cf3a78 Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Fri, 4 Apr 2025 12:51:19 -0700
Subject: [PATCH] [RISCV][Driver] Add riscv emulation mode to linker job of
 BareMetal toolchain

Change-Id: Ifce8a3a7f1df9c12561d35ca3c923595e3619428
---
 clang/lib/Driver/ToolChains/BareMetal.cpp  | 15 -
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 70 ++
 clang/lib/Driver/ToolChains/CommonArgs.h   |  2 +
 clang/lib/Driver/ToolChains/Gnu.cpp| 70 --
 clang/test/Driver/baremetal.cpp| 28 -
 5 files changed, 99 insertions(+), 86 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 65f3d0a8eefb1..74ae2dfb97c5d 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -575,8 +575,19 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   CmdArgs.push_back("-Bstatic");
 
-  if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
-CmdArgs.push_back("--no-relax");
+  if (Triple.isRISCV()) {
+if (const char *LDMOption = getLDMOption(TC.getTriple(), Args)) {
+  CmdArgs.push_back("-m");
+  CmdArgs.push_back(LDMOption);
+} else {
+  D.Diag(diag::err_target_unknown_triple) << Triple.str();
+  return;
+}
+
+CmdArgs.push_back("-X");
+if (Args.hasArg(options::OPT_mno_relax))
+  CmdArgs.push_back("--no-relax");
+  }
 
   if (Triple.isARM() || Triple.isThumb()) {
 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index ddeadff8f6dfb..292d52acdc002 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -535,6 +535,76 @@ void tools::AddLinkerInputs(const ToolChain &TC, const 
InputInfoList &Inputs,
   }
 }
 
+const char *tools::getLDMOption(const llvm::Triple &T, const ArgList &Args) {
+  switch (T.getArch()) {
+  case llvm::Triple::x86:
+if (T.isOSIAMCU())
+  return "elf_iamcu";
+return "elf_i386";
+  case llvm::Triple::aarch64:
+return "aarch64linux";
+  case llvm::Triple::aarch64_be:
+return "aarch64linuxb";
+  case llvm::Triple::arm:
+  case llvm::Triple::thumb:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumbeb:
+return tools::arm::isARMBigEndian(T, Args) ? "armelfb_linux_eabi"
+   : "armelf_linux_eabi";
+  case llvm::Triple::m68k:
+return "m68kelf";
+  case llvm::Triple::ppc:
+if (T.isOSLinux())
+  return "elf32ppclinux";
+return "elf32ppc";
+  case llvm::Triple::ppcle:
+if (T.isOSLinux())
+  return "elf32lppclinux";
+return "elf32lppc";
+  case llvm::Triple::ppc64:
+return "elf64ppc";
+  case llvm::Triple::ppc64le:
+return "elf64lppc";
+  case llvm::Triple::riscv32:
+return "elf32lriscv";
+  case llvm::Triple::riscv64:
+return "elf64lriscv";
+  case llvm::Triple::sparc:
+  case llvm::Triple::sparcel:
+return "elf32_sparc";
+  case llvm::Triple::sparcv9:
+return "elf64_sparc";
+  case llvm::Triple::loongarch32:
+return "elf32loongarch";
+  case llvm::Triple::loongarch64:
+return "elf64loongarch";
+  case llvm::Triple::mips:
+return "elf32btsmip";
+  case llvm::Triple::mipsel:
+return "elf32ltsmip";
+  case llvm::Triple::mips64:
+if (tools::mips::hasMipsAbiArg(Args, "n32") || T.isABIN32())
+  return "elf32btsmipn32";
+return "elf64btsmip";
+  case llvm::Triple::mips64el:
+if (tools::mips::hasMipsAbiArg(Args, "n32") || T.isABIN32())
+  return "elf32ltsmipn32";
+return "elf64ltsmip";
+  case llvm::Triple::systemz:
+return "elf64_s390";
+  case llvm::Triple::x86_64:
+if (T.isX32())
+  return "elf32_x86_64";
+return "elf_x86_64";
+  case llvm::Triple::ve:
+return "elf64ve";
+  case llvm::Triple::csky:
+return "cskyelf_linux";
+  default:
+return nullptr;
+  }
+}
+
 void tools::addLinkerCompressDebugSectionsOption(
 const ToolChain &TC, const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 96bc0619dcbc0..875354e969a2a 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -31,6 +31,8 @@ void AddLinkerInputs(const ToolChain &TC, const InputInfoList 
&Inputs,
  const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs, const JobAction &JA);
 
+const char *getLDMOption(const llvm::Triple &T, const llvm::opt::ArgList 
&Args);
+
 void addLinkerCompressDebugSectionsOption(const ToolChain &TC,
   const llvm::opt::ArgList &Args,
   

[llvm-branch-commits] [clang] [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (PR #121831)

2025-06-12 Thread Garvit Gupta via llvm-branch-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/121831

>From c0a78620b8bf244af397f989e0917d7c1733508c Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Mon, 6 Jan 2025 10:05:08 -0800
Subject: [PATCH] [RISCV] Integrate RISCV target in baremetal toolchain object
 and deprecate RISCVToolchain object

This patch:
- Adds CXXStdlib, runtimelib and unwindlib defaults for riscv target to
  BareMetal toolchain object.
- Add riscv 32 and 64-bit emulation flags to linker job of BareMetal
  toolchain.
- Removes call to RISCVToolChain object from llvm.

This PR is last patch in the series of patches of merging RISCVToolchain
object into BareMetal toolchain object.

RFC:
https: 
//discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524
Change-Id: Ic5d64a4ed3ebc58c30c12d9827e7e57a02eb13ca
---
 clang/lib/Driver/CMakeLists.txt   |   1 -
 clang/lib/Driver/Driver.cpp   |  10 +-
 clang/lib/Driver/ToolChains/BareMetal.cpp |  20 ++
 clang/lib/Driver/ToolChains/BareMetal.h   |  10 +-
 .../lib/Driver/ToolChains/RISCVToolchain.cpp  | 232 --
 clang/lib/Driver/ToolChains/RISCVToolchain.h  |  67 -
 .../test/Driver/baremetal-undefined-symbols.c |  14 +-
 clang/test/Driver/riscv32-toolchain-extra.c   |   7 +-
 clang/test/Driver/riscv32-toolchain.c |  26 +-
 clang/test/Driver/riscv64-toolchain-extra.c   |   7 +-
 clang/test/Driver/riscv64-toolchain.c |  20 +-
 11 files changed, 60 insertions(+), 354 deletions(-)
 delete mode 100644 clang/lib/Driver/ToolChains/RISCVToolchain.cpp
 delete mode 100644 clang/lib/Driver/ToolChains/RISCVToolchain.h

diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 5bdb6614389cf..eee29af5d181a 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -74,7 +74,6 @@ add_clang_library(clangDriver
   ToolChains/OHOS.cpp
   ToolChains/OpenBSD.cpp
   ToolChains/PS4CPU.cpp
-  ToolChains/RISCVToolchain.cpp
   ToolChains/Solaris.cpp
   ToolChains/SPIRV.cpp
   ToolChains/SPIRVOpenMP.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 07e36ea2efba4..cfc0ba63d5749 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -41,7 +41,6 @@
 #include "ToolChains/PPCFreeBSD.h"
 #include "ToolChains/PPCLinux.h"
 #include "ToolChains/PS4CPU.h"
-#include "ToolChains/RISCVToolchain.h"
 #include "ToolChains/SPIRV.h"
 #include "ToolChains/SPIRVOpenMP.h"
 #include "ToolChains/SYCL.h"
@@ -6889,16 +6888,11 @@ const ToolChain &Driver::getToolChain(const ArgList 
&Args,
 TC = std::make_unique(*this, Target, Args);
 break;
   case llvm::Triple::msp430:
-TC =
-std::make_unique(*this, Target, Args);
+TC = std::make_unique(*this, Target, 
Args);
 break;
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
-if (toolchains::RISCVToolChain::hasGCCToolchain(*this, Args))
-  TC =
-  std::make_unique(*this, Target, 
Args);
-else
-  TC = std::make_unique(*this, Target, Args);
+TC = std::make_unique(*this, Target, Args);
 break;
   case llvm::Triple::ve:
 TC = std::make_unique(*this, Target, Args);
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 74ae2dfb97c5d..d1ab991f75443 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -377,6 +377,26 @@ BareMetal::OrderedMultilibs 
BareMetal::getOrderedMultilibs() const {
   return llvm::reverse(Default);
 }
 
+ToolChain::CXXStdlibType BareMetal::GetDefaultCXXStdlibType() const {
+  if (getTriple().isRISCV() && GCCInstallation.isValid())
+return ToolChain::CST_Libstdcxx;
+  return ToolChain::CST_Libcxx;
+}
+
+ToolChain::RuntimeLibType BareMetal::GetDefaultRuntimeLibType() const {
+  if (getTriple().isRISCV() && GCCInstallation.isValid())
+return ToolChain::RLT_Libgcc;
+  return ToolChain::RLT_CompilerRT;
+}
+
+ToolChain::UnwindLibType
+BareMetal::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
+  if (getTriple().isRISCV())
+return ToolChain::UNW_None;
+
+  return ToolChain::GetUnwindLibType(Args);
+}
+
 void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdinc))
diff --git a/clang/lib/Driver/ToolChains/BareMetal.h 
b/clang/lib/Driver/ToolChains/BareMetal.h
index 54805530bae82..cc57fa21867a2 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.h
+++ b/clang/lib/Driver/ToolChains/BareMetal.h
@@ -56,13 +56,11 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public 
Generic_ELF {
 return UnwindTableLevel::None;
   }
 
-  RuntimeLibType GetDefaultRuntimeLibType() const override {
-return ToolChain::RLT_CompilerRT;
-  }
+  CXXStdlibType GetDefaultCXXStdlibType() const overr

[llvm-branch-commits] [clang-tools-extra] f8abd70 - Revert "[clang-tidy] Improve integer comparison by matching valid expressions…"

2025-06-12 Thread via llvm-branch-commits

Author: David Rivera
Date: 2025-06-12T13:56:16-04:00
New Revision: f8abd70d85becb4c5d2f56bbe193bb3d7b5a8c1c

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

LOG: Revert "[clang-tidy] Improve integer comparison by matching valid 
expressions…"

This reverts commit e65d32316646e6203a3f4d4c9921edcddbb1c57d.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
index c02c5dfa8756d..eeba5cce80da5 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
@@ -39,28 +39,21 @@ intCastExpression(bool IsSigned,
   // std::cmp_{} functions trigger a compile-time error if either LHS or RHS
   // is a non-integer type, char, enum or bool
   // (unsigned char/ signed char are Ok and can be used).
-  const auto HasIntegerType = hasType(hasCanonicalType(qualType(
+  auto IntTypeExpr = expr(hasType(hasCanonicalType(qualType(
   isInteger(), IsSigned ? isSignedInteger() : isUnsignedInteger(),
-  unless(isActualChar()), unless(booleanType()), unless(enumType();
-
-  const auto IntTypeExpr = expr(HasIntegerType);
+  unless(isActualChar()), unless(booleanType()), unless(enumType());
 
   const auto ImplicitCastExpr =
   CastBindName.empty() ? implicitCastExpr(hasSourceExpression(IntTypeExpr))
: implicitCastExpr(hasSourceExpression(IntTypeExpr))
  .bind(CastBindName);
 
-  const auto ExplicitCastExpr =
-  anyOf(explicitCastExpr(has(ImplicitCastExpr)),
-ignoringImpCasts(explicitCastExpr(has(ImplicitCastExpr;
-
-  // Match function calls or variable references not directly wrapped by an
-  // implicit cast
-  const auto CallIntExpr = CastBindName.empty()
-   ? callExpr(HasIntegerType)
-   : callExpr(HasIntegerType).bind(CastBindName);
+  const auto CStyleCastExpr = cStyleCastExpr(has(ImplicitCastExpr));
+  const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr));
+  const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr));
 
-  return expr(anyOf(ImplicitCastExpr, ExplicitCastExpr, CallIntExpr));
+  return expr(anyOf(ImplicitCastExpr, CStyleCastExpr, StaticCastExpr,
+FunctionalCastExpr));
 }
 
 static StringRef parseOpCode(BinaryOperator::Opcode Code) {

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 882ee0015df17..19ccd1790e757 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -237,10 +237,6 @@ Changes in existing checks
   ` check by avoiding
   diagnosing designated initializers for ``std::array`` initializations.
 
-- Improved :doc:`modernize-use-integer-sign-comparison
-  ` check by matching
-  valid integer expressions not directly wrapped around an implicit cast.
-
 - Improved :doc:`modernize-use-ranges
   ` check by updating suppress
   warnings logic for ``nullptr`` in ``std::find``.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
index d93a05ac38050..e0a84ef5aed26 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp
@@ -121,81 +121,3 @@ int AllComparisons() {
 
 return 0;
 }
-
-namespace PR127471 {
-int getSignedValue();
-unsigned int getUnsignedValue();
-
-void callExprTest() {
-
-if (getSignedValue() < getUnsignedValue())
-return;
-// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
-// CHECK-FIXES:  if (std::cmp_less(getSignedValue() , getUnsignedValue()))
-
-int sVar = 0;
-if (getUnsignedValue() > sVar)
-return;
-// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 
'unsigned' integers [modernize-use-integer-sign-comparison]
-// CHECK-FIXES: if (std::cmp_greater(getUnsignedValue() , sVar))
-
-unsigned int uVar = 0;
-if (getSignedValue() > uVar)
-return;
-// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 
'unsigned' integers

[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature (PR #143422)

2025-06-12 Thread via llvm-branch-commits

https://github.com/joaosaffran edited 
https://github.com/llvm/llvm-project/pull/143422
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [HLSL] Add descriptor table metadata parsing (PR #142492)

2025-06-12 Thread via llvm-branch-commits

https://github.com/joaosaffran edited 
https://github.com/llvm/llvm-project/pull/142492
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] c4f257c - [llvm-rc] Allow ALT on non-virtkey accelerators (#143374)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

Author: Martin Storsjö
Date: 2025-06-12T11:43:08-07:00
New Revision: c4f257cb74b54c271bbff1649b71c40e8d8c50d8

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

LOG: [llvm-rc] Allow ALT on non-virtkey accelerators (#143374)

While
https://learn.microsoft.com/en-us/windows/win32/menurc/accelerators-resource
specifies that ALT only applies to virtkeys, this doesn't seem to be the
case in reality.

https://learn.microsoft.com/en-us/windows/win32/menurc/using-keyboard-accelerators
contains an example that uses this combination:

"B",   ID_ACCEL5, ALT   ; ALT_SHIFT+B

Also Microsoft also includes such cases in their repo of test cases:
https://github.com/microsoft/Windows-classic-samples/blob/263dd514ad215d0a40d1ec44b4df84b30ec11dcf/Samples/Win7Samples/begin/sdkdiff/sdkdiff.rc#L161-L164

Also MS rc.exe doesn't warn/error about this. However if applying SHIFT
or CONTROL on a non-virtkey accelerator, MS rc.exe does produce this
warning:

warning RC4203 : SHIFT or CONTROL used without VIRTKEY

Hence, keep the checks for SHIFT and CONTROL, but remove the checks for
ALT, which seems to have been incorrect.

This fixes one aspect of
https://github.com/llvm/llvm-project/issues/143157.

(cherry picked from commit 77347d6513de6a6f5dee8ade76e0a0ad1552c12b)

Added: 


Modified: 
llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc
llvm/test/tools/llvm-rc/tag-accelerators.test
llvm/tools/llvm-rc/ResourceFileWriter.cpp

Removed: 
llvm/test/tools/llvm-rc/Inputs/tag-accelerators-ascii-alt.rc



diff  --git a/llvm/test/tools/llvm-rc/Inputs/tag-accelerators-ascii-alt.rc 
b/llvm/test/tools/llvm-rc/Inputs/tag-accelerators-ascii-alt.rc
deleted file mode 100644
index 363263bfe4cf2..0
--- a/llvm/test/tools/llvm-rc/Inputs/tag-accelerators-ascii-alt.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-2 ACCELERATORS {
-  "A", 15, ASCII, ALT
-}
-

diff  --git a/llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc 
b/llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc
index 90e7f926cc087..bcfc35bdeab68 100644
--- a/llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc
+++ b/llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc
@@ -110,5 +110,6 @@ LANGUAGE 5, 1
   "7", 71, VIRTKEY, NOINVERT, CONTROL, SHIFT, ALT
   "^j", 72, ASCII
   "^j", 73, ASCII, NOINVERT
+  "A", 15, ASCII, ALT
 }
 

diff  --git a/llvm/test/tools/llvm-rc/tag-accelerators.test 
b/llvm/test/tools/llvm-rc/tag-accelerators.test
index 336727f617687..4f44aebc75011 100644
--- a/llvm/test/tools/llvm-rc/tag-accelerators.test
+++ b/llvm/test/tools/llvm-rc/tag-accelerators.test
@@ -37,7 +37,7 @@
 ; ACCELERATORS-NEXT: Version (major): 0
 ; ACCELERATORS-NEXT: Version (minor): 0
 ; ACCELERATORS-NEXT: Characteristics: 0
-; ACCELERATORS-NEXT: Data size: 592
+; ACCELERATORS-NEXT: Data size: 600
 ; ACCELERATORS-NEXT: Data: (
 ; ACCELERATORS-NEXT:   : 2A00  01002A00 0100  
|..*...*.|
 ; ACCELERATORS-NEXT:   0010: 02002A00 0200 03002A00 0300  
|..*...*.|
@@ -75,7 +75,8 @@
 ; ACCELERATORS-NEXT:   0210: 15003700 4200 0F003700 4300  
|..7.B.7.C...|
 ; ACCELERATORS-NEXT:   0220: 1B003700 4400 17003700 4500  
|..7.D.7.E...|
 ; ACCELERATORS-NEXT:   0230: 1D003700 4600 1F003700 4700  
|..7.F.7.G...|
-; ACCELERATORS-NEXT:   0240: 0A00 4800 82000A00 4900  
|H...I...|
+; ACCELERATORS-NEXT:   0240: 0A00 4800 02000A00 4900  
|H...I...|
+; ACCELERATORS-NEXT:   0250: 90004100 0F00|..A.|
 ; ACCELERATORS-NEXT: )
 
 
@@ -94,19 +95,13 @@
 ; RUN: not llvm-rc -no-preprocess /FO %t -- 
%p/Inputs/tag-accelerators-ascii-control.rc 2>&1 | FileCheck %s --check-prefix 
ASCII2
 
 ; ASCII2: llvm-rc: Error in ACCELERATORS statement (ID 2):
-; ASCII2-NEXT: Accelerator ID 15: Can only apply ALT, SHIFT or CONTROL to 
VIRTKEY accelerators
+; ASCII2-NEXT: Accelerator ID 15: Can only apply SHIFT or CONTROL to VIRTKEY 
accelerators
 
 
 ; RUN: not llvm-rc -no-preprocess /FO %t -- 
%p/Inputs/tag-accelerators-ascii-shift.rc 2>&1 | FileCheck %s --check-prefix 
ASCII3
 
 ; ASCII3: llvm-rc: Error in ACCELERATORS statement (ID 2):
-; ASCII3-NEXT: Accelerator ID 15: Can only apply ALT, SHIFT or CONTROL to 
VIRTKEY accelerators
-
-
-; RUN: not llvm-rc -no-preprocess /FO %t -- 
%p/Inputs/tag-accelerators-ascii-alt.rc 2>&1 | FileCheck %s --check-prefix 
ASCII4
-
-; ASCII4: llvm-rc: Error in ACCELERATORS statement (ID 2):
-; ASCII4-NEXT: Accelerator ID 15: Can only apply ALT, SHIFT or CONTROL to 
VIRTKEY accelerators
+; ASCII3-NEXT: Accelerator ID 15: Can only apply SHIFT or CONTROL to VIRTKEY 
accelerators
 
 
 ; RUN: not llvm-rc -no-preprocess /FO %t -- 
%p/Inputs/tag-accelerators-bad-key-id.rc 2>&1 | FileCheck %s --check-prefix 
BADKEYID

diff 

[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature and fix descriptor range flags (PR #143422)

2025-06-12 Thread Finn Plummer via llvm-branch-commits




inbelic wrote:

accidently included

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature and fix descriptor range flags (PR #143422)

2025-06-12 Thread Finn Plummer via llvm-branch-commits


@@ -456,6 +664,48 @@ static bool validate(LLVMContext *Ctx, const 
mcdxbc::RootSignatureDesc &RSD) {
 }
   }
 
+  for (const dxbc::RTS0::v1::StaticSampler &Sampler : RSD.StaticSamplers) {
+if (!verifySamplerFilter(Sampler.Filter))
+  return reportValueError(Ctx, "Filter", Sampler.Filter);
+
+if (!verifyAddress(Sampler.AddressU))

inbelic wrote:

One thought that just came up. I don't think it is required for us to early 
exit on all these verifications.

Maybe we can report all invalid errors in one go rather than exiting on the 
first one? Can you provide an argument for why or why not?

I would assume reporting all errors (so long as they aren't too verbose) 
reduces the number of compile cycles for the user to correct their input.

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature and fix descriptor range flags (PR #143422)

2025-06-12 Thread Finn Plummer via llvm-branch-commits


@@ -399,6 +486,127 @@ static bool verifyDescriptorRangeFlag(uint32_t Version, 
uint32_t Type,
   return false;
 }
 
+static bool verifySamplerFilter(uint32_t Filter) {
+  switch (Filter) {
+  case llvm::to_underlying(dxbc::StaticSamplerFilter::MIN_MAG_MIP_POINT):

inbelic wrote:

We might be able to use a similar `BitEnumMask` technique here?

Or just a `<=` comparison?

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


[llvm-branch-commits] [llvm] [RISCV] Support memcmp expansion for vectors (PR #114517)

2025-06-12 Thread via llvm-branch-commits


@@ -2952,5 +2952,22 @@ RISCVTTIImpl::enableMemCmpExpansion(bool OptSize, bool 
IsZeroCmp) const {
 Options.LoadSizes = {4, 2, 1};
 Options.AllowedTailExpansions = {3};
   }
+
+  if (IsZeroCmp && ST->hasVInstructions()) {
+unsigned RealMinVLen = ST->getRealMinVLen();
+// Support Fractional LMULs if the lengths are larger than XLen.
+// TODO: Support non-power-of-2 types.

hiraditya wrote:

Should we create a github ticket for this?

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


[llvm-branch-commits] [llvm] Fix compilation with GCC 15.1.1 (PR #143925)

2025-06-12 Thread via llvm-branch-commits

github-actions[bot] wrote:

This repository does not accept pull requests. Please follow 
http://llvm.org/docs/Contributing.html#how-to-submit-a-patch for contribution 
to LLVM.

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


[llvm-branch-commits] [llvm] Fix compilation with GCC 15.1.1 (PR #143925)

2025-06-12 Thread via llvm-branch-commits

https://github.com/github-actions[bot] closed 
https://github.com/llvm/llvm-project/pull/143925
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] Fix compilation with GCC 15.1.1 (PR #143925)

2025-06-12 Thread via llvm-branch-commits

https://github.com/github-actions[bot] locked 
https://github.com/llvm/llvm-project/pull/143925
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] Fix compilation with GCC 15.1.1 (PR #143925)

2025-06-12 Thread Johan Förberg via llvm-branch-commits

https://github.com/jforberg created 
https://github.com/llvm/llvm-project/pull/143925

Missing standard includes cause compilation to fail with recent compilers.

  In file included from llvm/lib/Support/ErrorHandling.cpp:16: 
llvm/include/llvm/ADT/SmallVector.h:88:69: error: ‘uint64_t’ was not declared 
in this scope
 88 | typename std::conditional= 8, 
uint64_t,

From c0566ee5e3954a59b697758e994f0af2cab3b7f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Johan=20F=C3=B6rberg?= 
Date: Thu, 12 Jun 2025 18:02:17 +0200
Subject: [PATCH] Fix compilation with GCC 15.1.1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Missing standard includes cause compilation to fail with recent
compilers.

  In file included from llvm/lib/Support/ErrorHandling.cpp:16: 
llvm/include/llvm/ADT/SmallVector.h:88:69: error: ‘uint64_t’ was not declared 
in this scope
 88 | typename std::conditional= 8, 
uint64_t,
---
 llvm/include/llvm/ADT/SmallVector.h  | 1 +
 llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h | 1 +
 llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h   | 1 +
 3 files changed, 3 insertions(+)

diff --git a/llvm/include/llvm/ADT/SmallVector.h 
b/llvm/include/llvm/ADT/SmallVector.h
index e34702bdbb3c1..1c0f3465b2a9e 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h 
b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h
index c2e2563c3989c..53aac89341009 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCTARGETDESC_H
 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCTARGETDESC_H
 
+#include 
 #include 
 
 namespace llvm {
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h 
b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
index d0530bd4d6505..10b59462aebe0 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
 #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
 
+#include 
 #include 
 #include 
 

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


[llvm-branch-commits] [libcxx] release/20.x: [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to flat_{, multi}map::value_compare (#137594) (PR #138880)

2025-06-12 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ldionne (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

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


[llvm-branch-commits] [libcxx] release/20.x: [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to flat_{, multi}map::value_compare (#137594) (PR #138880)

2025-06-12 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/138880

>From 337beb73abfe05c2db1158f211042eb8763165ea Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Wed, 7 May 2025 16:09:40 +0200
Subject: [PATCH] [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to
 flat_{,multi}map::value_compare (#137594)

This breaks the ABI of `flat_{,multi}map::value_compare`, but this type
has only been introduced in LLVM 20, so it should be very unlikely that
we break anybody if we back-port this now.

(cherry picked from commit ed0aa9961caa177098e9b7e69e98034d676f192e)
---
 libcxx/include/__flat_map/flat_map.h  | 2 +-
 libcxx/include/__flat_map/flat_multimap.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__flat_map/flat_map.h 
b/libcxx/include/__flat_map/flat_map.h
index a0594ed9dc411..9cc39c0a1e067 100644
--- a/libcxx/include/__flat_map/flat_map.h
+++ b/libcxx/include/__flat_map/flat_map.h
@@ -113,7 +113,7 @@ class flat_map {
 
   class value_compare {
   private:
-key_compare __comp_;
+_LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_;
 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
 friend flat_map;
 
diff --git a/libcxx/include/__flat_map/flat_multimap.h 
b/libcxx/include/__flat_map/flat_multimap.h
index ea77fb5d79bd2..15fcd7995ad0a 100644
--- a/libcxx/include/__flat_map/flat_multimap.h
+++ b/libcxx/include/__flat_map/flat_multimap.h
@@ -115,7 +115,7 @@ class flat_multimap {
 
   class value_compare {
   private:
-key_compare __comp_;
+_LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_;
 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
 friend flat_multimap;
 

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


[llvm-branch-commits] [libcxx] 337beb7 - [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to flat_{, multi}map::value_compare (#137594)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

Author: Nikolas Klauser
Date: 2025-06-12T11:29:59-07:00
New Revision: 337beb73abfe05c2db1158f211042eb8763165ea

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

LOG: [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to flat_{,multi}map::value_compare 
(#137594)

This breaks the ABI of `flat_{,multi}map::value_compare`, but this type
has only been introduced in LLVM 20, so it should be very unlikely that
we break anybody if we back-port this now.

(cherry picked from commit ed0aa9961caa177098e9b7e69e98034d676f192e)

Added: 


Modified: 
libcxx/include/__flat_map/flat_map.h
libcxx/include/__flat_map/flat_multimap.h

Removed: 




diff  --git a/libcxx/include/__flat_map/flat_map.h 
b/libcxx/include/__flat_map/flat_map.h
index a0594ed9dc411..9cc39c0a1e067 100644
--- a/libcxx/include/__flat_map/flat_map.h
+++ b/libcxx/include/__flat_map/flat_map.h
@@ -113,7 +113,7 @@ class flat_map {
 
   class value_compare {
   private:
-key_compare __comp_;
+_LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_;
 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
 friend flat_map;
 

diff  --git a/libcxx/include/__flat_map/flat_multimap.h 
b/libcxx/include/__flat_map/flat_multimap.h
index ea77fb5d79bd2..15fcd7995ad0a 100644
--- a/libcxx/include/__flat_map/flat_multimap.h
+++ b/libcxx/include/__flat_map/flat_multimap.h
@@ -115,7 +115,7 @@ class flat_multimap {
 
   class value_compare {
   private:
-key_compare __comp_;
+_LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_;
 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
 friend flat_multimap;
 



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


[llvm-branch-commits] [libcxx] release/20.x: [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to flat_{, multi}map::value_compare (#137594) (PR #138880)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/138880
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [llvm-rc] Allow ALT on non-virtkey accelerators (#143374) (PR #143496)

2025-06-12 Thread via llvm-branch-commits

https://github.com/llvmbot updated 
https://github.com/llvm/llvm-project/pull/143496

>From c4f257cb74b54c271bbff1649b71c40e8d8c50d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Tue, 10 Jun 2025 10:23:19 +0300
Subject: [PATCH] [llvm-rc] Allow ALT on non-virtkey accelerators (#143374)

While
https://learn.microsoft.com/en-us/windows/win32/menurc/accelerators-resource
specifies that ALT only applies to virtkeys, this doesn't seem to be the
case in reality.

https://learn.microsoft.com/en-us/windows/win32/menurc/using-keyboard-accelerators
contains an example that uses this combination:

"B",   ID_ACCEL5, ALT   ; ALT_SHIFT+B

Also Microsoft also includes such cases in their repo of test cases:
https://github.com/microsoft/Windows-classic-samples/blob/263dd514ad215d0a40d1ec44b4df84b30ec11dcf/Samples/Win7Samples/begin/sdkdiff/sdkdiff.rc#L161-L164

Also MS rc.exe doesn't warn/error about this. However if applying SHIFT
or CONTROL on a non-virtkey accelerator, MS rc.exe does produce this
warning:

warning RC4203 : SHIFT or CONTROL used without VIRTKEY

Hence, keep the checks for SHIFT and CONTROL, but remove the checks for
ALT, which seems to have been incorrect.

This fixes one aspect of
https://github.com/llvm/llvm-project/issues/143157.

(cherry picked from commit 77347d6513de6a6f5dee8ade76e0a0ad1552c12b)
---
 .../llvm-rc/Inputs/tag-accelerators-ascii-alt.rc  |  4 
 .../test/tools/llvm-rc/Inputs/tag-accelerators.rc |  1 +
 llvm/test/tools/llvm-rc/tag-accelerators.test | 15 +--
 llvm/tools/llvm-rc/ResourceFileWriter.cpp |  4 ++--
 4 files changed, 8 insertions(+), 16 deletions(-)
 delete mode 100644 llvm/test/tools/llvm-rc/Inputs/tag-accelerators-ascii-alt.rc

diff --git a/llvm/test/tools/llvm-rc/Inputs/tag-accelerators-ascii-alt.rc 
b/llvm/test/tools/llvm-rc/Inputs/tag-accelerators-ascii-alt.rc
deleted file mode 100644
index 363263bfe4cf2..0
--- a/llvm/test/tools/llvm-rc/Inputs/tag-accelerators-ascii-alt.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-2 ACCELERATORS {
-  "A", 15, ASCII, ALT
-}
-
diff --git a/llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc 
b/llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc
index 90e7f926cc087..bcfc35bdeab68 100644
--- a/llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc
+++ b/llvm/test/tools/llvm-rc/Inputs/tag-accelerators.rc
@@ -110,5 +110,6 @@ LANGUAGE 5, 1
   "7", 71, VIRTKEY, NOINVERT, CONTROL, SHIFT, ALT
   "^j", 72, ASCII
   "^j", 73, ASCII, NOINVERT
+  "A", 15, ASCII, ALT
 }
 
diff --git a/llvm/test/tools/llvm-rc/tag-accelerators.test 
b/llvm/test/tools/llvm-rc/tag-accelerators.test
index 336727f617687..4f44aebc75011 100644
--- a/llvm/test/tools/llvm-rc/tag-accelerators.test
+++ b/llvm/test/tools/llvm-rc/tag-accelerators.test
@@ -37,7 +37,7 @@
 ; ACCELERATORS-NEXT: Version (major): 0
 ; ACCELERATORS-NEXT: Version (minor): 0
 ; ACCELERATORS-NEXT: Characteristics: 0
-; ACCELERATORS-NEXT: Data size: 592
+; ACCELERATORS-NEXT: Data size: 600
 ; ACCELERATORS-NEXT: Data: (
 ; ACCELERATORS-NEXT:   : 2A00  01002A00 0100  
|..*...*.|
 ; ACCELERATORS-NEXT:   0010: 02002A00 0200 03002A00 0300  
|..*...*.|
@@ -75,7 +75,8 @@
 ; ACCELERATORS-NEXT:   0210: 15003700 4200 0F003700 4300  
|..7.B.7.C...|
 ; ACCELERATORS-NEXT:   0220: 1B003700 4400 17003700 4500  
|..7.D.7.E...|
 ; ACCELERATORS-NEXT:   0230: 1D003700 4600 1F003700 4700  
|..7.F.7.G...|
-; ACCELERATORS-NEXT:   0240: 0A00 4800 82000A00 4900  
|H...I...|
+; ACCELERATORS-NEXT:   0240: 0A00 4800 02000A00 4900  
|H...I...|
+; ACCELERATORS-NEXT:   0250: 90004100 0F00|..A.|
 ; ACCELERATORS-NEXT: )
 
 
@@ -94,19 +95,13 @@
 ; RUN: not llvm-rc -no-preprocess /FO %t -- 
%p/Inputs/tag-accelerators-ascii-control.rc 2>&1 | FileCheck %s --check-prefix 
ASCII2
 
 ; ASCII2: llvm-rc: Error in ACCELERATORS statement (ID 2):
-; ASCII2-NEXT: Accelerator ID 15: Can only apply ALT, SHIFT or CONTROL to 
VIRTKEY accelerators
+; ASCII2-NEXT: Accelerator ID 15: Can only apply SHIFT or CONTROL to VIRTKEY 
accelerators
 
 
 ; RUN: not llvm-rc -no-preprocess /FO %t -- 
%p/Inputs/tag-accelerators-ascii-shift.rc 2>&1 | FileCheck %s --check-prefix 
ASCII3
 
 ; ASCII3: llvm-rc: Error in ACCELERATORS statement (ID 2):
-; ASCII3-NEXT: Accelerator ID 15: Can only apply ALT, SHIFT or CONTROL to 
VIRTKEY accelerators
-
-
-; RUN: not llvm-rc -no-preprocess /FO %t -- 
%p/Inputs/tag-accelerators-ascii-alt.rc 2>&1 | FileCheck %s --check-prefix 
ASCII4
-
-; ASCII4: llvm-rc: Error in ACCELERATORS statement (ID 2):
-; ASCII4-NEXT: Accelerator ID 15: Can only apply ALT, SHIFT or CONTROL to 
VIRTKEY accelerators
+; ASCII3-NEXT: Accelerator ID 15: Can only apply SHIFT or CONTROL to VIRTKEY 
accelerators
 
 
 ; RUN: not llvm-rc -no-preprocess /FO %t -- 
%p/Inputs/tag-accelerators-bad-key-id.rc 2>&1 | FileCheck %s --check-prefix 
BADKEYID
diff --gi

[llvm-branch-commits] [clang] release/20.x: [clang] Don't evaluate the initializer of constexpr-unknown parameters. (#142498) (PR #142648)

2025-06-12 Thread via llvm-branch-commits

github-actions[bot] wrote:

@efriedma-quic (or anyone else). If you would like to add a note about this fix 
in the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

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


[llvm-branch-commits] [llvm] release/20.x: [llvm-rc] Allow ALT on non-virtkey accelerators (#143374) (PR #143496)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/143496
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] release/20.x: [llvm-rc] Allow ALT on non-virtkey accelerators (#143374) (PR #143496)

2025-06-12 Thread via llvm-branch-commits

github-actions[bot] wrote:

@mstorsjo (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

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


[llvm-branch-commits] [clang] release/20.x: [clang] Don't evaluate the initializer of constexpr-unknown parameters. (#142498) (PR #142648)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/142648

>From 6fa0cdf3720b8b9103f31009c089b56a9a176653 Mon Sep 17 00:00:00 2001
From: Eli Friedman 
Date: Tue, 3 Jun 2025 09:51:37 -0700
Subject: [PATCH] release/20.x: [clang] Don't evaluate the initializer of
 constexpr-unknown parameters. (#142498)

Backport 97885213bd4507b204b050c3cd570e365d21cc7d
---
 clang/lib/AST/ExprConstant.cpp |  7 ++-
 clang/test/SemaCXX/constant-expression-p2280r4.cpp | 12 
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index e0746f4532245..209b269122a8e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -3525,7 +3525,12 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const 
Expr *E,
   // should begin within the evaluation of E
   // Used to be C++20 [expr.const]p5.12.2:
   // ... its lifetime began within the evaluation of E;
-  if (isa(VD) && !AllowConstexprUnknown) {
+  if (isa(VD)) {
+if (AllowConstexprUnknown) {
+  Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);
+  return true;
+}
+
 // Assume parameters of a potential constant expression are usable in
 // constant expressions.
 if (!Info.checkingPotentialConstantExpression() ||
diff --git a/clang/test/SemaCXX/constant-expression-p2280r4.cpp 
b/clang/test/SemaCXX/constant-expression-p2280r4.cpp
index 87beeb4d3dc84..dbaebb81b93e8 100644
--- a/clang/test/SemaCXX/constant-expression-p2280r4.cpp
+++ b/clang/test/SemaCXX/constant-expression-p2280r4.cpp
@@ -200,3 +200,15 @@ int f() {
 return !get_value(); // contextually convert the function call 
result to bool
 }
 }
+
+namespace param_reference {
+  constexpr int arbitrary = -12345;
+  constexpr void f(const int &x = arbitrary) { // expected-note {{declared 
here}}
+constexpr const int &v1 = x; // expected-error {{must be initialized by a 
constant expression}} \
+// expected-note {{reference to 'x' is not a constant expression}}
+constexpr const int &v2 = (x, arbitrary); // expected-warning {{left 
operand of comma operator has no effect}}
+constexpr int v3 = x; // expected-error {{must be initialized by a 
constant expression}}
+static_assert(x==arbitrary); // expected-error {{static assertion 
expression is not an integral constant expression}}
+static_assert(&x - &x == 0);
+  }
+}

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


[llvm-branch-commits] [clang] 6fa0cdf - release/20.x: [clang] Don't evaluate the initializer of constexpr-unknown parameters. (#142498)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

Author: Eli Friedman
Date: 2025-06-12T11:41:13-07:00
New Revision: 6fa0cdf3720b8b9103f31009c089b56a9a176653

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

LOG: release/20.x: [clang] Don't evaluate the initializer of constexpr-unknown 
parameters. (#142498)

Backport 97885213bd4507b204b050c3cd570e365d21cc7d

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/constant-expression-p2280r4.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index e0746f4532245..209b269122a8e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -3525,7 +3525,12 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const 
Expr *E,
   // should begin within the evaluation of E
   // Used to be C++20 [expr.const]p5.12.2:
   // ... its lifetime began within the evaluation of E;
-  if (isa(VD) && !AllowConstexprUnknown) {
+  if (isa(VD)) {
+if (AllowConstexprUnknown) {
+  Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);
+  return true;
+}
+
 // Assume parameters of a potential constant expression are usable in
 // constant expressions.
 if (!Info.checkingPotentialConstantExpression() ||

diff  --git a/clang/test/SemaCXX/constant-expression-p2280r4.cpp 
b/clang/test/SemaCXX/constant-expression-p2280r4.cpp
index 87beeb4d3dc84..dbaebb81b93e8 100644
--- a/clang/test/SemaCXX/constant-expression-p2280r4.cpp
+++ b/clang/test/SemaCXX/constant-expression-p2280r4.cpp
@@ -200,3 +200,15 @@ int f() {
 return !get_value(); // contextually convert the function call 
result to bool
 }
 }
+
+namespace param_reference {
+  constexpr int arbitrary = -12345;
+  constexpr void f(const int &x = arbitrary) { // expected-note {{declared 
here}}
+constexpr const int &v1 = x; // expected-error {{must be initialized by a 
constant expression}} \
+// expected-note {{reference to 'x' is not a constant expression}}
+constexpr const int &v2 = (x, arbitrary); // expected-warning {{left 
operand of comma operator has no effect}}
+constexpr int v3 = x; // expected-error {{must be initialized by a 
constant expression}}
+static_assert(x==arbitrary); // expected-error {{static assertion 
expression is not an integral constant expression}}
+static_assert(&x - &x == 0);
+  }
+}



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


[llvm-branch-commits] [clang] release/20.x: [clang] Don't evaluate the initializer of constexpr-unknown parameters. (#142498) (PR #142648)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/142648
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] Release/20.x clangd modules (PR #143647)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar updated 
https://github.com/llvm/llvm-project/pull/143647

>From 02aec86e4d0d1740fd6ca5a01b3154938682910d Mon Sep 17 00:00:00 2001
From: fleeting-xx 
Date: Thu, 5 Jun 2025 20:33:11 -0500
Subject: [PATCH 1/2] [clangd] [Modules] Fix to correctly handle module
 dependencies (#142828)

This is a re-application of llvm/llvm-project#142090 without the unit
test changes. A subsequent PR will follow that adds a unit test for
module dependencies.

- Fix dangling string references in the return value of
getAllRequiredModules()
- Change a couple of calls in getOrBuildModuleFile() to use the loop
variable instead of the ModuleName parameter.
---
 clang-tools-extra/clangd/ModulesBuilder.cpp   | 18 ++--
 clang-tools-extra/clangd/ProjectModules.h |  2 +-
 .../clangd/ScanningProjectModules.cpp |  6 +-
 .../clangd/test/module_dependencies.test  | 96 +++
 4 files changed, 110 insertions(+), 12 deletions(-)
 create mode 100644 clang-tools-extra/clangd/test/module_dependencies.test

diff --git a/clang-tools-extra/clangd/ModulesBuilder.cpp 
b/clang-tools-extra/clangd/ModulesBuilder.cpp
index bee31fe51555e..2d2f0f6374486 100644
--- a/clang-tools-extra/clangd/ModulesBuilder.cpp
+++ b/clang-tools-extra/clangd/ModulesBuilder.cpp
@@ -360,9 +360,9 @@ void ModuleFileCache::remove(StringRef ModuleName) {
 /// Collect the directly and indirectly required module names for \param
 /// ModuleName in topological order. The \param ModuleName is guaranteed to
 /// be the last element in \param ModuleNames.
-llvm::SmallVector getAllRequiredModules(ProjectModules &MDB,
+llvm::SmallVector getAllRequiredModules(ProjectModules &MDB,
StringRef ModuleName) {
-  llvm::SmallVector ModuleNames;
+  llvm::SmallVector ModuleNames;
   llvm::StringSet<> ModuleNamesSet;
 
   auto VisitDeps = [&](StringRef ModuleName, auto Visitor) -> void {
@@ -373,7 +373,7 @@ llvm::SmallVector 
getAllRequiredModules(ProjectModules &MDB,
   if (ModuleNamesSet.insert(RequiredModuleName).second)
 Visitor(RequiredModuleName, Visitor);
 
-ModuleNames.push_back(ModuleName);
+ModuleNames.push_back(ModuleName.str());
   };
   VisitDeps(ModuleName, VisitDeps);
 
@@ -418,13 +418,13 @@ llvm::Error 
ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
   // Get Required modules in topological order.
   auto ReqModuleNames = getAllRequiredModules(MDB, ModuleName);
   for (llvm::StringRef ReqModuleName : ReqModuleNames) {
-if (BuiltModuleFiles.isModuleUnitBuilt(ModuleName))
+if (BuiltModuleFiles.isModuleUnitBuilt(ReqModuleName))
   continue;
 
 if (auto Cached = Cache.getModule(ReqModuleName)) {
   if (IsModuleFileUpToDate(Cached->getModuleFilePath(), BuiltModuleFiles,
TFS.view(std::nullopt))) {
-log("Reusing module {0} from {1}", ModuleName,
+log("Reusing module {0} from {1}", ReqModuleName,
 Cached->getModuleFilePath());
 BuiltModuleFiles.addModuleFile(std::move(Cached));
 continue;
@@ -432,14 +432,16 @@ llvm::Error 
ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
   Cache.remove(ReqModuleName);
 }
 
+std::string ReqFileName =
+MDB.getSourceForModuleName(ReqModuleName);
 llvm::Expected MF = buildModuleFile(
-ModuleName, ModuleUnitFileName, getCDB(), TFS, BuiltModuleFiles);
+ReqModuleName, ReqFileName, getCDB(), TFS, BuiltModuleFiles);
 if (llvm::Error Err = MF.takeError())
   return Err;
 
-log("Built module {0} to {1}", ModuleName, MF->getModuleFilePath());
+log("Built module {0} to {1}", ReqModuleName, MF->getModuleFilePath());
 auto BuiltModuleFile = std::make_shared(std::move(*MF));
-Cache.add(ModuleName, BuiltModuleFile);
+Cache.add(ReqModuleName, BuiltModuleFile);
 BuiltModuleFiles.addModuleFile(std::move(BuiltModuleFile));
   }
 
diff --git a/clang-tools-extra/clangd/ProjectModules.h 
b/clang-tools-extra/clangd/ProjectModules.h
index 48d52ac9deb89..5296508e0584d 100644
--- a/clang-tools-extra/clangd/ProjectModules.h
+++ b/clang-tools-extra/clangd/ProjectModules.h
@@ -42,7 +42,7 @@ class ProjectModules {
   llvm::unique_function;
 
   virtual std::vector getRequiredModules(PathRef File) = 0;
-  virtual PathRef
+  virtual std::string
   getSourceForModuleName(llvm::StringRef ModuleName,
  PathRef RequiredSrcFile = PathRef()) = 0;
 
diff --git a/clang-tools-extra/clangd/ScanningProjectModules.cpp 
b/clang-tools-extra/clangd/ScanningProjectModules.cpp
index e4dc11c1c2895..859aba3673dc4 100644
--- a/clang-tools-extra/clangd/ScanningProjectModules.cpp
+++ b/clang-tools-extra/clangd/ScanningProjectModules.cpp
@@ -66,7 +66,7 @@ class ModuleDependencyScanner {
   ///
   /// TODO: We should handle the case that there are multiple source files
   /// declaring the same module.
-  PathRef getSourceForModuleName(llvm::StringRef ModuleName) const;
+  std

[llvm-branch-commits] [clang-tools-extra] 199e02a - Disable clangd/test/module_dependencies.test on Windows

2025-06-12 Thread Tom Stellard via llvm-branch-commits

Author: Hans Wennborg
Date: 2025-06-12T11:45:14-07:00
New Revision: 199e02a3643318a16a0a7fdcc677ac55cf769fdb

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

LOG: Disable clangd/test/module_dependencies.test on Windows

The test fails (sometimes); see discussion on 
https://github.com/llvm/llvm-project/pull/142828

Added: 


Modified: 
clang-tools-extra/clangd/test/module_dependencies.test

Removed: 




diff  --git a/clang-tools-extra/clangd/test/module_dependencies.test 
b/clang-tools-extra/clangd/test/module_dependencies.test
index 1023b2363c9fa..79306a73da435 100644
--- a/clang-tools-extra/clangd/test/module_dependencies.test
+++ b/clang-tools-extra/clangd/test/module_dependencies.test
@@ -1,8 +1,7 @@
 # A smoke test to check that a simple dependency chain for modules can work.
 #
-# FIXME: This fails on the Windows ARM64 build server. Not entirely sure why 
as it has been tested on
-#an ARM64 Windows VM and appears to work there.
-# UNSUPPORTED: host=aarch64-pc-windows-msvc
+# FIXME: The test fails on Windows; see comments on 
https://github.com/llvm/llvm-project/pull/142828
+# UNSUPPORTED: system-windows
 #
 # RUN: rm -fr %t
 # RUN: mkdir -p %t



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


[llvm-branch-commits] [clang-tools-extra] Release/20.x clangd modules (PR #143647)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/143647
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] 02aec86 - [clangd] [Modules] Fix to correctly handle module dependencies (#142828)

2025-06-12 Thread Tom Stellard via llvm-branch-commits

Author: fleeting-xx
Date: 2025-06-12T11:45:14-07:00
New Revision: 02aec86e4d0d1740fd6ca5a01b3154938682910d

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

LOG: [clangd] [Modules] Fix to correctly handle module dependencies (#142828)

This is a re-application of llvm/llvm-project#142090 without the unit
test changes. A subsequent PR will follow that adds a unit test for
module dependencies.

- Fix dangling string references in the return value of
getAllRequiredModules()
- Change a couple of calls in getOrBuildModuleFile() to use the loop
variable instead of the ModuleName parameter.

Added: 
clang-tools-extra/clangd/test/module_dependencies.test

Modified: 
clang-tools-extra/clangd/ModulesBuilder.cpp
clang-tools-extra/clangd/ProjectModules.h
clang-tools-extra/clangd/ScanningProjectModules.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ModulesBuilder.cpp 
b/clang-tools-extra/clangd/ModulesBuilder.cpp
index bee31fe51555e..2d2f0f6374486 100644
--- a/clang-tools-extra/clangd/ModulesBuilder.cpp
+++ b/clang-tools-extra/clangd/ModulesBuilder.cpp
@@ -360,9 +360,9 @@ void ModuleFileCache::remove(StringRef ModuleName) {
 /// Collect the directly and indirectly required module names for \param
 /// ModuleName in topological order. The \param ModuleName is guaranteed to
 /// be the last element in \param ModuleNames.
-llvm::SmallVector getAllRequiredModules(ProjectModules &MDB,
+llvm::SmallVector getAllRequiredModules(ProjectModules &MDB,
StringRef ModuleName) {
-  llvm::SmallVector ModuleNames;
+  llvm::SmallVector ModuleNames;
   llvm::StringSet<> ModuleNamesSet;
 
   auto VisitDeps = [&](StringRef ModuleName, auto Visitor) -> void {
@@ -373,7 +373,7 @@ llvm::SmallVector 
getAllRequiredModules(ProjectModules &MDB,
   if (ModuleNamesSet.insert(RequiredModuleName).second)
 Visitor(RequiredModuleName, Visitor);
 
-ModuleNames.push_back(ModuleName);
+ModuleNames.push_back(ModuleName.str());
   };
   VisitDeps(ModuleName, VisitDeps);
 
@@ -418,13 +418,13 @@ llvm::Error 
ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
   // Get Required modules in topological order.
   auto ReqModuleNames = getAllRequiredModules(MDB, ModuleName);
   for (llvm::StringRef ReqModuleName : ReqModuleNames) {
-if (BuiltModuleFiles.isModuleUnitBuilt(ModuleName))
+if (BuiltModuleFiles.isModuleUnitBuilt(ReqModuleName))
   continue;
 
 if (auto Cached = Cache.getModule(ReqModuleName)) {
   if (IsModuleFileUpToDate(Cached->getModuleFilePath(), BuiltModuleFiles,
TFS.view(std::nullopt))) {
-log("Reusing module {0} from {1}", ModuleName,
+log("Reusing module {0} from {1}", ReqModuleName,
 Cached->getModuleFilePath());
 BuiltModuleFiles.addModuleFile(std::move(Cached));
 continue;
@@ -432,14 +432,16 @@ llvm::Error 
ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile(
   Cache.remove(ReqModuleName);
 }
 
+std::string ReqFileName =
+MDB.getSourceForModuleName(ReqModuleName);
 llvm::Expected MF = buildModuleFile(
-ModuleName, ModuleUnitFileName, getCDB(), TFS, BuiltModuleFiles);
+ReqModuleName, ReqFileName, getCDB(), TFS, BuiltModuleFiles);
 if (llvm::Error Err = MF.takeError())
   return Err;
 
-log("Built module {0} to {1}", ModuleName, MF->getModuleFilePath());
+log("Built module {0} to {1}", ReqModuleName, MF->getModuleFilePath());
 auto BuiltModuleFile = std::make_shared(std::move(*MF));
-Cache.add(ModuleName, BuiltModuleFile);
+Cache.add(ReqModuleName, BuiltModuleFile);
 BuiltModuleFiles.addModuleFile(std::move(BuiltModuleFile));
   }
 

diff  --git a/clang-tools-extra/clangd/ProjectModules.h 
b/clang-tools-extra/clangd/ProjectModules.h
index 48d52ac9deb89..5296508e0584d 100644
--- a/clang-tools-extra/clangd/ProjectModules.h
+++ b/clang-tools-extra/clangd/ProjectModules.h
@@ -42,7 +42,7 @@ class ProjectModules {
   llvm::unique_function;
 
   virtual std::vector getRequiredModules(PathRef File) = 0;
-  virtual PathRef
+  virtual std::string
   getSourceForModuleName(llvm::StringRef ModuleName,
  PathRef RequiredSrcFile = PathRef()) = 0;
 

diff  --git a/clang-tools-extra/clangd/ScanningProjectModules.cpp 
b/clang-tools-extra/clangd/ScanningProjectModules.cpp
index e4dc11c1c2895..859aba3673dc4 100644
--- a/clang-tools-extra/clangd/ScanningProjectModules.cpp
+++ b/clang-tools-extra/clangd/ScanningProjectModules.cpp
@@ -66,7 +66,7 @@ class ModuleDependencyScanner {
   ///
   /// TODO: We should handle the case that there are multiple source files
   /// declaring the same module.
-  PathRef getSourceForModuleName(llvm::StringRe

[llvm-branch-commits] [clang-tools-extra] Release/20.x clangd modules (PR #143647)

2025-06-12 Thread via llvm-branch-commits

github-actions[bot] wrote:

@ChuanqiXu9 (or anyone else). If you would like to add a note about this fix in 
the release notes (completely optional). Please reply to this comment with a 
one or two sentence description of the fix.  When you are done, please add the 
release:note label to this PR. 

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature (PR #143422)

2025-06-12 Thread via llvm-branch-commits




joaosaffran wrote:

Working on getting this out of the diff

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


[llvm-branch-commits] [llvm] [DirectX] Add static sampler support to root signature (PR #143422)

2025-06-12 Thread via llvm-branch-commits

https://github.com/joaosaffran edited 
https://github.com/llvm/llvm-project/pull/143422
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [RISCV] Support memcmp expansion for vectors (PR #114517)

2025-06-12 Thread via llvm-branch-commits

hiraditya wrote:

>  The range of supported load sizes is (XLEN, VLEN * LMUL8]

Is there a way for users to change this, depending on the platform users may 
want to expand memcmp's on larger sequences.

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


[llvm-branch-commits] [llvm] [RISCV] Support memcmp expansion for vectors (PR #114517)

2025-06-12 Thread Craig Topper via llvm-branch-commits

topperc wrote:

Please don't @ me in the commit message. Sometimes when this commit gets pulled 
into some other fork of llvm I'll get an email that I don't want.

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


[llvm-branch-commits] [llvm] [RISCV] Support memcmp expansion for vectors (PR #114517)

2025-06-12 Thread Craig Topper via llvm-branch-commits

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

LGTM

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


[llvm-branch-commits] [llvm] release/20.x: [RISCV] Fix assertion failure when using -fstack-clash-protection (#135248) (PR #139388)

2025-06-12 Thread Craig Topper via llvm-branch-commits

https://github.com/topperc updated 
https://github.com/llvm/llvm-project/pull/139388

>From ff4132ec328ed80be247856939dbf7345106cc55 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Fri, 18 Apr 2025 09:12:52 -0700
Subject: [PATCH 1/2] [RISCV] Fix assertion failure when using
 -fstack-clash-protection (#135248)

We can't assume MBBI is still pointing at MBB if we've already expanded
a probe. We need to re-query the MBB from MBBI. Fixes #135206

Co-authored-by: Craig Topper 
(cherry picked from commit b3d2dc321c5c78b7204696afe07fe6ef3375acfd)
---
 llvm/lib/Target/RISCV/RISCVFrameLowering.cpp |  8 +-
 llvm/test/CodeGen/RISCV/pr135206.ll  | 84 
 2 files changed, 89 insertions(+), 3 deletions(-)
 create mode 100644 llvm/test/CodeGen/RISCV/pr135206.ll

diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index bb2e5781c34db..6f4c1e16190f4 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -2135,11 +2135,13 @@ TargetStackID::Value 
RISCVFrameLowering::getStackIDForScalableVectors() const {
 }
 
 // Synthesize the probe loop.
-static void emitStackProbeInline(MachineFunction &MF, MachineBasicBlock &MBB,
- MachineBasicBlock::iterator MBBI, DebugLoc DL,
+static void emitStackProbeInline(MachineBasicBlock::iterator MBBI, DebugLoc DL,
  Register TargetReg, bool IsRVV) {
   assert(TargetReg != RISCV::X2 && "New top of stack cannot already be in SP");
 
+  MachineBasicBlock &MBB = *MBBI->getParent();
+  MachineFunction &MF = *MBB.getParent();
+
   auto &Subtarget = MF.getSubtarget();
   const RISCVInstrInfo *TII = Subtarget.getInstrInfo();
   bool IsRV64 = Subtarget.is64Bit();
@@ -2228,7 +2230,7 @@ void RISCVFrameLowering::inlineStackProbe(MachineFunction 
&MF,
   MachineBasicBlock::iterator MBBI = MI->getIterator();
   DebugLoc DL = MBB.findDebugLoc(MBBI);
   Register TargetReg = MI->getOperand(1).getReg();
-  emitStackProbeInline(MF, MBB, MBBI, DL, TargetReg,
+  emitStackProbeInline(MBBI, DL, TargetReg,
(MI->getOpcode() == RISCV::PROBED_STACKALLOC_RVV));
   MBBI->eraseFromParent();
 }
diff --git a/llvm/test/CodeGen/RISCV/pr135206.ll 
b/llvm/test/CodeGen/RISCV/pr135206.ll
new file mode 100644
index 0..196e78d8ed8b9
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/pr135206.ll
@@ -0,0 +1,84 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
+; RUN: llc -mtriple riscv64 < %s -o - | FileCheck %s
+
+%"buff" = type { [4096 x i64] }
+
+declare void @llvm.memset.p0.i64(ptr, i8, i64, i1)
+declare void @bar()
+
+define i1 @foo() nounwind "probe-stack"="inline-asm" "target-features"="+v" {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:addi sp, sp, -2032
+; CHECK-NEXT:sd ra, 2024(sp) # 8-byte Folded Spill
+; CHECK-NEXT:sd s0, 2016(sp) # 8-byte Folded Spill
+; CHECK-NEXT:sd s1, 2008(sp) # 8-byte Folded Spill
+; CHECK-NEXT:sd s2, 2000(sp) # 8-byte Folded Spill
+; CHECK-NEXT:sd s3, 1992(sp) # 8-byte Folded Spill
+; CHECK-NEXT:lui a0, 7
+; CHECK-NEXT:sub t1, sp, a0
+; CHECK-NEXT:lui t2, 1
+; CHECK-NEXT:  .LBB0_1: # =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:sub sp, sp, t2
+; CHECK-NEXT:sd zero, 0(sp)
+; CHECK-NEXT:bne sp, t1, .LBB0_1
+; CHECK-NEXT:  # %bb.2:
+; CHECK-NEXT:addi sp, sp, -2048
+; CHECK-NEXT:addi sp, sp, -96
+; CHECK-NEXT:csrr t1, vlenb
+; CHECK-NEXT:lui t2, 1
+; CHECK-NEXT:  .LBB0_3: # =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:sub sp, sp, t2
+; CHECK-NEXT:sd zero, 0(sp)
+; CHECK-NEXT:sub t1, t1, t2
+; CHECK-NEXT:bge t1, t2, .LBB0_3
+; CHECK-NEXT:  # %bb.4:
+; CHECK-NEXT:sub sp, sp, t1
+; CHECK-NEXT:li a0, 86
+; CHECK-NEXT:addi s0, sp, 48
+; CHECK-NEXT:addi s1, sp, 32
+; CHECK-NEXT:addi s2, sp, 16
+; CHECK-NEXT:lui a1, 353637
+; CHECK-NEXT:vsetivli zero, 16, e8, m1, ta, ma
+; CHECK-NEXT:vmv.v.x v8, a0
+; CHECK-NEXT:lui a0, 8
+; CHECK-NEXT:addiw a0, a0, 32
+; CHECK-NEXT:add a0, sp, a0
+; CHECK-NEXT:vs1r.v v8, (a0) # vscale x 8-byte Folded Spill
+; CHECK-NEXT:addiw a0, a1, 1622
+; CHECK-NEXT:vse8.v v8, (s0)
+; CHECK-NEXT:vse8.v v8, (s1)
+; CHECK-NEXT:vse8.v v8, (s2)
+; CHECK-NEXT:slli a1, a0, 32
+; CHECK-NEXT:add s3, a0, a1
+; CHECK-NEXT:sd s3, 64(sp)
+; CHECK-NEXT:call bar
+; CHECK-NEXT:lui a0, 8
+; CHECK-NEXT:addiw a0, a0, 32
+; CHECK-NEXT:add a0, sp, a0
+; CHECK-NEXT:vl1r.v v8, (a0) # vscale x 8-byte Folded Reload
+; CHECK-NEXT:vsetivli zero, 16, e8, m1, ta, ma
+; CHECK-NEXT:vse8.v v8, (s0)
+; CHECK-NEXT:vse8.v v8, (s1)
+; CHECK-NEXT:vse8.v v8, (s2)
+; CHECK-NEXT:sd s3, 64(sp)
+; CHECK-NEXT:li a0, 0
+; CHECK-NEXT:csrr a1, vlenb
+; CHECK-NEXT:add sp, sp, a1
+; CHECK-NEXT:

[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-12 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/143463


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


[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-12 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/143462


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


[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-12 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/143463


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


[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-12 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/143462


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


[llvm-branch-commits] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-12 Thread via llvm-branch-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 HEAD~1 HEAD --extensions cpp -- 
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 72a340925..e2dfcaae7 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4192,7 +4192,7 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
   void handleAVXVpermil2var(IntrinsicInst &I) {
 assert(I.arg_size() == 3);
 assert(I.getArgOperand(0)->getType() == I.getArgOperand(2)->getType());
-assert(I.getType() == I.getArgOperand(0)->getType() );
+assert(I.getType() == I.getArgOperand(0)->getType());
 assert(I.getArgOperand(1)->getType()->isIntOrIntVectorTy());
 IRBuilder<> IRB(&I);
 Value *AShadow = getShadow(&I, 0);

``




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


[llvm-branch-commits] [llvm] [MSAN] handle AVX vpermi2var (PR #143463)

2025-06-12 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/143463

>From dd6d9e4fa3dee83c1f42f62eb6342dfeb60184ee Mon Sep 17 00:00:00 2001
From: Florian Mayer 
Date: Thu, 12 Jun 2025 14:19:00 -0700
Subject: [PATCH] fmt

Created using spr 1.3.4
---
 llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 72a3409251204..e2dfcaae71ba9 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4192,7 +4192,7 @@ struct MemorySanitizerVisitor : public 
InstVisitor {
   void handleAVXVpermil2var(IntrinsicInst &I) {
 assert(I.arg_size() == 3);
 assert(I.getArgOperand(0)->getType() == I.getArgOperand(2)->getType());
-assert(I.getType() == I.getArgOperand(0)->getType() );
+assert(I.getType() == I.getArgOperand(0)->getType());
 assert(I.getArgOperand(1)->getType()->isIntOrIntVectorTy());
 IRBuilder<> IRB(&I);
 Value *AShadow = getShadow(&I, 0);

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


[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-12 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/143462


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


[llvm-branch-commits] [MSAN] handle assorted AVX permutations (PR #143462)

2025-06-12 Thread Florian Mayer via llvm-branch-commits

https://github.com/fmayer updated 
https://github.com/llvm/llvm-project/pull/143462


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


  1   2   >