[llvm-branch-commits] [mlir] 1cc3b31 - Revert "[MLIR][Linalg] Enable fuse consumer (#85528)"

2024-04-23 Thread via llvm-branch-commits

Author: Oleksandr "Alex" Zinenko
Date: 2024-04-23T10:45:55+02:00
New Revision: 1cc3b3195644e36a19459c68278f64007649eb41

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

LOG: Revert "[MLIR][Linalg] Enable fuse consumer (#85528)"

This reverts commit 2a47ee070145438424b065a35c4a680ea0cb0c1f.

Added: 


Modified: 
mlir/include/mlir/Interfaces/TilingInterface.td
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp

Removed: 




diff  --git a/mlir/include/mlir/Interfaces/TilingInterface.td 
b/mlir/include/mlir/Interfaces/TilingInterface.td
index 84f7dec2f4003d..66382f29c24249 100644
--- a/mlir/include/mlir/Interfaces/TilingInterface.td
+++ b/mlir/include/mlir/Interfaces/TilingInterface.td
@@ -63,7 +63,7 @@ def TilingInterface : OpInterface<"TilingInterface"> {
   The method returns the operation that is the tiled
   implementation.
 }],
-/*retType=*/"FailureOr<::mlir::TilingResult>",
+/*retType=*/"FailureOr",
 /*methodName=*/"getTiledImplementation",
 /*args=*/(ins
 "OpBuilder &":$b,
@@ -82,34 +82,15 @@ def TilingInterface : OpInterface<"TilingInterface"> {
   by the tiled implementation. Expects the same `offsets` and `sizes` 
as
   used to obtain the tiled implementation of the operation.
 }],
-/*retType=*/"::mlir::LogicalResult",
+/*retType=*/"LogicalResult",
 /*methodName=*/"getResultTilePosition",
 /*args=*/(ins
   "OpBuilder &":$b,
   "unsigned":$resultNumber,
   "ArrayRef ":$offsets,
   "ArrayRef ":$sizes,
-  "SmallVectorImpl &":$resultOffsets,
-  "SmallVectorImpl &":$resultSizes),
-/*methodBody=*/"",
-/*defaultImplementation=*/[{
-  return failure();
-}]
-  >,
-  InterfaceMethod<
-/*desc=*/[{
-  Method to return the position of iteration domain tile computed by 
the
-  tiled operation.
-}],
-/*retType=*/"::mlir::LogicalResult",
-/*methodName=*/"getIterationDomainTileFromOperandTile",
-/*args=*/(ins
-  "OpBuilder &":$b,
-  "unsigned":$operandNumber,
-  "ArrayRef ":$offsets,
-  "ArrayRef ":$sizes,
-  "SmallVectorImpl &":$iterDomainOffsets,
-  "SmallVectorImpl &":$iterDomainSizes),
+  "SmallVector &":$resultOffsets,
+  "SmallVector &":$resultSizes),
 /*methodBody=*/"",
 /*defaultImplementation=*/[{
   return failure();
@@ -138,7 +119,7 @@ def TilingInterface : OpInterface<"TilingInterface"> {
 iteration space).
   - `sizes` provides the size of the tile.
 }],
-/*retType=*/"FailureOr<::mlir::TilingResult>",
+/*retType=*/"FailureOr",
 /*methodName=*/"generateResultTileValue",
 /*args=*/(ins
   "OpBuilder &":$b,
@@ -150,42 +131,6 @@ def TilingInterface : OpInterface<"TilingInterface"> {
   return failure();
 }]
   >,
-  InterfaceMethod<
-/*desc=*/[{
-  Method to generate the tiled implementation of an operation from
-  operand tile position.
-
-  Generates the IR that computes the tiled implementation of an
-  operation from operand tile.  The `offsets` and `sizes`
-  describe the tile of the operand required. This is 
diff erent from
-  `getTiledImplementation` which generates the tiled
-  implementation of the operation given a tile of the
-  iteration space. This method generates a tiled
-  implementation of the operation based on the tile of the
-  operand required. This method enables consumer fusion by using
-  tile and fuse. The method returns failure if the operation
-  can't be tiled to generate the operand tile. In practical terms
-  this implies it cannot be tiled and fused with its producers.
-
-  - `offsets` provides the offset of the tile in the coordinate system
-of the original iteration space, i.e., if an iteration space
-dimension had non-zero offset, it must be included in the offset
-provided here (as opposed to zero-based offset "relative" to the
-iteration space).
-  - `sizes` provides the size of the tile.
-}],
-/*retType=*/"FailureOr<::mlir::TilingResult>",
-/*methodName=*/"getTiledImplementationFromOperandTile",
-/*args=*/(ins
-  "OpBuilder &":$b,
-  "unsigned":$operandNumber,
-  "ArrayRef":$offsets,
-  "ArrayRef":$sizes),
-/*methodBody=*/"",
-/*defa

[llvm-branch-commits] [llvm] 686baf6 - Revert "[memprof] Omit the key length for the record table (#89527)"

2024-04-23 Thread via llvm-branch-commits

Author: Simon Pilgrim
Date: 2024-04-23T09:59:45+01:00
New Revision: 686baf6093643127f87f7cbfd009abcaa11ea0a3

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

LOG: Revert "[memprof] Omit the key length for the record table (#89527)"

This reverts commit b28f4d4dd0bbf50059cb19ca794af967374e1900.

Added: 


Modified: 
llvm/include/llvm/ProfileData/MemProf.h
llvm/include/llvm/Support/OnDiskHashTable.h

Removed: 




diff  --git a/llvm/include/llvm/ProfileData/MemProf.h 
b/llvm/include/llvm/ProfileData/MemProf.h
index f356e3a54a3645..aa6cdf198485b0 100644
--- a/llvm/include/llvm/ProfileData/MemProf.h
+++ b/llvm/include/llvm/ProfileData/MemProf.h
@@ -471,16 +471,12 @@ class RecordLookupTrait {
 
   hash_value_type ComputeHash(uint64_t K) { return K; }
 
-  std::pair
+  static std::pair
   ReadKeyDataLength(const unsigned char *&D) {
 using namespace support;
 
-// Starting with Version2, we don't read the key length because it is a
-// constant.
 offset_type KeyLen =
-Version < Version2
-? endian::readNext(D)
-: sizeof(uint64_t);
+endian::readNext(D);
 offset_type DataLen =
 endian::readNext(D);
 return std::make_pair(KeyLen, DataLen);
@@ -538,9 +534,7 @@ class RecordWriterTrait {
 
 endian::Writer LE(Out, llvm::endianness::little);
 offset_type N = sizeof(K);
-// Starting with Version2, we omit the key length because it is a constant.
-if (Version < Version2)
-  LE.write(N);
+LE.write(N);
 offset_type M = V.serializedSize(Version);
 LE.write(M);
 return std::make_pair(N, M);

diff  --git a/llvm/include/llvm/Support/OnDiskHashTable.h 
b/llvm/include/llvm/Support/OnDiskHashTable.h
index b6dbea53f3da6d..f6b4055e74de7e 100644
--- a/llvm/include/llvm/Support/OnDiskHashTable.h
+++ b/llvm/include/llvm/Support/OnDiskHashTable.h
@@ -377,7 +377,7 @@ template  class OnDiskChainedHashTable {
 
   // Determine the length of the key and the data.
   const std::pair &L =
-  InfoPtr->ReadKeyDataLength(Items);
+  Info::ReadKeyDataLength(Items);
   offset_type ItemLen = L.first + L.second;
 
   // Compare the hashes.  If they are not the same, skip the entry 
entirely.



___
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] [Frontend][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -25,6 +25,43 @@ using namespace llvm::omp;
 #define GEN_DIRECTIVES_IMPL
 #include "llvm/Frontend/OpenMP/OMP.inc"
 
+static iterator_range::iterator>
+getFirstCompositeRange(iterator_range::iterator> Leafs) {

skatrak wrote:

Is there any reason for these functions to support unsupported lists of 
directives as input? I think it's worth having a simpler implementation over 
allowing all sorts of invalid lists of leaf constructs as input, unless there's 
a good reason why we'd need that.

Not saying that the compiler should crash in that case, but they can just 
return empty ranges for unsupported lists of leaf constructs rather than trying 
to find subsets that match what we're looking for.

https://github.com/llvm/llvm-project/pull/89104
___
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] [Frontend][OpenMP] Implement getLeafOrCompositeConstructs (PR #89104)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak edited 
https://github.com/llvm/llvm-project/pull/89104
___
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] [analyzer] Backport performace regression fix (PR #89725)

2024-04-23 Thread Balazs Benics via llvm-branch-commits

https://github.com/steakhal milestoned 
https://github.com/llvm/llvm-project/pull/89725
___
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] [bolt] Revise IDE folder structure (PR #89742)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89742

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the BOLT part. See #89153 for the entire series and motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.


Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.


>From 140a539c9e3248b128bdffdbc9ae5e2e8b4366c0 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:23:47 +0200
Subject: [PATCH] [bolt] Revise IDE folder structure

---
 bolt/CMakeLists.txt  | 2 ++
 bolt/cmake/modules/AddBOLT.cmake | 1 -
 bolt/docs/CMakeLists.txt | 1 +
 bolt/test/CMakeLists.txt | 3 +--
 bolt/unittests/CMakeLists.txt| 2 +-
 5 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt
index cc3a70fa35e0ab..26df6a4208b7a9 100644
--- a/bolt/CMakeLists.txt
+++ b/bolt/CMakeLists.txt
@@ -1,3 +1,5 @@
+set(LLVM_SUBPROJECT_TITLE "BOLT")
+
 include(ExternalProject)
 
 set(BOLT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/bolt/cmake/modules/AddBOLT.cmake b/bolt/cmake/modules/AddBOLT.cmake
index 1f69b9046320a7..c7ac662c6b1217 100644
--- a/bolt/cmake/modules/AddBOLT.cmake
+++ b/bolt/cmake/modules/AddBOLT.cmake
@@ -3,7 +3,6 @@ include(LLVMDistributionSupport)
 
 macro(add_bolt_executable name)
   add_llvm_executable(${name} ${ARGN})
-  set_target_properties(${name} PROPERTIES FOLDER "BOLT")
 endmacro()
 
 macro(add_bolt_tool name)
diff --git a/bolt/docs/CMakeLists.txt b/bolt/docs/CMakeLists.txt
index b230512fe57170..12ae852566785f 100644
--- a/bolt/docs/CMakeLists.txt
+++ b/bolt/docs/CMakeLists.txt
@@ -79,6 +79,7 @@ if (LLVM_ENABLE_DOXYGEN)
 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating bolt doxygen documentation." VERBATIM)
+  set_target_properties(doxygen-bolt PROPERTIES FOLDER "BOLT/Docs")
 
   if (LLVM_BUILD_DOCS)
 add_dependencies(doxygen doxygen-bolt)
diff --git a/bolt/test/CMakeLists.txt b/bolt/test/CMakeLists.txt
index 89862fd59eb8ec..d468ff984840fc 100644
--- a/bolt/test/CMakeLists.txt
+++ b/bolt/test/CMakeLists.txt
@@ -56,7 +56,7 @@ list(APPEND BOLT_TEST_DEPS
   )
 
 add_custom_target(bolt-test-depends DEPENDS ${BOLT_TEST_DEPS})
-set_target_properties(bolt-test-depends PROPERTIES FOLDER "BOLT")
+set_target_properties(bolt-test-depends PROPERTIES FOLDER "BOLT/Tests")
 
 add_lit_testsuite(check-bolt "Running the BOLT regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}
@@ -64,7 +64,6 @@ add_lit_testsuite(check-bolt "Running the BOLT regression 
tests"
   DEPENDS ${BOLT_TEST_DEPS}
   ARGS ${BOLT_TEST_EXTRA_ARGS}
   )
-set_target_properties(check-bolt PROPERTIES FOLDER "BOLT")
 
 add_lit_testsuites(BOLT ${CMAKE_CURRENT_SOURCE_DIR}
   PARAMS ${BOLT_TEST_PARAMS}
diff --git a/bolt/unittests/CMakeLists.txt b/bolt/unittests/CMakeLists.txt
index 77159e92dec557..64414b83d39fe8 100644
--- a/bolt/unittests/CMakeLists.txt
+++ b/bolt/unittests/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_custom_target(BoltUnitTests)
-set_target_properties(BoltUnitTests PROPERTIES FOLDER "BOLT tests")
+set_target_properties(BoltUnitTests PROPERTIES FOLDER "BOLT/Tests")
 
 function(add_bolt_unittest test_dirname)
   add_unittest(BoltUnitTests ${test_dirname} ${ARGN})

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

[llvm-branch-commits] [clang] [clang] Revise IDE folder structure (PR #89743)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89743

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the Clang part. See #89153 for the entire series and 
motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.


Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.


>From afadef1f53e03e2cf3a1695f3c693913b27382dd Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:03:11 +0200
Subject: [PATCH] [clang] Revise IDE folder structure

---
 clang/CMakeLists.txt| 8 +---
 clang/bindings/python/tests/CMakeLists.txt  | 2 +-
 clang/cmake/modules/AddClang.cmake  | 3 ---
 clang/docs/CMakeLists.txt   | 1 +
 clang/lib/Analysis/FlowSensitive/CMakeLists.txt | 1 +
 clang/lib/Headers/CMakeLists.txt| 4 ++--
 clang/lib/Tooling/CMakeLists.txt| 2 ++
 clang/test/CMakeLists.txt   | 5 ++---
 clang/tools/libclang/CMakeLists.txt | 2 +-
 clang/unittests/CMakeLists.txt  | 2 +-
 clang/utils/ClangVisualizers/CMakeLists.txt | 2 +-
 clang/utils/TableGen/CMakeLists.txt | 2 --
 clang/utils/hmaptool/CMakeLists.txt | 2 +-
 13 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f092766fa19f07..09da3ad9979ffd 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "Clang")
 
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
@@ -390,7 +391,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   # Installing the headers needs to depend on generating any public
   # tablegen'd headers.
   add_custom_target(clang-headers DEPENDS clang-tablegen-targets)
-  set_target_properties(clang-headers PROPERTIES FOLDER "Misc")
+  set_target_properties(clang-headers PROPERTIES FOLDER "Clang/Resources")
   if(NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-clang-headers
  DEPENDS clang-headers
@@ -398,6 +399,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   endif()
 
   add_custom_target(bash-autocomplete DEPENDS utils/bash-autocomplete.sh)
+  set_target_properties(bash-autocomplete PROPERTIES FOLDER "Clang/Misc")
   install(FILES utils/bash-autocomplete.sh
   DESTINATION "${CMAKE_INSTALL_DATADIR}/clang"
   COMPONENT bash-autocomplete)
@@ -478,7 +480,7 @@ add_custom_target(clang-tablegen-targets
   omp_gen
   ClangDriverOptions
   ${CLANG_TABLEGEN_TARGETS})
-set_target_properties(clang-tablegen-targets PROPERTIES FOLDER "Misc")
+set_target_properties(clang-tablegen-targets PROPERTIES FOLDER 
"Clang/Tablegenning/Targets")
 list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
 
 # Force target to be built as soon as possible. Clang modules builds depend
@@ -541,7 +543,7 @@ endif()
 
 # Custom target to install all clang libraries.
 add_custom_target(clang-libraries)
-set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
+set_target_properties(clang-libraries PROPERTIES FOLDER "Clang/Install")
 
 if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-libraries
diff --git a/clang/bindings/python/tests/CMakeLists.txt 
b/clang/bindings/python/tests/CMakeLists.txt
index c4cd2539e9d6cf..2543cf739463d9 100644
--- a/clang/bindings/python/tests/CMakeLists.

[llvm-branch-commits] [clang-tools-extra] [clang-tools-extra] Revise IDE folder structure (PR #89744)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89744

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the Clang-tools-extra part. See #89153 for the entire series 
and motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From 937a7728542d880fd37c439bec6dca4ccd3f07d2 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:06:06 +0200
Subject: [PATCH] [clang-tools-extra] Revise IDE folder structure

---
 clang-tools-extra/CMakeLists.txt   | 2 ++
 clang-tools-extra/clang-tidy/CMakeLists.txt| 2 +-
 clang-tools-extra/clang-tidy/misc/CMakeLists.txt   | 2 ++
 clang-tools-extra/clangd/unittests/CMakeLists.txt  | 1 +
 clang-tools-extra/docs/CMakeLists.txt  | 1 +
 clang-tools-extra/include-cleaner/unittests/CMakeLists.txt | 1 +
 clang-tools-extra/pseudo/include/CMakeLists.txt| 1 +
 clang-tools-extra/pseudo/tool/CMakeLists.txt   | 1 +
 clang-tools-extra/pseudo/unittests/CMakeLists.txt  | 1 +
 clang-tools-extra/test/CMakeLists.txt  | 1 -
 clang-tools-extra/unittests/CMakeLists.txt | 2 +-
 11 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/CMakeLists.txt b/clang-tools-extra/CMakeLists.txt
index 6a3f741721ee6c..f6a6b57b5ef0bc 100644
--- a/clang-tools-extra/CMakeLists.txt
+++ b/clang-tools-extra/CMakeLists.txt
@@ -1,3 +1,5 @@
+set(LLVM_SUBPROJECT_TITLE "Clang Tools Extra")
+
 include(CMakeDependentOption)
 include(GNUInstallDirs)
 
diff --git a/clang-tools-extra/clang-tidy/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/CMakeLists.txt
index 7e1905aa897b7e..430ea4cdbb38e1 100644
--- a/clang-tools-extra/clang-tidy/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -121,7 +121,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 PATTERN "*.h"
 )
   add_custom_target(clang-tidy-headers)
-  set_target_properties(clang-tidy-headers PROPERTIES FOLDER "Misc")
+  set_target_properties(clang-tidy-headers PROPERTIES FOLDER "Clang Tools 
Extra/Resources")
   if(NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-clang-tidy-headers
  DEPENDS clang-tidy-headers
diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index d9ec268650c053..4eda705c45d2af 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -15,6 +15,7 @@ add_custom_command(
 DEPENDS ${clang_tidy_confusable_chars_gen_target} 
ConfusableTable/confusables.txt)
 
 add_custom_target(genconfusable DEPENDS Confusables.inc)
+set_target_properties(genconfusable PROPERTIES FOLDER "Clang Tools 
Extra/Tablegenning")
 
 add_clang_library(clangTidyMiscModule
   ConstCorrectnessCheck.cpp
@@ -51,6 +52,7 @@ add_clang_library(clangTidyMiscModule
   genconfusable
   ClangDriverOptions
   )
+set_target_properties(clangTidyMiscModule PROPERTIES FOLDER "Clang Tools 
Extra/Libraries")
 
 clang_target_link_libraries(clangTidyMiscModule
   PRIVATE
diff --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index 7f1ae5c43d80c6..0d4628ccf25d8c 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -29,6 +29,7 @@ 
include(${CMAKE_CURRENT_SOURCE_DIR}/../quality/CompletionModel.cmake)
 gen_decision_forest(${CMAKE_CURRENT_SOURCE_DIR}/decision_forest_model 
DecisionForestRuntimeTest ::ns1::ns2::test::Example)
 
 add_custom_target(ClangdUnitTests)
+set_target_properties(ClangdUnitTests PROPERTIES FOLDER "Clang Tools 
Extra/Tests")
 add_unittest(ClangdUnitTests ClangdTests
   Annotations.cpp
   ASTTests.cpp
diff --git a/clang-tools-extra/docs/CMakeLists.txt 
b/clang-tools-extra/docs/CMakeLists.txt
index 8f442e1f661ed3..272db266b50546 100644
--- a/clang-tools-extra/docs/CMakeLists.txt
+++ b/clang-tools-extra/docs/CMakeLists.txt
@@ -77,6 +77,7 @@ if (DOXYGEN_FOUND)
   COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 

[llvm-branch-commits] [flang] [flang] Revise IDE folder structure (PR #89745)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89745

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the Flang part. See #89153 for the entire series and 
motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.


>From 90d0d0f3bed2d826dc38e962a7a9140bf2ff3615 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:13:53 +0200
Subject: [PATCH] [flang] Revise IDE folder structure

---
 flang/CMakeLists.txt | 3 ++-
 flang/cmake/modules/AddFlang.cmake   | 3 +--
 flang/docs/CMakeLists.txt| 2 +-
 flang/include/flang/Optimizer/Dialect/CMakeLists.txt | 2 ++
 flang/runtime/CMakeLists.txt | 5 +
 flang/test/CMakeLists.txt| 3 ++-
 flang/tools/f18/CMakeLists.txt   | 1 +
 flang/unittests/CMakeLists.txt   | 3 ++-
 flang/unittests/Evaluate/CMakeLists.txt  | 1 +
 9 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index c8e75024823f2c..3bc4b5dd10c0ea 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "Flang")
 
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
@@ -481,7 +482,7 @@ endif()
 
 # Custom target to install Flang libraries.
 add_custom_target(flang-libraries)
-set_target_properties(flang-libraries PROPERTIES FOLDER "Misc")
+set_target_properties(flang-libraries PROPERTIES FOLDER "Flang/Meta")
 
 if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-flang-libraries
diff --git a/flang/cmake/modules/AddFlang.cmake 
b/flang/cmake/modules/AddFlang.cmake
index 41ce8738e7bf27..3a5119b83831f9 100644
--- a/flang/cmake/modules/AddFlang.cmake
+++ b/flang/cmake/modules/AddFlang.cmake
@@ -94,13 +94,12 @@ function(add_flang_library name)
 add_custom_target(${name})
   endif()
 
-  set_target_properties(${name} PROPERTIES FOLDER "Flang libraries")
+  set_target_properties(${name} PROPERTIES FOLDER "Flang/Libraries")
   set_flang_windows_version_resource_properties(${name})
 endfunction(add_flang_library)
 
 macro(add_flang_executable name)
   add_llvm_executable(${name} ${ARGN})
-  set_target_properties(${name} PROPERTIES FOLDER "Flang executables")
   set_flang_windows_version_resource_properties(${name})
 endmacro(add_flang_executable)
 
diff --git a/flang/docs/CMakeLists.txt b/flang/docs/CMakeLists.txt
index 3414b8e3acc463..3e4883e881ffac 100644
--- a/flang/docs/CMakeLists.txt
+++ b/flang/docs/CMakeLists.txt
@@ -79,7 +79,7 @@ if (LLVM_ENABLE_DOXYGEN)
 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating flang doxygen documentation." VERBATIM)
-
+  set_target_properties(doxygen-flang PROPERTIES FOLDER "Flang/Docs")
   if (LLVM_BUILD_DOCS)
add_dependencies(doxygen doxygen-flang)
   endif()
diff --git a/flang/include/flang/Optimizer/Dialect/CMakeLists.txt 
b/flang/include/flang/Optimizer/Dialect/CMakeLists.txt
index f00993d4d37780..203ac212d3ccfa 100644
--- a/flang/include/flang/Optimizer/Dialect/CMakeLists.txt
+++ b/flang/include/flang/Optimizer/Dialect/CMakeLists.txt
@@ -31,6 +31,7 @@ mlir_tablegen(CanonicalizationPatterns.inc -gen-rewriters)
 add_public_tablegen_target(CanonicalizationPatternsIncGen)
 
 add_custom_target(flang-doc)
+set_target_properties(flang-doc PROPERTIES FOLDER "Flang/Meta")
 set(dialect_doc_filename "FIRLangRef")
 
 set(LLVM_TARGET_DEFINITIONS FIROps.td)
@@ -43,4 +44,5 @@ add_custom_command(
 ${GEN_DOC_FILE}
 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${dialect_doc_filename}.md)
 add_custom_target(${dialect_doc_filename}DocGen DEPENDS ${GEN_DOC_FILE})
+set_target_properties(${dialect_doc_filename}DocGen PROPERTIES FOLDER 
"Flang/Docs")
 add_dependencies(flang-doc ${dialect_doc_filename}DocGen)
diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt
index bdd0e07bbfd4d1..eaa79851046c6c 100644
--- a/flang/runtime/CMakeLists.txt
+++ b/flan

[llvm-branch-commits] [libclc] [libclc] Revise IDE folder structure (PR #89746)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89746

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the libclc part. See #89153 for the entire series and 
motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From 24ed445050def3e41569cc25bc04dd3dc107c04f Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:25:53 +0200
Subject: [PATCH] [libclc] Revise IDE folder structure

---
 libclc/CMakeLists.txt| 13 -
 libclc/cmake/modules/AddLibclc.cmake |  5 -
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 5ce17952430854..05e0061d42298a 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -1,6 +1,7 @@
 cmake_minimum_required(VERSION 3.20.0)
 
 project( libclc VERSION 0.2.0 LANGUAGES CXX C)
+set(LLVM_SUBPROJECT_TITLE "libclc")
 
 set(CMAKE_CXX_STANDARD 17)
 
@@ -54,7 +55,10 @@ if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL 
CMAKE_CURRENT_SOURCE_DI
 foreach( tool IN ITEMS clang llvm-as llvm-link opt )
   find_program( LLVM_TOOL_${tool} ${tool} PATHS ${LLVM_TOOLS_BINARY_DIR} 
NO_DEFAULT_PATH )
   add_executable( libclc::${tool} IMPORTED GLOBAL )
-  set_target_properties( libclc::${tool} PROPERTIES IMPORTED_LOCATION 
${LLVM_TOOL_${tool}} )
+  set_target_properties( libclc::${tool} PROPERTIES
+IMPORTED_LOCATION ${LLVM_TOOL_${tool}}
+FOLDER "libclc/Tools"
+  )
 endforeach()
   endif()
 else()
@@ -168,6 +172,7 @@ if( LIBCLC_STANDALONE_BUILD )
 else()
   add_llvm_utility( prepare_builtins utils/prepare-builtins.cpp )
 endif()
+set_target_properties( prepare_builtins PROPERTIES FOLDER 
"libclc/Tablegenning")
 target_compile_definitions( prepare_builtins PRIVATE ${LLVM_VERSION_DEFINE} )
 # These were not properly reported in early LLVM and we don't need them
 target_compile_options( prepare_builtins PRIVATE -fno-rtti -fno-exceptions )
@@ -225,12 +230,14 @@ add_custom_command(
   COMMAND ${Python3_EXECUTABLE} ${script_loc} > convert.cl
   DEPENDS ${script_loc} )
 add_custom_target( "generate_convert.cl" DEPENDS convert.cl )
+set_target_properties( "generate_convert.cl" PROPERTIES FOLDER 
"libclc/Tablegenning" )
 
 add_custom_command(
   OUTPUT clspv-convert.cl
   COMMAND ${Python3_EXECUTABLE} ${script_loc} --clspv > clspv-convert.cl
   DEPENDS ${script_loc} )
 add_custom_target( "clspv-generate_convert.cl" DEPENDS clspv-convert.cl )
+set_target_properties( "clspv-generate_convert.cl" PROPERTIES FOLDER 
"libclc/Tablegenning" )
 
 enable_testing()
 
@@ -394,6 +401,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 DEPENDS ${builtins_link_lib}
   )
   add_custom_target( "prepare-${spv_suffix}" ALL DEPENDS "${spv_suffix}" )
+  set_target_properties( "prepare-${spv_suffix}" PROPERTIES FOLDER 
"libclc/Tablegenning" )
   install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${spv_suffix}
  DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
 else()
@@ -410,6 +418,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
   )
   set_target_properties( ${builtins_opt_lib_tgt}
 PROPERTIES TARGET_FILE ${builtins_opt_lib_tgt}.bc
+   FOLDER "libclc/BC Genning"
   )
 
   set( builtins_opt_lib 
$ )
@@ -420,6 +429,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 COMMAND prepare_builtins -o ${obj_suffix} ${builtins_opt_lib}
 DEPENDS ${builtins_opt_lib} prepare_builtins )
   add_custom_target( prepare-${obj_suffix} ALL DEPENDS ${obj_suffix} )
+  set_target_properties( "prepare-${obj_suffix}" PROPERTIES FOLDER 
"libclc/BC Genning" )
 
   # nvptx-- targets don't include workitem builtins
   if( NOT clang_triple MATCHES ".*ptx.*--$" )
@@ -434,6 +444,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 add_custom_target( ${alias_suffix} ALL
   COMMAND ${CMAKE_COMMAND} -E create_symlink ${obj_suffix} 
${alias_suffix}
   DEPENDS prepare-${obj_suffix} )
+set_target_properties( "${alias_suffix}" PROPERTIES FOLDER "libclc/BC 
Genning" )
 install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${alias_suffix} DESTINATION 
"${CMAKE_INSTALL_DATADIR}/clc" )
  

[llvm-branch-commits] [clang] [clang] Revise IDE folder structure (PR #89743)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/89743
___
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] [lld] [lld] Revise IDE folder structure (PR #89747)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89747

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the LLD part. See #89153 for the entire series and motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From 6c3206c8100ed68ab77ceb98741bef42659bcfc1 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:12:03 +0200
Subject: [PATCH] [lld] Revise IDE folder structure

---
 lld/CMakeLists.txt | 2 ++
 lld/cmake/modules/AddLLD.cmake | 2 --
 lld/test/CMakeLists.txt| 5 ++---
 lld/unittests/CMakeLists.txt   | 2 --
 4 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index cd8ba627306edb..64c9f238055092 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "LLD")
 
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
@@ -192,6 +193,7 @@ add_subdirectory(tools/lld)
 
 if (LLVM_INCLUDE_TESTS)
   add_custom_target(LLDUnitTests)
+  set_target_properties(LLDUnitTests PROPERTIES FOLDER "LLD/Tests")
   if (TARGET llvm_gtest)
 add_subdirectory(unittests)
   endif()
diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake
index 2ee066b4153519..9f2684b6f933ec 100644
--- a/lld/cmake/modules/AddLLD.cmake
+++ b/lld/cmake/modules/AddLLD.cmake
@@ -11,7 +11,6 @@ macro(add_lld_library name)
 set(ARG_ENABLE_SHARED SHARED)
   endif()
   llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS})
-  set_target_properties(${name} PROPERTIES FOLDER "lld libraries")
 
   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 get_target_export_arg(${name} LLD export_to_lldtargets)
@@ -33,7 +32,6 @@ endmacro(add_lld_library)
 
 macro(add_lld_executable name)
   add_llvm_executable(${name} ${ARGN})
-  set_target_properties(${name} PROPERTIES FOLDER "lld executables")
 endmacro(add_lld_executable)
 
 macro(add_lld_tool name)
diff --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index bb6164f19dcef3..25d8f0a424926d 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -83,10 +83,9 @@ add_lit_testsuite(check-lld "Running lld test suite"
   ${CMAKE_CURRENT_BINARY_DIR}
   DEPENDS ${LLD_TEST_DEPS}
   )
-set_target_properties(check-lld PROPERTIES FOLDER "lld tests")
 
 add_custom_target(lld-test-depends DEPENDS ${LLD_TEST_DEPS})
-set_target_properties(lld-test-depends PROPERTIES FOLDER "lld tests")
+set_target_properties(lld-test-depends PROPERTIES FOLDER "LLD/Tests")
 
 add_lit_testsuites(LLD ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${LLD_TEST_DEPS}
@@ -95,4 +94,4 @@ add_lit_testsuites(LLD ${CMAKE_CURRENT_SOURCE_DIR}
 # Add a legacy target spelling: lld-test
 add_custom_target(lld-test)
 add_dependencies(lld-test check-lld)
-set_target_properties(lld-test PROPERTIES FOLDER "lld tests")
+set_target_properties(lld-test PROPERTIES FOLDER "LLD/Tests")
diff --git a/lld/unittests/CMakeLists.txt b/lld/unittests/CMakeLists.txt
index ac878fa0190833..ffaea3f2078330 100644
--- a/lld/unittests/CMakeLists.txt
+++ b/lld/unittests/CMakeLists.txt
@@ -1,5 +1,3 @@
-set_target_properties(LLDUnitTests PROPERTIES FOLDER "lld tests")
-
 function(add_lld_unittests test_dirname)
   add_unittest(LLDUnitTests ${test_dirname} ${ARGN})
 endfunction()

___
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] [lldb] [lldb] Revise IDE folder structure (PR #89748)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89748

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the BOLT part. See #89153 for the entire series and motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From e29002224ef168934ae414e75e765cf197f65bc0 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:21:43 +0200
Subject: [PATCH] [lldb] Revise IDE folder structure

---
 lldb/CMakeLists.txt | 1 +
 lldb/cmake/modules/AddLLDB.cmake| 6 ++
 lldb/cmake/modules/LLDBConfig.cmake | 2 +-
 lldb/cmake/modules/LLDBFramework.cmake  | 2 +-
 lldb/cmake/modules/LLDBStandalone.cmake | 4 ++--
 lldb/docs/CMakeLists.txt| 1 +
 lldb/source/API/CMakeLists.txt  | 3 +--
 lldb/test/API/CMakeLists.txt| 1 +
 lldb/test/CMakeLists.txt| 4 ++--
 lldb/test/Shell/CMakeLists.txt  | 1 +
 lldb/test/Unit/CMakeLists.txt   | 1 +
 lldb/tools/driver/CMakeLists.txt| 2 --
 .../lldb-commandinterpreter-fuzzer/CMakeLists.txt   | 1 +
 lldb/tools/lldb-fuzzer/lldb-target-fuzzer/CMakeLists.txt| 1 +
 lldb/tools/lldb-server/CMakeLists.txt   | 1 -
 lldb/unittests/CMakeLists.txt   | 2 +-
 lldb/unittests/tools/lldb-server/CMakeLists.txt | 2 +-
 lldb/utils/TableGen/CMakeLists.txt  | 1 -
 lldb/utils/lit-cpuid/CMakeLists.txt | 2 +-
 lldb/utils/lldb-dotest/CMakeLists.txt   | 2 +-
 lldb/utils/lldb-repro/CMakeLists.txt| 2 +-
 21 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 7844d93d78d29a..db9e5517e287b2 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "LLDB")
 
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index fdc4ee0c05d755..538029037dd46a 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -29,7 +29,6 @@ function(lldb_tablegen)
 
   if(LTG_TARGET)
 add_public_tablegen_target(${LTG_TARGET})
-set_target_properties( ${LTG_TARGET} PROPERTIES FOLDER "LLDB tablegenning")
 set_property(GLOBAL APPEND PROPERTY LLDB_TABLEGEN_TARGETS ${LTG_TARGET})
   endif()
 endfunction(lldb_tablegen)
@@ -165,10 +164,10 @@ function(add_lldb_library name)
 get_property(parent_dir DIRECTORY PROPERTY PARENT_DIRECTORY)
 if(EXISTS ${parent_dir})
   get_filename_component(category ${parent_dir} NAME)
-  set_target_properties(${name} PROPERTIES FOLDER "lldb 
plugins/${category}")
+  set_target_properties(${name} PROPERTIES FOLDER 
"LLDB/Plugins/${category}")
 endif()
   else()
-set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
+set_target_properties(${name} PROPERTIES FOLDER "LLDB/Libraries")
   endif()
 
   # If we want to export all lldb symbols (i.e LLDB_EXPORT_ALL_SYMBOLS=ON), we
@@ -208,7 +207,6 @@ function(add_lldb_executable name)
   else()
 target_link_libraries(${name} PRIVATE ${ARG_CLANG_LIBS})
   endif()
-  set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
 
   if (ARG_BUILD_RPATH)
 set_target_properties(${name} PROPERTIES BUILD_RPATH "${ARG_BUILD_RPATH}")
diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index a758261073ac57..13d07a4fabd6de 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -271,7 +271,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 )
 
   add_custom_target(lldb-headers)
-  set_target_properties(lldb-headers PROPERTIES FOLDER "lldb misc")
+  set_target_properties(lldb-headers PROPERTIES FOLDER "LLDB/Resources")
 
   i

[llvm-branch-commits] [lldb] [lldb] Revise IDE folder structure (PR #89748)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/89748
___
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] Revise IDE folder structure (PR #89749)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89749

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the MLIR part. See #89153 for the entire series and motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From 82bac5ccd7d6d2b4e146ed4e383a8484e735606e Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:08:54 +0200
Subject: [PATCH] [mlir] Revise IDE folder structure

---
 mlir/CMakeLists.txt| 9 ++---
 mlir/cmake/modules/AddMLIR.cmake   | 5 +++--
 mlir/docs/CMakeLists.txt   | 1 +
 mlir/examples/toy/CMakeLists.txt   | 2 +-
 mlir/examples/transform/CMakeLists.txt | 1 +
 mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt | 2 ++
 mlir/lib/TableGen/CMakeLists.txt   | 1 +
 mlir/test/CAPI/CMakeLists.txt  | 2 ++
 mlir/test/CMakeLists.txt   | 2 +-
 mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt  | 1 +
 mlir/tools/mlir-pdll/CMakeLists.txt| 1 -
 mlir/tools/mlir-tblgen/CMakeLists.txt  | 1 -
 mlir/unittests/CMakeLists.txt  | 2 --
 13 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 5c4301af040b47..0ff6658f831f5d 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -1,5 +1,6 @@
 # MLIR project.
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "MLIR")
 
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
@@ -96,12 +97,13 @@ endif()
 # tablegen'd targets.
 # mlir-generic-headers are dialect-independent.
 add_custom_target(mlir-generic-headers)
-set_target_properties(mlir-generic-headers PROPERTIES FOLDER "Misc")
+set_target_properties(mlir-generic-headers PROPERTIES FOLDER "MLIR/Resources")
 # mlir-headers may be dialect-dependent.
 add_custom_target(mlir-headers)
-set_target_properties(mlir-headers PROPERTIES FOLDER "Misc")
+set_target_properties(mlir-headers PROPERTIES FOLDER "MLIR/Resources")
 add_dependencies(mlir-headers mlir-generic-headers)
 add_custom_target(mlir-doc)
+set_target_properties(mlir-doc PROPERTIES FOLDER "MLIR/Docs")
 
 # Only enable execution engine if the native target is available.
 if(${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD)
@@ -198,6 +200,7 @@ add_subdirectory(lib/CAPI)
 if (MLIR_INCLUDE_TESTS)
   add_definitions(-DMLIR_INCLUDE_TESTS)
   add_custom_target(MLIRUnitTests)
+  set_target_properties(MLIRUnitTests PROPERTIES FOLDER "MLIR/Tests")
   if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include/gtest/gtest.h)
 add_subdirectory(unittests)
   else()
@@ -258,7 +261,7 @@ endif()
 
 # Custom target to install all mlir libraries
 add_custom_target(mlir-libraries)
-set_target_properties(mlir-libraries PROPERTIES FOLDER "Misc")
+set_target_properties(mlir-libraries PROPERTIES FOLDER "MLIR/Install")
 
 if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-mlir-libraries
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index 1d2ed748bc2f13..5a9a5b799763a9 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -173,6 +173,7 @@ function(add_mlir_doc doc_filename output_file 
output_directory command)
   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output_file}.md)
   add_custom_target(${output_file}DocGen DEPENDS ${GEN_DOC_FILE})
   add_dependencies(mlir-doc ${output_file}DocGen)
+  set_target_properties(${output_file}DocGen PROPERTIES FOLDER "MLIR/Docs")
 endfunction()
 
 # Sets ${srcs} to contain the list of additional headers for the target. Extra
@@ -252,7 +253,7 @@ function(add_mlir_example_library name)
   list(APPEND ARG_DEPENDS mlir-generic-headers)
 
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs} 
DEPENDS ${ARG_DEPENDS} LINK_COMPONENTS ${ARG_LINK_COMPONENTS} LINK_LIBS 
${ARG_LINK_LIBS})
-  set_target_properties(${name} PROPERTIES FOLDER "Examples")
+  set_target_properties(${name} PROPERTIES FOLDER "MLIR/Examples")
   if (LLVM_BUILD_EXAMPLES AND NOT ${ARG_DISABLE_INSTALL})
 

[llvm-branch-commits] [llvm] [openmp] [openmp] Revise IDE folder structure (PR #89750)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89750

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the OpenMP part. See #89153 for the entire series and 
motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From c3edd260d7a917e120d02253083eb472e0985844 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:27:20 +0200
Subject: [PATCH] [openmp] Revise IDE folder structure

---
 offload/unittests/CMakeLists.txt| 2 +-
 openmp/CMakeLists.txt   | 1 +
 openmp/docs/CMakeLists.txt  | 1 +
 openmp/runtime/cmake/LibompMicroTests.cmake | 5 +
 openmp/runtime/src/CMakeLists.txt   | 7 +++
 5 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/offload/unittests/CMakeLists.txt b/offload/unittests/CMakeLists.txt
index 73c87b708d25fd..c818a3d985ba34 100644
--- a/offload/unittests/CMakeLists.txt
+++ b/offload/unittests/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_custom_target(LibomptUnitTests)
-set_target_properties(LibomptUnitTests PROPERTIES FOLDER "Tests/UnitTests")
+set_target_properties(LibomptUnitTests PROPERTIES FOLDER "Tests")
 
 function(add_libompt_unittest test_dirname)
   add_unittest(LibomptUnitTests ${test_dirname} ${ARGN})
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 95f2425db3ee6b..daef2b77fd4dd5 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "OpenMP")
 
 set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
 
diff --git a/openmp/docs/CMakeLists.txt b/openmp/docs/CMakeLists.txt
index 1e4be31a6f609e..4cb9fb486ff34f 100644
--- a/openmp/docs/CMakeLists.txt
+++ b/openmp/docs/CMakeLists.txt
@@ -78,6 +78,7 @@ if (LLVM_ENABLE_DOXYGEN)
 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating openmp doxygen documentation." VERBATIM)
+  set_target_properties(doxygen-openmp PROPERTIES FOLDER "OpenMP/Docs")
 
   if (LLVM_BUILD_DOCS)
 add_dependencies(doxygen doxygen-openmp)
diff --git a/openmp/runtime/cmake/LibompMicroTests.cmake 
b/openmp/runtime/cmake/LibompMicroTests.cmake
index e8cc218af0c294..6fcde37259931e 100644
--- a/openmp/runtime/cmake/LibompMicroTests.cmake
+++ b/openmp/runtime/cmake/LibompMicroTests.cmake
@@ -126,6 +126,7 @@ macro(libomp_test_touch_recipe test_touch_dir)
 endmacro()
 libomp_append(libomp_test_touch_env "KMP_VERSION=1")
 add_custom_target(libomp-test-touch DEPENDS ${libomp_test_touch_targets})
+set_target_properties(libomp-test-touch PROPERTIES FOLDER "OpenMP/Tests")
 if(WIN32)
   libomp_test_touch_recipe(test-touch-mt)
   libomp_test_touch_recipe(test-touch-md)
@@ -135,6 +136,7 @@ endif()
 
 # test-relo
 add_custom_target(libomp-test-relo DEPENDS test-relo/.success)
+set_target_properties(libomp-test-relo PROPERTIES FOLDER "OpenMP/Tests")
 add_custom_command(
   OUTPUT  test-relo/.success test-relo/readelf.log
   COMMAND ${CMAKE_COMMAND} -E make_directory 
${CMAKE_CURRENT_BINARY_DIR}/test-relo
@@ -146,6 +148,7 @@ add_custom_command(
 
 # test-execstack
 add_custom_target(libomp-test-execstack DEPENDS test-execstack/.success)
+set_target_properties(libomp-test-execstack PROPERTIES FOLDER "OpenMP/Tests")
 add_custom_command(
   OUTPUT  test-execstack/.success
   COMMAND ${CMAKE_COMMAND} -E make_directory 
${CMAKE_CURRENT_BINARY_DIR}/test-execstack
@@ -157,6 +160,7 @@ add_custom_command(
 
 # test-instr
 add_custom_target(libomp-test-instr DEPENDS test-instr/.success)
+set_target_properties(libomp-test-instr PROPERTIES FOLDER "OpenMP/Tests")
 add_custom_command(
   OUTPUT  test-instr/.success
   COMMAND ${CMAKE_COMMAND} -E make_directory 
${CMAKE_CURRENT_BINARY_DIR}/test-instr
@@ -168,6 +172,7 @@ add_custom_command(
 
 # test-deps
 add_custom_target(libomp-test-deps DEPENDS test-deps/.success)
+set_target_properties(libomp-test-deps PROPERTIES FOLDER "OpenMP/Tests")
 set(libomp_expected_library_deps)
 if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
   set(libomp_expected_library_deps libc.so.7 libthr.so.3 libm.so.5)
diff --git a/openmp/runtime/src/CMakeLists.txt 
b/open

[llvm-branch-commits] [polly] [polly] Revise IDE folder structure (PR #89752)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89752

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the Polly part. See #89153 for the entire series and 
motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From a85a17723d76371ccc8feb245c455d6aaf2c297f Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:19:16 +0200
Subject: [PATCH] [polly] Revise IDE folder structure

---
 polly/CMakeLists.txt   | 5 +++--
 polly/cmake/polly_macros.cmake | 2 +-
 polly/docs/CMakeLists.txt  | 1 +
 polly/lib/CMakeLists.txt   | 4 +---
 polly/test/CMakeLists.txt  | 7 ++-
 polly/unittests/CMakeLists.txt | 2 +-
 6 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt
index 5d0f2cd7f00ece..a0d1ab49e78379 100644
--- a/polly/CMakeLists.txt
+++ b/polly/CMakeLists.txt
@@ -4,6 +4,7 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   cmake_minimum_required(VERSION 3.20.0)
   set(POLLY_STANDALONE_BUILD TRUE)
 endif()
+set(LLVM_SUBPROJECT_TITLE "Polly")
 
 # Must go below project(..)
 include(GNUInstallDirs)
@@ -157,8 +158,8 @@ foreach (file IN LISTS files)
 endforeach ()
 
 add_custom_target(polly-check-format DEPENDS ${check_format_depends})
-set_target_properties(polly-check-format PROPERTIES FOLDER "Polly")
+set_target_properties(polly-check-format PROPERTIES FOLDER "Polly/Meta")
 
 add_custom_target(polly-update-format DEPENDS ${update_format_depends})
-set_target_properties(polly-update-format PROPERTIES FOLDER "Polly")
+set_target_properties(polly-update-format PROPERTIES FOLDER "Polly/Meta")
 
diff --git a/polly/cmake/polly_macros.cmake b/polly/cmake/polly_macros.cmake
index df541eeccc4cb5..b1bd1e1b03cda8 100644
--- a/polly/cmake/polly_macros.cmake
+++ b/polly/cmake/polly_macros.cmake
@@ -21,7 +21,7 @@ macro(add_polly_library name)
 set(libkind)
   endif()
   add_library( ${name} ${libkind} ${srcs} )
-  set_target_properties(${name} PROPERTIES FOLDER "Polly")
+  set_target_properties(${name} PROPERTIES FOLDER "Polly/Libraries")
 
   if( LLVM_COMMON_DEPENDS )
 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
diff --git a/polly/docs/CMakeLists.txt b/polly/docs/CMakeLists.txt
index a1ef5ce5277f7a..2bd16e53c542f6 100644
--- a/polly/docs/CMakeLists.txt
+++ b/polly/docs/CMakeLists.txt
@@ -77,6 +77,7 @@ if (LLVM_ENABLE_DOXYGEN)
 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating polly doxygen documentation." VERBATIM)
+  set_target_properties(doxygen-polly PROPERTIES FOLDER "Polly/Docs")
 
   if (LLVM_BUILD_DOCS)
 add_dependencies(doxygen doxygen-polly)
diff --git a/polly/lib/CMakeLists.txt b/polly/lib/CMakeLists.txt
index 4557878e515e66..f18cdcd09cfca7 100644
--- a/polly/lib/CMakeLists.txt
+++ b/polly/lib/CMakeLists.txt
@@ -92,8 +92,6 @@ add_llvm_pass_plugin(Polly
   LINK_COMPONENTS
   ${POLLY_COMPONENTS}
   )
-set_target_properties(obj.Polly PROPERTIES FOLDER "Polly")
-set_target_properties(Polly PROPERTIES FOLDER "Polly")
 
 if (MSVC_IDE OR XCODE)
   # Configure source groups for Polly source files. By default, in the IDE 
there
@@ -120,7 +118,7 @@ if (WIN32 OR CYGWIN OR NOT LLVM_ENABLE_PIC)
   # Add dummy target, either because loadable modules are not supported
   # as on Windows or because PIC code has been disabled
   add_custom_target(LLVMPolly)
-  set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly")
+  set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly/Meta")
 else ()
   add_polly_loadable_module(LLVMPolly
 Plugin/Polly.cpp
diff --git a/polly/test/CMakeLists.txt b/polly/test/CMakeLists.txt
index 81cee34a780d61..338c7dbfa1158c 100644
--- a/polly/test/CMakeLists.txt
+++ b/polly/test/CMakeLists.txt
@@ -1,7 +1,7 @@
 set(LLVM_SHLIBEXT "${CMAKE_SHARED_MODULE_SUFFIX}")
 
 add_custom_target(check-polly)
-set_target_properties(check-polly PROPERTIES FOLDER "Polly")
+set_target_properties(check-polly PROPERTIES FOLDER "Polly/Tests")
 
 if(NOT LLVM_MAIN_SRC_DIR)
   find_program(LLVM_OPT NAMES opt HINTS ${LLVM_TOOLS_BINARY_DIR})
@@ -64,7 +64,6 @@ add_lit_testsuite(check-polly-tests "Running polly regres

[llvm-branch-commits] [compiler-rt] [compiler-rt] Revise IDE folder structure (PR #89753)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89753

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the Compiler-RT part. See #89153 for the entire series and 
motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From 19ef183fcfb44fa8b9bae34bdc8eafb8d2425722 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:15:38 +0200
Subject: [PATCH] [compiler-rt] Revise IDE folder structure

---
 compiler-rt/CMakeLists.txt|  3 ++-
 compiler-rt/cmake/Modules/AddCompilerRT.cmake | 21 ++-
 .../cmake/Modules/CompilerRTDarwinUtils.cmake |  4 ++--
 .../cmake/Modules/CompilerRTUtils.cmake   |  4 ++--
 compiler-rt/cmake/base-config-ix.cmake|  4 ++--
 compiler-rt/include/CMakeLists.txt|  2 +-
 compiler-rt/lib/asan/tests/CMakeLists.txt |  8 +++
 compiler-rt/lib/builtins/CMakeLists.txt   |  2 +-
 compiler-rt/lib/fuzzer/tests/CMakeLists.txt   |  6 +++---
 compiler-rt/lib/gwp_asan/tests/CMakeLists.txt |  4 ++--
 .../lib/interception/tests/CMakeLists.txt |  4 ++--
 compiler-rt/lib/memprof/tests/CMakeLists.txt  |  4 ++--
 compiler-rt/lib/orc/tests/CMakeLists.txt  |  6 +++---
 .../lib/sanitizer_common/tests/CMakeLists.txt |  4 ++--
 compiler-rt/lib/stats/CMakeLists.txt  |  2 +-
 compiler-rt/lib/tsan/CMakeLists.txt   |  2 +-
 compiler-rt/lib/tsan/dd/CMakeLists.txt|  2 +-
 compiler-rt/lib/tsan/rtl/CMakeLists.txt   |  2 +-
 compiler-rt/lib/xray/tests/CMakeLists.txt |  4 ++--
 compiler-rt/test/CMakeLists.txt   |  1 +
 compiler-rt/test/asan/CMakeLists.txt  |  3 ---
 compiler-rt/test/asan_abi/CMakeLists.txt  |  1 -
 compiler-rt/test/builtins/CMakeLists.txt  |  1 -
 compiler-rt/test/cfi/CMakeLists.txt   |  3 ---
 compiler-rt/test/dfsan/CMakeLists.txt |  1 -
 compiler-rt/test/fuzzer/CMakeLists.txt|  1 -
 compiler-rt/test/gwp_asan/CMakeLists.txt  |  1 -
 compiler-rt/test/hwasan/CMakeLists.txt|  2 --
 compiler-rt/test/interception/CMakeLists.txt  |  1 -
 compiler-rt/test/lsan/CMakeLists.txt  |  1 -
 compiler-rt/test/memprof/CMakeLists.txt   |  3 ---
 compiler-rt/test/metadata/CMakeLists.txt  |  1 -
 compiler-rt/test/msan/CMakeLists.txt  |  1 -
 compiler-rt/test/orc/CMakeLists.txt   |  1 -
 compiler-rt/test/profile/CMakeLists.txt   |  1 -
 compiler-rt/test/safestack/CMakeLists.txt |  1 -
 .../test/sanitizer_common/CMakeLists.txt  |  2 --
 .../test/shadowcallstack/CMakeLists.txt   |  1 -
 compiler-rt/test/tsan/CMakeLists.txt  |  1 -
 compiler-rt/test/ubsan/CMakeLists.txt |  2 --
 compiler-rt/test/ubsan_minimal/CMakeLists.txt |  1 -
 compiler-rt/test/xray/CMakeLists.txt  |  1 -
 42 files changed, 46 insertions(+), 74 deletions(-)

diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 6ce451e3cac2e3..65063e0057bbca 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -4,6 +4,7 @@
 # based on the ability of the host toolchain to target various platforms.
 
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "Compiler-RT")
 
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
@@ -90,7 +91,7 @@ if (COMPILER_RT_STANDALONE_BUILD)
   if (TARGET intrinsics_gen)
 # Loading the llvm config causes this target to be imported so place it
 # under the appropriate folder in an IDE.
-set_target_properties(intrinsics_gen PROPERTIES FOLDER "Compiler-RT Misc")
+set_target_properties(intrinsics_gen PROPERTIES FOLDER "LLVM/Tablegenning")
   endif()
 
   find_package(Python3 COMPONENTS Interpreter)
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 6e0d9dbff65a9e..61c727b36bff30 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -89,7 +89,7 @@ function(add_compiler_rt_object_libraries name)
 "${libname}" MATCHES ".*\.osx.*")
   foreach(arch ${LIB_ARCHS_${libname}})
 list(APPEND target_flags
-  "

[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak edited 
https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -903,24 +908,39 @@ bool ClauseProcessor::processMap(
   // Explicit map captures are captured ByRef by default,
   // optimisation passes may alter this to ByCopy or other capture
   // types to optimise
-  mlir::Value mapOp = createMapInfoOp(
+  mlir::omp::MapInfoOp mapOp = createMapInfoOp(
   firOpBuilder, clauseLocation, symAddr, mlir::Value{},

skatrak wrote:

```suggestion
  firOpBuilder, clauseLocation, symAddr, 
/*varPtrPtr=*/mlir::Value{},
```

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak commented:

Thank you for all the work here Andrew, I've got some comments but they should 
be relatively easy to address.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -903,24 +908,39 @@ bool ClauseProcessor::processMap(
   // Explicit map captures are captured ByRef by default,
   // optimisation passes may alter this to ByCopy or other capture
   // types to optimise
-  mlir::Value mapOp = createMapInfoOp(
+  mlir::omp::MapInfoOp mapOp = createMapInfoOp(
   firOpBuilder, clauseLocation, symAddr, mlir::Value{},
-  asFortran.str(), bounds, {},
+  asFortran.str(), bounds, {}, mlir::DenseIntElementsAttr{},

skatrak wrote:

```suggestion
  asFortran.str(), bounds, /*members=*/{}, 
/*membersIndex=*/mlir::DenseIntElementsAttr{},
```

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -185,7 +184,12 @@ template 
 bool ClauseProcessor::processMotionClauses(

skatrak wrote:

Not for this patch, but perhaps we should think about refactoring `processMap` 
and `processMotionClauses` to avoid code duplication for those parts that are 
shared between them.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -903,24 +908,39 @@ bool ClauseProcessor::processMap(
   // Explicit map captures are captured ByRef by default,
   // optimisation passes may alter this to ByCopy or other capture
   // types to optimise
-  mlir::Value mapOp = createMapInfoOp(
+  mlir::omp::MapInfoOp mapOp = createMapInfoOp(
   firOpBuilder, clauseLocation, symAddr, mlir::Value{},
-  asFortran.str(), bounds, {},
+  asFortran.str(), bounds, {}, mlir::DenseIntElementsAttr{},
   static_cast<
   
std::underlying_type_t>(
   mapTypeBits),
   mlir::omp::VariableCaptureKind::ByRef, symAddr.getType());
 
-  result.mapVars.push_back(mapOp);
-
-  if (mapSyms)
+  if (object.id()->owner().IsDerivedType()) {
+if (auto dataRef{ExtractDataRef(object.designator)}) {

skatrak wrote:

```suggestion
if (auto dataRef = ExtractDataRef(object.designator)) {
```

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -1177,10 +1178,11 @@ static void genTargetDataClauses(
 llvm::SmallVectorImpl &useDeviceTypes,
 llvm::SmallVectorImpl &useDeviceLocs,
 llvm::SmallVectorImpl &useDeviceSyms) {
+  llvm::SmallVector mapSyms;

skatrak wrote:

Changes to this function can probably be reverted if `mapSyms` is made optional 
again.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -218,17 +223,34 @@ bool ClauseProcessor::processMotionClauses(
   // Explicit map captures are captured ByRef by default,
   // optimisation passes may alter this to ByCopy or other capture
   // types to optimise
-  mlir::Value mapOp = createMapInfoOp(
+  mlir::omp::MapInfoOp mapOp = createMapInfoOp(
   firOpBuilder, clauseLocation, symAddr, mlir::Value{},

skatrak wrote:

Nit: Add comments for unnamed arguments.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -115,8 +115,7 @@ class ClauseProcessor {
   bool processMap(
   mlir::Location currentLocation, Fortran::lower::StatementContext 
&stmtCtx,
   mlir::omp::MapClauseOps &result,
-  llvm::SmallVectorImpl *mapSyms =
-  nullptr,
+  llvm::SmallVectorImpl *mapSyms,

skatrak wrote:

If `mapSyms` is no longer optional, then it should be passed as a reference 
rather than as a pointer here. However, I don't think it should be, since it's 
not always needed by the caller (at least currently).

I think the proper solution would be to do something like this in `processMap`:
```c++
llvm::SmallVector localMapSyms;
llvm::SmallVectorImpl *ptrMapSyms =
mapSyms ? mapSyms : &localMapSyms;
// Use ptrMapSyms instead of mapSyms...
```
Let me know what you think.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -1664,7 +1667,7 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
 
 mlir::Value mapOp = createMapInfoOp(
 firOpBuilder, baseOp.getLoc(), baseOp, mlir::Value{}, name.str(),
-bounds, {},
+bounds, {}, mlir::DenseIntElementsAttr{},

skatrak wrote:

Nit: Add comments for unnamed arguments.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -811,9 +811,10 @@ mlir::omp::MapInfoOp
 createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,

skatrak wrote:

It looks like this function belongs in Utils.cpp, rather than here. I suppose 
that change doesn't belong in this PR, but it's something to keep in mind.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -88,6 +91,175 @@ void gatherFuncAndVarSyms(
 symbolAndClause.emplace_back(clause, *object.id());
 }
 
+int getComponentPlacementInParent(
+const Fortran::semantics::Symbol *componentSym) {
+  const auto *derived =
+  componentSym->owner()
+  .derivedTypeSpec()
+  ->typeSymbol()
+  .detailsIf();
+  assert(derived &&
+ "expected derived type details when processing component symbol");
+  int placement = 0;
+  for (auto t : derived->componentNames()) {
+if (t == componentSym->name())
+  return placement;
+placement++;
+  }
+  return -1;
+}
+
+std::optional
+getCompObjOrNull(std::optional object,

skatrak wrote:

```suggestion
getComponentObject(std::optional object,
```

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -88,6 +91,175 @@ void gatherFuncAndVarSyms(
 symbolAndClause.emplace_back(clause, *object.id());
 }
 
+int getComponentPlacementInParent(
+const Fortran::semantics::Symbol *componentSym) {
+  const auto *derived =
+  componentSym->owner()
+  .derivedTypeSpec()
+  ->typeSymbol()
+  .detailsIf();
+  assert(derived &&
+ "expected derived type details when processing component symbol");
+  int placement = 0;
+  for (auto t : derived->componentNames()) {
+if (t == componentSym->name())
+  return placement;
+placement++;
+  }
+  return -1;
+}
+
+std::optional
+getCompObjOrNull(std::optional object,
+ Fortran::semantics::SemanticsContext &semaCtx) {
+  if (!object)
+return std::nullopt;
+
+  auto ref = evaluate::ExtractDataRef(*object.value().ref());
+  if (!ref)
+return std::nullopt;
+
+  if (std::get_if(&ref->u))

skatrak wrote:

```suggestion
  if (std::holds_alternative(ref->u))
```

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -966,6 +966,7 @@ genBodyOfTargetOp(Fortran::lower::AbstractConverter 
&converter,
 mlir::Value mapOp = createMapInfoOp(
 firOpBuilder, copyVal.getLoc(), copyVal, mlir::Value{}, name.str(),
 bounds, llvm::SmallVector{},
+mlir::DenseIntElementsAttr{},

skatrak wrote:

Nit: Add comments for unnamed arguments.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -0,0 +1,260 @@
+//===- OMPMapInfoFinalization.cpp
+//---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+//===--===//
+/// \file
+/// An OpenMP dialect related pass for FIR/HLFIR which performs some
+/// pre-processing of MapInfoOp's after the module has been lowered to
+/// finalize them.
+///
+/// For example, it expands MapInfoOp's containing descriptor related
+/// types (fir::BoxType's) into multiple MapInfoOp's containing the parent
+/// descriptor and pointer member components for individual mapping,
+/// treating the descriptor type as a record type for later lowering in the
+/// OpenMP dialect.
+///
+/// The pass also adds MapInfoOp's that are members of a parent object but are
+/// not directly used in the body of a target region to it's BlockArgument list
+/// to maintain consistency across all MapInfoOp's tied to a region directly or
+/// indirectly via an parent object.
+//===--===//
+
+#include "flang/Optimizer/Builder/FIRBuilder.h"
+#include "flang/Optimizer/Dialect/FIRType.h"
+#include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Optimizer/Transforms/Passes.h"
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
+#include "mlir/IR/BuiltinDialect.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/Operation.h"
+#include "mlir/IR/SymbolTable.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Support/LLVM.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
+#include 
+
+namespace fir {
+#define GEN_PASS_DEF_OMPMAPINFOFINALIZATIONPASS
+#include "flang/Optimizer/Transforms/Passes.h.inc"
+} // namespace fir
+
+namespace {
+class OMPMapInfoFinalizationPass
+: public fir::impl::OMPMapInfoFinalizationPassBase<
+  OMPMapInfoFinalizationPass> {
+
+  void genDescriptorMemberMaps(mlir::omp::MapInfoOp op,
+   fir::FirOpBuilder &builder,
+   mlir::Operation *target) {
+mlir::Location loc = builder.getUnknownLoc();

skatrak wrote:

```suggestion
mlir::Location loc = op.getLoc();
```

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -19,7 +19,7 @@
 
 subroutine foo()
   implicit none
-
+  

skatrak wrote:

Nit: Accidental change?

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -903,24 +908,39 @@ bool ClauseProcessor::processMap(
   // Explicit map captures are captured ByRef by default,
   // optimisation passes may alter this to ByCopy or other capture
   // types to optimise
-  mlir::Value mapOp = createMapInfoOp(
+  mlir::omp::MapInfoOp mapOp = createMapInfoOp(
   firOpBuilder, clauseLocation, symAddr, mlir::Value{},
-  asFortran.str(), bounds, {},
+  asFortran.str(), bounds, {}, mlir::DenseIntElementsAttr{},
   static_cast<
   
std::underlying_type_t>(
   mapTypeBits),
   mlir::omp::VariableCaptureKind::ByRef, symAddr.getType());
 
-  result.mapVars.push_back(mapOp);
-
-  if (mapSyms)
+  if (object.id()->owner().IsDerivedType()) {
+if (auto dataRef{ExtractDataRef(object.designator)}) {

skatrak wrote:

If it's a derived type and `ExtractDataRef` returns `std::nullopt`, then 
nothing will be done with the created `mapOp`, without letting the user know. 
Is that the expected behavior? If `ExtractDataRef` is always expected to return 
something in this case, then maybe we could assert instead. If not, maybe it 
should error out or at least emit a warning.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -0,0 +1,260 @@
+//===- OMPMapInfoFinalization.cpp
+//---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+//===--===//
+/// \file
+/// An OpenMP dialect related pass for FIR/HLFIR which performs some
+/// pre-processing of MapInfoOp's after the module has been lowered to
+/// finalize them.
+///
+/// For example, it expands MapInfoOp's containing descriptor related
+/// types (fir::BoxType's) into multiple MapInfoOp's containing the parent
+/// descriptor and pointer member components for individual mapping,
+/// treating the descriptor type as a record type for later lowering in the
+/// OpenMP dialect.
+///
+/// The pass also adds MapInfoOp's that are members of a parent object but are
+/// not directly used in the body of a target region to it's BlockArgument list
+/// to maintain consistency across all MapInfoOp's tied to a region directly or
+/// indirectly via an parent object.
+//===--===//
+
+#include "flang/Optimizer/Builder/FIRBuilder.h"
+#include "flang/Optimizer/Dialect/FIRType.h"
+#include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "flang/Optimizer/Transforms/Passes.h"
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
+#include "mlir/IR/BuiltinDialect.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/Operation.h"
+#include "mlir/IR/SymbolTable.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Support/LLVM.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
+#include 
+
+namespace fir {
+#define GEN_PASS_DEF_OMPMAPINFOFINALIZATIONPASS
+#include "flang/Optimizer/Transforms/Passes.h.inc"
+} // namespace fir
+
+namespace {
+class OMPMapInfoFinalizationPass
+: public fir::impl::OMPMapInfoFinalizationPassBase<
+  OMPMapInfoFinalizationPass> {
+
+  void genDescriptorMemberMaps(mlir::omp::MapInfoOp op,
+   fir::FirOpBuilder &builder,
+   mlir::Operation *target) {
+mlir::Location loc = builder.getUnknownLoc();
+mlir::Value descriptor = op.getVarPtr();
+
+// If we enter this function, but the mapped type itself is not the
+// descriptor, then it's likely the address of the descriptor so we
+// must retrieve the descriptor SSA.
+if (!fir::isTypeWithDescriptor(op.getVarType())) {
+  if (auto addrOp = mlir::dyn_cast_if_present(
+  op.getVarPtr().getDefiningOp())) {
+descriptor = addrOp.getVal();
+  }
+}
+
+// The fir::BoxOffsetOp only works with !fir.ref> types, as
+// allowing it to access non-reference box operations can cause some
+// problematic SSA IR. However, in the case of assumed shape's the type
+// is not a !fir.ref, in these cases to retrieve the appropriate
+// !fir.ref> to access the data we need to map we must
+// perform an alloca and then store to it and retrieve the data from the 
new
+// alloca.
+if (mlir::isa(descriptor.getType())) {
+  mlir::OpBuilder::InsertPoint insPt = builder.saveInsertionPoint();
+  builder.setInsertionPointToStart(builder.getAllocaBlock());
+  auto alloca = builder.create(loc, descriptor.getType());
+  builder.restoreInsertionPoint(insPt);
+  builder.create(loc, descriptor, alloca);
+  descriptor = alloca;
+}
+
+mlir::Value baseAddrAddr = builder.create(
+loc, descriptor, fir::BoxFieldAttr::base_addr);
+
+// Member of the descriptor pointing at the allocated data
+mlir::Value baseAddr = builder.create(
+loc, baseAddrAddr.getType(), descriptor,
+mlir::TypeAttr::get(llvm::cast(
+fir::unwrapRefType(baseAddrAddr.getType()))
+.getElementType()),
+baseAddrAddr, mlir::SmallVector{},
+mlir::DenseIntElementsAttr{}, op.getBounds(),
+builder.getIntegerAttr(builder.getIntegerType(64, false),
+   op.getMapType().value()),
+builder.getAttr(
+mlir::omp::VariableCaptureKind::ByRef),
+builder.getStringAttr("") /*name*/,
+builder.getBoolAttr(false) /*partial_map*/);
+
+// TODO: map the addendum segment of the descriptor, similarly to the
+// above base address/data pointer member.
+
+if (auto mapClauseOwner =
+llvm::dyn_cast(target)) {
+  llvm::SmallVector newMapOps;
+  mlir::OperandRange mapOperandsArr = mapClauseOwner.getMapOperands();
+
+  for (size_t i = 0; i < mapOperandsArr.size(); ++i) {
+if (mapOperandsArr[i] == op) {
+   

[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -88,6 +91,175 @@ void gatherFuncAndVarSyms(
 symbolAndClause.emplace_back(clause, *object.id());
 }
 
+int getComponentPlacementInParent(
+const Fortran::semantics::Symbol *componentSym) {
+  const auto *derived =
+  componentSym->owner()
+  .derivedTypeSpec()
+  ->typeSymbol()
+  .detailsIf();
+  assert(derived &&
+ "expected derived type details when processing component symbol");
+  int placement = 0;
+  for (auto t : derived->componentNames()) {
+if (t == componentSym->name())
+  return placement;
+placement++;
+  }
+  return -1;
+}
+
+std::optional
+getCompObjOrNull(std::optional object,
+ Fortran::semantics::SemanticsContext &semaCtx) {
+  if (!object)
+return std::nullopt;
+
+  auto ref = evaluate::ExtractDataRef(*object.value().ref());
+  if (!ref)
+return std::nullopt;
+
+  if (std::get_if(&ref->u))
+return object;
+
+  auto baseObj = getBaseObject(object.value(), semaCtx);
+  if (!baseObj)
+return std::nullopt;
+
+  return getCompObjOrNull(baseObj.value(), semaCtx);
+}
+
+llvm::SmallVector
+generateMemberPlacementIndices(const Object &object,
+   Fortran::semantics::SemanticsContext &semaCtx) {
+  std::list indices;
+  auto compObj = getCompObjOrNull(object, semaCtx);
+  while (compObj) {
+indices.push_front(getComponentPlacementInParent(compObj->id()));
+compObj =
+getCompObjOrNull(getBaseObject(compObj.value(), semaCtx), semaCtx);
+  }
+
+  return llvm::SmallVector{std::begin(indices), std::end(indices)};
+}
+
+static void calculateShapeAndFillIndices(
+llvm::SmallVectorImpl &shape,
+llvm::SmallVector &memberPlacementData) {
+  shape.push_back(memberPlacementData.size());
+  size_t largestIndicesSize =
+  std::max_element(memberPlacementData.begin(), memberPlacementData.end(),
+   [](auto a, auto b) {
+ return a.memberPlacementIndices.size() <
+b.memberPlacementIndices.size();
+   })
+  ->memberPlacementIndices.size();
+  shape.push_back(largestIndicesSize);
+
+  // DenseElementsAttr expects a rectangular shape for the data, so all
+  // index lists have to be of the same length, this implaces -1 as filler
+  // values
+  for (auto &v : memberPlacementData)

skatrak wrote:

Nit: Add braces, since the nested `if` is braced: 
https://llvm.org/docs/CodingStandards.html#id60.

https://github.com/llvm/llvm-project/pull/82853
___
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][MLIR] Initial derived type member map support (PR #82853)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -218,17 +223,34 @@ bool ClauseProcessor::processMotionClauses(
   // Explicit map captures are captured ByRef by default,
   // optimisation passes may alter this to ByCopy or other capture
   // types to optimise
-  mlir::Value mapOp = createMapInfoOp(
+  mlir::omp::MapInfoOp mapOp = createMapInfoOp(
   firOpBuilder, clauseLocation, symAddr, mlir::Value{},
-  asFortran.str(), bounds, {},
+  asFortran.str(), bounds, {}, mlir::DenseIntElementsAttr{},
   static_cast<
   
std::underlying_type_t>(
   mapTypeBits),
   mlir::omp::VariableCaptureKind::ByRef, symAddr.getType());
 
-  result.mapVars.push_back(mapOp);
+  if (object.id()->owner().IsDerivedType()) {
+if (auto dataRef{ExtractDataRef(object.designator)}) {
+  const Fortran::semantics::Symbol *parentSym =
+  &dataRef->GetFirstSymbol();
+  assert(parentSym &&
+ "Could not find parent symbol during lower of "
+ "a component member in OpenMP map clause");
+  parentMemberIndices[parentSym].push_back(
+  {generateMemberPlacementIndices(object, semaCtx), mapOp});
+}
+  } else {
+result.mapVars.push_back(mapOp);
+mapSymbols.push_back(object.id());
+  }
 }
   });
+
+  insertChildMapInfoIntoParent(converter, parentMemberIndices, result.mapVars,
+   nullptr, nullptr, &mapSymbols);

skatrak wrote:

Nit: Add comments for unnamed arguments.

https://github.com/llvm/llvm-project/pull/82853
___
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] [libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur created 
https://github.com/llvm/llvm-project/pull/89755

Reviewers of #89153 suggested to break up the patch into per-subproject 
patches. This is the part for the remaining subprojects that have just one file 
changed each. For the runtime subprojects this is because they cannot be used 
in `LLVM_ENABLE_PROJECTS` and therefore its targets do not appear in the IDE 
when compiling as part of LLVM. `LLVM_SUBPROJECT_TITLE` is still defined and 
useful when loading the project from the `runtimes/runtimes-bins` folder 
withing the LLVM build dir, or for out-of-tree builds. A follow-up patch may do 
a more complete folder organization. See #89153 for the entire series and 
motivation.

Update the folder titles for targets in the monorepository that have not seen 
taken care of for some time. These are the folders that targets are organized 
in Visual Studio and XCode (`set_property(TARGET  PROPERTY FOLDER 
"")`) when using the respective CMake's IDE generator.

 * Ensure that every target is in a folder
 * Use a folder hierarchy with each LLVM subproject as a top-level folder
 * Use consistent folder names between subprojects
 * When using target-creating functions from AddLLVM.cmake, automatically 
deduce the folder. This reduces the number of 
`set_property`/`set_target_property`, but are still necessary when 
`add_custom_target`, `add_executable`, `add_library`, etc. are used. A 
LLVM_SUBPROJECT_TITLE definition is used for that in each subproject's root 
CMakeLists.txt.

>From 0ce849c6e5455577a77f4c25d08e8ec83115a290 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:29:28 +0200
Subject: [PATCH] Revise IDE folder structure

---
 cross-project-tests/CMakeLists.txt | 6 +-
 libc/CMakeLists.txt| 1 +
 libcxx/CMakeLists.txt  | 1 +
 libcxxabi/CMakeLists.txt   | 1 +
 libunwind/CMakeLists.txt   | 1 +
 llvm-libgcc/CMakeLists.txt | 1 +
 offload/CMakeLists.txt | 1 +
 pstl/CMakeLists.txt| 1 +
 runtimes/CMakeLists.txt| 1 +
 9 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/cross-project-tests/CMakeLists.txt 
b/cross-project-tests/CMakeLists.txt
index f7c2ca7ad83de3..7f2fee48fda778 100644
--- a/cross-project-tests/CMakeLists.txt
+++ b/cross-project-tests/CMakeLists.txt
@@ -3,6 +3,7 @@
 # The subset inside debuginfo-tests invoke clang to generate programs with
 # various types of debug info, and then run those programs under a debugger
 # such as GDB or LLDB to verify the results.
+set(LLVM_SUBPROJECT_TITLE "Cross-Project")
 
 find_package(Python3 COMPONENTS Interpreter)
 
@@ -97,8 +98,3 @@ add_lit_testsuite(check-cross-amdgpu "Running AMDGPU 
cross-project tests"
 add_lit_testsuites(CROSS_PROJECT ${CMAKE_CURRENT_SOURCE_DIR}
   DEPENDS ${CROSS_PROJECT_TEST_DEPS}
   )
-
-set_target_properties(check-cross-project PROPERTIES FOLDER "Tests")
-set_target_properties(check-debuginfo PROPERTIES FOLDER "Tests")
-set_target_properties(check-intrinsic-headers PROPERTIES FOLDER "Tests")
-set_target_properties(check-cross-amdgpu PROPERTIES FOLDER "Tests")
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 175efd89d67e6d..f35471a06a53e5 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "libc")
 
 # Include LLVM's cmake policies.
 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 2977c26646cb2e..d75f22ecf02229 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -5,6 +5,7 @@
 # Setup Project
 
#===
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "libc++")
 
 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
 
diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt
index da998d2221dc4f..f7673da25d20e0 100644
--- a/libcxxabi/CMakeLists.txt
+++ b/libcxxabi/CMakeLists.txt
@@ -5,6 +5,7 @@
 
#===
 
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "libc++abi")
 
 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
 
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 806d5a783ec39c..2117cd9e756efc 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -3,6 +3,7 @@
 
#===
 
 cmake_minimum_required(VERSION 3.20.0)
+set(LLVM_SUBPROJECT_TITLE "libunwind")
 
 set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
 
diff --git a/llvm-libgcc/CMakeLists.txt b/llvm-libgcc/CMakeLists.txt
index 013c9ca2e33076..c6641ab9e32191 100644
--- a/llvm-libgcc/CMakeLists.txt
+++ b/llvm-libgcc/CMakeLists.txt
@@ -3,6 +3,7 @@
 
#==

[llvm-branch-commits] [llvm] [bolt] Revise IDE folder structure (PR #89742)

2024-04-23 Thread Michael Kruse via llvm-branch-commits

https://github.com/Meinersbur edited 
https://github.com/llvm/llvm-project/pull/89742
___
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] [libc] [libcxx] [libcxxabi] [libunwind] [llvm] [pstl] Revise IDE folder structure (PR #89755)

2024-04-23 Thread Louis Dionne via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/89755
___
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/18.x: [DAGCombiner] Fix miscompile bug in combineShiftOfShiftedLogic (#89616) (PR #89766)

2024-04-23 Thread via llvm-branch-commits
=?utf-8?q?Björn?= Pettersson 
Message-ID: 
In-Reply-To:


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

Cherry-picked from commits 5fd9bbdea6cc248469d5465de44e747378ffafcb 
 and f9b419b7a038dcd51a7943b160acc867714c595f

>From 52f1e63dddcdd478fe34cfb2e322b23a3c5fbfbf Mon Sep 17 00:00:00 2001
From: Bjorn Pettersson 
Date: Mon, 22 Apr 2024 17:34:48 +0200
Subject: [PATCH 1/2] [DAGCombiner] Pre-commit test case for miscompile bug in
 combineShiftOfShiftedLogic

DAGCombiner is trying to fold shl over binops, and in the process
combining it with another shl. However it needs to be more careful
to ensure that the sum of the shift counts fits in the type used
for the shift amount.
For example, X86 is using i8 as shift amount type. So we need to
make sure that the sum of the shift amounts isn't greater than 255.

Fix will be applied in a later commit. This only pre-commits the
test case to show that we currently get the wrong result.

Bug was found when testing the C23 BitInt feature.

(cherry picked from commit 5fd9bbdea6cc248469d5465de44e747378ffafcb)
---
 llvm/test/CodeGen/X86/shift-combine.ll | 65 ++
 1 file changed, 65 insertions(+)

diff --git a/llvm/test/CodeGen/X86/shift-combine.ll 
b/llvm/test/CodeGen/X86/shift-combine.ll
index cf45641fba6321..f5bf3de9114dc5 100644
--- a/llvm/test/CodeGen/X86/shift-combine.ll
+++ b/llvm/test/CodeGen/X86/shift-combine.ll
@@ -787,3 +787,68 @@ define <4 x i32> 
@or_tree_with_mismatching_shifts_vec_i32(<4 x i32> %a, <4 x i32
   %r = or <4 x i32> %or.ab, %or.cd
   ret <4 x i32> %r
 }
+
+; FIXME: Reproducer for a DAGCombiner::combineShiftOfShiftedLogic
+; bug. DAGCombiner need to check that the sum of the shift amounts fits in i8,
+; which is the legal type used to described X86 shift amounts. Verify that we
+; do not try to create a shift with 130+160 as shift amount, and verify that
+; the stored value do not depend on %a1.
+define void @combineShiftOfShiftedLogic(i128 %a1, i32 %a2, ptr %p) {
+; X86-LABEL: combineShiftOfShiftedLogic:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebx
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:pushl %edi
+; X86-NEXT:.cfi_def_cfa_offset 12
+; X86-NEXT:pushl %esi
+; X86-NEXT:.cfi_def_cfa_offset 16
+; X86-NEXT:.cfi_offset %esi, -16
+; X86-NEXT:.cfi_offset %edi, -12
+; X86-NEXT:.cfi_offset %ebx, -8
+; X86-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ebx
+; X86-NEXT:movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT:movl %edi, %esi
+; X86-NEXT:shldl $2, %ebx, %edi
+; X86-NEXT:shldl $2, %edx, %ebx
+; X86-NEXT:shrl $30, %esi
+; X86-NEXT:orl {{[0-9]+}}(%esp), %esi
+; X86-NEXT:shldl $2, %ecx, %edx
+; X86-NEXT:shll $2, %ecx
+; X86-NEXT:movl %edi, 16(%eax)
+; X86-NEXT:movl %ebx, 12(%eax)
+; X86-NEXT:movl %edx, 8(%eax)
+; X86-NEXT:movl %ecx, 4(%eax)
+; X86-NEXT:movl %esi, 20(%eax)
+; X86-NEXT:movl $0, (%eax)
+; X86-NEXT:popl %esi
+; X86-NEXT:.cfi_def_cfa_offset 12
+; X86-NEXT:popl %edi
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:popl %ebx
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+;
+; X64-LABEL: combineShiftOfShiftedLogic:
+; X64:   # %bb.0:
+; X64-NEXT:# kill: def $edx killed $edx def $rdx
+; X64-NEXT:shlq $32, %rdx
+; X64-NEXT:movq %rsi, %rax
+; X64-NEXT:shrq $30, %rax
+; X64-NEXT:orq %rdx, %rax
+; X64-NEXT:shldq $34, %rdi, %rsi
+; X64-NEXT:shlq $34, %rdi
+; X64-NEXT:movq %rsi, 8(%rcx)
+; X64-NEXT:movq %rdi, (%rcx)
+; X64-NEXT:movq %rax, 16(%rcx)
+; X64-NEXT:retq
+  %zext1 = zext i128 %a1 to i192
+  %zext2 = zext i32 %a2 to i192
+  %shl = shl i192 %zext1, 130
+  %or = or i192 %shl, %zext2
+  %res = shl i192 %or, 160
+  store i192 %res, ptr %p, align 8
+  ret void
+}

>From c14230b5fa1cc41ad5c8f39de312f7f79cb1c105 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Pettersson?= 
Date: Tue, 23 Apr 2024 14:11:34 +0200
Subject: [PATCH 2/2] [DAGCombiner] Fix miscompile bug in
 combineShiftOfShiftedLogic (#89616)

Ensure that the sum of the shift amounts does not overflow the
shift amount type when combining shifts in combineShiftOfShiftedLogic.

Solves a miscompile bug found when testing the C23 BitInt feature.

Targets like X86 that only use an i8 for shift amounts after
legalization seems to be extra susceptible for bugs like this as it
isn't legal to shift more than 255 steps.

(cherry picked from commit f9b419b7a038dcd51a7943b160acc867714c595f)
---
 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp |  9 ++-
 llvm/test/CodeGen/X86/shift-combine.ll| 58 +--
 2 files changed, 22 insertions(+), 45 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index e806e0f0731f23..5038f8a1fc1562 100644
--- a/llvm/lib/CodeGen/Selection

[llvm-branch-commits] [llvm] release/18.x: [DAGCombiner] Fix miscompile bug in combineShiftOfShiftedLogic (#89616) (PR #89766)

2024-04-23 Thread via llvm-branch-commits
=?utf-8?q?Björn?= Pettersson 
Message-ID:
In-Reply-To: 


llvmbot wrote:




@llvm/pr-subscribers-llvm-selectiondag

Author: AtariDreams (AtariDreams)


Changes

Cherry-picked from commits 5fd9bbdea6cc248469d5465de44e747378ffafcb 
 and f9b419b7a038dcd51a7943b160acc867714c595f

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


2 Files Affected:

- (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+8-1) 
- (modified) llvm/test/CodeGen/X86/shift-combine.ll (+35) 


``diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index e806e0f0731f23..5038f8a1fc1562 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9636,8 +9636,15 @@ static SDValue combineShiftOfShiftedLogic(SDNode *Shift, 
SelectionDAG &DAG) {
 if (ShiftAmtVal->getBitWidth() != C1Val.getBitWidth())
   return false;
 
+// The fold is not valid if the sum of the shift values doesn't fit in the
+// given shift amount type.
+bool Overflow = false;
+APInt NewShiftAmt = C1Val.uadd_ov(*ShiftAmtVal, Overflow);
+if (Overflow)
+  return false;
+
 // The fold is not valid if the sum of the shift values exceeds bitwidth.
-if ((*ShiftAmtVal + C1Val).uge(V.getScalarValueSizeInBits()))
+if (NewShiftAmt.uge(V.getScalarValueSizeInBits()))
   return false;
 
 return true;
diff --git a/llvm/test/CodeGen/X86/shift-combine.ll 
b/llvm/test/CodeGen/X86/shift-combine.ll
index cf45641fba6321..3316a332fafdff 100644
--- a/llvm/test/CodeGen/X86/shift-combine.ll
+++ b/llvm/test/CodeGen/X86/shift-combine.ll
@@ -787,3 +787,38 @@ define <4 x i32> 
@or_tree_with_mismatching_shifts_vec_i32(<4 x i32> %a, <4 x i32
   %r = or <4 x i32> %or.ab, %or.cd
   ret <4 x i32> %r
 }
+
+; Reproducer for a DAGCombiner::combineShiftOfShiftedLogic bug. DAGCombiner
+; need to check that the sum of the shift amounts fits in i8, which is the
+; legal type used to described X86 shift amounts. Verify that we do not try to
+; create a shift with 130+160 as shift amount, and verify that the stored
+; value do not depend on %a1.
+define void @combineShiftOfShiftedLogic(i128 %a1, i32 %a2, ptr %p) {
+; X86-LABEL: combineShiftOfShiftedLogic:
+; X86:   # %bb.0:
+; X86-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:movl %eax, 20(%ecx)
+; X86-NEXT:movl $0, 16(%ecx)
+; X86-NEXT:movl $0, 12(%ecx)
+; X86-NEXT:movl $0, 8(%ecx)
+; X86-NEXT:movl $0, 4(%ecx)
+; X86-NEXT:movl $0, (%ecx)
+; X86-NEXT:retl
+;
+; X64-LABEL: combineShiftOfShiftedLogic:
+; X64:   # %bb.0:
+; X64-NEXT:# kill: def $edx killed $edx def $rdx
+; X64-NEXT:shlq $32, %rdx
+; X64-NEXT:movq %rdx, 16(%rcx)
+; X64-NEXT:movq $0, 8(%rcx)
+; X64-NEXT:movq $0, (%rcx)
+; X64-NEXT:retq
+  %zext1 = zext i128 %a1 to i192
+  %zext2 = zext i32 %a2 to i192
+  %shl = shl i192 %zext1, 130
+  %or = or i192 %shl, %zext2
+  %res = shl i192 %or, 160
+  store i192 %res, ptr %p, align 8
+  ret void
+}

``




https://github.com/llvm/llvm-project/pull/89766
___
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/18.x: [DAGCombiner] Fix miscompile bug in combineShiftOfShiftedLogic (#89616) (PR #89766)

2024-04-23 Thread Matt Arsenault via llvm-branch-commits
=?utf-8?q?Björn?= Pettersson 
Message-ID:
In-Reply-To: 


https://github.com/arsenm milestoned 
https://github.com/llvm/llvm-project/pull/89766
___
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] [analyzer] Backport performace regression fix (PR #89725)

2024-04-23 Thread Gábor Horváth via llvm-branch-commits

https://github.com/Xazax-hun approved this pull request.


https://github.com/llvm/llvm-project/pull/89725
___
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/18.x: [AArch64] Remove invalid uabdl patterns. (#89272) (PR #89380)

2024-04-23 Thread David Green via llvm-branch-commits

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

I think this should be OK for the branch, if it is wanted. It should be a safe 
commit to backport, considering it just removes some invalid patterns. LGTM.

https://github.com/llvm/llvm-project/pull/89380
___
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/18.x: [AArch64] Remove invalid uabdl patterns. (#89272) (PR #89380)

2024-04-23 Thread Matt Arsenault via llvm-branch-commits

https://github.com/arsenm milestoned 
https://github.com/llvm/llvm-project/pull/89380
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak commented:

Thank you Andrew, as usual I have a lot of nits but the overall approach seems 
reasonable to me.

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2081,6 +2083,79 @@ void collectMapDataFromMapOperands(MapInfoData &mapData,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData &mapData,
+   mlir::omp::MapInfoOp memberOp) {
+  auto *res = llvm::find(mapData.MapClause, memberOp);
+  assert(res != mapData.MapClause.end());

skatrak wrote:

Nit: Add a message as well.
```suggestion
  assert(res != mapData.MapClause.end() && "...");
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak edited 
https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2210,42 +2287,68 @@ static llvm::omp::OpenMPOffloadMappingFlags 
mapParentWithMembers(
   // Fortran pointers and allocatables, the mapping of the pointed to
   // data by the descriptor (which itself, is a structure containing
   // runtime information on the dynamically allocated data).
-  llvm::Value *lowAddr = builder.CreatePointerCast(
-  mapData.Pointers[mapDataIndex], builder.getPtrTy());
-  llvm::Value *highAddr = builder.CreatePointerCast(
-  builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
- mapData.Pointers[mapDataIndex], 1),
-  builder.getPtrTy());
+  auto parentClause =
+  mlir::dyn_cast(mapData.MapClause[mapDataIndex]);

skatrak wrote:

Nit: It's assumed that it returned a valid object by never checking it, so it's 
better to use `cast` to at least assert this is the case.
```suggestion
  llvm::cast(mapData.MapClause[mapDataIndex]);
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2081,6 +2083,79 @@ void collectMapDataFromMapOperands(MapInfoData &mapData,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData &mapData,
+   mlir::omp::MapInfoOp memberOp) {
+  auto *res = llvm::find(mapData.MapClause, memberOp);
+  assert(res != mapData.MapClause.end());
+  return std::distance(mapData.MapClause.begin(), res);
+}
+
+static mlir::omp::MapInfoOp
+getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
+  // Only 1 member has been mapped, we can return it.
+  if (mapInfo.getMembersIndex()->size() == 1)
+if (auto mapOp = mlir::dyn_cast(
+mapInfo.getMembers()[0].getDefiningOp()))
+  return mapOp;
+
+  std::vector indices(
+  mapInfo.getMembersIndexAttr().getShapedType().getShape()[0]);
+  std::iota(indices.begin(), indices.end(), 0);
+
+  llvm::sort(
+  indices.begin(), indices.end(), [&](const size_t a, const size_t b) {
+for (int i = 0;
+ i < mapInfo.getMembersIndexAttr().getShapedType().getShape()[1];
+ ++i) {
+  int aIndex =
+  mapInfo.getMembersIndexAttr()
+  .getValues()[a * mapInfo.getMembersIndexAttr()
+.getShapedType()
+.getShape()[1] +
+i];
+  int bIndex =
+  mapInfo.getMembersIndexAttr()
+  .getValues()[b * mapInfo.getMembersIndexAttr()
+.getShapedType()
+.getShape()[1] +
+i];
+
+  // As we have iterated to a stage where both indices are invalid
+  // we likely have the same member index, possibly the same member
+  // being mapped, return the first.
+  if (aIndex == -1 && bIndex == -1)
+return true;
+
+  if (aIndex == -1)
+return true;
+
+  if (bIndex == -1)
+return false;
+
+  // A is earlier in the record type layout than B
+  if (aIndex < bIndex)
+return true;
+
+  if (bIndex < aIndex)
+return false;
+}
+
+// iterated the entire list and couldn't make a decision, all elements
+// were likely the same, return true for now similar to reaching the 
end
+// of both and finding invalid indices.
+return true;
+  });
+
+  if (auto mapOp = mlir::dyn_cast(
+  mapInfo.getMembers()[((first) ? indices.front() : indices.back())]
+  .getDefiningOp()))
+return mapOp;
+
+  assert(false && "getFirstOrLastMappedMemberPtr could not find approproaite "
+  "map information");
+  return {};

skatrak wrote:

Nit: Replace with `llvm_unreachable()` for a custom failure message or `return 
llvm::cast(...)`, since that already asserts.

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2306,18 +2405,81 @@ static void processMapMembersWithParent(
 llvm::OpenMPIRBuilder::DeviceInfoTy::None);
 combinedInfo.Names.emplace_back(
 LLVM::createMappingInformation(memberClause.getLoc(), ompBuilder));
-
-
combinedInfo.BasePointers.emplace_back(mapData.BasePointers[memberDataIdx]);
+combinedInfo.BasePointers.emplace_back(mapData.BasePointers[mapDataIndex]);
 combinedInfo.Pointers.emplace_back(mapData.Pointers[memberDataIdx]);
 combinedInfo.Sizes.emplace_back(mapData.Sizes[memberDataIdx]);
   }
 }
 
+static void
+processIndividualMap(MapInfoData &mapData, size_t mapDataIdx,
+ llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo,
+ bool isTargetParams, int mapDataParentIdx = -1) {
+  // Declare Target Mappings are excluded from being marked as
+  // OMP_MAP_TARGET_PARAM as they are not passed as parameters, they're
+  // marked with OMP_MAP_PTR_AND_OBJ instead.
+  auto mapFlag = mapData.Types[mapDataIdx];
+  auto mapInfoOp =
+  dyn_cast(mapData.MapClause[mapDataIdx]);
+
+  bool isPtrTy = checkIfPointerMap(mapInfoOp);
+  if (isPtrTy)
+mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ;
+
+  if (isTargetParams && !mapData.IsDeclareTarget[mapDataIdx])
+mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TARGET_PARAM;
+
+  if (mapInfoOp.getMapCaptureType().value() ==
+  mlir::omp::VariableCaptureKind::ByCopy &&
+  !isPtrTy)
+mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_LITERAL;
+
+  // if we're provided a mapDataParentIdx, then the data being mapped is
+  // part of a larger object (in a parent <-> member mapping) and in this
+  // case our BasePointer should be the parent.
+  if (mapDataParentIdx >= 0)
+combinedInfo.BasePointers.emplace_back(
+mapData.BasePointers[mapDataParentIdx]);
+  else
+combinedInfo.BasePointers.emplace_back(mapData.BasePointers[mapDataIdx]);
+
+  combinedInfo.Pointers.emplace_back(mapData.Pointers[mapDataIdx]);
+  combinedInfo.DevicePointers.emplace_back(mapData.DevicePointers[mapDataIdx]);
+  combinedInfo.Names.emplace_back(mapData.Names[mapDataIdx]);
+  combinedInfo.Types.emplace_back(mapFlag);
+  combinedInfo.Sizes.emplace_back(mapData.Sizes[mapDataIdx]);
+}
+
 static void processMapWithMembersOf(
 LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder,
 llvm::OpenMPIRBuilder &ompBuilder, DataLayout &dl,
 llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo, MapInfoData &mapData,
 uint64_t mapDataIndex, bool isTargetParams) {
+  auto parentClause =
+  mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+
+  // If we have a partial map (no parent referneced in the map clauses of the

skatrak wrote:

```suggestion
  // If we have a partial map (no parent referenced in the map clauses of the
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2186,6 +2261,9 @@ calculateBoundsOffset(LLVM::ModuleTranslation 
&moduleTranslation,
 // which is utilised in subsequent member mappings (by modifying there map type
 // with it) to indicate that a member is part of this parent and should be
 // treated by the runtime as such. Important to achieve the correct mapping.
+//
+// This function borrows a lot from it's Clang parallel function
+// emitCombinedEntry inside of CGOpenMPRuntime.cpp

skatrak wrote:

```suggestion
// This function borrows a lot from Clang's emitCombinedEntry function
// inside of CGOpenMPRuntime.cpp
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2210,42 +2287,68 @@ static llvm::omp::OpenMPOffloadMappingFlags 
mapParentWithMembers(
   // Fortran pointers and allocatables, the mapping of the pointed to
   // data by the descriptor (which itself, is a structure containing
   // runtime information on the dynamically allocated data).
-  llvm::Value *lowAddr = builder.CreatePointerCast(
-  mapData.Pointers[mapDataIndex], builder.getPtrTy());
-  llvm::Value *highAddr = builder.CreatePointerCast(
-  builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
- mapData.Pointers[mapDataIndex], 1),
-  builder.getPtrTy());
+  auto parentClause =
+  mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+
+  llvm::Value *lowAddr, *highAddr;
+  if (!parentClause.getPartialMap()) {
+lowAddr = builder.CreatePointerCast(mapData.Pointers[mapDataIndex],
+builder.getPtrTy());
+highAddr = builder.CreatePointerCast(
+builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
+   mapData.Pointers[mapDataIndex], 1),
+builder.getPtrTy());
+combinedInfo.Pointers.emplace_back(mapData.Pointers[mapDataIndex]);
+  } else {
+auto mapOp =
+mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+int firstMemberIdx = getMapDataMemberIdx(
+mapData, getFirstOrLastMappedMemberPtr(mapOp, true));
+lowAddr = builder.CreatePointerCast(mapData.Pointers[firstMemberIdx],
+builder.getPtrTy());
+int lastMemberIdx = getMapDataMemberIdx(
+mapData, getFirstOrLastMappedMemberPtr(mapOp, false));
+highAddr = builder.CreatePointerCast(
+builder.CreateGEP(mapData.BaseType[lastMemberIdx],
+  mapData.Pointers[lastMemberIdx], 
builder.getInt64(1)),
+builder.getPtrTy());
+combinedInfo.Pointers.emplace_back(mapData.Pointers[firstMemberIdx]);
+  }
+
   llvm::Value *size = builder.CreateIntCast(
   builder.CreatePtrDiff(builder.getInt8Ty(), highAddr, lowAddr),
   builder.getInt64Ty(),
   /*isSigned=*/false);
   combinedInfo.Sizes.push_back(size);
 
-  // This creates the initial MEMBER_OF mapping that consists of
-  // the parent/top level container (same as above effectively, except
-  // with a fixed initial compile time size and seperate maptype which
-  // indicates the true mape type (tofrom etc.) and that it is a part
-  // of a larger mapping and indicating the link between it and it's
-  // members that are also explicitly mapped).
+  // TODO: This will need expanded to include the whole host of logic for the
+  // map flags that Clang currently supports (e.g. it hsould take the map flag

skatrak wrote:

```suggestion
  // map flags that Clang currently supports (e.g. it should take the map flag
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2210,42 +2287,68 @@ static llvm::omp::OpenMPOffloadMappingFlags 
mapParentWithMembers(
   // Fortran pointers and allocatables, the mapping of the pointed to
   // data by the descriptor (which itself, is a structure containing
   // runtime information on the dynamically allocated data).
-  llvm::Value *lowAddr = builder.CreatePointerCast(
-  mapData.Pointers[mapDataIndex], builder.getPtrTy());
-  llvm::Value *highAddr = builder.CreatePointerCast(
-  builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
- mapData.Pointers[mapDataIndex], 1),
-  builder.getPtrTy());
+  auto parentClause =
+  mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+
+  llvm::Value *lowAddr, *highAddr;
+  if (!parentClause.getPartialMap()) {
+lowAddr = builder.CreatePointerCast(mapData.Pointers[mapDataIndex],
+builder.getPtrTy());
+highAddr = builder.CreatePointerCast(
+builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
+   mapData.Pointers[mapDataIndex], 1),
+builder.getPtrTy());
+combinedInfo.Pointers.emplace_back(mapData.Pointers[mapDataIndex]);
+  } else {
+auto mapOp =
+mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+int firstMemberIdx = getMapDataMemberIdx(
+mapData, getFirstOrLastMappedMemberPtr(mapOp, true));
+lowAddr = builder.CreatePointerCast(mapData.Pointers[firstMemberIdx],
+builder.getPtrTy());
+int lastMemberIdx = getMapDataMemberIdx(
+mapData, getFirstOrLastMappedMemberPtr(mapOp, false));
+highAddr = builder.CreatePointerCast(
+builder.CreateGEP(mapData.BaseType[lastMemberIdx],
+  mapData.Pointers[lastMemberIdx], 
builder.getInt64(1)),
+builder.getPtrTy());
+combinedInfo.Pointers.emplace_back(mapData.Pointers[firstMemberIdx]);
+  }
+
   llvm::Value *size = builder.CreateIntCast(
   builder.CreatePtrDiff(builder.getInt8Ty(), highAddr, lowAddr),
   builder.getInt64Ty(),
   /*isSigned=*/false);
   combinedInfo.Sizes.push_back(size);
 
-  // This creates the initial MEMBER_OF mapping that consists of
-  // the parent/top level container (same as above effectively, except
-  // with a fixed initial compile time size and seperate maptype which
-  // indicates the true mape type (tofrom etc.) and that it is a part
-  // of a larger mapping and indicating the link between it and it's
-  // members that are also explicitly mapped).
+  // TODO: This will need expanded to include the whole host of logic for the
+  // map flags that Clang currently supports (e.g. it hsould take the map flag
+  // of the parent map flag, remove the OMP_MAP_TARGET_PARAM and do some 
further
+  // case specific flag modifications), for the moment it handles what we
+  // support as expected.
   llvm::omp::OpenMPOffloadMappingFlags mapFlag =
   llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
-  if (isTargetParams)
-mapFlag &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TARGET_PARAM;
 
   llvm::omp::OpenMPOffloadMappingFlags memberOfFlag =
   ompBuilder.getMemberOfFlag(combinedInfo.BasePointers.size() - 1);
   ompBuilder.setCorrectMemberOfFlag(mapFlag, memberOfFlag);
 
-  combinedInfo.Types.emplace_back(mapFlag);
-  combinedInfo.DevicePointers.emplace_back(
-  llvm::OpenMPIRBuilder::DeviceInfoTy::None);
-  combinedInfo.Names.emplace_back(LLVM::createMappingInformation(
-  mapData.MapClause[mapDataIndex]->getLoc(), ompBuilder));
-  combinedInfo.BasePointers.emplace_back(mapData.BasePointers[mapDataIndex]);
-  combinedInfo.Pointers.emplace_back(mapData.Pointers[mapDataIndex]);
-  combinedInfo.Sizes.emplace_back(mapData.Sizes[mapDataIndex]);
-
+  // This creates the initial MEMBER_OF mapping that consists of
+  // the parent/top level container (same as above effectively, except
+  // with a fixed initial compile time size and seperate maptype which
+  // indicates the true mape type (tofrom etc.). This parent mapping is
+  // only relevant if the structure in it's totality is being mapped,

skatrak wrote:

```suggestion
  // only relevant if the structure in its totality is being mapped,
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2210,42 +2287,68 @@ static llvm::omp::OpenMPOffloadMappingFlags 
mapParentWithMembers(
   // Fortran pointers and allocatables, the mapping of the pointed to
   // data by the descriptor (which itself, is a structure containing
   // runtime information on the dynamically allocated data).
-  llvm::Value *lowAddr = builder.CreatePointerCast(
-  mapData.Pointers[mapDataIndex], builder.getPtrTy());
-  llvm::Value *highAddr = builder.CreatePointerCast(
-  builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
- mapData.Pointers[mapDataIndex], 1),
-  builder.getPtrTy());
+  auto parentClause =
+  mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+
+  llvm::Value *lowAddr, *highAddr;
+  if (!parentClause.getPartialMap()) {
+lowAddr = builder.CreatePointerCast(mapData.Pointers[mapDataIndex],
+builder.getPtrTy());
+highAddr = builder.CreatePointerCast(
+builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
+   mapData.Pointers[mapDataIndex], 1),
+builder.getPtrTy());
+combinedInfo.Pointers.emplace_back(mapData.Pointers[mapDataIndex]);
+  } else {
+auto mapOp =
+mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+int firstMemberIdx = getMapDataMemberIdx(
+mapData, getFirstOrLastMappedMemberPtr(mapOp, true));
+lowAddr = builder.CreatePointerCast(mapData.Pointers[firstMemberIdx],
+builder.getPtrTy());
+int lastMemberIdx = getMapDataMemberIdx(
+mapData, getFirstOrLastMappedMemberPtr(mapOp, false));
+highAddr = builder.CreatePointerCast(
+builder.CreateGEP(mapData.BaseType[lastMemberIdx],
+  mapData.Pointers[lastMemberIdx], 
builder.getInt64(1)),
+builder.getPtrTy());
+combinedInfo.Pointers.emplace_back(mapData.Pointers[firstMemberIdx]);
+  }
+
   llvm::Value *size = builder.CreateIntCast(
   builder.CreatePtrDiff(builder.getInt8Ty(), highAddr, lowAddr),
   builder.getInt64Ty(),
   /*isSigned=*/false);
   combinedInfo.Sizes.push_back(size);
 
-  // This creates the initial MEMBER_OF mapping that consists of
-  // the parent/top level container (same as above effectively, except
-  // with a fixed initial compile time size and seperate maptype which
-  // indicates the true mape type (tofrom etc.) and that it is a part
-  // of a larger mapping and indicating the link between it and it's
-  // members that are also explicitly mapped).
+  // TODO: This will need expanded to include the whole host of logic for the

skatrak wrote:

```suggestion
  // TODO: This will need to be expanded to include the whole host of logic for 
the
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2081,6 +2083,79 @@ void collectMapDataFromMapOperands(MapInfoData &mapData,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData &mapData,
+   mlir::omp::MapInfoOp memberOp) {
+  auto *res = llvm::find(mapData.MapClause, memberOp);
+  assert(res != mapData.MapClause.end());
+  return std::distance(mapData.MapClause.begin(), res);
+}
+
+static mlir::omp::MapInfoOp
+getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
+  // Only 1 member has been mapped, we can return it.
+  if (mapInfo.getMembersIndex()->size() == 1)
+if (auto mapOp = mlir::dyn_cast(
+mapInfo.getMembers()[0].getDefiningOp()))
+  return mapOp;
+
+  std::vector indices(
+  mapInfo.getMembersIndexAttr().getShapedType().getShape()[0]);
+  std::iota(indices.begin(), indices.end(), 0);

skatrak wrote:

```suggestion
  llvm::SmallVector indices(
  mapInfo.getMembersIndexAttr().getShapedType().getShape()[0], 0);
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2210,42 +2287,68 @@ static llvm::omp::OpenMPOffloadMappingFlags 
mapParentWithMembers(
   // Fortran pointers and allocatables, the mapping of the pointed to
   // data by the descriptor (which itself, is a structure containing
   // runtime information on the dynamically allocated data).
-  llvm::Value *lowAddr = builder.CreatePointerCast(
-  mapData.Pointers[mapDataIndex], builder.getPtrTy());
-  llvm::Value *highAddr = builder.CreatePointerCast(
-  builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
- mapData.Pointers[mapDataIndex], 1),
-  builder.getPtrTy());
+  auto parentClause =
+  mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+
+  llvm::Value *lowAddr, *highAddr;
+  if (!parentClause.getPartialMap()) {
+lowAddr = builder.CreatePointerCast(mapData.Pointers[mapDataIndex],
+builder.getPtrTy());
+highAddr = builder.CreatePointerCast(
+builder.CreateConstGEP1_32(mapData.BaseType[mapDataIndex],
+   mapData.Pointers[mapDataIndex], 1),
+builder.getPtrTy());
+combinedInfo.Pointers.emplace_back(mapData.Pointers[mapDataIndex]);
+  } else {
+auto mapOp =
+mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+int firstMemberIdx = getMapDataMemberIdx(
+mapData, getFirstOrLastMappedMemberPtr(mapOp, true));
+lowAddr = builder.CreatePointerCast(mapData.Pointers[firstMemberIdx],
+builder.getPtrTy());
+int lastMemberIdx = getMapDataMemberIdx(
+mapData, getFirstOrLastMappedMemberPtr(mapOp, false));
+highAddr = builder.CreatePointerCast(
+builder.CreateGEP(mapData.BaseType[lastMemberIdx],
+  mapData.Pointers[lastMemberIdx], 
builder.getInt64(1)),
+builder.getPtrTy());
+combinedInfo.Pointers.emplace_back(mapData.Pointers[firstMemberIdx]);
+  }
+
   llvm::Value *size = builder.CreateIntCast(
   builder.CreatePtrDiff(builder.getInt8Ty(), highAddr, lowAddr),
   builder.getInt64Ty(),
   /*isSigned=*/false);
   combinedInfo.Sizes.push_back(size);
 
-  // This creates the initial MEMBER_OF mapping that consists of
-  // the parent/top level container (same as above effectively, except
-  // with a fixed initial compile time size and seperate maptype which
-  // indicates the true mape type (tofrom etc.) and that it is a part
-  // of a larger mapping and indicating the link between it and it's
-  // members that are also explicitly mapped).
+  // TODO: This will need expanded to include the whole host of logic for the
+  // map flags that Clang currently supports (e.g. it hsould take the map flag
+  // of the parent map flag, remove the OMP_MAP_TARGET_PARAM and do some 
further
+  // case specific flag modifications), for the moment it handles what we

skatrak wrote:

```suggestion
  // case-specific flag modifications). For the moment, it handles what we
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2081,6 +2083,79 @@ void collectMapDataFromMapOperands(MapInfoData &mapData,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData &mapData,
+   mlir::omp::MapInfoOp memberOp) {
+  auto *res = llvm::find(mapData.MapClause, memberOp);
+  assert(res != mapData.MapClause.end());
+  return std::distance(mapData.MapClause.begin(), res);
+}
+
+static mlir::omp::MapInfoOp
+getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
+  // Only 1 member has been mapped, we can return it.
+  if (mapInfo.getMembersIndex()->size() == 1)
+if (auto mapOp = mlir::dyn_cast(
+mapInfo.getMembers()[0].getDefiningOp()))
+  return mapOp;
+
+  std::vector indices(
+  mapInfo.getMembersIndexAttr().getShapedType().getShape()[0]);

skatrak wrote:

Nit: Maybe store the output of `mapInfo.getMembersIndexAttr()` and a reference 
to the result of calling   `getShapedType().getShape()` on it to reduce 
verbosity below, since there are many uses of these.

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2306,18 +2405,81 @@ static void processMapMembersWithParent(
 llvm::OpenMPIRBuilder::DeviceInfoTy::None);
 combinedInfo.Names.emplace_back(
 LLVM::createMappingInformation(memberClause.getLoc(), ompBuilder));
-
-
combinedInfo.BasePointers.emplace_back(mapData.BasePointers[memberDataIdx]);
+combinedInfo.BasePointers.emplace_back(mapData.BasePointers[mapDataIndex]);
 combinedInfo.Pointers.emplace_back(mapData.Pointers[memberDataIdx]);
 combinedInfo.Sizes.emplace_back(mapData.Sizes[memberDataIdx]);
   }
 }
 
+static void
+processIndividualMap(MapInfoData &mapData, size_t mapDataIdx,
+ llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo,
+ bool isTargetParams, int mapDataParentIdx = -1) {
+  // Declare Target Mappings are excluded from being marked as
+  // OMP_MAP_TARGET_PARAM as they are not passed as parameters, they're
+  // marked with OMP_MAP_PTR_AND_OBJ instead.
+  auto mapFlag = mapData.Types[mapDataIdx];
+  auto mapInfoOp =
+  dyn_cast(mapData.MapClause[mapDataIdx]);

skatrak wrote:

```suggestion
  cast(mapData.MapClause[mapDataIdx]);
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2306,18 +2405,81 @@ static void processMapMembersWithParent(
 llvm::OpenMPIRBuilder::DeviceInfoTy::None);
 combinedInfo.Names.emplace_back(
 LLVM::createMappingInformation(memberClause.getLoc(), ompBuilder));
-
-
combinedInfo.BasePointers.emplace_back(mapData.BasePointers[memberDataIdx]);
+combinedInfo.BasePointers.emplace_back(mapData.BasePointers[mapDataIndex]);
 combinedInfo.Pointers.emplace_back(mapData.Pointers[memberDataIdx]);
 combinedInfo.Sizes.emplace_back(mapData.Sizes[memberDataIdx]);
   }
 }
 
+static void
+processIndividualMap(MapInfoData &mapData, size_t mapDataIdx,
+ llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo,
+ bool isTargetParams, int mapDataParentIdx = -1) {
+  // Declare Target Mappings are excluded from being marked as
+  // OMP_MAP_TARGET_PARAM as they are not passed as parameters, they're
+  // marked with OMP_MAP_PTR_AND_OBJ instead.
+  auto mapFlag = mapData.Types[mapDataIdx];
+  auto mapInfoOp =
+  dyn_cast(mapData.MapClause[mapDataIdx]);
+
+  bool isPtrTy = checkIfPointerMap(mapInfoOp);
+  if (isPtrTy)
+mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PTR_AND_OBJ;
+
+  if (isTargetParams && !mapData.IsDeclareTarget[mapDataIdx])
+mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TARGET_PARAM;
+
+  if (mapInfoOp.getMapCaptureType().value() ==
+  mlir::omp::VariableCaptureKind::ByCopy &&
+  !isPtrTy)
+mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_LITERAL;
+
+  // if we're provided a mapDataParentIdx, then the data being mapped is
+  // part of a larger object (in a parent <-> member mapping) and in this
+  // case our BasePointer should be the parent.
+  if (mapDataParentIdx >= 0)
+combinedInfo.BasePointers.emplace_back(
+mapData.BasePointers[mapDataParentIdx]);
+  else
+combinedInfo.BasePointers.emplace_back(mapData.BasePointers[mapDataIdx]);
+
+  combinedInfo.Pointers.emplace_back(mapData.Pointers[mapDataIdx]);
+  combinedInfo.DevicePointers.emplace_back(mapData.DevicePointers[mapDataIdx]);
+  combinedInfo.Names.emplace_back(mapData.Names[mapDataIdx]);
+  combinedInfo.Types.emplace_back(mapFlag);
+  combinedInfo.Sizes.emplace_back(mapData.Sizes[mapDataIdx]);
+}
+
 static void processMapWithMembersOf(
 LLVM::ModuleTranslation &moduleTranslation, llvm::IRBuilderBase &builder,
 llvm::OpenMPIRBuilder &ompBuilder, DataLayout &dl,
 llvm::OpenMPIRBuilder::MapInfosTy &combinedInfo, MapInfoData &mapData,
 uint64_t mapDataIndex, bool isTargetParams) {
+  auto parentClause =
+  mlir::dyn_cast(mapData.MapClause[mapDataIndex]);
+
+  // If we have a partial map (no parent referneced in the map clauses of the
+  // directive, only members) and only a single member, we do not need to bind
+  // the map of the member to the parent, we can pass the member seperately.
+  if (parentClause.getMembers().size() == 1 && parentClause.getPartialMap()) {
+auto memberClause = mlir::dyn_cast(

skatrak wrote:

```suggestion
auto memberClause = mlir::cast(
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2283,16 +2386,12 @@ static void processMapMembersWithParent(
   for (auto mappedMembers : parentClause.getMembers()) {
 auto memberClause =
 mlir::dyn_cast(mappedMembers.getDefiningOp());
-int memberDataIdx = -1;
-for (size_t i = 0; i < mapData.MapClause.size(); ++i) {
-  if (mapData.MapClause[i] == memberClause)
-memberDataIdx = i;
-}
+int memberDataIdx = getMapDataMemberIdx(mapData, memberClause);
 
 assert(memberDataIdx >= 0 && "could not find mapped member of structure");
 
 // Same MemberOfFlag to indicate its link with parent and other members
-// of, and we flag that it's part of a pointer and object coupling.
+// of

skatrak wrote:

```suggestion
// of.
```

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -33,6 +33,8 @@
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 
 #include 
+#include 
+#include 

skatrak wrote:

Maybe not needed if `std::iota` call is removed?

https://github.com/llvm/llvm-project/pull/82852
___
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][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -2081,6 +2083,79 @@ void collectMapDataFromMapOperands(MapInfoData &mapData,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData &mapData,
+   mlir::omp::MapInfoOp memberOp) {
+  auto *res = llvm::find(mapData.MapClause, memberOp);
+  assert(res != mapData.MapClause.end());
+  return std::distance(mapData.MapClause.begin(), res);
+}
+
+static mlir::omp::MapInfoOp
+getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
+  // Only 1 member has been mapped, we can return it.
+  if (mapInfo.getMembersIndex()->size() == 1)
+if (auto mapOp = mlir::dyn_cast(
+mapInfo.getMembers()[0].getDefiningOp()))
+  return mapOp;
+
+  std::vector indices(
+  mapInfo.getMembersIndexAttr().getShapedType().getShape()[0]);
+  std::iota(indices.begin(), indices.end(), 0);
+
+  llvm::sort(
+  indices.begin(), indices.end(), [&](const size_t a, const size_t b) {
+for (int i = 0;
+ i < mapInfo.getMembersIndexAttr().getShapedType().getShape()[1];
+ ++i) {
+  int aIndex =
+  mapInfo.getMembersIndexAttr()
+  .getValues()[a * mapInfo.getMembersIndexAttr()
+.getShapedType()
+.getShape()[1] +
+i];
+  int bIndex =
+  mapInfo.getMembersIndexAttr()
+  .getValues()[b * mapInfo.getMembersIndexAttr()
+.getShapedType()
+.getShape()[1] +
+i];
+
+  // As we have iterated to a stage where both indices are invalid
+  // we likely have the same member index, possibly the same member
+  // being mapped, return the first.
+  if (aIndex == -1 && bIndex == -1)
+return true;
+
+  if (aIndex == -1)
+return true;
+
+  if (bIndex == -1)
+return false;

skatrak wrote:

Redundant check, if I'm not wrong.
```suggestion
  if (aIndex == -1)
return true;

  if (bIndex == -1)
return false;
```

https://github.com/llvm/llvm-project/pull/82852
___
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] [GSYM][DWARF] Include end_sequence debug_line rows when looking up addr ranges (PR #89703)

2024-04-23 Thread Paul T Robinson via llvm-branch-commits

pogo59 wrote:

I'd like to know how this affects the output of llvm-dwarfdump. Intuitively it 
feels like something around the display of end_sequence rows should have 
changed, but I'm willing to be corrected.

https://github.com/llvm/llvm-project/pull/89703
___
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][OpenMP] Update op verifiers dependent on omp.wsloop (2/5) (PR #89211)

2024-04-23 Thread Sergio Afonso via llvm-branch-commits


@@ -1977,9 +1977,10 @@ LogicalResult OrderedRegionOp::verify() {
   if (getSimd())
 return failure();
 
-  if (auto container = (*this)->getParentOfType()) {
-if (!container.getOrderedValAttr() ||
-container.getOrderedValAttr().getInt() != 0)
+  if (auto loopOp = dyn_cast((*this)->getParentOp())) {

skatrak wrote:

Small ping @tblah. This is now the only thing left to be approved so that I can 
update and merge the whole PR stack. Thank you for your time!

https://github.com/llvm/llvm-project/pull/89211
___
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] [clang][CallGraphSection] Add type id metadata to indirect call and targets (PR #87573)

2024-04-23 Thread via llvm-branch-commits


@@ -93,9 +93,17 @@ RValue CodeGenFunction::EmitCXXMemberOrOperatorCall(
   *this, MD, This, ImplicitParam, ImplicitParamTy, CE, Args, RtlArgs);
   auto &FnInfo = CGM.getTypes().arrangeCXXMethodCall(
   Args, FPT, CallInfo.ReqArgs, CallInfo.PrefixSize);
-  return EmitCall(FnInfo, Callee, ReturnValue, Args, nullptr,
+  llvm::CallBase *CallOrInvoke = nullptr;
+  auto Call = EmitCall(FnInfo, Callee, ReturnValue, Args, &CallOrInvoke,
   CE && CE == MustTailCall,
   CE ? CE->getExprLoc() : SourceLocation());
+  
+  // Set type identifier metadata of indirect calls for call graph section.
+  if (CGM.getCodeGenOpts().CallGraphSection && CallOrInvoke &&
+  CallOrInvoke->isIndirectCall())
+CGM.CreateFunctionTypeMetadataForIcall(MD->getType(), CallOrInvoke);

Prabhuk wrote:

Thank you. That's a fair point! I'll try and refactor to call 
CreateFunctionTypeMetadataForIcall in EmitCall method.

https://github.com/llvm/llvm-project/pull/87573
___
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] c6d63d4 - Bump version to 18.1.5 (#89291)

2024-04-23 Thread via llvm-branch-commits

Author: Tom Stellard
Date: 2024-04-23T08:51:18-07:00
New Revision: c6d63d4fc555cf743503a3418ad78768bc276042

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

LOG: Bump version to 18.1.5 (#89291)

Added: 


Modified: 
llvm/CMakeLists.txt
llvm/utils/lit/lit/__init__.py

Removed: 




diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 98dbab810bacbf..f82be164ac9c48 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -22,7 +22,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 4)
+  set(LLVM_VERSION_PATCH 5)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)

diff  --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index fcf4a9d8b5f398..1cfcc7d37813bc 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = "Daniel Dunbar"
 __email__ = "dan...@minormatter.com"
-__versioninfo__ = (18, 1, 4)
+__versioninfo__ = (18, 1, 5)
 __version__ = ".".join(str(v) for v in __versioninfo__) + "dev"
 
 __all__ = []



___
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] Bump version to 18.1.5 (PR #89291)

2024-04-23 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/89291
___
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] Backport fix for crash reported in #88181 (PR #89022)

2024-04-23 Thread Tom Stellard via llvm-branch-commits

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

>From 4ddac856c55f6352d0004a1734ca4651511aadbb Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Wed, 17 Apr 2024 08:02:49 +0200
Subject: [PATCH] [analyzer] Fix a security.cert.env.InvalidPtr crash

Fixes #88181

(cherry picked from commit e096c144921daba59963f15e89d2ca6fb32d3a78)
---
 clang/docs/ReleaseNotes.rst|  4 
 .../StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp |  6 +-
 clang/test/Analysis/invalid-ptr-checker.cpp| 10 ++
 3 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Analysis/invalid-ptr-checker.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce7e615d878944..1e88b58725bd95 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1474,6 +1474,10 @@ Crash and bug fixes
 - Fix false positive in mutation check when using pointer to member function.
   (`#66204 `_)
 
+- Fixed a crash in ``security.cert.env.InvalidPtr`` checker when accidentally
+  matched user-defined ``strerror`` and similar library functions.
+  (`#88181 `_)
+
 Improvements
 
 
diff --git a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
index e5dd907c660d8e..b2947f590c4ec1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
@@ -205,8 +205,12 @@ void InvalidPtrChecker::postPreviousReturnInvalidatingCall(
   CE, LCtx, CE->getType(), C.blockCount());
   State = State->BindExpr(CE, LCtx, RetVal);
 
+  const auto *SymRegOfRetVal =
+  dyn_cast_or_null(RetVal.getAsRegion());
+  if (!SymRegOfRetVal)
+return;
+
   // Remember to this region.
-  const auto *SymRegOfRetVal = cast(RetVal.getAsRegion());
   const MemRegion *MR = SymRegOfRetVal->getBaseRegion();
   State = State->set(FD, MR);
 
diff --git a/clang/test/Analysis/invalid-ptr-checker.cpp 
b/clang/test/Analysis/invalid-ptr-checker.cpp
new file mode 100644
index 00..58bb45e0fb8421
--- /dev/null
+++ b/clang/test/Analysis/invalid-ptr-checker.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,security.cert.env.InvalidPtr 
-verify %s
+
+// expected-no-diagnostics
+
+namespace other {
+int strerror(int errnum); // custom strerror
+void no_crash_on_custom_strerror() {
+  (void)strerror(0); // no-crash
+}
+} // namespace other

___
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] 4ddac85 - [analyzer] Fix a security.cert.env.InvalidPtr crash

2024-04-23 Thread Tom Stellard via llvm-branch-commits

Author: Balazs Benics
Date: 2024-04-23T08:52:08-07:00
New Revision: 4ddac856c55f6352d0004a1734ca4651511aadbb

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

LOG: [analyzer] Fix a security.cert.env.InvalidPtr crash

Fixes #88181

(cherry picked from commit e096c144921daba59963f15e89d2ca6fb32d3a78)

Added: 
clang/test/Analysis/invalid-ptr-checker.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce7e615d878944..1e88b58725bd95 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1474,6 +1474,10 @@ Crash and bug fixes
 - Fix false positive in mutation check when using pointer to member function.
   (`#66204 `_)
 
+- Fixed a crash in ``security.cert.env.InvalidPtr`` checker when accidentally
+  matched user-defined ``strerror`` and similar library functions.
+  (`#88181 `_)
+
 Improvements
 
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
index e5dd907c660d8e..b2947f590c4ec1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp
@@ -205,8 +205,12 @@ void InvalidPtrChecker::postPreviousReturnInvalidatingCall(
   CE, LCtx, CE->getType(), C.blockCount());
   State = State->BindExpr(CE, LCtx, RetVal);
 
+  const auto *SymRegOfRetVal =
+  dyn_cast_or_null(RetVal.getAsRegion());
+  if (!SymRegOfRetVal)
+return;
+
   // Remember to this region.
-  const auto *SymRegOfRetVal = cast(RetVal.getAsRegion());
   const MemRegion *MR = SymRegOfRetVal->getBaseRegion();
   State = State->set(FD, MR);
 

diff  --git a/clang/test/Analysis/invalid-ptr-checker.cpp 
b/clang/test/Analysis/invalid-ptr-checker.cpp
new file mode 100644
index 00..58bb45e0fb8421
--- /dev/null
+++ b/clang/test/Analysis/invalid-ptr-checker.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,security.cert.env.InvalidPtr 
-verify %s
+
+// expected-no-diagnostics
+
+namespace other {
+int strerror(int errnum); // custom strerror
+void no_crash_on_custom_strerror() {
+  (void)strerror(0); // no-crash
+}
+} // namespace other



___
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] Backport fix for crash reported in #88181 (PR #89022)

2024-04-23 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/89022
___
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] [lldb] [lldb] Revise IDE folder structure (PR #89748)

2024-04-23 Thread Jonas Devlieghere via llvm-branch-commits

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

Thanks for splitting this up. LGTM modulo one folder name. 

https://github.com/llvm/llvm-project/pull/89748
___
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] [lldb] [lldb] Revise IDE folder structure (PR #89748)

2024-04-23 Thread Jonas Devlieghere via llvm-branch-commits

https://github.com/JDevlieghere edited 
https://github.com/llvm/llvm-project/pull/89748
___
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] [lldb] [lldb] Revise IDE folder structure (PR #89748)

2024-04-23 Thread Jonas Devlieghere via llvm-branch-commits


@@ -232,7 +231,7 @@ elseif (LLDB_EXPORT_ALL_SYMBOLS)
   )
 
   add_llvm_symbol_exports(liblldb ${exported_symbol_file})
-  set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
+  set_target_properties(liblldb PROPERTIES FOLDER "LLDB/Misc")

JDevlieghere wrote:

Should this be `LLDB/API`?

https://github.com/llvm/llvm-project/pull/89748
___
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/18.x: [X86] Always use 64-bit relocations in no-PIC large code model (#89101) (PR #89124)

2024-04-23 Thread Tom Stellard via llvm-branch-commits

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

>From a981a4f7653c112277817da3b661e9e6b24389ac Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Wed, 17 Apr 2024 12:04:18 -0700
Subject: [PATCH] [X86] Always use 64-bit relocations in no-PIC large code
 model (#89101)

This matches other types of relocations, e.g. to constant pool. And
makes things more consistent with PIC large code model.

Some users of the large code model may not place small data in the lower
2GB of the address space (e.g.
https://github.com/ClangBuiltLinux/linux/issues/2016), so just
unconditionally use 64-bit relocations in the large code model.

So now functions in a section not marked large will use 64-bit
relocations to reference everything when using the large code model.

This also fixes some lldb tests broken by #88172
(https://lab.llvm.org/buildbot/#/builders/68/builds/72458).

(cherry picked from commit 6cea7c491f4c4c68aa0494a9b18f36ff40c22c81)
---
 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 7 +++
 llvm/test/CodeGen/X86/code-model-elf.ll | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp 
b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 833f058253d880..553d338b77904a 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2923,11 +2923,10 @@ bool X86DAGToDAGISel::selectAddr(SDNode *Parent, 
SDValue N, SDValue &Base,
 }
 
 bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
-  // Cannot use 32 bit constants to reference objects in kernel code model.
-  // Cannot use 32 bit constants to reference objects in large PIC mode since
-  // GOTOFF is 64 bits.
+  // Cannot use 32 bit constants to reference objects in kernel/large code
+  // model.
   if (TM.getCodeModel() == CodeModel::Kernel ||
-  (TM.getCodeModel() == CodeModel::Large && TM.isPositionIndependent()))
+  TM.getCodeModel() == CodeModel::Large)
 return false;
 
   // In static codegen with small code model, we can get the address of a label
diff --git a/llvm/test/CodeGen/X86/code-model-elf.ll 
b/llvm/test/CodeGen/X86/code-model-elf.ll
index afcffb3a7adeda..b6634403dc1d05 100644
--- a/llvm/test/CodeGen/X86/code-model-elf.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf.ll
@@ -346,7 +346,7 @@ define dso_local ptr @lea_forced_small_data() #0 {
 ;
 ; LARGE-STATIC-LABEL: lea_forced_small_data:
 ; LARGE-STATIC:   # %bb.0:
-; LARGE-STATIC-NEXT:movl $forced_small_data, %eax
+; LARGE-STATIC-NEXT:movabsq $forced_small_data, %rax
 ; LARGE-STATIC-NEXT:retq
 ;
 ; SMALL-PIC-LABEL: lea_forced_small_data:
@@ -399,7 +399,7 @@ define dso_local i32 @load_forced_small_data() #0 {
 ;
 ; LARGE-STATIC-LABEL: load_forced_small_data:
 ; LARGE-STATIC:   # %bb.0:
-; LARGE-STATIC-NEXT:movl $forced_small_data+8, %eax
+; LARGE-STATIC-NEXT:movabsq $forced_small_data+8, %rax
 ; LARGE-STATIC-NEXT:movl (%rax), %eax
 ; LARGE-STATIC-NEXT:retq
 ;

___
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] a981a4f - [X86] Always use 64-bit relocations in no-PIC large code model (#89101)

2024-04-23 Thread Tom Stellard via llvm-branch-commits

Author: Arthur Eubanks
Date: 2024-04-23T08:59:40-07:00
New Revision: a981a4f7653c112277817da3b661e9e6b24389ac

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

LOG: [X86] Always use 64-bit relocations in no-PIC large code model (#89101)

This matches other types of relocations, e.g. to constant pool. And
makes things more consistent with PIC large code model.

Some users of the large code model may not place small data in the lower
2GB of the address space (e.g.
https://github.com/ClangBuiltLinux/linux/issues/2016), so just
unconditionally use 64-bit relocations in the large code model.

So now functions in a section not marked large will use 64-bit
relocations to reference everything when using the large code model.

This also fixes some lldb tests broken by #88172
(https://lab.llvm.org/buildbot/#/builders/68/builds/72458).

(cherry picked from commit 6cea7c491f4c4c68aa0494a9b18f36ff40c22c81)

Added: 


Modified: 
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/test/CodeGen/X86/code-model-elf.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp 
b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 833f058253d880..553d338b77904a 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -2923,11 +2923,10 @@ bool X86DAGToDAGISel::selectAddr(SDNode *Parent, 
SDValue N, SDValue &Base,
 }
 
 bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue &Imm) {
-  // Cannot use 32 bit constants to reference objects in kernel code model.
-  // Cannot use 32 bit constants to reference objects in large PIC mode since
-  // GOTOFF is 64 bits.
+  // Cannot use 32 bit constants to reference objects in kernel/large code
+  // model.
   if (TM.getCodeModel() == CodeModel::Kernel ||
-  (TM.getCodeModel() == CodeModel::Large && TM.isPositionIndependent()))
+  TM.getCodeModel() == CodeModel::Large)
 return false;
 
   // In static codegen with small code model, we can get the address of a label

diff  --git a/llvm/test/CodeGen/X86/code-model-elf.ll 
b/llvm/test/CodeGen/X86/code-model-elf.ll
index afcffb3a7adeda..b6634403dc1d05 100644
--- a/llvm/test/CodeGen/X86/code-model-elf.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf.ll
@@ -346,7 +346,7 @@ define dso_local ptr @lea_forced_small_data() #0 {
 ;
 ; LARGE-STATIC-LABEL: lea_forced_small_data:
 ; LARGE-STATIC:   # %bb.0:
-; LARGE-STATIC-NEXT:movl $forced_small_data, %eax
+; LARGE-STATIC-NEXT:movabsq $forced_small_data, %rax
 ; LARGE-STATIC-NEXT:retq
 ;
 ; SMALL-PIC-LABEL: lea_forced_small_data:
@@ -399,7 +399,7 @@ define dso_local i32 @load_forced_small_data() #0 {
 ;
 ; LARGE-STATIC-LABEL: load_forced_small_data:
 ; LARGE-STATIC:   # %bb.0:
-; LARGE-STATIC-NEXT:movl $forced_small_data+8, %eax
+; LARGE-STATIC-NEXT:movabsq $forced_small_data+8, %rax
 ; LARGE-STATIC-NEXT:movl (%rax), %eax
 ; LARGE-STATIC-NEXT:retq
 ;



___
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/18.x: [X86] Always use 64-bit relocations in no-PIC large code model (#89101) (PR #89124)

2024-04-23 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/89124
___
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/18.x: [DAGCombiner] Fix miscompile bug in combineShiftOfShiftedLogic (#89616) (PR #89766)

2024-04-23 Thread via llvm-branch-commits
=?utf-8?q?Björn?= Pettersson 
Message-ID:
In-Reply-To: 


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

>From 0c4e89aaf2c23af6ddc031289fec3530cac29c94 Mon Sep 17 00:00:00 2001
From: Bjorn Pettersson 
Date: Mon, 22 Apr 2024 17:34:48 +0200
Subject: [PATCH 1/2] [DAGCombiner] Pre-commit test case for miscompile bug in
 combineShiftOfShiftedLogic

DAGCombiner is trying to fold shl over binops, and in the process
combining it with another shl. However it needs to be more careful
to ensure that the sum of the shift counts fits in the type used
for the shift amount.
For example, X86 is using i8 as shift amount type. So we need to
make sure that the sum of the shift amounts isn't greater than 255.

Fix will be applied in a later commit. This only pre-commits the
test case to show that we currently get the wrong result.

Bug was found when testing the C23 BitInt feature.

(cherry picked from commit 5fd9bbdea6cc248469d5465de44e747378ffafcb)
---
 llvm/test/CodeGen/X86/shift-combine.ll | 65 ++
 1 file changed, 65 insertions(+)

diff --git a/llvm/test/CodeGen/X86/shift-combine.ll 
b/llvm/test/CodeGen/X86/shift-combine.ll
index cf45641fba6321..f5bf3de9114dc5 100644
--- a/llvm/test/CodeGen/X86/shift-combine.ll
+++ b/llvm/test/CodeGen/X86/shift-combine.ll
@@ -787,3 +787,68 @@ define <4 x i32> 
@or_tree_with_mismatching_shifts_vec_i32(<4 x i32> %a, <4 x i32
   %r = or <4 x i32> %or.ab, %or.cd
   ret <4 x i32> %r
 }
+
+; FIXME: Reproducer for a DAGCombiner::combineShiftOfShiftedLogic
+; bug. DAGCombiner need to check that the sum of the shift amounts fits in i8,
+; which is the legal type used to described X86 shift amounts. Verify that we
+; do not try to create a shift with 130+160 as shift amount, and verify that
+; the stored value do not depend on %a1.
+define void @combineShiftOfShiftedLogic(i128 %a1, i32 %a2, ptr %p) {
+; X86-LABEL: combineShiftOfShiftedLogic:
+; X86:   # %bb.0:
+; X86-NEXT:pushl %ebx
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:pushl %edi
+; X86-NEXT:.cfi_def_cfa_offset 12
+; X86-NEXT:pushl %esi
+; X86-NEXT:.cfi_def_cfa_offset 16
+; X86-NEXT:.cfi_offset %esi, -16
+; X86-NEXT:.cfi_offset %edi, -12
+; X86-NEXT:.cfi_offset %ebx, -8
+; X86-NEXT:movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:movl {{[0-9]+}}(%esp), %edx
+; X86-NEXT:movl {{[0-9]+}}(%esp), %ebx
+; X86-NEXT:movl {{[0-9]+}}(%esp), %edi
+; X86-NEXT:movl %edi, %esi
+; X86-NEXT:shldl $2, %ebx, %edi
+; X86-NEXT:shldl $2, %edx, %ebx
+; X86-NEXT:shrl $30, %esi
+; X86-NEXT:orl {{[0-9]+}}(%esp), %esi
+; X86-NEXT:shldl $2, %ecx, %edx
+; X86-NEXT:shll $2, %ecx
+; X86-NEXT:movl %edi, 16(%eax)
+; X86-NEXT:movl %ebx, 12(%eax)
+; X86-NEXT:movl %edx, 8(%eax)
+; X86-NEXT:movl %ecx, 4(%eax)
+; X86-NEXT:movl %esi, 20(%eax)
+; X86-NEXT:movl $0, (%eax)
+; X86-NEXT:popl %esi
+; X86-NEXT:.cfi_def_cfa_offset 12
+; X86-NEXT:popl %edi
+; X86-NEXT:.cfi_def_cfa_offset 8
+; X86-NEXT:popl %ebx
+; X86-NEXT:.cfi_def_cfa_offset 4
+; X86-NEXT:retl
+;
+; X64-LABEL: combineShiftOfShiftedLogic:
+; X64:   # %bb.0:
+; X64-NEXT:# kill: def $edx killed $edx def $rdx
+; X64-NEXT:shlq $32, %rdx
+; X64-NEXT:movq %rsi, %rax
+; X64-NEXT:shrq $30, %rax
+; X64-NEXT:orq %rdx, %rax
+; X64-NEXT:shldq $34, %rdi, %rsi
+; X64-NEXT:shlq $34, %rdi
+; X64-NEXT:movq %rsi, 8(%rcx)
+; X64-NEXT:movq %rdi, (%rcx)
+; X64-NEXT:movq %rax, 16(%rcx)
+; X64-NEXT:retq
+  %zext1 = zext i128 %a1 to i192
+  %zext2 = zext i32 %a2 to i192
+  %shl = shl i192 %zext1, 130
+  %or = or i192 %shl, %zext2
+  %res = shl i192 %or, 160
+  store i192 %res, ptr %p, align 8
+  ret void
+}

>From f015692843e4090591ae329224b65b13f06dfaaf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Pettersson?= 
Date: Tue, 23 Apr 2024 14:11:34 +0200
Subject: [PATCH 2/2] [DAGCombiner] Fix miscompile bug in
 combineShiftOfShiftedLogic (#89616)

Ensure that the sum of the shift amounts does not overflow the
shift amount type when combining shifts in combineShiftOfShiftedLogic.

Solves a miscompile bug found when testing the C23 BitInt feature.

Targets like X86 that only use an i8 for shift amounts after
legalization seems to be extra susceptible for bugs like this as it
isn't legal to shift more than 255 steps.

(cherry picked from commit f9b419b7a038dcd51a7943b160acc867714c595f)
---
 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp |  9 ++-
 llvm/test/CodeGen/X86/shift-combine.ll| 58 +--
 2 files changed, 22 insertions(+), 45 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index e806e0f0731f23..5038f8a1fc1562 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9636,8 +9636,15 @@ static SDValue combin

[llvm-branch-commits] [llvm] release/18.x: [AArch64] Remove invalid uabdl patterns. (#89272) (PR #89380)

2024-04-23 Thread via llvm-branch-commits

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

>From b4c65e7d69fa01b219f56f7a5203158ee613a660 Mon Sep 17 00:00:00 2001
From: David Green 
Date: Fri, 19 Apr 2024 09:30:13 +0100
Subject: [PATCH] [AArch64] Remove invalid uabdl patterns. (#89272)

These were added in https://reviews.llvm.org/D14208, which look like
they attempt to detect abs from xor+add+ashr. They do not appear to be
detecting the correct value for the src input though, which I think is
intended to be the sub(zext, zext) part of the pattern. We have pattens
from abs now, so the old invalid patterns can be removed.

Fixes #88784

(cherry picked from commit 851462fcaa7f6e3301865de84f98be7e872e64b6)
---
 llvm/lib/Target/AArch64/AArch64InstrInfo.td | 10 -
 llvm/test/CodeGen/AArch64/arm64-vabs.ll | 48 +
 2 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 03baa7497615e3..ac61dd8745d4e6 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -4885,19 +4885,9 @@ defm UABDL   : SIMDLongThreeVectorBHSabdl<1, 0b0111, 
"uabdl",
 def : Pat<(abs (v8i16 (sub (zext (v8i8 V64:$opA)),
(zext (v8i8 V64:$opB),
   (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
-def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
-   (v8i16 (add (sub (zext (v8i8 V64:$opA)),
-(zext (v8i8 V64:$opB))),
-   (AArch64vashr v8i16:$src, (i32 15),
-  (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
 def : Pat<(abs (v8i16 (sub (zext (extract_high_v16i8 (v16i8 V128:$opA))),
(zext (extract_high_v16i8 (v16i8 V128:$opB)),
   (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
-def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
-   (v8i16 (add (sub (zext (extract_high_v16i8 (v16i8 V128:$opA))),
-(zext (extract_high_v16i8 (v16i8 V128:$opB,
-   (AArch64vashr v8i16:$src, (i32 15),
-  (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
 def : Pat<(abs (v4i32 (sub (zext (v4i16 V64:$opA)),
(zext (v4i16 V64:$opB),
   (UABDLv4i16_v4i32 V64:$opA, V64:$opB)>;
diff --git a/llvm/test/CodeGen/AArch64/arm64-vabs.ll 
b/llvm/test/CodeGen/AArch64/arm64-vabs.ll
index fe4da2e7cf36b5..89c8d540b97e04 100644
--- a/llvm/test/CodeGen/AArch64/arm64-vabs.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-vabs.ll
@@ -1848,3 +1848,51 @@ define <2 x i128> @uabd_i64(<2 x i64> %a, <2 x i64> %b) {
   %absel = select <2 x i1> %abcmp, <2 x i128> %ababs, <2 x i128> %abdiff
   ret <2 x i128> %absel
 }
+
+define <8 x i16> @pr88784(<8 x i8> %l0, <8 x i8> %l1, <8 x i16> %l2) {
+; CHECK-SD-LABEL: pr88784:
+; CHECK-SD:   // %bb.0:
+; CHECK-SD-NEXT:usubl.8h v0, v0, v1
+; CHECK-SD-NEXT:cmlt.8h v1, v2, #0
+; CHECK-SD-NEXT:ssra.8h v0, v2, #15
+; CHECK-SD-NEXT:eor.16b v0, v1, v0
+; CHECK-SD-NEXT:ret
+;
+; CHECK-GI-LABEL: pr88784:
+; CHECK-GI:   // %bb.0:
+; CHECK-GI-NEXT:usubl.8h v0, v0, v1
+; CHECK-GI-NEXT:sshr.8h v1, v2, #15
+; CHECK-GI-NEXT:ssra.8h v0, v2, #15
+; CHECK-GI-NEXT:eor.16b v0, v1, v0
+; CHECK-GI-NEXT:ret
+  %l4 = zext <8 x i8> %l0 to <8 x i16>
+  %l5 = ashr <8 x i16> %l2, 
+  %l6 = zext <8 x i8> %l1 to <8 x i16>
+  %l7 = sub <8 x i16> %l4, %l6
+  %l8 = add <8 x i16> %l5, %l7
+  %l9 = xor <8 x i16> %l5, %l8
+  ret <8 x i16> %l9
+}
+
+define <8 x i16> @pr88784_fixed(<8 x i8> %l0, <8 x i8> %l1, <8 x i16> %l2) {
+; CHECK-SD-LABEL: pr88784_fixed:
+; CHECK-SD:   // %bb.0:
+; CHECK-SD-NEXT:uabdl.8h v0, v0, v1
+; CHECK-SD-NEXT:ret
+;
+; CHECK-GI-LABEL: pr88784_fixed:
+; CHECK-GI:   // %bb.0:
+; CHECK-GI-NEXT:usubl.8h v0, v0, v1
+; CHECK-GI-NEXT:sshr.8h v1, v0, #15
+; CHECK-GI-NEXT:ssra.8h v0, v0, #15
+; CHECK-GI-NEXT:eor.16b v0, v1, v0
+; CHECK-GI-NEXT:ret
+  %l4 = zext <8 x i8> %l0 to <8 x i16>
+  %l6 = zext <8 x i8> %l1 to <8 x i16>
+  %l7 = sub <8 x i16> %l4, %l6
+  %l5 = ashr <8 x i16> %l7, 
+  %l8 = add <8 x i16> %l5, %l7
+  %l9 = xor <8 x i16> %l5, %l8
+  ret <8 x i16> %l9
+}
+

___
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/18.x: [GlobalISel] Fix fewerElementsVectorPhi to insert after G_PHIs (#87927) (PR #89240)

2024-04-23 Thread via llvm-branch-commits

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

>From 93aac2d2ca54a6c4d9736875fec5442624606d99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?D=C3=A1vid=20Ferenc=20Szab=C3=B3?=
 <30732159+dfsz...@users.noreply.github.com>
Date: Mon, 15 Apr 2024 11:01:55 +0200
Subject: [PATCH] [GlobalISel] Fix fewerElementsVectorPhi to insert after
 G_PHIs (#87927)

Currently the inserted mergelike instructions will be inserted at the
location of the G_PHI. Seems like the behaviour was correct before, but
the rework done in https://reviews.llvm.org/D114198 forgot to include
the part which makes sure the instructions will be inserted after all
the G_PHIs.

(cherry picked from commit 2347020e4ce62ee7c7378824dc6ad2b94917a638)
---
 llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp   | 4 
 llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp 
b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
index c0c22e36004f72..47d045ac48171e 100644
--- a/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -4180,6 +4180,10 @@ 
LegalizerHelper::fewerElementsVectorPhi(GenericMachineInstr &MI,
 }
   }
 
+  // Set the insert point after the existing PHIs
+  MachineBasicBlock &MBB = *MI.getParent();
+  MIRBuilder.setInsertPt(MBB, MBB.getFirstNonPHI());
+
   // Merge small outputs into MI's def.
   if (NumLeftovers) {
 mergeMixedSubvectors(MI.getReg(0), OutputRegs);
diff --git a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp 
b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
index d7876b7ce87490..531360a697039c 100644
--- a/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
+++ b/llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
@@ -1556,12 +1556,12 @@ TEST_F(AArch64GISelMITest, FewerElementsPhi) {
   CHECK: [[PHI0:%[0-9]+]]:_(<2 x s32>) = G_PHI [[INITVAL_E01]]:_(<2 x s32>), 
%bb.0, [[MIDVAL_E01]]:_(<2 x s32>), %bb.1
   CHECK: [[PHI1:%[0-9]+]]:_(<2 x s32>) = G_PHI [[INITVAL_E23]]:_(<2 x s32>), 
%bb.0, [[MIDVAL_E23]]:_(<2 x s32>), %bb.1
   CHECK: [[PHI2:%[0-9]+]]:_(s32) = G_PHI [[INITVAL_E4]]:_(s32), %bb.0, 
[[MIDVAL_E4]]:_(s32), %bb.1
-  CHECK: [[UNMERGE0:%[0-9]+]]:_(s32), [[UNMERGE1:%[0-9]+]]:_(s32) = 
G_UNMERGE_VALUES [[PHI0]]:_(<2 x s32>)
-  CHECK: [[UNMERGE2:%[0-9]+]]:_(s32), [[UNMERGE3:%[0-9]+]]:_(s32) = 
G_UNMERGE_VALUES [[PHI1]]:_(<2 x s32>)
-  CHECK: [[BV:%[0-9]+]]:_(<5 x s32>) = G_BUILD_VECTOR [[UNMERGE0]]:_(s32), 
[[UNMERGE1]]:_(s32), [[UNMERGE2]]:_(s32), [[UNMERGE3]]:_(s32), [[PHI2]]:_(s32)
 
   CHECK: [[OTHER_PHI:%[0-9]+]]:_(s64) = G_PHI
 
+  CHECK: [[UNMERGE0:%[0-9]+]]:_(s32), [[UNMERGE1:%[0-9]+]]:_(s32) = 
G_UNMERGE_VALUES [[PHI0]]:_(<2 x s32>)
+  CHECK: [[UNMERGE2:%[0-9]+]]:_(s32), [[UNMERGE3:%[0-9]+]]:_(s32) = 
G_UNMERGE_VALUES [[PHI1]]:_(<2 x s32>)
+  CHECK: [[BV:%[0-9]+]]:_(<5 x s32>) = G_BUILD_VECTOR [[UNMERGE0]]:_(s32), 
[[UNMERGE1]]:_(s32), [[UNMERGE2]]:_(s32), [[UNMERGE3]]:_(s32), [[PHI2]]:_(s32)
   CHECK: [[USE_OP:%[0-9]+]]:_(<5 x s32>) = G_AND [[BV]]:_, [[BV]]:_
   )";
 

___
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++][TZDB] Fixes reverse time lookups. (PR #89502)

2024-04-23 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne edited 
https://github.com/llvm/llvm-project/pull/89502
___
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++][TZDB] Fixes reverse time lookups. (PR #89502)

2024-04-23 Thread Louis Dionne via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/89502
___
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++] Makes saturation functions privately available. (PR #89503)

2024-04-23 Thread Louis Dionne via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/89503
___
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++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne edited 
https://github.com/llvm/llvm-project/pull/89537
___
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/18.x: [TableGen] Fix ReplaceRegAction RTTI Kind (PR #89790)

2024-04-23 Thread via llvm-branch-commits

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

cherry picked from commit 8a631d789859d09ba3a11a1206c30e595f4b6428

>From f8f2f514681d6619354a4a65d73a51a5774a5152 Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Tue, 23 Apr 2024 12:54:50 +0200
Subject: [PATCH] [TableGen] Fix ReplaceRegAction RTTI Kind

---
 llvm/utils/TableGen/GlobalISelMatchTable.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/TableGen/GlobalISelMatchTable.h 
b/llvm/utils/TableGen/GlobalISelMatchTable.h
index 7cb5345f51f8cb..9192550de8f10e 100644
--- a/llvm/utils/TableGen/GlobalISelMatchTable.h
+++ b/llvm/utils/TableGen/GlobalISelMatchTable.h
@@ -2333,11 +2333,11 @@ class ReplaceRegAction : public MatchAction {
 public:
   ReplaceRegAction(unsigned OldInsnID, unsigned OldOpIdx, unsigned NewInsnId,
unsigned NewOpIdx)
-  : MatchAction(AK_EraseInst), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
+  : MatchAction(AK_ReplaceReg), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
 NewInsnId(NewInsnId), NewOpIdx(NewOpIdx) {}
 
   ReplaceRegAction(unsigned OldInsnID, unsigned OldOpIdx, unsigned TempRegID)
-  : MatchAction(AK_EraseInst), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
+  : MatchAction(AK_ReplaceReg), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
 TempRegID(TempRegID) {}
 
   static bool classof(const MatchAction *A) {

___
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/18.x: [TableGen] Fix ReplaceRegAction RTTI Kind (PR #89790)

2024-04-23 Thread via llvm-branch-commits

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

>From 44ee562ebe3d89e09f64a3b04921a3f0c5f6ed07 Mon Sep 17 00:00:00 2001
From: pvanhout 
Date: Tue, 23 Apr 2024 12:54:50 +0200
Subject: [PATCH] [TableGen] Fix ReplaceRegAction RTTI Kind

---
 llvm/utils/TableGen/GlobalISelMatchTable.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/TableGen/GlobalISelMatchTable.h 
b/llvm/utils/TableGen/GlobalISelMatchTable.h
index 7cb5345f51f8cb..9192550de8f10e 100644
--- a/llvm/utils/TableGen/GlobalISelMatchTable.h
+++ b/llvm/utils/TableGen/GlobalISelMatchTable.h
@@ -2333,11 +2333,11 @@ class ReplaceRegAction : public MatchAction {
 public:
   ReplaceRegAction(unsigned OldInsnID, unsigned OldOpIdx, unsigned NewInsnId,
unsigned NewOpIdx)
-  : MatchAction(AK_EraseInst), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
+  : MatchAction(AK_ReplaceReg), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
 NewInsnId(NewInsnId), NewOpIdx(NewOpIdx) {}
 
   ReplaceRegAction(unsigned OldInsnID, unsigned OldOpIdx, unsigned TempRegID)
-  : MatchAction(AK_EraseInst), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
+  : MatchAction(AK_ReplaceReg), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
 TempRegID(TempRegID) {}
 
   static bool classof(const MatchAction *A) {

___
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/18.x: [TableGen] Fix ReplaceRegAction RTTI Kind (PR #89790)

2024-04-23 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-globalisel

Author: AtariDreams (AtariDreams)


Changes

cherry picked from commit 8a631d789859d09ba3a11a1206c30e595f4b6428

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


1 Files Affected:

- (modified) llvm/utils/TableGen/GlobalISelMatchTable.h (+2-2) 


``diff
diff --git a/llvm/utils/TableGen/GlobalISelMatchTable.h 
b/llvm/utils/TableGen/GlobalISelMatchTable.h
index 7cb5345f51f8cb..9192550de8f10e 100644
--- a/llvm/utils/TableGen/GlobalISelMatchTable.h
+++ b/llvm/utils/TableGen/GlobalISelMatchTable.h
@@ -2333,11 +2333,11 @@ class ReplaceRegAction : public MatchAction {
 public:
   ReplaceRegAction(unsigned OldInsnID, unsigned OldOpIdx, unsigned NewInsnId,
unsigned NewOpIdx)
-  : MatchAction(AK_EraseInst), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
+  : MatchAction(AK_ReplaceReg), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
 NewInsnId(NewInsnId), NewOpIdx(NewOpIdx) {}
 
   ReplaceRegAction(unsigned OldInsnID, unsigned OldOpIdx, unsigned TempRegID)
-  : MatchAction(AK_EraseInst), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
+  : MatchAction(AK_ReplaceReg), OldInsnID(OldInsnID), OldOpIdx(OldOpIdx),
 TempRegID(TempRegID) {}
 
   static bool classof(const MatchAction *A) {

``




https://github.com/llvm/llvm-project/pull/89790
___
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] [clang][CallGraphSection] Add type id metadata to indirect call and targets (PR #87573)

2024-04-23 Thread via llvm-branch-commits


@@ -2220,6 +2220,14 @@ 
CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
   RValue rvalue = CGF.EmitCall(MSI.CallInfo, Callee, Return, ActualArgs,
&CallSite);
 
+  // Set type identifier metadata of indirect calls for call graph section.
+  if (CGM.getCodeGenOpts().CallGraphSection && Method && CallSite &&

Prabhuk wrote:

Ack. This change should not have been made for ObjC. I will remove this snippet 
of code that makes the call to CreateFunctionTypeMetadataforIcall which should 
also address this comment. I will upload the change along with the refactoring 
change suggested by Eli as soon as I can. Thank you.

https://github.com/llvm/llvm-project/pull/87573
___
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][OpenMP] Update op verifiers dependent on omp.wsloop (2/5) (PR #89211)

2024-04-23 Thread Tom Eccles via llvm-branch-commits

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

LGTM. I'm sorry this fell off my radar

https://github.com/llvm/llvm-project/pull/89211
___
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++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits

https://github.com/ldionne edited 
https://github.com/llvm/llvm-project/pull/89537
___
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++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits


@@ -903,6 +904,180 @@ time_zone::__get_info(sys_seconds __time) const {
   std::__throw_runtime_error("tzdb: corrupt db");
 }
 
+enum class __position {
+  __beginning,
+  __middle,
+  __end,
+};
+
+// Determines the position of "__time" inside "__info".
+//
+// The code picks an arbitrary value to determine the "middle"
+// - Every time that is more than the threshold from a boundary, or
+// - Every value that is at the boundary sys_seconds::min() or
+//   sys_seconds::max().
+//
+// If not in the middle, it returns __beginning or __end.
+[[nodiscard]] static __position __get_position(sys_seconds __time, const 
sys_info __info) {
+  _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
+  __time >= __info.begin && __time < __info.end, "A value outside the 
range's position can't be determined.");
+
+  using _Tp = sys_seconds::rep;
+  // Africa/Freetown has a 4 day "zone"
+  // Africa/Freetown  Fri Sep  1 00:59:59 1939 UT = Thu Aug 31 23:59:59 1939 
-01 isdst=0 gmtoff=-3600
+  // Africa/Freetown  Fri Sep  1 01:00:00 1939 UT = Fri Sep  1 00:20:00 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:39:59 1939 UT = Mon Sep  4 23:59:59 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:40:00 1939 UT = Mon Sep  4 23:40:00 1939 
-01 isdst=0 gmtoff=-3600
+  //
+  // Originally used a one week threshold, but due to this switched to 1 day.
+  // This seems to work in practice.
+  //
+  // TODO TZDB Evaluate the proper threshold.
+  constexpr _Tp __threshold = 24 * 3600;
+
+  _Tp __upper = std::__add_sat(__info.begin.time_since_epoch().count(), 
__threshold);
+  if (__time >= __info.begin && __time.time_since_epoch().count() < __upper)
+return __info.begin != sys_seconds::min() ? __position::__beginning : 
__position::__middle;
+
+  _Tp __lower = std::__sub_sat(__info.end.time_since_epoch().count(), 
__threshold);
+  if (__time < __info.end && __time.time_since_epoch().count() >= __lower)
+return __info.end != sys_seconds::max() ? __position::__end : 
__position::__middle;
+
+  return __position::__middle;
+}
+
+[[nodiscard]] static local_info
+__get_info(local_seconds __local_time, const sys_info& __first, const 
sys_info& __second) {
+  std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + 
__first.offset};
+  std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() 
+ __second.offset};
+
+  if (__local_time < __end_first) {
+if (__local_time >= __begin_second)
+  // ||
+  //|--|
+  // ^
+  return {local_info::ambiguous, __first, __second};
+
+// ||
+//  |--|
+// ^
+return {local_info::unique, __first, sys_info{}};
+  }
+
+  if (__local_time < __begin_second)
+// ||
+// |--|
+//   ^
+return {local_info::nonexistent, __first, __second};
+
+  // ||
+  //  |--|
+  //   ^
+  return {local_info::unique, __second, sys_info{}};
+}
+
+[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info
+time_zone::__get_info(local_seconds __local_time) const {
+  seconds __local_seconds = __local_time.time_since_epoch();
+
+  /* An example of a typical year with a DST switch displayed in local time.
+   *
+   * At the first of April the time goes forward one hour. This means the
+   * time marked with ~~ is not a valid local time. This is represented by the
+   * nonexistent value in local_info.result.
+   *
+   * At the first of November the time goes backward one hour. This means the
+   * time marked with ^^ happens twice. This is represented by the ambiguous
+   * value in local_info.result.
+   *
+   * 2020.11.01  2021.04.01  2021.11.01
+   * offset +05  offset +05  offset +05
+   * save0s  save1h  save0s
+   * |-W--|
+   * |--W--|
+   *|-
+   *   ~~^^
+   *
+   * These shifts can happen due to changes in the current time zone for a
+   * location. For example, Indian/Kerguelen switched only once. In 1950 from 
an
+   * offset of 0 hours to an offset of +05 hours.
+   *
+   * During all these shifts the UTC time will have not gaps.
+   */
+
+  // The code needs to determine the system time for the local time. There is 
no
+  // information available. Assume the offset between system time and local 
time
+  // is 0s. This gives an initial estimate.
+  sys_seconds __guess{__local_seconds};
+  sys_info __info = __get_info(__guess);
+
+  // At this point the offset can be used to determine an estimate for the 
local
+  // time. Before doing the determine the offset validate whether the local 
time
+  // is the range [chrono::local_seconds::min(), chrono::local_seconds::max()).
+  if (__loca

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/89537
___
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++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits


@@ -903,6 +904,180 @@ time_zone::__get_info(sys_seconds __time) const {
   std::__throw_runtime_error("tzdb: corrupt db");
 }
 
+enum class __position {
+  __beginning,
+  __middle,
+  __end,
+};
+
+// Determines the position of "__time" inside "__info".
+//
+// The code picks an arbitrary value to determine the "middle"
+// - Every time that is more than the threshold from a boundary, or
+// - Every value that is at the boundary sys_seconds::min() or
+//   sys_seconds::max().
+//
+// If not in the middle, it returns __beginning or __end.
+[[nodiscard]] static __position __get_position(sys_seconds __time, const 
sys_info __info) {
+  _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
+  __time >= __info.begin && __time < __info.end, "A value outside the 
range's position can't be determined.");
+
+  using _Tp = sys_seconds::rep;
+  // Africa/Freetown has a 4 day "zone"
+  // Africa/Freetown  Fri Sep  1 00:59:59 1939 UT = Thu Aug 31 23:59:59 1939 
-01 isdst=0 gmtoff=-3600
+  // Africa/Freetown  Fri Sep  1 01:00:00 1939 UT = Fri Sep  1 00:20:00 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:39:59 1939 UT = Mon Sep  4 23:59:59 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:40:00 1939 UT = Mon Sep  4 23:40:00 1939 
-01 isdst=0 gmtoff=-3600
+  //
+  // Originally used a one week threshold, but due to this switched to 1 day.
+  // This seems to work in practice.
+  //
+  // TODO TZDB Evaluate the proper threshold.
+  constexpr _Tp __threshold = 24 * 3600;
+
+  _Tp __upper = std::__add_sat(__info.begin.time_since_epoch().count(), 
__threshold);
+  if (__time >= __info.begin && __time.time_since_epoch().count() < __upper)
+return __info.begin != sys_seconds::min() ? __position::__beginning : 
__position::__middle;
+
+  _Tp __lower = std::__sub_sat(__info.end.time_since_epoch().count(), 
__threshold);
+  if (__time < __info.end && __time.time_since_epoch().count() >= __lower)
+return __info.end != sys_seconds::max() ? __position::__end : 
__position::__middle;
+
+  return __position::__middle;
+}
+
+[[nodiscard]] static local_info
+__get_info(local_seconds __local_time, const sys_info& __first, const 
sys_info& __second) {
+  std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + 
__first.offset};
+  std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() 
+ __second.offset};
+
+  if (__local_time < __end_first) {
+if (__local_time >= __begin_second)
+  // ||
+  //|--|
+  // ^
+  return {local_info::ambiguous, __first, __second};
+
+// ||
+//  |--|
+// ^
+return {local_info::unique, __first, sys_info{}};
+  }
+
+  if (__local_time < __begin_second)
+// ||
+// |--|
+//   ^
+return {local_info::nonexistent, __first, __second};
+
+  // ||
+  //  |--|
+  //   ^
+  return {local_info::unique, __second, sys_info{}};
+}
+
+[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info
+time_zone::__get_info(local_seconds __local_time) const {
+  seconds __local_seconds = __local_time.time_since_epoch();
+
+  /* An example of a typical year with a DST switch displayed in local time.
+   *
+   * At the first of April the time goes forward one hour. This means the
+   * time marked with ~~ is not a valid local time. This is represented by the
+   * nonexistent value in local_info.result.
+   *
+   * At the first of November the time goes backward one hour. This means the
+   * time marked with ^^ happens twice. This is represented by the ambiguous
+   * value in local_info.result.
+   *
+   * 2020.11.01  2021.04.01  2021.11.01
+   * offset +05  offset +05  offset +05
+   * save0s  save1h  save0s
+   * |-W--|
+   * |--W--|
+   *|-
+   *   ~~^^
+   *
+   * These shifts can happen due to changes in the current time zone for a
+   * location. For example, Indian/Kerguelen switched only once. In 1950 from 
an
+   * offset of 0 hours to an offset of +05 hours.
+   *
+   * During all these shifts the UTC time will have not gaps.
+   */
+
+  // The code needs to determine the system time for the local time. There is 
no
+  // information available. Assume the offset between system time and local 
time
+  // is 0s. This gives an initial estimate.
+  sys_seconds __guess{__local_seconds};
+  sys_info __info = __get_info(__guess);
+
+  // At this point the offset can be used to determine an estimate for the 
local
+  // time. Before doing the determine the offset validate whether the local 
time

ldionne wrote:

```suggestion
  // time. Before doing that, determine the off

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits


@@ -903,6 +904,180 @@ time_zone::__get_info(sys_seconds __time) const {
   std::__throw_runtime_error("tzdb: corrupt db");
 }
 
+enum class __position {
+  __beginning,
+  __middle,
+  __end,
+};
+
+// Determines the position of "__time" inside "__info".
+//
+// The code picks an arbitrary value to determine the "middle"
+// - Every time that is more than the threshold from a boundary, or
+// - Every value that is at the boundary sys_seconds::min() or
+//   sys_seconds::max().
+//
+// If not in the middle, it returns __beginning or __end.
+[[nodiscard]] static __position __get_position(sys_seconds __time, const 
sys_info __info) {
+  _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
+  __time >= __info.begin && __time < __info.end, "A value outside the 
range's position can't be determined.");
+
+  using _Tp = sys_seconds::rep;
+  // Africa/Freetown has a 4 day "zone"
+  // Africa/Freetown  Fri Sep  1 00:59:59 1939 UT = Thu Aug 31 23:59:59 1939 
-01 isdst=0 gmtoff=-3600
+  // Africa/Freetown  Fri Sep  1 01:00:00 1939 UT = Fri Sep  1 00:20:00 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:39:59 1939 UT = Mon Sep  4 23:59:59 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:40:00 1939 UT = Mon Sep  4 23:40:00 1939 
-01 isdst=0 gmtoff=-3600
+  //
+  // Originally used a one week threshold, but due to this switched to 1 day.
+  // This seems to work in practice.
+  //
+  // TODO TZDB Evaluate the proper threshold.
+  constexpr _Tp __threshold = 24 * 3600;
+
+  _Tp __upper = std::__add_sat(__info.begin.time_since_epoch().count(), 
__threshold);
+  if (__time >= __info.begin && __time.time_since_epoch().count() < __upper)
+return __info.begin != sys_seconds::min() ? __position::__beginning : 
__position::__middle;
+
+  _Tp __lower = std::__sub_sat(__info.end.time_since_epoch().count(), 
__threshold);
+  if (__time < __info.end && __time.time_since_epoch().count() >= __lower)
+return __info.end != sys_seconds::max() ? __position::__end : 
__position::__middle;
+
+  return __position::__middle;
+}
+
+[[nodiscard]] static local_info
+__get_info(local_seconds __local_time, const sys_info& __first, const 
sys_info& __second) {
+  std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + 
__first.offset};
+  std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() 
+ __second.offset};
+
+  if (__local_time < __end_first) {
+if (__local_time >= __begin_second)
+  // ||
+  //|--|
+  // ^
+  return {local_info::ambiguous, __first, __second};
+
+// ||
+//  |--|
+// ^
+return {local_info::unique, __first, sys_info{}};
+  }
+
+  if (__local_time < __begin_second)
+// ||
+// |--|
+//   ^
+return {local_info::nonexistent, __first, __second};
+
+  // ||
+  //  |--|
+  //   ^
+  return {local_info::unique, __second, sys_info{}};
+}
+
+[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info
+time_zone::__get_info(local_seconds __local_time) const {
+  seconds __local_seconds = __local_time.time_since_epoch();
+
+  /* An example of a typical year with a DST switch displayed in local time.
+   *
+   * At the first of April the time goes forward one hour. This means the
+   * time marked with ~~ is not a valid local time. This is represented by the
+   * nonexistent value in local_info.result.
+   *
+   * At the first of November the time goes backward one hour. This means the
+   * time marked with ^^ happens twice. This is represented by the ambiguous
+   * value in local_info.result.
+   *
+   * 2020.11.01  2021.04.01  2021.11.01
+   * offset +05  offset +05  offset +05
+   * save0s  save1h  save0s
+   * |-W--|
+   * |--W--|
+   *|-
+   *   ~~^^
+   *
+   * These shifts can happen due to changes in the current time zone for a
+   * location. For example, Indian/Kerguelen switched only once. In 1950 from 
an
+   * offset of 0 hours to an offset of +05 hours.
+   *
+   * During all these shifts the UTC time will have not gaps.
+   */
+
+  // The code needs to determine the system time for the local time. There is 
no
+  // information available. Assume the offset between system time and local 
time
+  // is 0s. This gives an initial estimate.
+  sys_seconds __guess{__local_seconds};
+  sys_info __info = __get_info(__guess);
+
+  // At this point the offset can be used to determine an estimate for the 
local
+  // time. Before doing the determine the offset validate whether the local 
time
+  // is the range [chrono::local_seconds::min(), chrono::local_seconds::max()).
+  if (__loca

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits


@@ -903,6 +904,180 @@ time_zone::__get_info(sys_seconds __time) const {
   std::__throw_runtime_error("tzdb: corrupt db");
 }
 
+enum class __position {
+  __beginning,
+  __middle,
+  __end,
+};
+
+// Determines the position of "__time" inside "__info".
+//
+// The code picks an arbitrary value to determine the "middle"
+// - Every time that is more than the threshold from a boundary, or
+// - Every value that is at the boundary sys_seconds::min() or
+//   sys_seconds::max().
+//
+// If not in the middle, it returns __beginning or __end.
+[[nodiscard]] static __position __get_position(sys_seconds __time, const 
sys_info __info) {
+  _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
+  __time >= __info.begin && __time < __info.end, "A value outside the 
range's position can't be determined.");
+
+  using _Tp = sys_seconds::rep;
+  // Africa/Freetown has a 4 day "zone"
+  // Africa/Freetown  Fri Sep  1 00:59:59 1939 UT = Thu Aug 31 23:59:59 1939 
-01 isdst=0 gmtoff=-3600
+  // Africa/Freetown  Fri Sep  1 01:00:00 1939 UT = Fri Sep  1 00:20:00 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:39:59 1939 UT = Mon Sep  4 23:59:59 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:40:00 1939 UT = Mon Sep  4 23:40:00 1939 
-01 isdst=0 gmtoff=-3600
+  //
+  // Originally used a one week threshold, but due to this switched to 1 day.
+  // This seems to work in practice.
+  //
+  // TODO TZDB Evaluate the proper threshold.
+  constexpr _Tp __threshold = 24 * 3600;
+
+  _Tp __upper = std::__add_sat(__info.begin.time_since_epoch().count(), 
__threshold);
+  if (__time >= __info.begin && __time.time_since_epoch().count() < __upper)
+return __info.begin != sys_seconds::min() ? __position::__beginning : 
__position::__middle;
+
+  _Tp __lower = std::__sub_sat(__info.end.time_since_epoch().count(), 
__threshold);
+  if (__time < __info.end && __time.time_since_epoch().count() >= __lower)
+return __info.end != sys_seconds::max() ? __position::__end : 
__position::__middle;
+
+  return __position::__middle;
+}
+
+[[nodiscard]] static local_info
+__get_info(local_seconds __local_time, const sys_info& __first, const 
sys_info& __second) {
+  std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + 
__first.offset};
+  std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() 
+ __second.offset};
+
+  if (__local_time < __end_first) {
+if (__local_time >= __begin_second)
+  // ||
+  //|--|
+  // ^
+  return {local_info::ambiguous, __first, __second};
+
+// ||
+//  |--|
+// ^
+return {local_info::unique, __first, sys_info{}};
+  }
+
+  if (__local_time < __begin_second)
+// ||
+// |--|
+//   ^
+return {local_info::nonexistent, __first, __second};
+
+  // ||
+  //  |--|
+  //   ^
+  return {local_info::unique, __second, sys_info{}};
+}
+
+[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info
+time_zone::__get_info(local_seconds __local_time) const {
+  seconds __local_seconds = __local_time.time_since_epoch();
+
+  /* An example of a typical year with a DST switch displayed in local time.
+   *
+   * At the first of April the time goes forward one hour. This means the
+   * time marked with ~~ is not a valid local time. This is represented by the
+   * nonexistent value in local_info.result.
+   *
+   * At the first of November the time goes backward one hour. This means the
+   * time marked with ^^ happens twice. This is represented by the ambiguous
+   * value in local_info.result.
+   *
+   * 2020.11.01  2021.04.01  2021.11.01
+   * offset +05  offset +05  offset +05
+   * save0s  save1h  save0s
+   * |-W--|
+   * |--W--|
+   *|-
+   *   ~~^^
+   *
+   * These shifts can happen due to changes in the current time zone for a
+   * location. For example, Indian/Kerguelen switched only once. In 1950 from 
an
+   * offset of 0 hours to an offset of +05 hours.
+   *
+   * During all these shifts the UTC time will have not gaps.
+   */
+
+  // The code needs to determine the system time for the local time. There is 
no
+  // information available. Assume the offset between system time and local 
time
+  // is 0s. This gives an initial estimate.
+  sys_seconds __guess{__local_seconds};
+  sys_info __info = __get_info(__guess);
+
+  // At this point the offset can be used to determine an estimate for the 
local
+  // time. Before doing the determine the offset validate whether the local 
time
+  // is the range [chrono::local_seconds::min(), chrono::local_seconds::max()).
+  if (__loca

[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits


@@ -903,6 +904,180 @@ time_zone::__get_info(sys_seconds __time) const {
   std::__throw_runtime_error("tzdb: corrupt db");
 }
 
+enum class __position {
+  __beginning,
+  __middle,
+  __end,
+};
+
+// Determines the position of "__time" inside "__info".
+//
+// The code picks an arbitrary value to determine the "middle"
+// - Every time that is more than the threshold from a boundary, or
+// - Every value that is at the boundary sys_seconds::min() or
+//   sys_seconds::max().
+//
+// If not in the middle, it returns __beginning or __end.
+[[nodiscard]] static __position __get_position(sys_seconds __time, const 
sys_info __info) {
+  _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
+  __time >= __info.begin && __time < __info.end, "A value outside the 
range's position can't be determined.");
+
+  using _Tp = sys_seconds::rep;
+  // Africa/Freetown has a 4 day "zone"
+  // Africa/Freetown  Fri Sep  1 00:59:59 1939 UT = Thu Aug 31 23:59:59 1939 
-01 isdst=0 gmtoff=-3600
+  // Africa/Freetown  Fri Sep  1 01:00:00 1939 UT = Fri Sep  1 00:20:00 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:39:59 1939 UT = Mon Sep  4 23:59:59 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:40:00 1939 UT = Mon Sep  4 23:40:00 1939 
-01 isdst=0 gmtoff=-3600
+  //
+  // Originally used a one week threshold, but due to this switched to 1 day.
+  // This seems to work in practice.
+  //
+  // TODO TZDB Evaluate the proper threshold.
+  constexpr _Tp __threshold = 24 * 3600;
+
+  _Tp __upper = std::__add_sat(__info.begin.time_since_epoch().count(), 
__threshold);
+  if (__time >= __info.begin && __time.time_since_epoch().count() < __upper)
+return __info.begin != sys_seconds::min() ? __position::__beginning : 
__position::__middle;
+
+  _Tp __lower = std::__sub_sat(__info.end.time_since_epoch().count(), 
__threshold);
+  if (__time < __info.end && __time.time_since_epoch().count() >= __lower)
+return __info.end != sys_seconds::max() ? __position::__end : 
__position::__middle;
+
+  return __position::__middle;
+}
+
+[[nodiscard]] static local_info
+__get_info(local_seconds __local_time, const sys_info& __first, const 
sys_info& __second) {
+  std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + 
__first.offset};
+  std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() 
+ __second.offset};
+
+  if (__local_time < __end_first) {
+if (__local_time >= __begin_second)
+  // ||
+  //|--|
+  // ^
+  return {local_info::ambiguous, __first, __second};
+
+// ||
+//  |--|
+// ^
+return {local_info::unique, __first, sys_info{}};
+  }
+
+  if (__local_time < __begin_second)
+// ||
+// |--|
+//   ^
+return {local_info::nonexistent, __first, __second};
+
+  // ||
+  //  |--|
+  //   ^
+  return {local_info::unique, __second, sys_info{}};
+}
+
+[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info
+time_zone::__get_info(local_seconds __local_time) const {
+  seconds __local_seconds = __local_time.time_since_epoch();
+
+  /* An example of a typical year with a DST switch displayed in local time.
+   *
+   * At the first of April the time goes forward one hour. This means the
+   * time marked with ~~ is not a valid local time. This is represented by the
+   * nonexistent value in local_info.result.
+   *
+   * At the first of November the time goes backward one hour. This means the
+   * time marked with ^^ happens twice. This is represented by the ambiguous
+   * value in local_info.result.
+   *
+   * 2020.11.01  2021.04.01  2021.11.01
+   * offset +05  offset +05  offset +05
+   * save0s  save1h  save0s
+   * |-W--|
+   * |--W--|
+   *|-
+   *   ~~^^
+   *
+   * These shifts can happen due to changes in the current time zone for a
+   * location. For example, Indian/Kerguelen switched only once. In 1950 from 
an
+   * offset of 0 hours to an offset of +05 hours.
+   *
+   * During all these shifts the UTC time will have not gaps.

ldionne wrote:

```suggestion
   * During all these shifts the UTC time will not have gaps.
```

https://github.com/llvm/llvm-project/pull/89537
___
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++][TZDB] Implements time_zone get_info(local_time). (PR #89537)

2024-04-23 Thread Louis Dionne via llvm-branch-commits


@@ -903,6 +904,180 @@ time_zone::__get_info(sys_seconds __time) const {
   std::__throw_runtime_error("tzdb: corrupt db");
 }
 
+enum class __position {
+  __beginning,
+  __middle,
+  __end,
+};
+
+// Determines the position of "__time" inside "__info".
+//
+// The code picks an arbitrary value to determine the "middle"
+// - Every time that is more than the threshold from a boundary, or
+// - Every value that is at the boundary sys_seconds::min() or
+//   sys_seconds::max().
+//
+// If not in the middle, it returns __beginning or __end.
+[[nodiscard]] static __position __get_position(sys_seconds __time, const 
sys_info __info) {
+  _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
+  __time >= __info.begin && __time < __info.end, "A value outside the 
range's position can't be determined.");
+
+  using _Tp = sys_seconds::rep;
+  // Africa/Freetown has a 4 day "zone"
+  // Africa/Freetown  Fri Sep  1 00:59:59 1939 UT = Thu Aug 31 23:59:59 1939 
-01 isdst=0 gmtoff=-3600
+  // Africa/Freetown  Fri Sep  1 01:00:00 1939 UT = Fri Sep  1 00:20:00 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:39:59 1939 UT = Mon Sep  4 23:59:59 1939 
-0040 isdst=1 gmtoff=-2400
+  // Africa/Freetown  Tue Sep  5 00:40:00 1939 UT = Mon Sep  4 23:40:00 1939 
-01 isdst=0 gmtoff=-3600
+  //
+  // Originally used a one week threshold, but due to this switched to 1 day.
+  // This seems to work in practice.
+  //
+  // TODO TZDB Evaluate the proper threshold.
+  constexpr _Tp __threshold = 24 * 3600;
+
+  _Tp __upper = std::__add_sat(__info.begin.time_since_epoch().count(), 
__threshold);
+  if (__time >= __info.begin && __time.time_since_epoch().count() < __upper)
+return __info.begin != sys_seconds::min() ? __position::__beginning : 
__position::__middle;
+
+  _Tp __lower = std::__sub_sat(__info.end.time_since_epoch().count(), 
__threshold);
+  if (__time < __info.end && __time.time_since_epoch().count() >= __lower)
+return __info.end != sys_seconds::max() ? __position::__end : 
__position::__middle;
+
+  return __position::__middle;
+}
+
+[[nodiscard]] static local_info
+__get_info(local_seconds __local_time, const sys_info& __first, const 
sys_info& __second) {
+  std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + 
__first.offset};
+  std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() 
+ __second.offset};
+
+  if (__local_time < __end_first) {
+if (__local_time >= __begin_second)
+  // ||
+  //|--|
+  // ^
+  return {local_info::ambiguous, __first, __second};
+
+// ||
+//  |--|
+// ^
+return {local_info::unique, __first, sys_info{}};
+  }
+
+  if (__local_time < __begin_second)
+// ||
+// |--|
+//   ^
+return {local_info::nonexistent, __first, __second};
+
+  // ||
+  //  |--|
+  //   ^
+  return {local_info::unique, __second, sys_info{}};
+}
+
+[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info
+time_zone::__get_info(local_seconds __local_time) const {
+  seconds __local_seconds = __local_time.time_since_epoch();
+
+  /* An example of a typical year with a DST switch displayed in local time.
+   *
+   * At the first of April the time goes forward one hour. This means the
+   * time marked with ~~ is not a valid local time. This is represented by the
+   * nonexistent value in local_info.result.
+   *
+   * At the first of November the time goes backward one hour. This means the
+   * time marked with ^^ happens twice. This is represented by the ambiguous
+   * value in local_info.result.
+   *
+   * 2020.11.01  2021.04.01  2021.11.01
+   * offset +05  offset +05  offset +05
+   * save0s  save1h  save0s
+   * |-W--|
+   * |--W--|

ldionne wrote:

```suggestion
   * |-//-|
   * |--//-|
```

That might make it clearer that this is meant to represent "a jump on the axis".

https://github.com/llvm/llvm-project/pull/89537
___
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] Improves escaping. (PR #88283)

2024-04-23 Thread Louis Dionne via llvm-branch-commits

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


  1   2   >