[llvm-branch-commits] [llvm] release/18.x: [X86] Fix miscompile in combineShiftRightArithmetic (PR #86728)

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

topperc wrote:

> > @phoebewang What do you think about backporting this?
> 
> I didn't review on it. Maybe @topperc can evaluate it.

I think this is ok to backport.

https://github.com/llvm/llvm-project/pull/86728
___
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 Tom Stellard via llvm-branch-commits

tstellar wrote:

@Pierre-vh What do you think about backporting this?

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

2024-04-23 Thread Tom Stellard via llvm-branch-commits
=?utf-8?q?Bj=C3=B6rn?= Pettersson 
Message-ID:
In-Reply-To: 


tstellar wrote:

@bjope What do you think about backporting this?

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

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

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

>From e29002224ef168934ae414e75e765cf197f65bc0 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 23 Apr 2024 13:21:43 +0200
Subject: [PATCH 1/2] [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")
 
   if (NOT CMAKE_CONFIGURATION_TYPES)
 add_llvm_install_targets(install-lldb-headers
diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index f915839f6b45a5..88ea6a568ec4ca 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -104,7 +104,7 @@ endforeach()
 
 # Wrap output in a target, so lldb-framework can depend on it.
 add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
-set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "lldb misc")
+set_target_properties(liblldb-resource-headers PROPERTIES FOLDER 
"LLDB/Resources")
 add_dependencies(liblldb liblldb-resource-headers)
 
 # At build time, copy the staged headers into the framework bundle (and do
diff --git a/lldb/cmake/modules/LLDBStandalone.cmake 
b/lldb/cmake/modules/LLDBStandalone.cmake
index fd16716d71419c..c9367214848fda 100644
--- 

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

2024-04-23 Thread Michael Kruse 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")

Meinersbur wrote:

This `set_target_properties` is actually redundant: `add_llvm_symbol_exports` 
already puts it into a folder. It is also `${LLVM_SUBPROJECT_TITLE}/Misc`. I 
agree `${LLVM_SUBPROJECT_TITLE}/API` would be a better name. I am going to make 
that change in #89741. Thanks.

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] [GSYM][DWARF] Include end_sequence debug_line rows when looking up addr ranges (PR #89703)

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

avillega wrote:

I was trying to figure out why llvm-dwarfdump does not seem to be affected by 
my change, there are note failing tests and I don't see any changes by doing 
some manual testing of some simple test cases. It seems that `llvm-dwarfdump` 
does not use the API I changed, for `--debug_lines` they use 
`DWARFDebugLine::SectionParser::parseNext` instead. However, it does affect 
`llvm-rdtyld` as exposed by the checks. I could ignore the `end_sequence` row 
when they are at the last position of the rows vector, for the users of 
`DWARFDebugLine::LineTable::lookupAddressRange`. Please let me know what do you 
think. Either way I will split the PR into dwarf api changes and gsym changes. 

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] [llvm] release/18.x: [InstCombine] Fix unexpected overwriting in `foldSelectWithSRem` (#89539) (PR #89546)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/89546
___
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] e7c816b - [InstCombine] Fix unexpected overwriting in `foldSelectWithSRem` (#89539)

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

Author: Yingwei Zheng
Date: 2024-04-23T15:02:50-07:00
New Revision: e7c816b3cd3e1e28a9817291885b647d0c42ca9a

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

LOG:  [InstCombine] Fix unexpected overwriting in `foldSelectWithSRem` (#89539)

Fixes #89516

(cherry picked from commit 6309440c218778db027306826993e484eab2be17)

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-divrem.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 9f220ec003ec33..8cc7901cbac7fa 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2606,7 +2606,7 @@ static Instruction *foldSelectWithSRem(SelectInst , 
InstCombinerImpl ,
   // %cnd = icmp slt i32 %rem, 0
   // %add = add i32 %rem, %n
   // %sel = select i1 %cnd, i32 %add, i32 %rem
-  if (match(TrueVal, m_Add(m_Value(RemRes), m_Value(Remainder))) &&
+  if (match(TrueVal, m_Add(m_Specific(RemRes), m_Value(Remainder))) &&
   match(RemRes, m_SRem(m_Value(Op), m_Specific(Remainder))) &&
   IC.isKnownToBeAPowerOfTwo(Remainder, /*OrZero*/ true) &&
   FalseVal == RemRes)

diff  --git a/llvm/test/Transforms/InstCombine/select-divrem.ll 
b/llvm/test/Transforms/InstCombine/select-divrem.ll
index f007c53359ca5a..e0c460c37451db 100644
--- a/llvm/test/Transforms/InstCombine/select-divrem.ll
+++ b/llvm/test/Transforms/InstCombine/select-divrem.ll
@@ -343,3 +343,20 @@ define i32 @rem_euclid_pow2_false_arm_folded(i32 %n) {
   %res = select i1 %nonneg, i32 %rem, i32 1
   ret i32 %res
 }
+
+define i8 @pr89516(i8 %n, i8 %x) {
+; CHECK-LABEL: @pr89516(
+; CHECK-NEXT:[[COND:%.*]] = icmp slt i8 [[X:%.*]], 0
+; CHECK-NEXT:[[POW2:%.*]] = shl nuw i8 1, [[N:%.*]]
+; CHECK-NEXT:[[SREM:%.*]] = srem i8 1, [[POW2]]
+; CHECK-NEXT:[[ADD:%.*]] = select i1 [[COND]], i8 [[POW2]], i8 0
+; CHECK-NEXT:[[RES:%.*]] = add nuw i8 [[SREM]], [[ADD]]
+; CHECK-NEXT:ret i8 [[RES]]
+;
+  %cond = icmp slt i8 %x, 0
+  %pow2 = shl nuw i8 1, %n
+  %srem = srem i8 1, %pow2
+  %add = add nuw i8 %srem, %pow2
+  %res = select i1 %cond, i8 %add, i8 %srem
+  ret i8 %res
+}



___
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: [InstCombine] Fix unexpected overwriting in `foldSelectWithSRem` (#89539) (PR #89546)

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

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

>From e7c816b3cd3e1e28a9817291885b647d0c42ca9a Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Sun, 21 Apr 2024 22:41:32 +0800
Subject: [PATCH]  [InstCombine] Fix unexpected overwriting in
 `foldSelectWithSRem` (#89539)

Fixes #89516

(cherry picked from commit 6309440c218778db027306826993e484eab2be17)
---
 .../InstCombine/InstCombineSelect.cpp   |  2 +-
 .../Transforms/InstCombine/select-divrem.ll | 17 +
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 9f220ec003ec33..8cc7901cbac7fa 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2606,7 +2606,7 @@ static Instruction *foldSelectWithSRem(SelectInst , 
InstCombinerImpl ,
   // %cnd = icmp slt i32 %rem, 0
   // %add = add i32 %rem, %n
   // %sel = select i1 %cnd, i32 %add, i32 %rem
-  if (match(TrueVal, m_Add(m_Value(RemRes), m_Value(Remainder))) &&
+  if (match(TrueVal, m_Add(m_Specific(RemRes), m_Value(Remainder))) &&
   match(RemRes, m_SRem(m_Value(Op), m_Specific(Remainder))) &&
   IC.isKnownToBeAPowerOfTwo(Remainder, /*OrZero*/ true) &&
   FalseVal == RemRes)
diff --git a/llvm/test/Transforms/InstCombine/select-divrem.ll 
b/llvm/test/Transforms/InstCombine/select-divrem.ll
index f007c53359ca5a..e0c460c37451db 100644
--- a/llvm/test/Transforms/InstCombine/select-divrem.ll
+++ b/llvm/test/Transforms/InstCombine/select-divrem.ll
@@ -343,3 +343,20 @@ define i32 @rem_euclid_pow2_false_arm_folded(i32 %n) {
   %res = select i1 %nonneg, i32 %rem, i32 1
   ret i32 %res
 }
+
+define i8 @pr89516(i8 %n, i8 %x) {
+; CHECK-LABEL: @pr89516(
+; CHECK-NEXT:[[COND:%.*]] = icmp slt i8 [[X:%.*]], 0
+; CHECK-NEXT:[[POW2:%.*]] = shl nuw i8 1, [[N:%.*]]
+; CHECK-NEXT:[[SREM:%.*]] = srem i8 1, [[POW2]]
+; CHECK-NEXT:[[ADD:%.*]] = select i1 [[COND]], i8 [[POW2]], i8 0
+; CHECK-NEXT:[[RES:%.*]] = add nuw i8 [[SREM]], [[ADD]]
+; CHECK-NEXT:ret i8 [[RES]]
+;
+  %cond = icmp slt i8 %x, 0
+  %pow2 = shl nuw i8 1, %n
+  %srem = srem i8 1, %pow2
+  %add = add nuw i8 %srem, %pow2
+  %res = select i1 %cond, i8 %add, i8 %srem
+  ret i8 %res
+}

___
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] ReleaseNote: Mention SpecialCaseList change (PR #89141)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/89141
___
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] 3685a59 - ReleaseNote: Mention SpecialCaseList change (#89141)

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

Author: Fangrui Song
Date: 2024-04-23T14:43:48-07:00
New Revision: 3685a599c8668dfa17b31bca1bb69ab9c051a385

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

LOG: ReleaseNote: Mention SpecialCaseList change (#89141)

Co-authored-by: Paul T Robinson 

Added: 


Modified: 
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index ecfcd2c983ce5e..ff929b0bc5e15b 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -435,6 +435,13 @@ Changes to Sanitizers
 -
 * HWASan now defaults to detecting use-after-scope bugs.
 
+* `SpecialCaseList 
`_
+  used by sanitizer ignore lists (e.g. ``*_ignorelist.txt`` in the Clang
+  resource directory) now uses glob patterns instead of a variant of POSIX
+  Extended Regular Expression (where ``*`` is translated to ``.*``) by default.
+  Search for ``|`` to find patterns that may have 
diff erent meanings now, and
+  replace ``a|b`` with ``{a,b}``.
+
 Changes to the Profile Runtime
 --
 



___
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 Matt Arsenault via llvm-branch-commits

https://github.com/arsenm milestoned 
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


[clang] [polly] release/18.x: [clang-format] Correctly annotate braces in macros (#87… (PR #89491)

2024-04-23 Thread Björn Schäpers via llvm-branch-commits

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


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


[clang] release/18.x: [clang-format] Fix a regression in annotating BK_Braced… (PR #89489)

2024-04-23 Thread Björn Schäpers via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/89489
___
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] [polly] release/18.x: [clang-format] Correctly annotate braces in macros (#87… (PR #89491)

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

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


https://github.com/llvm/llvm-project/pull/89491
___
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 Mark de Wever via llvm-branch-commits

mordante wrote:

> @mordante The PR looks odd. Is this intentional or have you mixed two 
> branches?

This is due to using manually stacked reviews in GitHub. This is patch 3 in a 
series
* patch 1 has landed
* I just rebased patch 2 and wait for the CI
* patch 3 now believes patches 1 & 2 part of this branch. This will be fixed 
after I rebase this patch on the new patch 2

I really miss the nice stacked reviews of Phabriacator.

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++] Makes saturation functions privately available. (PR #89503)

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

Zingam wrote:

@mordante The PR looks odd. Is this intentional or have you mixed two branches?

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] [GSYM][DWARF] Include end_sequence debug_line rows when looking up addr ranges (PR #89703)

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

dwblaikie 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.

+1 - given the change to DWARFDebugLine, I'd expect this to be observable 
through llvm-dwarfdump, and if that's the case, it should be probably two 
patches - one to change DWARFDebugLine and with a lit test for llvm-dwarfdump, 
then a separate change to use this from gsym

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] [OpenMP][MLIR] Add new arguments to map_info to help support record type maps (PR #82851)

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

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


https://github.com/llvm/llvm-project/pull/82851
___
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] Add new arguments to map_info to help support record type maps (PR #82851)

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


@@ -990,6 +990,77 @@ static void printMapClause(OpAsmPrinter , Operation *op,
   }
 }
 
+static ParseResult parseMembersIndex(OpAsmParser ,
+ DenseIntElementsAttr ) {
+  SmallVector values;
+  int64_t value;
+  int64_t shape[2] = {0, 0};
+  unsigned shapeTmp = 0;
+  auto parseIndices = [&]() -> ParseResult {
+if (parser.parseInteger(value))
+  return failure();
+shapeTmp++;
+values.push_back(APInt(32, value));
+return success();
+  };
+
+  do {
+if (failed(parser.parseLSquare()))
+  return failure();
+
+if (parser.parseCommaSeparatedList(parseIndices))
+  return failure();
+
+if (failed(parser.parseRSquare()))
+  return failure();
+
+// Only set once, if any indices are not the same size
+// we error out in the next check as that's unsupported
+if (shape[1] == 0)
+  shape[1] = shapeTmp;
+
+// Verify that the recently parsed list is equal to the
+// first one we parsed, they must be equal lengths to
+// keep the rectangular shape DenseIntElementsAttr
+// requires
+if (shapeTmp != shape[1])
+  return failure();
+
+shapeTmp = 0;
+shape[0]++;
+  } while (succeeded(parser.parseOptionalComma()));
+
+  if (!values.empty()) {
+ShapedType valueType =
+VectorType::get(shape, IntegerType::get(parser.getContext(), 32));
+membersIdx = DenseIntElementsAttr::get(valueType, values);
+  }
+
+  return success();
+}
+
+static void printMembersIndex(OpAsmPrinter , MapInfoOp op,
+  DenseIntElementsAttr membersIdx) {
+  assert(membersIdx.getShapedType().getShape().size() <= 2);

jsjodin wrote:

Using names for the local references might help also to make the code clearer.
`i * membersIdx.getShapedType().getShape()[1]` can be hoisted out of the inner 
loop also.

https://github.com/llvm/llvm-project/pull/82851
___
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] Add new arguments to map_info to help support record type maps (PR #82851)

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

https://github.com/jsjodin edited 
https://github.com/llvm/llvm-project/pull/82851
___
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 Jan Leyonberg via llvm-branch-commits

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

Other than fixing some nits I think this looks good.


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 Jan Leyonberg via llvm-branch-commits

https://github.com/jsjodin 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 Jan Leyonberg via llvm-branch-commits

https://github.com/jsjodin 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 Jan Leyonberg via llvm-branch-commits


@@ -2283,16 +2386,12 @@ static void processMapMembersWithParent(
   for (auto mappedMembers : parentClause.getMembers()) {
 auto memberClause =
 mlir::dyn_cast(mappedMembers.getDefiningOp());

jsjodin wrote:

Another dyn_cast here that could be a 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] [libcxx] [libc++][format] Improves escaping performance. (PR #88533)

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


@@ -106,1110 +105,748 @@ namespace __escaped_output_table {
 /// table lacks a property, thus having more bits available for the size.
 ///
 /// The data has 2 values:
-/// - bits [0, 10] The size of the range, allowing 2048 elements.
-/// - bits [11, 31] The lower bound code point of the range. The upper bound of
-///   the range is lower bound + size.
-_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1077] = {
+/// - bits [0, 13] The size of the range, allowing 16384 elements.
+/// - bits [14, 31] The lower bound code point of the range. The upper bound of
+///   the range is lower bound + size. Note the code expects code units the fit
+///   into 18 bits, instead of the 21 bits needed for the full Unicode range.
+_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
 0x0020 /*  - 0020 [   33] */,
-0x0003f821 /* 007f - 00a0 [   34] */,
-0x00056800 /* 00ad - 00ad [1] */,
-0x001bc001 /* 0378 - 0379 [2] */,
-0x001c0003 /* 0380 - 0383 [4] */,
-0x001c5800 /* 038b - 038b [1] */,
-0x001c6800 /* 038d - 038d [1] */,
-0x001d1000 /* 03a2 - 03a2 [1] */,
-0x00298000 /* 0530 - 0530 [1] */,
-0x002ab801 /* 0557 - 0558 [2] */,
-0x002c5801 /* 058b - 058c [2] */,
-0x002c8000 /* 0590 - 0590 [1] */,
-0x002e4007 /* 05c8 - 05cf [8] */,
-0x002f5803 /* 05eb - 05ee [4] */,
-0x002fa810 /* 05f5 - 0605 [   17] */,
-0x0030e000 /* 061c - 061c [1] */,
-0x0036e800 /* 06dd - 06dd [1] */,
-0x00387001 /* 070e - 070f [2] */,
-0x003a5801 /* 074b - 074c [2] */,
-0x003d900d /* 07b2 - 07bf [   14] */,
-0x003fd801 /* 07fb - 07fc [2] */,
-0x00417001 /* 082e - 082f [2] */,
-0x0041f800 /* 083f - 083f [1] */,
-0x0042e001 /* 085c - 085d [2] */,
-0x0042f800 /* 085f - 085f [1] */,
-0x00435804 /* 086b - 086f [5] */,
-0x00447808 /* 088f - 0897 [9] */,
-0x00471000 /* 08e2 - 08e2 [1] */,
-0x004c2000 /* 0984 - 0984 [1] */,
-0x004c6801 /* 098d - 098e [2] */,
-0x004c8801 /* 0991 - 0992 [2] */,
-0x004d4800 /* 09a9 - 09a9 [1] */,
-0x004d8800 /* 09b1 - 09b1 [1] */,
-0x004d9802 /* 09b3 - 09b5 [3] */,
-0x004dd001 /* 09ba - 09bb [2] */,
-0x004e2801 /* 09c5 - 09c6 [2] */,
-0x004e4801 /* 09c9 - 09ca [2] */,
-0x004e7807 /* 09cf - 09d6 [8] */,
-0x004ec003 /* 09d8 - 09db [4] */,
-0x004ef000 /* 09de - 09de [1] */,
-0x004f2001 /* 09e4 - 09e5 [2] */,
-0x004ff801 /* 09ff - 0a00 [2] */,
-0x00502000 /* 0a04 - 0a04 [1] */,
-0x00505803 /* 0a0b - 0a0e [4] */,
-0x00508801 /* 0a11 - 0a12 [2] */,
-0x00514800 /* 0a29 - 0a29 [1] */,
-0x00518800 /* 0a31 - 0a31 [1] */,
-0x0051a000 /* 0a34 - 0a34 [1] */,
-0x0051b800 /* 0a37 - 0a37 [1] */,
-0x0051d001 /* 0a3a - 0a3b [2] */,
-0x0051e800 /* 0a3d - 0a3d [1] */,
-0x00521803 /* 0a43 - 0a46 [4] */,
-0x00524801 /* 0a49 - 0a4a [2] */,
-0x00527002 /* 0a4e - 0a50 [3] */,
-0x00529006 /* 0a52 - 0a58 [7] */,
-0x0052e800 /* 0a5d - 0a5d [1] */,
-0x0052f806 /* 0a5f - 0a65 [7] */,
-0x0053b809 /* 0a77 - 0a80 [   10] */,
-0x00542000 /* 0a84 - 0a84 [1] */,
-0x00547000 /* 0a8e - 0a8e [1] */,
-0x00549000 /* 0a92 - 0a92 [1] */,
-0x00554800 /* 0aa9 - 0aa9 [1] */,
-0x00558800 /* 0ab1 - 0ab1 [1] */,
-0x0055a000 /* 0ab4 - 0ab4 [1] */,
-0x0055d001 /* 0aba - 0abb [2] */,
-0x00563000 /* 0ac6 - 0ac6 [1] */,
-0x00565000 /* 0aca - 0aca [1] */,
-0x00567001 /* 0ace - 0acf [2] */,
-0x0056880e /* 0ad1 - 0adf [   15] */,
-0x00572001 /* 0ae4 - 0ae5 [2] */,
-0x00579006 /* 0af2 - 0af8 [7] */,
-0x0058 /* 0b00 - 0b00 [1] */,
-0x00582000 /* 0b04 - 0b04 [1] */,
-0x00586801 /* 0b0d - 0b0e [2] */,
-0x00588801 /* 0b11 - 0b12 [2] */,
-0x00594800 /* 0b29 - 0b29 [1] */,
-0x00598800 /* 0b31 - 0b31 [1] */,
-0x0059a000 /* 0b34 - 0b34 [1] */,
-0x0059d001 /* 0b3a - 0b3b [2] */,
-0x005a2801 /* 0b45 - 0b46 [2] */,
-0x005a4801 /* 0b49 - 0b4a [2] */,
-0x005a7006 /* 0b4e - 0b54 [7] 

[llvm-branch-commits] [libcxx] [libc++][format] Improves escaping performance. (PR #88533)

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


@@ -106,1110 +105,748 @@ namespace __escaped_output_table {
 /// table lacks a property, thus having more bits available for the size.
 ///
 /// The data has 2 values:
-/// - bits [0, 10] The size of the range, allowing 2048 elements.
-/// - bits [11, 31] The lower bound code point of the range. The upper bound of
-///   the range is lower bound + size.
-_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1077] = {
+/// - bits [0, 13] The size of the range, allowing 16384 elements.
+/// - bits [14, 31] The lower bound code point of the range. The upper bound of
+///   the range is lower bound + size. Note the code expects code units the fit
+///   into 18 bits, instead of the 21 bits needed for the full Unicode range.
+_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
 0x0020 /*  - 0020 [   33] */,
-0x0003f821 /* 007f - 00a0 [   34] */,
-0x00056800 /* 00ad - 00ad [1] */,
-0x001bc001 /* 0378 - 0379 [2] */,
-0x001c0003 /* 0380 - 0383 [4] */,
-0x001c5800 /* 038b - 038b [1] */,
-0x001c6800 /* 038d - 038d [1] */,
-0x001d1000 /* 03a2 - 03a2 [1] */,
-0x00298000 /* 0530 - 0530 [1] */,
-0x002ab801 /* 0557 - 0558 [2] */,
-0x002c5801 /* 058b - 058c [2] */,
-0x002c8000 /* 0590 - 0590 [1] */,
-0x002e4007 /* 05c8 - 05cf [8] */,
-0x002f5803 /* 05eb - 05ee [4] */,
-0x002fa810 /* 05f5 - 0605 [   17] */,
-0x0030e000 /* 061c - 061c [1] */,
-0x0036e800 /* 06dd - 06dd [1] */,
-0x00387001 /* 070e - 070f [2] */,
-0x003a5801 /* 074b - 074c [2] */,
-0x003d900d /* 07b2 - 07bf [   14] */,
-0x003fd801 /* 07fb - 07fc [2] */,
-0x00417001 /* 082e - 082f [2] */,
-0x0041f800 /* 083f - 083f [1] */,
-0x0042e001 /* 085c - 085d [2] */,
-0x0042f800 /* 085f - 085f [1] */,
-0x00435804 /* 086b - 086f [5] */,
-0x00447808 /* 088f - 0897 [9] */,
-0x00471000 /* 08e2 - 08e2 [1] */,
-0x004c2000 /* 0984 - 0984 [1] */,
-0x004c6801 /* 098d - 098e [2] */,
-0x004c8801 /* 0991 - 0992 [2] */,
-0x004d4800 /* 09a9 - 09a9 [1] */,
-0x004d8800 /* 09b1 - 09b1 [1] */,
-0x004d9802 /* 09b3 - 09b5 [3] */,
-0x004dd001 /* 09ba - 09bb [2] */,
-0x004e2801 /* 09c5 - 09c6 [2] */,
-0x004e4801 /* 09c9 - 09ca [2] */,
-0x004e7807 /* 09cf - 09d6 [8] */,
-0x004ec003 /* 09d8 - 09db [4] */,
-0x004ef000 /* 09de - 09de [1] */,
-0x004f2001 /* 09e4 - 09e5 [2] */,
-0x004ff801 /* 09ff - 0a00 [2] */,
-0x00502000 /* 0a04 - 0a04 [1] */,
-0x00505803 /* 0a0b - 0a0e [4] */,
-0x00508801 /* 0a11 - 0a12 [2] */,
-0x00514800 /* 0a29 - 0a29 [1] */,
-0x00518800 /* 0a31 - 0a31 [1] */,
-0x0051a000 /* 0a34 - 0a34 [1] */,
-0x0051b800 /* 0a37 - 0a37 [1] */,
-0x0051d001 /* 0a3a - 0a3b [2] */,
-0x0051e800 /* 0a3d - 0a3d [1] */,
-0x00521803 /* 0a43 - 0a46 [4] */,
-0x00524801 /* 0a49 - 0a4a [2] */,
-0x00527002 /* 0a4e - 0a50 [3] */,
-0x00529006 /* 0a52 - 0a58 [7] */,
-0x0052e800 /* 0a5d - 0a5d [1] */,
-0x0052f806 /* 0a5f - 0a65 [7] */,
-0x0053b809 /* 0a77 - 0a80 [   10] */,
-0x00542000 /* 0a84 - 0a84 [1] */,
-0x00547000 /* 0a8e - 0a8e [1] */,
-0x00549000 /* 0a92 - 0a92 [1] */,
-0x00554800 /* 0aa9 - 0aa9 [1] */,
-0x00558800 /* 0ab1 - 0ab1 [1] */,
-0x0055a000 /* 0ab4 - 0ab4 [1] */,
-0x0055d001 /* 0aba - 0abb [2] */,
-0x00563000 /* 0ac6 - 0ac6 [1] */,
-0x00565000 /* 0aca - 0aca [1] */,
-0x00567001 /* 0ace - 0acf [2] */,
-0x0056880e /* 0ad1 - 0adf [   15] */,
-0x00572001 /* 0ae4 - 0ae5 [2] */,
-0x00579006 /* 0af2 - 0af8 [7] */,
-0x0058 /* 0b00 - 0b00 [1] */,
-0x00582000 /* 0b04 - 0b04 [1] */,
-0x00586801 /* 0b0d - 0b0e [2] */,
-0x00588801 /* 0b11 - 0b12 [2] */,
-0x00594800 /* 0b29 - 0b29 [1] */,
-0x00598800 /* 0b31 - 0b31 [1] */,
-0x0059a000 /* 0b34 - 0b34 [1] */,
-0x0059d001 /* 0b3a - 0b3b [2] */,
-0x005a2801 /* 0b45 - 0b46 [2] */,
-0x005a4801 /* 0b49 - 0b4a [2] */,
-0x005a7006 /* 0b4e - 0b54 [7] 

[llvm-branch-commits] [libcxx] [libc++][format] Improves escaping performance. (PR #88533)

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

https://github.com/ldionne edited 
https://github.com/llvm/llvm-project/pull/88533
___
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 performance. (PR #88533)

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


@@ -305,23 +316,28 @@ def generate_data_tables() -> str:
 
 data = compactPropertyRanges(sorted(properties, key=lambda x: x.lower))
 
-# The last entry is large. In Unicode 14 it contains the entries
-# 3134B..0 912564 elements
-# This are 446 entries of 1325 entries in the table.
-# Based on the nature of these entries it is expected they remain for the
-# forseeable future. Therefore we only store the lower bound of this 
section.
-#
-# When this region becomes substantially smaller we need to investigate
-# this design.
-#
-# Due to P2713R1 Escaping improvements in std::format the range
+# The output table has two large entries at the end, with a small "gap"
 #   E0100..E01EF  ; Grapheme_Extend # Mn [240] VARIATION 
SELECTOR-17..VARIATION SELECTOR-256
-# is no longer part of these entries. This causes an increase in the size
-# of the table.
-assert data[-1].upper == 0x10
-# assert data[-1].upper - data[-1].lower > 90
-
-return "\n".join([generate_cpp_data(data[:-1], data[-1].lower)])
+# Based on Unicode 15.1.0:
+# - Encoding all these entries in the table requires 1173 entries.
+# - Manually handling these last two blocks reduces the size to 729 
entries.
+# This not only reduces the binary size, but also improves the performance
+# by having less elements to search.
+# The exact entrires may differ between Unicode versions. When these 
numbers
+# change the test needs to be updated too.
+#   
test/libcxx/utilities/format/format.string/format.string.std/escaped_output.pass.cpp

ldionne wrote:

```suggestion
#   
libcxx/test/libcxx/utilities/format/format.string/format.string.std/escaped_output.pass.cpp
```

https://github.com/llvm/llvm-project/pull/88533
___
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 performance. (PR #88533)

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


@@ -305,23 +316,28 @@ def generate_data_tables() -> str:
 
 data = compactPropertyRanges(sorted(properties, key=lambda x: x.lower))
 
-# The last entry is large. In Unicode 14 it contains the entries
-# 3134B..0 912564 elements
-# This are 446 entries of 1325 entries in the table.
-# Based on the nature of these entries it is expected they remain for the
-# forseeable future. Therefore we only store the lower bound of this 
section.
-#
-# When this region becomes substantially smaller we need to investigate
-# this design.
-#
-# Due to P2713R1 Escaping improvements in std::format the range
+# The output table has two large entries at the end, with a small "gap"
 #   E0100..E01EF  ; Grapheme_Extend # Mn [240] VARIATION 
SELECTOR-17..VARIATION SELECTOR-256
-# is no longer part of these entries. This causes an increase in the size
-# of the table.
-assert data[-1].upper == 0x10
-# assert data[-1].upper - data[-1].lower > 90
-
-return "\n".join([generate_cpp_data(data[:-1], data[-1].lower)])
+# Based on Unicode 15.1.0:
+# - Encoding all these entries in the table requires 1173 entries.
+# - Manually handling these last two blocks reduces the size to 729 
entries.
+# This not only reduces the binary size, but also improves the performance
+# by having less elements to search.
+# The exact entrires may differ between Unicode versions. When these 
numbers

ldionne wrote:

```suggestion
# The exact entries may differ between Unicode versions. When these numbers
```

https://github.com/llvm/llvm-project/pull/88533
___
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 performance. (PR #88533)

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


@@ -0,0 +1,100 @@
+//===--===//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
+
+// 
+
+// Tests the properties of the Unicode escaped output table.
+// The libc++ algorithm has size and speed optimizations based on the 
properties
+// of Unicode. This means updating the Unicode tables has a likilihood of
+// breaking test. This is an assert; it requires validating whether the
+// assumptions of the size and speed optimizations are still valid.
+
+#include 
+#include 
+#include 
+#include 
+
+// Contains the entries for [format.string.escaped]/2.2.1.2.1
+//   CE is a Unicode encoding and C corresponds to a UCS scalar value whose
+//   Unicode property General_Category has a value in the groups Separator (Z)
+//   or Other (C), as described by table 12 of UAX #44
+//
+// Separator (Z) consists of General_Category
+// - Zs Space_Separator,
+// - Zl Line_Separator,
+// - Zp Paragraph_Separator.
+//
+// Other (C) consists of General_Category
+// - Cc Control,
+// - Cf Format,
+// - Cs Surrogate,
+// - Co Private_Use,
+// - Cn Unassigned.
+inline constexpr int Zs = 17;
+inline constexpr int Zl = 1;
+inline constexpr int Zp = 1;
+inline constexpr int Z  = Zs + Zl + Zp;
+
+inline constexpr int Cc = 65;
+inline constexpr int Cf = 170;
+inline constexpr int Cs = 2'048;
+inline constexpr int Co = 137'468;
+inline constexpr int Cn = 824'718;
+inline constexpr int C  = Cc + Cf + Cs + Co + Cn;
+
+// This is the final part of the Unicode properties table:
+//
+// 31350..323AF  ; Lo # [4192] CJK UNIFIED IDEOGRAPH-31350..CJK UNIFIED 
IDEOGRAPH-323AF
+// 323B0..E  ; Cn # [711761] ..
+// E0001 ; Cf #   LANGUAGE TAG
+// E0002..E001F  ; Cn #  [30] ..
+// E0020..E007F  ; Cf #  [96] TAG SPACE..CANCEL TAG
+// E0080..E00FF  ; Cn # [128] ..
+// E0100..E01EF  ; Mn # [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256
+// E01F0..E  ; Cn # [65040] ..
+// F..D  ; Co # [65534] ..
+// E..F  ; Cn #   [2] ..
+// 10..10FFFD; Co # [65534] ..
+// 10FFFE..10; Cn #   [2] ..
+//
+// It can be observed all entries in the range 323B0..10 are in the
+// categories Cf, Co, Cn, except a small range with the property Mn.
+// In order to reduce the size of the table only the entires in the range
+// [, 323B0) are stored in the table. The entries in the range
+// [323B0, 10] use a hand-crafted algorithm.
+//
+// This means a number of entries are omitted
+inline constexpr int excluded = ((0x10 - 0x323B0) + 1) - 240;
+
+inline constexpr int entries = Z + C - excluded;
+
+static constexpr int count_entries() {
+  return std::transform_reduce(
+  std::begin(std::__escaped_output_table::__entries),
+  std::end(std::__escaped_output_table::__entries),
+  0,
+  std::plus{},
+  [](auto entry) { return 1 + static_cast(entry & 0x3fffu); });
+}
+static_assert(count_entries() == entries);
+
+int main() {

ldionne wrote:

```suggestion
int main(int, char**) {
```

and `return 0;`

https://github.com/llvm/llvm-project/pull/88533
___
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 performance. (PR #88533)

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

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

LGTM with a few comments!

https://github.com/llvm/llvm-project/pull/88533
___
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 performance. (PR #88533)

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


@@ -305,23 +316,28 @@ def generate_data_tables() -> str:
 
 data = compactPropertyRanges(sorted(properties, key=lambda x: x.lower))
 
-# The last entry is large. In Unicode 14 it contains the entries
-# 3134B..0 912564 elements
-# This are 446 entries of 1325 entries in the table.
-# Based on the nature of these entries it is expected they remain for the
-# forseeable future. Therefore we only store the lower bound of this 
section.
-#
-# When this region becomes substantially smaller we need to investigate
-# this design.
-#
-# Due to P2713R1 Escaping improvements in std::format the range
+# The output table has two large entries at the end, with a small "gap"
 #   E0100..E01EF  ; Grapheme_Extend # Mn [240] VARIATION 
SELECTOR-17..VARIATION SELECTOR-256
-# is no longer part of these entries. This causes an increase in the size
-# of the table.
-assert data[-1].upper == 0x10
-# assert data[-1].upper - data[-1].lower > 90
-
-return "\n".join([generate_cpp_data(data[:-1], data[-1].lower)])
+# Based on Unicode 15.1.0:
+# - Encoding all these entries in the table requires 1173 entries.
+# - Manually handling these last two blocks reduces the size to 729 
entries.
+# This not only reduces the binary size, but also improves the performance
+# by having less elements to search.

ldionne wrote:

```suggestion
# by having fewer elements to search.
```

https://github.com/llvm/llvm-project/pull/88533
___
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 performance. (PR #88533)

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

https://github.com/ldionne edited 
https://github.com/llvm/llvm-project/pull/88533
___
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


@@ -328,8 +313,13 @@ def generate_data_tables() -> str:
 #
 # When this region becomes substantially smaller we need to investigate
 # this design.
+#
+# Due to P2713R1 Escaping improvements in std::format the range
+#   E0100..E01EF  ; Grapheme_Extend # Mn [240] VARIATION 
SELECTOR-17..VARIATION SELECTOR-256
+# is no longer part of these entries. This causes an increase in the size
+# of the table.
 assert data[-1].upper == 0x10
-assert data[-1].upper - data[-1].lower > 90
+# assert data[-1].upper - data[-1].lower > 90

ldionne wrote:

Is this intended to be commented out? Why?

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


[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


[llvm-branch-commits] [libcxx] [libc++][format] Improves escaping. (PR #88283)

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/88283
___
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


[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


[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


[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 

[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 

[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++][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 

[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 

[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] [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] [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 ,
   RValue rvalue = CGF.EmitCall(MSI.CallInfo, Callee, Return, ActualArgs,
);
 
+  // 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] [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] [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

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] [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++] 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] 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++][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] [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 ,
 }
   }
 
+  // Set the insert point after the existing PHIs
+  MachineBasicBlock  = *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] [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: [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 

[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] 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 ,
 }
 
 bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue ) {
-  // 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 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 ,
 }
 
 bool X86DAGToDAGISel::selectMOV64Imm32(SDValue N, SDValue ) {
-  // 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] [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] [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

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] [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] [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 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] [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] [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] [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  = 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, ,
   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] [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] [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] [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 ,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData ,
+   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] [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 ,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData ,
+   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 , size_t mapDataIdx,
+ llvm::OpenMPIRBuilder::MapInfosTy ,
+ 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 , size_t mapDataIdx,
+ llvm::OpenMPIRBuilder::MapInfosTy ,
+ 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 , llvm::IRBuilderBase ,
 llvm::OpenMPIRBuilder , DataLayout ,
 llvm::OpenMPIRBuilder::MapInfosTy , MapInfoData ,
 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


@@ -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 ,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData ,
+   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]);

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 ,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData ,
+   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 , size_t mapDataIdx,
+ llvm::OpenMPIRBuilder::MapInfosTy ,
+ 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 , llvm::IRBuilderBase ,
 llvm::OpenMPIRBuilder , DataLayout ,
 llvm::OpenMPIRBuilder::MapInfosTy , MapInfoData ,
 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 
,
 // 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

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

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 ,
   }
 }
 
+static int getMapDataMemberIdx(MapInfoData ,
+   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] [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] [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] [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: [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] [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 ) {
 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 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
--- 

[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] [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


  1   2   >