[llvm-branch-commits] [libcxx] release/20.x: [libc++][test] Backport test skipping for Apple Clang 17 (PR #131506)

2025-03-16 Thread A. Jiang via llvm-branch-commits

https://github.com/frederick-vs-ja milestoned 
https://github.com/llvm/llvm-project/pull/131506
___
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++][test] Backport test skipping for Apple Clang 17 (PR #131506)

2025-03-16 Thread A. Jiang via llvm-branch-commits

https://github.com/frederick-vs-ja created 
https://github.com/llvm/llvm-project/pull/131506

Cherry-pick of b552e35a06aef4366a933ea85ad3d4bef71e586a and #131438 to 
release/20.x.

It is observed that Apple Clang 17 has started to be used for CI, even for 
backporting to release/20.x. So I think we should backport skipping to 
release/20.x to resolve CI failures.

>From bbb319c0bfa2f5a09532f73a9cd11f86acfc849d Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Thu, 30 Jan 2025 12:46:24 -0500
Subject: [PATCH 1/2] [libc++] Forward-proof some tests for AppleClang 17

---
 .../new.delete/new.delete.array/sized_delete_array.pass.cpp | 1 +
 .../new.delete/new.delete.single/sized_delete.pass.cpp  | 1 +
 libcxx/test/std/numerics/c.math/signbit.pass.cpp| 2 +-
 .../meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp| 2 +-
 .../meta.unary/meta.unary.prop/is_implicit_lifetime.verify.cpp  | 2 +-
 5 files changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
 
b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
index 1d763d6caba6a..01387feed67b6 100644
--- 
a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
+++ 
b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
@@ -14,6 +14,7 @@
 // ADDITIONAL_COMPILE_FLAGS(clang-18): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(apple-clang-15): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(apple-clang-16): -fsized-deallocation
+// ADDITIONAL_COMPILE_FLAGS(apple-clang-17): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(target=x86_64-w64-windows-gnu): 
-fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(target=i686-w64-windows-gnu): -fsized-deallocation
 
diff --git 
a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
 
b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
index 462037e53374b..06d3b0e5b3c35 100644
--- 
a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
+++ 
b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
@@ -14,6 +14,7 @@
 // ADDITIONAL_COMPILE_FLAGS(clang-18): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(apple-clang-15): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(apple-clang-16): -fsized-deallocation
+// ADDITIONAL_COMPILE_FLAGS(apple-clang-17): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(target=x86_64-w64-windows-gnu): 
-fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(target=i686-w64-windows-gnu): -fsized-deallocation
 
diff --git a/libcxx/test/std/numerics/c.math/signbit.pass.cpp 
b/libcxx/test/std/numerics/c.math/signbit.pass.cpp
index 143baf1fec941..b5e63dedf136e 100644
--- a/libcxx/test/std/numerics/c.math/signbit.pass.cpp
+++ b/libcxx/test/std/numerics/c.math/signbit.pass.cpp
@@ -12,7 +12,7 @@
 // UNSUPPORTED: windows
 
 // These compilers don't support constexpr `__builtin_signbit` yet.
-// UNSUPPORTED: clang-18, clang-19, apple-clang-15, apple-clang-16
+// UNSUPPORTED: clang-18, clang-19, apple-clang-15, apple-clang-16, 
apple-clang-17
 
 // XFAIL: FROZEN-CXX03-HEADERS-FIXME
 
diff --git 
a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
 
b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
index 24adec37431e7..681ad13a07dfd 100644
--- 
a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
+++ 
b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
@@ -9,7 +9,7 @@
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
 
 // These compilers don't support __builtin_is_implicit_lifetime yet.
-// UNSUPPORTED: clang-18, clang-19, gcc-14, apple-clang-15, apple-clang-16
+// UNSUPPORTED: clang-18, clang-19, gcc-14, apple-clang-15, apple-clang-16, 
apple-clang-17
 
 // 
 
diff --git 
a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.verify.cpp
 
b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.verify.cpp
index 4bcb10d0b7579..34462f9bf0ec6 100644
--- 
a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.verify.cpp
+++ 
b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.verify.cpp
@@ -9,7 +9,7 @@
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
 
 // These compilers don't support __builtin_is_implicit_lifetime yet.
-// UNSUPPORTED: clang-18, clang-19, gcc-14, apple-clang-15, apple-clang-16
+// UNSUPPORTED: clang-18, clang-19, gcc-14, apple-clang-15, apple-clang-16, 
apple-clang-17
 
 // 
 

>From d986fb74a21e735d72931093f27abc098831684f Mon Sep 17 00:00:00 2001
From: "A. Jian

[llvm-branch-commits] [libcxx] release/20.x: [libc++][test] Backport test skipping for Apple Clang 17 (PR #131506)

2025-03-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)


Changes

Cherry-pick of b552e35a06aef4366a933ea85ad3d4bef71e586a and #131438 to 
release/20.x.

It is observed that Apple Clang 17 has started to be used for CI, even for 
backporting to release/20.x. So I think we should backport skipping to 
release/20.x to resolve CI failures.

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


6 Files Affected:

- (modified) 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
 (+1) 
- (modified) 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
 (+1) 
- (modified) libcxx/test/std/numerics/c.math/signbit.pass.cpp (+1-1) 
- (modified) 
libcxx/test/std/utilities/meta/meta.rel/is_virtual_base_of.pass.cpp (+1-1) 
- (modified) 
libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
 (+1-1) 
- (modified) 
libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.verify.cpp
 (+1-1) 


``diff
diff --git 
a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
 
b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
index 1d763d6caba6a..01387feed67b6 100644
--- 
a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
+++ 
b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array.pass.cpp
@@ -14,6 +14,7 @@
 // ADDITIONAL_COMPILE_FLAGS(clang-18): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(apple-clang-15): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(apple-clang-16): -fsized-deallocation
+// ADDITIONAL_COMPILE_FLAGS(apple-clang-17): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(target=x86_64-w64-windows-gnu): 
-fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(target=i686-w64-windows-gnu): -fsized-deallocation
 
diff --git 
a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
 
b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
index 462037e53374b..06d3b0e5b3c35 100644
--- 
a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
+++ 
b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete.pass.cpp
@@ -14,6 +14,7 @@
 // ADDITIONAL_COMPILE_FLAGS(clang-18): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(apple-clang-15): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(apple-clang-16): -fsized-deallocation
+// ADDITIONAL_COMPILE_FLAGS(apple-clang-17): -fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(target=x86_64-w64-windows-gnu): 
-fsized-deallocation
 // ADDITIONAL_COMPILE_FLAGS(target=i686-w64-windows-gnu): -fsized-deallocation
 
diff --git a/libcxx/test/std/numerics/c.math/signbit.pass.cpp 
b/libcxx/test/std/numerics/c.math/signbit.pass.cpp
index 143baf1fec941..b5e63dedf136e 100644
--- a/libcxx/test/std/numerics/c.math/signbit.pass.cpp
+++ b/libcxx/test/std/numerics/c.math/signbit.pass.cpp
@@ -12,7 +12,7 @@
 // UNSUPPORTED: windows
 
 // These compilers don't support constexpr `__builtin_signbit` yet.
-// UNSUPPORTED: clang-18, clang-19, apple-clang-15, apple-clang-16
+// UNSUPPORTED: clang-18, clang-19, apple-clang-15, apple-clang-16, 
apple-clang-17
 
 // XFAIL: FROZEN-CXX03-HEADERS-FIXME
 
diff --git 
a/libcxx/test/std/utilities/meta/meta.rel/is_virtual_base_of.pass.cpp 
b/libcxx/test/std/utilities/meta/meta.rel/is_virtual_base_of.pass.cpp
index bcffa5812d04e..f443d2030961d 100644
--- a/libcxx/test/std/utilities/meta/meta.rel/is_virtual_base_of.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.rel/is_virtual_base_of.pass.cpp
@@ -9,7 +9,7 @@
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
 
 // These compilers don't support __builtin_is_virtual_base_of yet.
-// UNSUPPORTED: clang-18, clang-19, gcc-14, apple-clang-16
+// UNSUPPORTED: clang-18, clang-19, gcc-14, apple-clang-16, apple-clang-17
 
 // 
 
diff --git 
a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
 
b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
index 24adec37431e7..681ad13a07dfd 100644
--- 
a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
+++ 
b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
@@ -9,7 +9,7 @@
 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
 
 // These compilers don't support __builtin_is_implicit_lifetime yet.
-// UNSUPPORTED: clang-18, clang-19, gcc-14, apple-clang-15, apple-clang-16
+// UNSUPPORTED: clang-18, clang-19, gcc-14, apple-clang-15, apple-clang-16, 
apple-clang-17
 
 // 
 
diff --git 
a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_l

[llvm-branch-commits] [libcxx] release/20.x: [libcxx] Add a missing include for __bit_iterator (#127015) (PR #131382)

2025-03-16 Thread A. Jiang via llvm-branch-commits

https://github.com/frederick-vs-ja approved this pull request.

LGTM. I opened #131506 for resolving CI failures with Apple Clang 17, perhaps 
that patch should be backported first.

https://github.com/llvm/llvm-project/pull/131382
___
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] [mlir] [mlir] Use `getSingleElement`/`hasSingleElement` in various places (PR #131460)

2025-03-16 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer edited 
https://github.com/llvm/llvm-project/pull/131460
___
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] [mlir] [mlir] Use `getSingleElement`/`hasSingleElement` in various places (PR #131460)

2025-03-16 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 d781ac1cf0d561b79f6ff834d786c6a999429901 
62173153f73910cdb2023700badeb27d5633c724 --extensions cpp,h -- 
llvm/include/llvm/ADT/STLExtras.h llvm/unittests/ADT/STLExtrasTest.cpp 
mlir/include/mlir/Dialect/CommonFolders.h mlir/lib/Analysis/SliceAnalysis.cpp 
mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp 
mlir/lib/Conversion/GPUToSPIRV/WmmaOpsToSPIRV.cpp 
mlir/lib/Conversion/MeshToMPI/MeshToMPI.cpp 
mlir/lib/Dialect/Affine/IR/AffineOps.cpp 
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp 
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp 
mlir/lib/Dialect/Linalg/Transforms/SubsetInsertionOpInterfaceImpl.cpp 
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp 
mlir/lib/Dialect/Quant/Transforms/StripFuncQuantTypes.cpp 
mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp 
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp 
mlir/lib/Dialect/SCF/Utils/Utils.cpp 
mlir/lib/Dialect/Shape/Transforms/BufferizableOpInterfaceImpl.cpp 
mlir/lib/Dialect/SparseTensor/Transforms/SparseIterationToScf.cpp 
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp 
mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp 
mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.cpp 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp 
mlir/test/lib/Analysis/TestCFGLoopInfo.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/unittests/ADT/STLExtrasTest.cpp 
b/llvm/unittests/ADT/STLExtrasTest.cpp
index df8c0a4e48..d476710957 100644
--- a/llvm/unittests/ADT/STLExtrasTest.cpp
+++ b/llvm/unittests/ADT/STLExtrasTest.cpp
@@ -1025,7 +1025,7 @@ TEST(STLExtrasTest, getSingleElement) {
   std::vector V2 = {8};
   EXPECT_EQ(getSingleElement(V2), 8);
 
-  SmallVector V3 {9};
+  SmallVector V3{9};
   EXPECT_EQ(getSingleElement(V3), 9);
 
   std::list L1 = {10};
diff --git a/mlir/lib/Conversion/MeshToMPI/MeshToMPI.cpp 
b/mlir/lib/Conversion/MeshToMPI/MeshToMPI.cpp
index 3339199588..87c2938e4e 100644
--- a/mlir/lib/Conversion/MeshToMPI/MeshToMPI.cpp
+++ b/mlir/lib/Conversion/MeshToMPI/MeshToMPI.cpp
@@ -769,17 +769,18 @@ struct ConvertMeshToMPIPass
 typeConverter.addConversion([](Type type) { return type; });
 
 // convert mesh::ShardingType to a tuple of RankedTensorTypes
-typeConverter.addConversion([](ShardingType type,
-   SmallVectorImpl &results)
--> std::optional {
-  auto i16 = IntegerType::get(type.getContext(), 16);
-  auto i64 = IntegerType::get(type.getContext(), 64);
-  std::array shp = {ShapedType::kDynamic, 
ShapedType::kDynamic};
-  results.emplace_back(RankedTensorType::get(shp, i16));
-  results.emplace_back(RankedTensorType::get(shp, i64)); // actually ?x2
-  results.emplace_back(RankedTensorType::get(shp, i64));
-  return success();
-});
+typeConverter.addConversion(
+[](ShardingType type,
+   SmallVectorImpl &results) -> std::optional {
+  auto i16 = IntegerType::get(type.getContext(), 16);
+  auto i64 = IntegerType::get(type.getContext(), 64);
+  std::array shp = {ShapedType::kDynamic,
+ShapedType::kDynamic};
+  results.emplace_back(RankedTensorType::get(shp, i16));
+  results.emplace_back(RankedTensorType::get(shp, i64)); // actually 
?x2
+  results.emplace_back(RankedTensorType::get(shp, i64));
+  return success();
+});
 
 // To 'extract' components, a UnrealizedConversionCastOp is expected
 // to define the input

``




https://github.com/llvm/llvm-project/pull/131460
___
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] [mlir] [mlir] Use `getSingleElement`/`hasSingleElement` in various places (PR #131460)

2025-03-16 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer edited 
https://github.com/llvm/llvm-project/pull/131460
___
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] [mlir] [mlir] Use `getSingleElement`/`hasSingleElement` in various places (PR #131460)

2025-03-16 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer updated 
https://github.com/llvm/llvm-project/pull/131460

>From cacf322a8476879786076c2537363b8ac4af6d57 Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Sat, 15 Mar 2025 16:45:53 +0100
Subject: [PATCH] [llvm] Add `getSingleElement` helper and use in MLIR

---
 mlir/include/mlir/Dialect/CommonFolders.h |  6 ++--
 mlir/lib/Analysis/SliceAnalysis.cpp   |  2 +-
 .../Conversion/ArithToSPIRV/ArithToSPIRV.cpp  |  3 +-
 .../Conversion/GPUToSPIRV/WmmaOpsToSPIRV.cpp  |  6 ++--
 mlir/lib/Conversion/MeshToMPI/MeshToMPI.cpp   | 29 +--
 mlir/lib/Dialect/Affine/IR/AffineOps.cpp  |  6 ++--
 .../Dialect/Affine/Transforms/LoopFusion.cpp  |  3 +-
 mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp   |  6 ++--
 .../SubsetInsertionOpInterfaceImpl.cpp| 13 -
 mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp  |  2 +-
 .../Quant/Transforms/StripFuncQuantTypes.cpp  |  4 +--
 .../BufferizableOpInterfaceImpl.cpp   |  2 +-
 .../Transforms/StructuralTypeConversions.cpp  | 15 --
 mlir/lib/Dialect/SCF/Utils/Utils.cpp  |  6 ++--
 .../BufferizableOpInterfaceImpl.cpp   |  4 +--
 .../Transforms/SparseIterationToScf.cpp   | 12 ++--
 .../Transforms/SparseTensorCodegen.cpp| 16 --
 .../Transforms/Sparsification.cpp |  5 ++--
 .../Transforms/Utils/SparseTensorIterator.cpp | 13 +++--
 .../OpenMP/OpenMPToLLVMIRTranslation.cpp  |  3 +-
 mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp   |  3 +-
 mlir/test/lib/Analysis/TestCFGLoopInfo.cpp|  2 +-
 22 files changed, 59 insertions(+), 102 deletions(-)

diff --git a/mlir/include/mlir/Dialect/CommonFolders.h 
b/mlir/include/mlir/Dialect/CommonFolders.h
index 6f497a259262a..b5a12426aff80 100644
--- a/mlir/include/mlir/Dialect/CommonFolders.h
+++ b/mlir/include/mlir/Dialect/CommonFolders.h
@@ -196,8 +196,7 @@ template (ElementValueT)>>
 Attribute constFoldUnaryOpConditional(ArrayRef operands,
   CalculationT &&calculate) {
-  assert(operands.size() == 1 && "unary op takes one operands");
-  if (!operands[0])
+  if (!llvm::getSingleElement(operands))
 return {};
 
   static_assert(
@@ -268,8 +267,7 @@ template <
 class CalculationT = function_ref>
 Attribute constFoldCastOp(ArrayRef operands, Type resType,
   CalculationT &&calculate) {
-  assert(operands.size() == 1 && "Cast op takes one operand");
-  if (!operands[0])
+  if (!llvm::getSingleElement(operands))
 return {};
 
   static_assert(
diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp 
b/mlir/lib/Analysis/SliceAnalysis.cpp
index 8803ba994b2c1..e01cb3a080b5c 100644
--- a/mlir/lib/Analysis/SliceAnalysis.cpp
+++ b/mlir/lib/Analysis/SliceAnalysis.cpp
@@ -107,7 +107,7 @@ static void getBackwardSliceImpl(Operation *op,
   // into us. For now, just bail.
   if (parentOp && backwardSlice->count(parentOp) == 0) {
 assert(parentOp->getNumRegions() == 1 &&
-   parentOp->getRegion(0).getBlocks().size() == 1);
+   llvm::hasSingleElement(parentOp->getRegion(0).getBlocks()));
 getBackwardSliceImpl(parentOp, backwardSlice, options);
   }
 } else {
diff --git a/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp 
b/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
index 1f2781aa82114..9c4dfa27b1447 100644
--- a/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
+++ b/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
@@ -834,8 +834,7 @@ struct TypeCastingOpPattern final : public 
OpConversionPattern {
   LogicalResult
   matchAndRewrite(Op op, typename Op::Adaptor adaptor,
   ConversionPatternRewriter &rewriter) const override {
-assert(adaptor.getOperands().size() == 1);
-Type srcType = adaptor.getOperands().front().getType();
+Type srcType = llvm::getSingleElement(adaptor.getOperands()).getType();
 Type dstType = this->getTypeConverter()->convertType(op.getType());
 if (!dstType)
   return getTypeConversionFailure(rewriter, op);
diff --git a/mlir/lib/Conversion/GPUToSPIRV/WmmaOpsToSPIRV.cpp 
b/mlir/lib/Conversion/GPUToSPIRV/WmmaOpsToSPIRV.cpp
index 1b0f023527891..df2da138d3b52 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/WmmaOpsToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/WmmaOpsToSPIRV.cpp
@@ -101,8 +101,7 @@ struct WmmaConstantOpToSPIRVLowering final
   LogicalResult
   matchAndRewrite(gpu::SubgroupMmaConstantMatrixOp op, OpAdaptor adaptor,
   ConversionPatternRewriter &rewriter) const override {
-assert(adaptor.getOperands().size() == 1);
-Value cst = adaptor.getOperands().front();
+Value cst = llvm::getSingleElement(adaptor.getOperands());
 auto coopType = getTypeConverter()->convertType(op.getType());
 if (!coopType)
   return rewriter.notifyMatchFailure(op, "type conversion failed");
@@ -181,8 +180,7 @@ struct WmmaElementwiseOpToSPIRVScalarMulLowering final
  "sp

[llvm-branch-commits] [libcxx] [libc++][format] Implements P3107R5 in . (PR #130500)

2025-03-16 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/130500

>From c132aa555a38efde9b04c2a3f435ba598778c28d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 30 Mar 2024 17:35:56 +0100
Subject: [PATCH 1/3] [libc++][format] Implements P3107R5 in .

The followup paper P3235R3 which is voted in as a DR changes the names
foo_locking to foo_buffered. These changes have been applied in this
patch.

Before
---
Benchmark Time CPU   Iterations
---
printf 71.3 ns 71.3 ns  9525175
print_string226 ns  226 ns  3105850
print_stack 232 ns  232 ns  3026498
print_direct530 ns  530 ns  1318447

After
---
Benchmark Time CPU   Iterations
---
printf 70.6 ns 70.6 ns  9789585
print_string222 ns  222 ns  3147678
print_stack 227 ns  227 ns  3084767
print_direct474 ns  474 ns  1472786

Note: The performance of libc++'s std::print is still extemely slow
compared to printf. Based on P3107R5 std::print should outperform
printf. The main culprit is the call to isatty, which is resolved
after implementing
LWG4044  Confusing requirements for std::print on POSIX platforms

Implements
- P3107R5 - Permit an efficient implementation of ``std::print``

Implements parts of
- P3235R3 std::print more types faster with less memory

Fixes: #105435
---
 libcxx/docs/ReleaseNotes/21.rst   |   1 +
 libcxx/include/__format/buffer.h  |   3 +
 libcxx/include/print  | 270 +-
 libcxx/modules/std/print.inc  |   1 +
 .../test/libcxx/system_reserved_names.gen.py  |   5 +
 .../test/libcxx/transitive_includes/cxx03.csv |   5 +
 .../test/libcxx/transitive_includes/cxx11.csv |   5 +
 .../test/libcxx/transitive_includes/cxx14.csv |   5 +
 .../test/libcxx/transitive_includes/cxx17.csv |   5 +
 .../test/libcxx/transitive_includes/cxx23.csv |   5 +-
 .../test/libcxx/transitive_includes/cxx26.csv |   4 +
 11 files changed, 296 insertions(+), 13 deletions(-)

diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst
index e7cfa625a132c..a1f30b26c5a1d 100644
--- a/libcxx/docs/ReleaseNotes/21.rst
+++ b/libcxx/docs/ReleaseNotes/21.rst
@@ -40,6 +40,7 @@ Implemented Papers
 
 - N4258: Cleaning-up noexcept in the Library (`Github 
`__)
 - P1361R2: Integration of chrono with text formatting (`Github 
`__)
+- P3107R5 - Permit an efficient implementation of ``std::print`` (`Github 
`__)
 
 Improvements and New Features
 -
diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h
index c88b7f3222010..d6e4ddc840e2d 100644
--- a/libcxx/include/__format/buffer.h
+++ b/libcxx/include/__format/buffer.h
@@ -12,6 +12,7 @@
 
 #include <__algorithm/copy_n.h>
 #include <__algorithm/fill_n.h>
+#include <__algorithm/for_each.h>
 #include <__algorithm/max.h>
 #include <__algorithm/min.h>
 #include <__algorithm/ranges_copy.h>
@@ -34,11 +35,13 @@
 #include <__memory/construct_at.h>
 #include <__memory/destroy.h>
 #include <__memory/uninitialized_algorithms.h>
+#include <__system_error/system_error.h>
 #include <__type_traits/add_pointer.h>
 #include <__type_traits/conditional.h>
 #include <__utility/exception_guard.h>
 #include <__utility/move.h>
 #include 
+#include  // Uses the POSIX/Windows unlocked stream I/O
 #include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/print b/libcxx/include/print
index 1794d6014efcd..f6d03edfbd4bc 100644
--- a/libcxx/include/print
+++ b/libcxx/include/print
@@ -27,9 +27,11 @@ namespace std {
 
   void vprint_unicode(string_view fmt, format_args args);
   void vprint_unicode(FILE* stream, string_view fmt, format_args args);
+  void vprint_unicode_buffered(FILE* stream, string_view fmt, format_args 
args);
 
   void vprint_nonunicode(string_view fmt, format_args args);
   void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
+  void vprint_nonunicode_buffered(FILE* stream, string_view fmt, format_args 
args);
 }
 */
 
@@ -41,6 +43,7 @@ namespace std {
 #  include <__config>
 #  include <__system_error/throw_system_error.h>
 #  include <__utility/forward.h>
+#  include <__utility/move.h>
 #  include 
 #  include 
 #  include 
@@ -52,6 +55,9 @@ namespace std {
 #pragma GCC system_header
 #  endif
 
+_LIBCPP_PUSH_MACROS
+#  include <__undef_macros>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #  ifdef _LIBCPP_WIN32API
@@ -213,6 +219,122 @@ _LIBCPP_HIDE_FROM_ABI inline

[llvm-branch-commits] [clang] Backport: [clang] fix matching of nested template template parameters (PR #130950)

2025-03-16 Thread Mike Lothian via llvm-branch-commits

FireBurn wrote:

Thanks, that was a big help https://github.com/llvm/llvm-project/issues/131520 
now raised

https://github.com/llvm/llvm-project/pull/130950
___
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] [mlir] [mlir] Use `getSingleElement`/`hasSingleElement` in various places (PR #131460)

2025-03-16 Thread Jakub Kuderski via llvm-branch-commits

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

LGTM % formatting

https://github.com/llvm/llvm-project/pull/131460
___
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] Support image_bvh8_intersect_ray instruction and intrinsic. (PR #130041)

2025-03-16 Thread Mariusz Sikora via llvm-branch-commits

https://github.com/mariusz-sikora-at-amd updated 
https://github.com/llvm/llvm-project/pull/130041

>From b62b5fb5137585872f7a10950bc08f28383e3eea Mon Sep 17 00:00:00 2001
From: Ivan Kosarev 
Date: Mon, 3 Mar 2025 05:34:48 -0500
Subject: [PATCH 1/3] [AMDGPU] Support image_bvh8_intersect_ray instruction and
 intrinsic.

---
 llvm/include/llvm/IR/IntrinsicsAMDGPU.td  | 11 +++
 .../AMDGPU/AMDGPUInstructionSelector.cpp  |  1 +
 .../lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 21 +++--
 llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h  |  3 +-
 .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp  | 18 ++--
 llvm/lib/Target/AMDGPU/MIMGInstructions.td| 32 ---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 16 ++--
 llvm/lib/Target/AMDGPU/SIInstructions.td  |  8 ++
 .../AMDGPU/llvm.amdgcn.bvh8_intersect_ray.ll  | 87 +++
 llvm/test/MC/AMDGPU/gfx12_asm_vimage.s|  3 +
 llvm/test/MC/AMDGPU/gfx12_asm_vimage_alias.s  |  3 +
 .../Disassembler/AMDGPU/gfx12_dasm_vimage.txt |  3 +
 12 files changed, 171 insertions(+), 35 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/llvm.amdgcn.bvh8_intersect_ray.ll

diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index a1cfcfa8e67d6..33aca93735074 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -2812,6 +2812,17 @@ def int_amdgcn_image_bvh_dual_intersect_ray :
  llvm_v3f32_ty, llvm_v2i32_ty, llvm_v4i32_ty],
 [IntrReadMem, IntrWillReturn, IntrNoCallback, IntrNoFree]>;
 
+// , , 
+//   llvm.amdgcn.image.bvh8.intersect.ray , ,
+//, ,
+//, ,
+//
+def int_amdgcn_image_bvh8_intersect_ray :
+  Intrinsic<[llvm_v10i32_ty, llvm_v3f32_ty, llvm_v3f32_ty],
+[llvm_i64_ty, llvm_float_ty, llvm_i8_ty, llvm_v3f32_ty,
+ llvm_v3f32_ty, llvm_i32_ty, llvm_v4i32_ty],
+[IntrReadMem, IntrWillReturn]>;
+
 // llvm.amdgcn.permlane16.var 
 def int_amdgcn_permlane16_var : 
ClangBuiltin<"__builtin_amdgcn_permlane16_var">,
   Intrinsic<[llvm_i32_ty],
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index 0f9096d4cec5b..20abe4bc77dd1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -4101,6 +4101,7 @@ bool AMDGPUInstructionSelector::select(MachineInstr &I) {
   }
   case AMDGPU::G_AMDGPU_BVH_DUAL_INTERSECT_RAY:
   case AMDGPU::G_AMDGPU_BVH_INTERSECT_RAY:
+  case AMDGPU::G_AMDGPU_BVH8_INTERSECT_RAY:
 return selectBVHIntersectRayIntrinsic(I);
   case AMDGPU::G_SBFX:
   case AMDGPU::G_UBFX:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
index 03d75d006c982..761770ebe1c20 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
@@ -7183,8 +7183,8 @@ bool 
AMDGPULegalizerInfo::legalizeBVHIntersectRayIntrinsic(
   return true;
 }
 
-bool AMDGPULegalizerInfo::legalizeBVHDualIntrinsic(MachineInstr &MI,
-   MachineIRBuilder &B) const {
+bool AMDGPULegalizerInfo::legalizeBVHDualOrBVH8IntersectRayIntrinsic(
+MachineInstr &MI, MachineIRBuilder &B) const {
   const LLT S32 = LLT::scalar(32);
   const LLT V2S32 = LLT::fixed_vector(2, 32);
 
@@ -7207,17 +7207,21 @@ bool 
AMDGPULegalizerInfo::legalizeBVHDualIntrinsic(MachineInstr &MI,
 return false;
   }
 
+  bool IsBVH8 = cast(MI).getIntrinsicID() ==
+Intrinsic::amdgcn_image_bvh8_intersect_ray;
   const unsigned NumVDataDwords = 10;
-  const unsigned NumVAddrDwords = 12;
-  int Opcode = AMDGPU::getMIMGOpcode(AMDGPU::IMAGE_BVH_DUAL_INTERSECT_RAY,
- AMDGPU::MIMGEncGfx12, NumVDataDwords,
- NumVAddrDwords);
+  const unsigned NumVAddrDwords = IsBVH8 ? 11 : 12;
+  int Opcode = AMDGPU::getMIMGOpcode(
+  IsBVH8 ? AMDGPU::IMAGE_BVH8_INTERSECT_RAY
+ : AMDGPU::IMAGE_BVH_DUAL_INTERSECT_RAY,
+  AMDGPU::MIMGEncGfx12, NumVDataDwords, NumVAddrDwords);
   assert(Opcode != -1);
 
   auto RayExtentInstanceMaskVec = B.buildMergeLikeInstr(
   V2S32, {RayExtent, B.buildAnyExt(S32, InstanceMask)});
 
-  B.buildInstr(AMDGPU::G_AMDGPU_BVH_DUAL_INTERSECT_RAY)
+  B.buildInstr(IsBVH8 ? AMDGPU::G_AMDGPU_BVH8_INTERSECT_RAY
+  : AMDGPU::G_AMDGPU_BVH_DUAL_INTERSECT_RAY)
   .addDef(DstReg)
   .addDef(DstOrigin)
   .addDef(DstDir)
@@ -7583,7 +7587,8 @@ bool 
AMDGPULegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper,
   case Intrinsic::amdgcn_image_bvh_intersect_ray:
 return legalizeBVHIntersectRayIntrinsic(MI, B);
   case Intrinsic::amdgcn_image_bvh_dual_intersect_ray:
-return legalizeBVHDualIntrinsic(MI, B);
+  c

[llvm-branch-commits] [libcxx] release/20.x: [libc++][test] Backport test skipping for Apple Clang 17 (PR #131506)

2025-03-16 Thread Ian Anderson via llvm-branch-commits

https://github.com/ian-twilightcoder approved this pull request.


https://github.com/llvm/llvm-project/pull/131506
___
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] [libc++][format] Implements P3107R5 in . (PR #130500)

2025-03-16 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/130500

>From c132aa555a38efde9b04c2a3f435ba598778c28d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 30 Mar 2024 17:35:56 +0100
Subject: [PATCH 1/3] [libc++][format] Implements P3107R5 in .

The followup paper P3235R3 which is voted in as a DR changes the names
foo_locking to foo_buffered. These changes have been applied in this
patch.

Before
---
Benchmark Time CPU   Iterations
---
printf 71.3 ns 71.3 ns  9525175
print_string226 ns  226 ns  3105850
print_stack 232 ns  232 ns  3026498
print_direct530 ns  530 ns  1318447

After
---
Benchmark Time CPU   Iterations
---
printf 70.6 ns 70.6 ns  9789585
print_string222 ns  222 ns  3147678
print_stack 227 ns  227 ns  3084767
print_direct474 ns  474 ns  1472786

Note: The performance of libc++'s std::print is still extemely slow
compared to printf. Based on P3107R5 std::print should outperform
printf. The main culprit is the call to isatty, which is resolved
after implementing
LWG4044  Confusing requirements for std::print on POSIX platforms

Implements
- P3107R5 - Permit an efficient implementation of ``std::print``

Implements parts of
- P3235R3 std::print more types faster with less memory

Fixes: #105435
---
 libcxx/docs/ReleaseNotes/21.rst   |   1 +
 libcxx/include/__format/buffer.h  |   3 +
 libcxx/include/print  | 270 +-
 libcxx/modules/std/print.inc  |   1 +
 .../test/libcxx/system_reserved_names.gen.py  |   5 +
 .../test/libcxx/transitive_includes/cxx03.csv |   5 +
 .../test/libcxx/transitive_includes/cxx11.csv |   5 +
 .../test/libcxx/transitive_includes/cxx14.csv |   5 +
 .../test/libcxx/transitive_includes/cxx17.csv |   5 +
 .../test/libcxx/transitive_includes/cxx23.csv |   5 +-
 .../test/libcxx/transitive_includes/cxx26.csv |   4 +
 11 files changed, 296 insertions(+), 13 deletions(-)

diff --git a/libcxx/docs/ReleaseNotes/21.rst b/libcxx/docs/ReleaseNotes/21.rst
index e7cfa625a132c..a1f30b26c5a1d 100644
--- a/libcxx/docs/ReleaseNotes/21.rst
+++ b/libcxx/docs/ReleaseNotes/21.rst
@@ -40,6 +40,7 @@ Implemented Papers
 
 - N4258: Cleaning-up noexcept in the Library (`Github 
`__)
 - P1361R2: Integration of chrono with text formatting (`Github 
`__)
+- P3107R5 - Permit an efficient implementation of ``std::print`` (`Github 
`__)
 
 Improvements and New Features
 -
diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h
index c88b7f3222010..d6e4ddc840e2d 100644
--- a/libcxx/include/__format/buffer.h
+++ b/libcxx/include/__format/buffer.h
@@ -12,6 +12,7 @@
 
 #include <__algorithm/copy_n.h>
 #include <__algorithm/fill_n.h>
+#include <__algorithm/for_each.h>
 #include <__algorithm/max.h>
 #include <__algorithm/min.h>
 #include <__algorithm/ranges_copy.h>
@@ -34,11 +35,13 @@
 #include <__memory/construct_at.h>
 #include <__memory/destroy.h>
 #include <__memory/uninitialized_algorithms.h>
+#include <__system_error/system_error.h>
 #include <__type_traits/add_pointer.h>
 #include <__type_traits/conditional.h>
 #include <__utility/exception_guard.h>
 #include <__utility/move.h>
 #include 
+#include  // Uses the POSIX/Windows unlocked stream I/O
 #include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/print b/libcxx/include/print
index 1794d6014efcd..f6d03edfbd4bc 100644
--- a/libcxx/include/print
+++ b/libcxx/include/print
@@ -27,9 +27,11 @@ namespace std {
 
   void vprint_unicode(string_view fmt, format_args args);
   void vprint_unicode(FILE* stream, string_view fmt, format_args args);
+  void vprint_unicode_buffered(FILE* stream, string_view fmt, format_args 
args);
 
   void vprint_nonunicode(string_view fmt, format_args args);
   void vprint_nonunicode(FILE* stream, string_view fmt, format_args args);
+  void vprint_nonunicode_buffered(FILE* stream, string_view fmt, format_args 
args);
 }
 */
 
@@ -41,6 +43,7 @@ namespace std {
 #  include <__config>
 #  include <__system_error/throw_system_error.h>
 #  include <__utility/forward.h>
+#  include <__utility/move.h>
 #  include 
 #  include 
 #  include 
@@ -52,6 +55,9 @@ namespace std {
 #pragma GCC system_header
 #  endif
 
+_LIBCPP_PUSH_MACROS
+#  include <__undef_macros>
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #  ifdef _LIBCPP_WIN32API
@@ -213,6 +219,122 @@ _LIBCPP_HIDE_FROM_ABI inline

[llvm-branch-commits] [llvm] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Akshat Oke via llvm-branch-commits

https://github.com/optimisan created 
https://github.com/llvm/llvm-project/pull/131563

None

>From b4613eade6cc67b3236c7a9ebf155ff20138b90d Mon Sep 17 00:00:00 2001
From: Akshat Oke 
Date: Wed, 12 Mar 2025 09:31:58 +
Subject: [PATCH] [CodeGen][NPM] Port LiveDebugValues to NPM

---
 llvm/include/llvm/InitializePasses.h  |  2 +-
 llvm/include/llvm/Passes/CodeGenPassBuilder.h |  3 +-
 .../llvm/Passes/MachinePassRegistry.def   | 13 -
 llvm/lib/CodeGen/CodeGen.cpp  |  2 +-
 .../LiveDebugValues/LiveDebugValues.cpp   | 56 ++-
 llvm/lib/Passes/PassBuilder.cpp   |  1 +
 6 files changed, 58 insertions(+), 19 deletions(-)

diff --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index 36be3d552f556..06fd686a4a43d 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -153,7 +153,7 @@ void initializeLegacyLICMPassPass(PassRegistry &);
 void initializeLegalizerPass(PassRegistry &);
 void initializeGISelCSEAnalysisWrapperPassPass(PassRegistry &);
 void initializeGISelKnownBitsAnalysisPass(PassRegistry &);
-void initializeLiveDebugValuesPass(PassRegistry &);
+void initializeLiveDebugValuesLegacyPass(PassRegistry &);
 void initializeLiveDebugVariablesWrapperLegacyPass(PassRegistry &);
 void initializeLiveIntervalsWrapperPassPass(PassRegistry &);
 void initializeLiveRangeShrinkPass(PassRegistry &);
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h 
b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 90a0cdf803560..c580f5a3eb3e9 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -43,6 +43,7 @@
 #include "llvm/CodeGen/InterleavedAccess.h"
 #include "llvm/CodeGen/InterleavedLoadCombine.h"
 #include "llvm/CodeGen/JMCInstrumenter.h"
+#include "llvm/CodeGen/LiveDebugValuesPass.h"
 #include "llvm/CodeGen/LiveIntervals.h"
 #include "llvm/CodeGen/LocalStackSlotAllocation.h"
 #include "llvm/CodeGen/LowerEmuTLS.h"
@@ -999,7 +1000,7 @@ Error CodeGenPassBuilder::addMachinePasses(
   addPass(FuncletLayoutPass());
 
   addPass(StackMapLivenessPass());
-  addPass(LiveDebugValuesPass());
+  
addPass(LiveDebugValuesPass(getTM().Options.ShouldEmitDebugEntryValues()));
   addPass(MachineSanitizerBinaryMetadata());
 
   if (TM.Options.EnableMachineOutliner &&
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def 
b/llvm/include/llvm/Passes/MachinePassRegistry.def
index ebfdaf82169d8..77d9c41864424 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -195,6 +195,18 @@ MACHINE_FUNCTION_PASS("verify", 
MachineTraceMetricsVerifi
 #define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER,
\
   PARAMS)
 #endif
+
+MACHINE_FUNCTION_PASS_WITH_PARAMS(
+"live-debug-values", "LiveDebugValuesPass",
+[](bool ShouldEmitDebugEntryValues) {
+  return LiveDebugValuesPass(ShouldEmitDebugEntryValues);
+},
+[](StringRef Params) {
+  return parseSinglePassOption(Params, "emit-debug-entry-values",
+   "LiveDebugValuesPass");
+},
+"emit-debug-entry-values")
+
 MACHINE_FUNCTION_PASS_WITH_PARAMS(
 "machine-sink", "MachineSinkingPass",
 [](bool EnableSinkAndFold) {
@@ -262,7 +274,6 @@ DUMMY_MACHINE_FUNCTION_PASS("instruction-select", 
InstructionSelectPass)
 DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass)
 DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass)
 DUMMY_MACHINE_FUNCTION_PASS("legalizer", LegalizerPass)
-DUMMY_MACHINE_FUNCTION_PASS("livedebugvalues", LiveDebugValuesPass)
 DUMMY_MACHINE_FUNCTION_PASS("lrshrink", LiveRangeShrinkPass)
 DUMMY_MACHINE_FUNCTION_PASS("machine-combiner", MachineCombinerPass)
 DUMMY_MACHINE_FUNCTION_PASS("static-data-splitter", StaticDataSplitter)
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index b36d2f743d512..94ce0a072f91f 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -58,7 +58,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
   initializeInterleavedLoadCombinePass(Registry);
   initializeInterleavedAccessPass(Registry);
   initializeJMCInstrumenterPass(Registry);
-  initializeLiveDebugValuesPass(Registry);
+  initializeLiveDebugValuesLegacyPass(Registry);
   initializeLiveDebugVariablesWrapperLegacyPass(Registry);
   initializeLiveIntervalsWrapperPassPass(Registry);
   initializeLiveRangeShrinkPass(Registry);
diff --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
index 484143a03fca1..585eff9a8417a 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
@@ -8,6 +8,7 @@
 
 #include "LiveDebugValues.h"
 
+#include "llvm/CodeGen/LiveDebugValuesPass.h"
 #include "llvm/CodeGen/MachineDominators.h"
 #

[llvm-branch-commits] [llvm] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Akshat Oke via llvm-branch-commits

https://github.com/optimisan ready_for_review 
https://github.com/llvm/llvm-project/pull/131563
___
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] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 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 bb1d6f1ef5fca622ce100e70e30f59dd1cd9fcbc 
b4613eade6cc67b3236c7a9ebf155ff20138b90d --extensions h,cpp -- 
llvm/include/llvm/InitializePasses.h 
llvm/include/llvm/Passes/CodeGenPassBuilder.h llvm/lib/CodeGen/CodeGen.cpp 
llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp 
llvm/lib/Passes/PassBuilder.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h 
b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index c580f5a3eb..9d16e0ddb1 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -1000,7 +1000,8 @@ Error CodeGenPassBuilder::addMachinePasses(
   addPass(FuncletLayoutPass());
 
   addPass(StackMapLivenessPass());
-  
addPass(LiveDebugValuesPass(getTM().Options.ShouldEmitDebugEntryValues()));
+  addPass(LiveDebugValuesPass(
+  getTM().Options.ShouldEmitDebugEntryValues()));
   addPass(MachineSanitizerBinaryMetadata());
 
   if (TM.Options.EnableMachineOutliner &&
diff --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
index 585eff9a84..654e8eb022 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
@@ -84,6 +84,7 @@ struct LiveDebugValues {
   LiveDebugValues();
   ~LiveDebugValues() = default;
   bool run(MachineFunction &MF, bool ShouldEmitDebugEntryValues);
+
 private:
   std::unique_ptr InstrRefImpl;
   std::unique_ptr VarLocImpl;
@@ -95,8 +96,8 @@ char LiveDebugValuesLegacy::ID = 0;
 
 char &llvm::LiveDebugValuesID = LiveDebugValuesLegacy::ID;
 
-INITIALIZE_PASS(LiveDebugValuesLegacy, DEBUG_TYPE, "Live DEBUG_VALUE 
analysis", false,
-false)
+INITIALIZE_PASS(LiveDebugValuesLegacy, DEBUG_TYPE, "Live DEBUG_VALUE analysis",
+false, false)
 
 /// Default construct and initialize the pass.
 LiveDebugValuesLegacy::LiveDebugValuesLegacy() : MachineFunctionPass(ID) {
@@ -109,16 +110,18 @@ LiveDebugValues::LiveDebugValues() {
   VarLocImpl = 
std::unique_ptr(llvm::makeVarLocBasedLiveDebugValues());
 }
 
-PreservedAnalyses LiveDebugValuesPass::run(MachineFunction &MF,
-   MachineFunctionAnalysisManager 
&MFAM) {
-  if(!LiveDebugValues().run(MF, ShouldEmitDebugEntryValues))
+PreservedAnalyses
+LiveDebugValuesPass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+  if (!LiveDebugValues().run(MF, ShouldEmitDebugEntryValues))
 return PreservedAnalyses::all();
   auto PA = getMachineFunctionPassPreservedAnalyses();
   PA.preserveSet();
   return PA;
 }
 
-void LiveDebugValuesPass::printPipeline(raw_ostream &OS, 
function_ref MapClassName2PassName){
+void LiveDebugValuesPass::printPipeline(
+raw_ostream &OS, function_ref MapClassName2PassName) 
{
   OS << MapClassName2PassName(name());
   if (ShouldEmitDebugEntryValues)
 OS << "";
@@ -127,10 +130,12 @@ void LiveDebugValuesPass::printPipeline(raw_ostream &OS, 
function_ref();
   assert(TPC && "TargetPassConfig must be available");
-  return LiveDebugValues().run(MF, 
TPC->getTM().Options.ShouldEmitDebugEntryValues());
+  return LiveDebugValues().run(
+  MF, TPC->getTM().Options.ShouldEmitDebugEntryValues());
 }
 
-bool LiveDebugValues::run(MachineFunction &MF, bool 
ShouldEmitDebugEntryValues) {
+bool LiveDebugValues::run(MachineFunction &MF,
+  bool ShouldEmitDebugEntryValues) {
   bool InstrRefBased = MF.useDebugInstrRef();
   // Allow the user to force selection of InstrRef LDV.
   InstrRefBased |= ForceInstrRefLDV;

``




https://github.com/llvm/llvm-project/pull/131563
___
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] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-debuginfo

Author: Akshat Oke (optimisan)


Changes



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


6 Files Affected:

- (modified) llvm/include/llvm/InitializePasses.h (+1-1) 
- (modified) llvm/include/llvm/Passes/CodeGenPassBuilder.h (+2-1) 
- (modified) llvm/include/llvm/Passes/MachinePassRegistry.def (+12-1) 
- (modified) llvm/lib/CodeGen/CodeGen.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp (+41-15) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1) 


``diff
diff --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index 36be3d552f556..06fd686a4a43d 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -153,7 +153,7 @@ void initializeLegacyLICMPassPass(PassRegistry &);
 void initializeLegalizerPass(PassRegistry &);
 void initializeGISelCSEAnalysisWrapperPassPass(PassRegistry &);
 void initializeGISelKnownBitsAnalysisPass(PassRegistry &);
-void initializeLiveDebugValuesPass(PassRegistry &);
+void initializeLiveDebugValuesLegacyPass(PassRegistry &);
 void initializeLiveDebugVariablesWrapperLegacyPass(PassRegistry &);
 void initializeLiveIntervalsWrapperPassPass(PassRegistry &);
 void initializeLiveRangeShrinkPass(PassRegistry &);
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h 
b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 90a0cdf803560..c580f5a3eb3e9 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -43,6 +43,7 @@
 #include "llvm/CodeGen/InterleavedAccess.h"
 #include "llvm/CodeGen/InterleavedLoadCombine.h"
 #include "llvm/CodeGen/JMCInstrumenter.h"
+#include "llvm/CodeGen/LiveDebugValuesPass.h"
 #include "llvm/CodeGen/LiveIntervals.h"
 #include "llvm/CodeGen/LocalStackSlotAllocation.h"
 #include "llvm/CodeGen/LowerEmuTLS.h"
@@ -999,7 +1000,7 @@ Error CodeGenPassBuilder::addMachinePasses(
   addPass(FuncletLayoutPass());
 
   addPass(StackMapLivenessPass());
-  addPass(LiveDebugValuesPass());
+  
addPass(LiveDebugValuesPass(getTM().Options.ShouldEmitDebugEntryValues()));
   addPass(MachineSanitizerBinaryMetadata());
 
   if (TM.Options.EnableMachineOutliner &&
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def 
b/llvm/include/llvm/Passes/MachinePassRegistry.def
index ebfdaf82169d8..77d9c41864424 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -195,6 +195,18 @@ MACHINE_FUNCTION_PASS("verify", 
MachineTraceMetricsVerifi
 #define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER,
\
   PARAMS)
 #endif
+
+MACHINE_FUNCTION_PASS_WITH_PARAMS(
+"live-debug-values", "LiveDebugValuesPass",
+[](bool ShouldEmitDebugEntryValues) {
+  return LiveDebugValuesPass(ShouldEmitDebugEntryValues);
+},
+[](StringRef Params) {
+  return parseSinglePassOption(Params, "emit-debug-entry-values",
+   "LiveDebugValuesPass");
+},
+"emit-debug-entry-values")
+
 MACHINE_FUNCTION_PASS_WITH_PARAMS(
 "machine-sink", "MachineSinkingPass",
 [](bool EnableSinkAndFold) {
@@ -262,7 +274,6 @@ DUMMY_MACHINE_FUNCTION_PASS("instruction-select", 
InstructionSelectPass)
 DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass)
 DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass)
 DUMMY_MACHINE_FUNCTION_PASS("legalizer", LegalizerPass)
-DUMMY_MACHINE_FUNCTION_PASS("livedebugvalues", LiveDebugValuesPass)
 DUMMY_MACHINE_FUNCTION_PASS("lrshrink", LiveRangeShrinkPass)
 DUMMY_MACHINE_FUNCTION_PASS("machine-combiner", MachineCombinerPass)
 DUMMY_MACHINE_FUNCTION_PASS("static-data-splitter", StaticDataSplitter)
diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp
index b36d2f743d512..94ce0a072f91f 100644
--- a/llvm/lib/CodeGen/CodeGen.cpp
+++ b/llvm/lib/CodeGen/CodeGen.cpp
@@ -58,7 +58,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) {
   initializeInterleavedLoadCombinePass(Registry);
   initializeInterleavedAccessPass(Registry);
   initializeJMCInstrumenterPass(Registry);
-  initializeLiveDebugValuesPass(Registry);
+  initializeLiveDebugValuesLegacyPass(Registry);
   initializeLiveDebugVariablesWrapperLegacyPass(Registry);
   initializeLiveIntervalsWrapperPassPass(Registry);
   initializeLiveRangeShrinkPass(Registry);
diff --git a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp 
b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
index 484143a03fca1..585eff9a8417a 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp
@@ -8,6 +8,7 @@
 
 #include "LiveDebugValues.h"
 
+#include "llvm/CodeGen/LiveDebugValuesPass.h"
 #include "llvm/CodeGen/MachineDominators.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
@@ -63,12 +64,12 @@ namesp

[llvm-branch-commits] [llvm] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Matt Arsenault via llvm-branch-commits


@@ -102,6 +102,7 @@
 #include "llvm/CodeGen/InterleavedAccess.h"
 #include "llvm/CodeGen/InterleavedLoadCombine.h"
 #include "llvm/CodeGen/JMCInstrumenter.h"
+#include "llvm/CodeGen/LiveDebugValuesPass.h"

arsenm wrote:

Dead include? 

https://github.com/llvm/llvm-project/pull/131563
___
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: [SCEV] Check whether the start is non-zero in `ScalarEvolution::howFarToZero` (#131522) (PR #131568)

2025-03-16 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/131568

Backport c5a491e9ea22014b65664b6e09134b4f055933e2

Requested by: @dtcxzyw

>From c8fbb460d24dbbb8ef079ba2aae710892a91093b Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Mon, 17 Mar 2025 13:59:16 +0800
Subject: [PATCH] [SCEV] Check whether the start is non-zero in
 `ScalarEvolution::howFarToZero` (#131522)

https://github.com/llvm/llvm-project/pull/94525 assumes that the loop
will be infinite when the stride is zero. However, it doesn't hold when
the start value of addrec is also zero.

Closes https://github.com/llvm/llvm-project/issues/131465.

(cherry picked from commit c5a491e9ea22014b65664b6e09134b4f055933e2)
---
 llvm/lib/Analysis/ScalarEvolution.cpp |  9 ++--
 .../trip-count-unknown-stride.ll  | 34 +++
 llvm/test/Transforms/LoopUnroll/pr131465.ll   | 43 +++
 3 files changed, 74 insertions(+), 12 deletions(-)
 create mode 100644 llvm/test/Transforms/LoopUnroll/pr131465.ll

diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp 
b/llvm/lib/Analysis/ScalarEvolution.cpp
index c71202c8dd58e..b8069df4e6598 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -10635,10 +10635,11 @@ ScalarEvolution::ExitLimit 
ScalarEvolution::howFarToZero(const SCEV *V,
   if (ControlsOnlyExit && AddRec->hasNoSelfWrap() &&
   loopHasNoAbnormalExits(AddRec->getLoop())) {
 
-// If the stride is zero, the loop must be infinite.  In C++, most loops
-// are finite by assumption, in which case the step being zero implies
-// UB must execute if the loop is entered.
-if (!loopIsFiniteByAssumption(L) && !isKnownNonZero(StepWLG))
+// If the stride is zero and the start is non-zero, the loop must be
+// infinite. In C++, most loops are finite by assumption, in which case the
+// step being zero implies UB must execute if the loop is entered.
+if (!(loopIsFiniteByAssumption(L) && isKnownNonZero(Start)) &&
+!isKnownNonZero(StepWLG))
   return getCouldNotCompute();
 
 const SCEV *Exact =
diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll 
b/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
index 2d02cb6194f4c..1f08a620b2e15 100644
--- a/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
+++ b/llvm/test/Analysis/ScalarEvolution/trip-count-unknown-stride.ll
@@ -329,10 +329,9 @@ define void @ne_nsw_nonneg_step(ptr nocapture %A, i32 %n, 
i32 %s) mustprogress {
 ;
 ; CHECK-LABEL: 'ne_nsw_nonneg_step'
 ; CHECK-NEXT:  Determining loop execution counts for: @ne_nsw_nonneg_step
-; CHECK-NEXT:  Loop %for.body: backedge-taken count is (((-1 * %s) + %n) /u %s)
-; CHECK-NEXT:  Loop %for.body: constant max backedge-taken count is i32 -1
-; CHECK-NEXT:  Loop %for.body: symbolic max backedge-taken count is (((-1 * 
%s) + %n) /u %s)
-; CHECK-NEXT:  Loop %for.body: Trip multiple is 1
+; CHECK-NEXT:  Loop %for.body: Unpredictable backedge-taken count.
+; CHECK-NEXT:  Loop %for.body: Unpredictable constant max backedge-taken count.
+; CHECK-NEXT:  Loop %for.body: Unpredictable symbolic max backedge-taken count.
 ;
 entry:
   %nonneg_step = icmp sge i32 %s, 0
@@ -442,10 +441,9 @@ define void @ne_nuw_nonneg_step(ptr nocapture %A, i32 %n, 
i32 %s) mustprogress {
 ;
 ; CHECK-LABEL: 'ne_nuw_nonneg_step'
 ; CHECK-NEXT:  Determining loop execution counts for: @ne_nuw_nonneg_step
-; CHECK-NEXT:  Loop %for.body: backedge-taken count is (((-1 * %s) + %n) /u %s)
-; CHECK-NEXT:  Loop %for.body: constant max backedge-taken count is i32 -1
-; CHECK-NEXT:  Loop %for.body: symbolic max backedge-taken count is (((-1 * 
%s) + %n) /u %s)
-; CHECK-NEXT:  Loop %for.body: Trip multiple is 1
+; CHECK-NEXT:  Loop %for.body: Unpredictable backedge-taken count.
+; CHECK-NEXT:  Loop %for.body: Unpredictable constant max backedge-taken count.
+; CHECK-NEXT:  Loop %for.body: Unpredictable symbolic max backedge-taken count.
 ;
 entry:
   %nonneg_step = icmp sge i32 %s, 0
@@ -493,6 +491,26 @@ for.end:  ; preds 
= %for.body, %entry
   ret void
 }
 
+define i32 @pr131465(i1 %x) mustprogress {
+; CHECK-LABEL: 'pr131465'
+; CHECK-NEXT:  Determining loop execution counts for: @pr131465
+; CHECK-NEXT:  Loop %for.body: Unpredictable backedge-taken count.
+; CHECK-NEXT:  Loop %for.body: Unpredictable constant max backedge-taken count.
+; CHECK-NEXT:  Loop %for.body: Unpredictable symbolic max backedge-taken count.
+;
+entry:
+  %inc = zext i1 %x to i32
+  br label %for.body
+
+for.body:
+  %indvar = phi i32 [ 2, %entry ], [ %next, %for.body ]
+  %next = add nsw i32 %indvar, %inc
+  %exitcond = icmp eq i32 %next, 2
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:
+  ret i32 0
+}
 
 declare void @llvm.assume(i1)
 
diff --git a/llvm/test/Transforms/LoopUnroll/pr131465.ll 
b/llvm/test/Transforms/LoopUnroll/pr131465.ll
new file mode 100644
index 0..643b02

[llvm-branch-commits] [llvm] release/20.x: [SCEV] Check whether the start is non-zero in `ScalarEvolution::howFarToZero` (#131522) (PR #131568)

2025-03-16 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/131568
___
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] [openmp] c0ea872 - Revert "[OpenMP] Update OpenMP runtime to adopt taskgraph clause from 6.0 Spe…"

2025-03-16 Thread via llvm-branch-commits

Author: Josep Pinot
Date: 2025-03-17T07:34:19+01:00
New Revision: c0ea872f36f6d72f2d33405a970c962e618b26fb

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

LOG: Revert "[OpenMP] Update OpenMP runtime to adopt taskgraph clause from 6.0 
Spe…"

This reverts commit 77ad061923418ba0f4c8fd4a0710a5ace825bf8e.

Added: 


Modified: 
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_global.cpp
openmp/runtime/src/kmp_tasking.cpp

Removed: 
openmp/runtime/test/tasking/omp_record_replay_random_id.cpp
openmp/runtime/test/tasking/omp_record_replay_reset.cpp



diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index 856f14e5f057f..9b8c6102dbee2 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -2606,9 +2606,7 @@ typedef struct {
 typedef struct kmp_taskgraph_flags { /*This needs to be exactly 32 bits */
   unsigned nowait : 1;
   unsigned re_record : 1;
-  unsigned graph_reset : 1; /* 1==discard taskgraph record, 0==use taskgraph
-   record */
-  unsigned reserved : 29;
+  unsigned reserved : 30;
 } kmp_taskgraph_flags_t;
 
 /// Represents a TDG node
@@ -2652,7 +2650,7 @@ typedef struct kmp_tdg_info {
 extern int __kmp_tdg_dot;
 extern kmp_int32 __kmp_max_tdgs;
 extern kmp_tdg_info_t **__kmp_global_tdgs;
-extern kmp_tdg_info_t *__kmp_curr_tdg;
+extern kmp_int32 __kmp_curr_tdg_idx;
 extern kmp_int32 __kmp_successors_size;
 extern std::atomic __kmp_tdg_task_id;
 extern kmp_int32 __kmp_num_tdg;

diff  --git a/openmp/runtime/src/kmp_global.cpp 
b/openmp/runtime/src/kmp_global.cpp
index 7b6bfff7c54ea..52e0fdbdfb1da 100644
--- a/openmp/runtime/src/kmp_global.cpp
+++ b/openmp/runtime/src/kmp_global.cpp
@@ -554,7 +554,8 @@ int *__kmp_nesting_nth_level;
 int __kmp_tdg_dot = 0;
 kmp_int32 __kmp_max_tdgs = 100;
 kmp_tdg_info_t **__kmp_global_tdgs = NULL;
-kmp_tdg_info_t *__kmp_curr_tdg = NULL; // Current TDG being recorded or 
executed
+kmp_int32 __kmp_curr_tdg_idx =
+0; // Id of the current TDG being recorded or executed
 kmp_int32 __kmp_num_tdg = 0;
 kmp_int32 __kmp_successors_size = 10; // Initial succesor size list for
   // recording

diff  --git a/openmp/runtime/src/kmp_tasking.cpp 
b/openmp/runtime/src/kmp_tasking.cpp
index 90004bfc8afe0..563aa29f6265e 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -1651,11 +1651,11 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, 
kmp_int32 gtid,
   }
 
 #if OMPX_TASKGRAPH
-  kmp_tdg_info_t *tdg = __kmp_curr_tdg;
+  kmp_tdg_info_t *tdg = __kmp_find_tdg(__kmp_curr_tdg_idx);
   if (tdg && __kmp_tdg_is_recording(tdg->tdg_status) &&
   (task_entry != (kmp_routine_entry_t)__kmp_taskloop_task)) {
 taskdata->is_taskgraph = 1;
-taskdata->tdg = tdg;
+taskdata->tdg = __kmp_global_tdgs[__kmp_curr_tdg_idx];
 taskdata->td_task_id = KMP_GEN_TASK_ID();
 taskdata->td_tdg_task_id = KMP_ATOMIC_INC(&__kmp_tdg_task_id);
   }
@@ -2577,11 +2577,14 @@ without help of the runtime library.
 */
 void *__kmpc_task_reduction_init(int gtid, int num, void *data) {
 #if OMPX_TASKGRAPH
-  kmp_tdg_info_t *tdg = __kmp_curr_tdg;
+  kmp_tdg_info_t *tdg = __kmp_find_tdg(__kmp_curr_tdg_idx);
   if (tdg && __kmp_tdg_is_recording(tdg->tdg_status)) {
-tdg->rec_taskred_data = __kmp_allocate(sizeof(kmp_task_red_input_t) * num);
-tdg->rec_num_taskred = num;
-KMP_MEMCPY(tdg->rec_taskred_data, data, sizeof(kmp_task_red_input_t) * 
num);
+kmp_tdg_info_t *this_tdg = __kmp_global_tdgs[__kmp_curr_tdg_idx];
+this_tdg->rec_taskred_data =
+__kmp_allocate(sizeof(kmp_task_red_input_t) * num);
+this_tdg->rec_num_taskred = num;
+KMP_MEMCPY(this_tdg->rec_taskred_data, data,
+   sizeof(kmp_task_red_input_t) * num);
   }
 #endif
   return __kmp_task_reduction_init(gtid, num, (kmp_task_red_input_t *)data);
@@ -2601,11 +2604,14 @@ has two parameters, pointer to object to be initialized 
and pointer to omp_orig
 */
 void *__kmpc_taskred_init(int gtid, int num, void *data) {
 #if OMPX_TASKGRAPH
-  kmp_tdg_info_t *tdg = __kmp_curr_tdg;
+  kmp_tdg_info_t *tdg = __kmp_find_tdg(__kmp_curr_tdg_idx);
   if (tdg && __kmp_tdg_is_recording(tdg->tdg_status)) {
-tdg->rec_taskred_data = __kmp_allocate(sizeof(kmp_task_red_input_t) * num);
-tdg->rec_num_taskred = num;
-KMP_MEMCPY(tdg->rec_taskred_data, data, sizeof(kmp_task_red_input_t) * 
num);
+kmp_tdg_info_t *this_tdg = __kmp_global_tdgs[__kmp_curr_tdg_idx];
+this_tdg->rec_taskred_data =
+__kmp_allocate(sizeof(kmp_task_red_input_t) * num);
+this_tdg->rec_num_taskred = num;
+KMP_MEMCPY(this_tdg->rec_taskred_data, data,
+   sizeof(kmp_task_red_input_t) * num);
   }
 #endif
   return __kmp_task_reduction_init(g

[llvm-branch-commits] [llvm] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Akshat Oke via llvm-branch-commits

https://github.com/optimisan updated 
https://github.com/llvm/llvm-project/pull/131563

>From be6e70fa3feb46b4a92f0f9719976c6efec8a28c Mon Sep 17 00:00:00 2001
From: Akshat Oke 
Date: Wed, 12 Mar 2025 09:31:58 +
Subject: [PATCH 1/2] [CodeGen][NPM] Port LiveDebugValues to NPM

---
 .../llvm/CodeGen/LiveDebugValuesPass.h| 30 +
 llvm/include/llvm/InitializePasses.h  |  2 +-
 llvm/include/llvm/Passes/CodeGenPassBuilder.h |  4 +-
 .../llvm/Passes/MachinePassRegistry.def   | 12 +++-
 llvm/lib/CodeGen/CodeGen.cpp  |  2 +-
 .../LiveDebugValues/LiveDebugValues.cpp   | 63 ++-
 llvm/lib/Passes/PassBuilder.cpp   |  1 +
 llvm/test/CodeGen/ARM/dbg-range-extension.mir |  1 +
 .../compiler-gen-bbs-livedebugvalues.mir  |  3 +
 9 files changed, 98 insertions(+), 20 deletions(-)
 create mode 100644 llvm/include/llvm/CodeGen/LiveDebugValuesPass.h

diff --git a/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h 
b/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
new file mode 100644
index 0..023a699360688
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
@@ -0,0 +1,30 @@
+//===- llvm/CodeGen/LiveDebugValuesPass.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
+#define LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
+
+#include "llvm/CodeGen/MachinePassManager.h"
+
+namespace llvm {
+
+class LiveDebugValuesPass : public PassInfoMixin {
+  bool ShouldEmitDebugEntryValues;
+
+public:
+  LiveDebugValuesPass(bool ShouldEmitDebugEntryValues)
+  : ShouldEmitDebugEntryValues(ShouldEmitDebugEntryValues) {}
+  PreservedAnalyses run(MachineFunction &MF,
+MachineFunctionAnalysisManager &MFAM);
+  void printPipeline(raw_ostream &OS,
+ function_ref MapClassName2PassName);
+};
+
+} // namespace llvm
+
+#endif // LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
diff --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index 460c7eb3ebe24..e820277724393 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -153,7 +153,7 @@ void initializeLegacyLICMPassPass(PassRegistry &);
 void initializeLegalizerPass(PassRegistry &);
 void initializeGISelCSEAnalysisWrapperPassPass(PassRegistry &);
 void initializeGISelKnownBitsAnalysisPass(PassRegistry &);
-void initializeLiveDebugValuesPass(PassRegistry &);
+void initializeLiveDebugValuesLegacyPass(PassRegistry &);
 void initializeLiveDebugVariablesWrapperLegacyPass(PassRegistry &);
 void initializeLiveIntervalsWrapperPassPass(PassRegistry &);
 void initializeLiveRangeShrinkPass(PassRegistry &);
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h 
b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 571b363fadfc2..bdb81cf77cfd1 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -45,6 +45,7 @@
 #include "llvm/CodeGen/InterleavedAccess.h"
 #include "llvm/CodeGen/InterleavedLoadCombine.h"
 #include "llvm/CodeGen/JMCInstrumenter.h"
+#include "llvm/CodeGen/LiveDebugValuesPass.h"
 #include "llvm/CodeGen/LiveIntervals.h"
 #include "llvm/CodeGen/LocalStackSlotAllocation.h"
 #include "llvm/CodeGen/LowerEmuTLS.h"
@@ -1002,7 +1003,8 @@ Error CodeGenPassBuilder::addMachinePasses(
   addPass(FuncletLayoutPass());
 
   addPass(StackMapLivenessPass());
-  addPass(LiveDebugValuesPass());
+  addPass(LiveDebugValuesPass(
+  getTM().Options.ShouldEmitDebugEntryValues()));
   addPass(MachineSanitizerBinaryMetadata());
 
   if (TM.Options.EnableMachineOutliner &&
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def 
b/llvm/include/llvm/Passes/MachinePassRegistry.def
index d3320ef82098c..956304560b683 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -214,6 +214,17 @@ MACHINE_FUNCTION_PASS_WITH_PARAMS(
 },
 "enable-tail-merge")
 
+MACHINE_FUNCTION_PASS_WITH_PARAMS(
+"live-debug-values", "LiveDebugValuesPass",
+[](bool ShouldEmitDebugEntryValues) {
+  return LiveDebugValuesPass(ShouldEmitDebugEntryValues);
+},
+[](StringRef Params) {
+  return parseSinglePassOption(Params, "emit-debug-entry-values",
+   "LiveDebugValuesPass");
+},
+"emit-debug-entry-values")
+
 MACHINE_FUNCTION_PASS_WITH_PARAMS(
 "machine-sink", "MachineSinkingPass",
 [](bool EnableSinkAndFold) {
@@ -278,7 +289,6 @@ DUMMY_MACHINE_FUNCTION_PASS("instruction-select", 
InstructionSelectPass)
 DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass)
 DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass)
 DUM

[llvm-branch-commits] [llvm] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Akshat Oke via llvm-branch-commits

optimisan 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/131563?utm_source=stack-comment-downstack-mergeability-warning";
>  >on Graphite.
> https://graphite.dev/docs/merge-pull-requests";>Learn more

* **#131563** https://app.graphite.dev/github/pr/llvm/llvm-project/131563?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/131563?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* **#131562** https://app.graphite.dev/github/pr/llvm/llvm-project/131562?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/131563
___
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] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Akshat Oke via llvm-branch-commits

https://github.com/optimisan edited 
https://github.com/llvm/llvm-project/pull/131563
___
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] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Akshat Oke via llvm-branch-commits


@@ -102,6 +102,7 @@
 #include "llvm/CodeGen/InterleavedAccess.h"
 #include "llvm/CodeGen/InterleavedLoadCombine.h"
 #include "llvm/CodeGen/JMCInstrumenter.h"
+#include "llvm/CodeGen/LiveDebugValuesPass.h"

optimisan wrote:

whoops forgot to add the new header file again.

https://github.com/llvm/llvm-project/pull/131563
___
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] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Akshat Oke via llvm-branch-commits

https://github.com/optimisan updated 
https://github.com/llvm/llvm-project/pull/131563

>From be6e70fa3feb46b4a92f0f9719976c6efec8a28c Mon Sep 17 00:00:00 2001
From: Akshat Oke 
Date: Wed, 12 Mar 2025 09:31:58 +
Subject: [PATCH] [CodeGen][NPM] Port LiveDebugValues to NPM

---
 .../llvm/CodeGen/LiveDebugValuesPass.h| 30 +
 llvm/include/llvm/InitializePasses.h  |  2 +-
 llvm/include/llvm/Passes/CodeGenPassBuilder.h |  4 +-
 .../llvm/Passes/MachinePassRegistry.def   | 12 +++-
 llvm/lib/CodeGen/CodeGen.cpp  |  2 +-
 .../LiveDebugValues/LiveDebugValues.cpp   | 63 ++-
 llvm/lib/Passes/PassBuilder.cpp   |  1 +
 llvm/test/CodeGen/ARM/dbg-range-extension.mir |  1 +
 .../compiler-gen-bbs-livedebugvalues.mir  |  3 +
 9 files changed, 98 insertions(+), 20 deletions(-)
 create mode 100644 llvm/include/llvm/CodeGen/LiveDebugValuesPass.h

diff --git a/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h 
b/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
new file mode 100644
index 0..023a699360688
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
@@ -0,0 +1,30 @@
+//===- llvm/CodeGen/LiveDebugValuesPass.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
+#define LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
+
+#include "llvm/CodeGen/MachinePassManager.h"
+
+namespace llvm {
+
+class LiveDebugValuesPass : public PassInfoMixin {
+  bool ShouldEmitDebugEntryValues;
+
+public:
+  LiveDebugValuesPass(bool ShouldEmitDebugEntryValues)
+  : ShouldEmitDebugEntryValues(ShouldEmitDebugEntryValues) {}
+  PreservedAnalyses run(MachineFunction &MF,
+MachineFunctionAnalysisManager &MFAM);
+  void printPipeline(raw_ostream &OS,
+ function_ref MapClassName2PassName);
+};
+
+} // namespace llvm
+
+#endif // LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
diff --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index 460c7eb3ebe24..e820277724393 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -153,7 +153,7 @@ void initializeLegacyLICMPassPass(PassRegistry &);
 void initializeLegalizerPass(PassRegistry &);
 void initializeGISelCSEAnalysisWrapperPassPass(PassRegistry &);
 void initializeGISelKnownBitsAnalysisPass(PassRegistry &);
-void initializeLiveDebugValuesPass(PassRegistry &);
+void initializeLiveDebugValuesLegacyPass(PassRegistry &);
 void initializeLiveDebugVariablesWrapperLegacyPass(PassRegistry &);
 void initializeLiveIntervalsWrapperPassPass(PassRegistry &);
 void initializeLiveRangeShrinkPass(PassRegistry &);
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h 
b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 571b363fadfc2..bdb81cf77cfd1 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -45,6 +45,7 @@
 #include "llvm/CodeGen/InterleavedAccess.h"
 #include "llvm/CodeGen/InterleavedLoadCombine.h"
 #include "llvm/CodeGen/JMCInstrumenter.h"
+#include "llvm/CodeGen/LiveDebugValuesPass.h"
 #include "llvm/CodeGen/LiveIntervals.h"
 #include "llvm/CodeGen/LocalStackSlotAllocation.h"
 #include "llvm/CodeGen/LowerEmuTLS.h"
@@ -1002,7 +1003,8 @@ Error CodeGenPassBuilder::addMachinePasses(
   addPass(FuncletLayoutPass());
 
   addPass(StackMapLivenessPass());
-  addPass(LiveDebugValuesPass());
+  addPass(LiveDebugValuesPass(
+  getTM().Options.ShouldEmitDebugEntryValues()));
   addPass(MachineSanitizerBinaryMetadata());
 
   if (TM.Options.EnableMachineOutliner &&
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def 
b/llvm/include/llvm/Passes/MachinePassRegistry.def
index d3320ef82098c..956304560b683 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -214,6 +214,17 @@ MACHINE_FUNCTION_PASS_WITH_PARAMS(
 },
 "enable-tail-merge")
 
+MACHINE_FUNCTION_PASS_WITH_PARAMS(
+"live-debug-values", "LiveDebugValuesPass",
+[](bool ShouldEmitDebugEntryValues) {
+  return LiveDebugValuesPass(ShouldEmitDebugEntryValues);
+},
+[](StringRef Params) {
+  return parseSinglePassOption(Params, "emit-debug-entry-values",
+   "LiveDebugValuesPass");
+},
+"emit-debug-entry-values")
+
 MACHINE_FUNCTION_PASS_WITH_PARAMS(
 "machine-sink", "MachineSinkingPass",
 [](bool EnableSinkAndFold) {
@@ -278,7 +289,6 @@ DUMMY_MACHINE_FUNCTION_PASS("instruction-select", 
InstructionSelectPass)
 DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass)
 DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass)
 DUMMY_M

[llvm-branch-commits] [llvm] [CodeGen][NPM] Port LiveDebugValues to NPM (PR #131563)

2025-03-16 Thread Akshat Oke via llvm-branch-commits

https://github.com/optimisan updated 
https://github.com/llvm/llvm-project/pull/131563

>From be6e70fa3feb46b4a92f0f9719976c6efec8a28c Mon Sep 17 00:00:00 2001
From: Akshat Oke 
Date: Wed, 12 Mar 2025 09:31:58 +
Subject: [PATCH] [CodeGen][NPM] Port LiveDebugValues to NPM

---
 .../llvm/CodeGen/LiveDebugValuesPass.h| 30 +
 llvm/include/llvm/InitializePasses.h  |  2 +-
 llvm/include/llvm/Passes/CodeGenPassBuilder.h |  4 +-
 .../llvm/Passes/MachinePassRegistry.def   | 12 +++-
 llvm/lib/CodeGen/CodeGen.cpp  |  2 +-
 .../LiveDebugValues/LiveDebugValues.cpp   | 63 ++-
 llvm/lib/Passes/PassBuilder.cpp   |  1 +
 llvm/test/CodeGen/ARM/dbg-range-extension.mir |  1 +
 .../compiler-gen-bbs-livedebugvalues.mir  |  3 +
 9 files changed, 98 insertions(+), 20 deletions(-)
 create mode 100644 llvm/include/llvm/CodeGen/LiveDebugValuesPass.h

diff --git a/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h 
b/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
new file mode 100644
index 0..023a699360688
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/LiveDebugValuesPass.h
@@ -0,0 +1,30 @@
+//===- llvm/CodeGen/LiveDebugValuesPass.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
+#define LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
+
+#include "llvm/CodeGen/MachinePassManager.h"
+
+namespace llvm {
+
+class LiveDebugValuesPass : public PassInfoMixin {
+  bool ShouldEmitDebugEntryValues;
+
+public:
+  LiveDebugValuesPass(bool ShouldEmitDebugEntryValues)
+  : ShouldEmitDebugEntryValues(ShouldEmitDebugEntryValues) {}
+  PreservedAnalyses run(MachineFunction &MF,
+MachineFunctionAnalysisManager &MFAM);
+  void printPipeline(raw_ostream &OS,
+ function_ref MapClassName2PassName);
+};
+
+} // namespace llvm
+
+#endif // LLVM_CODEGEN_LIVEDEBUGVALUESPASS_H
diff --git a/llvm/include/llvm/InitializePasses.h 
b/llvm/include/llvm/InitializePasses.h
index 460c7eb3ebe24..e820277724393 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -153,7 +153,7 @@ void initializeLegacyLICMPassPass(PassRegistry &);
 void initializeLegalizerPass(PassRegistry &);
 void initializeGISelCSEAnalysisWrapperPassPass(PassRegistry &);
 void initializeGISelKnownBitsAnalysisPass(PassRegistry &);
-void initializeLiveDebugValuesPass(PassRegistry &);
+void initializeLiveDebugValuesLegacyPass(PassRegistry &);
 void initializeLiveDebugVariablesWrapperLegacyPass(PassRegistry &);
 void initializeLiveIntervalsWrapperPassPass(PassRegistry &);
 void initializeLiveRangeShrinkPass(PassRegistry &);
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h 
b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 571b363fadfc2..bdb81cf77cfd1 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -45,6 +45,7 @@
 #include "llvm/CodeGen/InterleavedAccess.h"
 #include "llvm/CodeGen/InterleavedLoadCombine.h"
 #include "llvm/CodeGen/JMCInstrumenter.h"
+#include "llvm/CodeGen/LiveDebugValuesPass.h"
 #include "llvm/CodeGen/LiveIntervals.h"
 #include "llvm/CodeGen/LocalStackSlotAllocation.h"
 #include "llvm/CodeGen/LowerEmuTLS.h"
@@ -1002,7 +1003,8 @@ Error CodeGenPassBuilder::addMachinePasses(
   addPass(FuncletLayoutPass());
 
   addPass(StackMapLivenessPass());
-  addPass(LiveDebugValuesPass());
+  addPass(LiveDebugValuesPass(
+  getTM().Options.ShouldEmitDebugEntryValues()));
   addPass(MachineSanitizerBinaryMetadata());
 
   if (TM.Options.EnableMachineOutliner &&
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def 
b/llvm/include/llvm/Passes/MachinePassRegistry.def
index d3320ef82098c..956304560b683 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -214,6 +214,17 @@ MACHINE_FUNCTION_PASS_WITH_PARAMS(
 },
 "enable-tail-merge")
 
+MACHINE_FUNCTION_PASS_WITH_PARAMS(
+"live-debug-values", "LiveDebugValuesPass",
+[](bool ShouldEmitDebugEntryValues) {
+  return LiveDebugValuesPass(ShouldEmitDebugEntryValues);
+},
+[](StringRef Params) {
+  return parseSinglePassOption(Params, "emit-debug-entry-values",
+   "LiveDebugValuesPass");
+},
+"emit-debug-entry-values")
+
 MACHINE_FUNCTION_PASS_WITH_PARAMS(
 "machine-sink", "MachineSinkingPass",
 [](bool EnableSinkAndFold) {
@@ -278,7 +289,6 @@ DUMMY_MACHINE_FUNCTION_PASS("instruction-select", 
InstructionSelectPass)
 DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass)
 DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass)
 DUMMY_M