[llvm-branch-commits] [clang] 0fa09be - Revert "[Clang][Sema] Fix crash when 'this' is used in a dependent class scop…"

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

Author: Krystian Stasiowski
Date: 2024-04-10T08:36:37-04:00
New Revision: 0fa09befb37c36ec1ed796c28f6b33605fc04ecd

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

LOG: Revert "[Clang][Sema] Fix crash when 'this' is used in a dependent class 
scop…"

This reverts commit 4657ab1c968e486e9f45329daa07340ebcf3bffd.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaExprMember.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaTemplate/ms-function-specialization-class-scope.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6bff80ed4d210b..f5359afe1f0999 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -520,8 +520,6 @@ Bug Fixes to C++ Support
 - Fix an issue caused by not handling invalid cases when substituting into the 
parameter mapping of a constraint. Fixes (#GH86757).
 - Fixed a bug that prevented member function templates of class templates 
declared with a deduced return type
   from being explicitly specialized for a given implicit instantiation of the 
class template.
-- Fixed a crash when ``this`` is used in a dependent class scope function 
template specialization
-  that instantiates to a static member function.
 
 - Fix crash when inheriting from a cv-qualified type. Fixes:
   (`#35603 `_)

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index f311f9f3743454..9769d36900664c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -5439,8 +5439,7 @@ class Sema final : public SemaBase {
 
   ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R,
   bool NeedsADL,
-  bool AcceptInvalidDecl = false,
-  bool NeedUnresolved = false);
+  bool AcceptInvalidDecl = false);
   ExprResult BuildDeclarationNameExpr(
   const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl 
*D,
   NamedDecl *FoundD = nullptr,
@@ -6592,10 +6591,7 @@ class Sema final : public SemaBase {
 SourceLocation RParenLoc);
 
    ActOnCXXThis -  Parse 'this' pointer.
-  ExprResult ActOnCXXThis(SourceLocation Loc);
-
-  /// Check whether the type of 'this' is valid in the current context.
-  bool CheckCXXThisType(SourceLocation Loc, QualType Type);
+  ExprResult ActOnCXXThis(SourceLocation loc);
 
   /// Build a CXXThisExpr and mark it referenced in the current context.
   Expr *BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 45acbf197ea6b4..594c11788f4e7e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3442,11 +3442,10 @@ static bool 
ShouldLookupResultBeMultiVersionOverload(const LookupResult &R) {
 
 ExprResult Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
   LookupResult &R, bool NeedsADL,
-  bool AcceptInvalidDecl,
-  bool NeedUnresolved) {
+  bool AcceptInvalidDecl) {
   // If this is a single, fully-resolved result and we don't need ADL,
   // just build an ordinary singleton decl ref.
-  if (!NeedUnresolved && !NeedsADL && R.isSingleResult() &&
+  if (!NeedsADL && R.isSingleResult() &&
   !R.getAsSingle() &&
   !ShouldLookupResultBeMultiVersionOverload(R))
 return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), 
R.getFoundDecl(),

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 9822477260e592..7b9b8f149d9edd 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1415,42 +1415,26 @@ bool Sema::CheckCXXThisCapture(SourceLocation Loc, 
const bool Explicit,
 }
 
 ExprResult Sema::ActOnCXXThis(SourceLocation Loc) {
-  // C++20 [expr.prim.this]p1:
-  //   The keyword this names a pointer to the object for which an
-  //   implicit object member function is invoked or a non-static
-  //   data member's initializer is evaluated.
+  /// C++ 9.3.2: In the body of a non-static member function, the keyword this
+  /// is a non-lvalue expression whose value is the address of the object for
+  /// which the function is called.
   QualType ThisTy = getCurrentThisType();
 
-  if (CheckCXXThisType(Loc, ThisTy))
-return ExprError();
+  if (ThisTy.isNull()) {
+

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

2024-04-10 Thread Mark de Wever via llvm-branch-commits

https://github.com/mordante created 
https://github.com/llvm/llvm-project/pull/88283

The change increments the size of the lookup table considerably. The table has 
an "upper boundary" check. The removal of the code units with the property 
Grapheme_Extend=Yes removes the range E0100..E01EF. This breaks the trailing 
large continues section in two parts. This will be improved in a followup patch.

Implements:
- P2713R1 Escaping improvements in std::format
- LWG3965 Incorrect example in [format.string.escaped] p3 for formatting of 
combining characters

Before
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped95696 ns95459 ns 7341
BM_unicode_escaped  89311 ns89088 ns 7835
BM_cyrillic_escaped 58633 ns58494 ns11964
BM_japanese_escaped 44500 ns44382 ns15780
BM_emoji_escaped99156 ns98911 ns 7075
BM_ascii_escaped 92245 ns92017 ns 7592
BM_unicode_escaped   80970 ns80747 ns 8651
BM_cyrillic_escaped  51253 ns51112 ns13729
BM_japanese_escaped  37252 ns37156 ns18758
BM_emoji_escaped 96226 ns95961 ns 7270

After
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped   110704 ns   110696 ns 6206
BM_unicode_escaped 101371 ns   101374 ns 6862
BM_cyrillic_escaped 63329 ns63327 ns11013
BM_japanese_escaped 41223 ns41225 ns16938
BM_emoji_escaped   111022 ns   111021 ns 6304
BM_ascii_escaped112441 ns   112443 ns 6231
BM_unicode_escaped  102776 ns   102779 ns 6813
BM_cyrillic_escaped  58977 ns58975 ns11868
BM_japanese_escaped  36885 ns36886 ns18975
BM_emoji_escaped115885 ns   115881 ns 6051

>From 1f06034f8d6fc581b0b3d4c3d1f0ed8ef491979a Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sat, 3 Feb 2024 17:08:59 +0100
Subject: [PATCH] [libc++][format] Improves escaping.

The change increments the size of the lookup table considerably. The table
has an "upper boundary" check. The removal of the code units with the
property Grapheme_Extend=Yes removes the range E0100..E01EF. This breaks
the trailing large continues section in two parts. This will be improved
in a followup patch.

Implements:
- P2713R1 Escaping improvements in std::format
- LWG3965 Incorrect example in [format.string.escaped] p3 for formatting of 
combining characters

Before
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped95696 ns95459 ns 7341
BM_unicode_escaped  89311 ns89088 ns 7835
BM_cyrillic_escaped 58633 ns58494 ns11964
BM_japanese_escaped 44500 ns44382 ns15780
BM_emoji_escaped99156 ns98911 ns 7075
BM_ascii_escaped 92245 ns92017 ns 7592
BM_unicode_escaped   80970 ns80747 ns 8651
BM_cyrillic_escaped  51253 ns51112 ns13729
BM_japanese_escaped  37252 ns37156 ns18758
BM_emoji_escaped 96226 ns95961 ns 7270

After
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped   110704 ns   110696 ns 6206
BM_unicode_escaped 101371 ns   101374 ns 6862
BM_cyrillic_escaped 63329 ns63327 ns11013
BM_japanese_escaped 41223 ns41225 ns16938
BM_emoji_escaped   111022 ns   111021 ns 6304
BM_ascii_escaped112441 ns   112443 ns 6231
BM_unicode_escaped  102776 ns   102779 ns 6813
BM_cyrillic_escaped  58977 ns58975 ns11868
BM_japanese_escaped  36885 ns36886 ns18975
BM_emoji_escaped115885 ns   115881 ns 6051
---
 libcxx/docs/ReleaseNotes/19.rst   |2 +
 libcxx/docs/Status/Cxx23Papers.csv|2 +-
 libcxx/docs/Status/Cxx2cIssues.csv|2 +-
 libcxx/docs/Status/FormatIssues.csv   |2 +-
 .../include/__format/escaped_output_table.h   | 1982 +
 libcxx

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

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

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

The change increments the size of the lookup table considerably. The table has 
an "upper boundary" check. The removal of the code units with the property 
Grapheme_Extend=Yes removes the range E0100..E01EF. This breaks the trailing 
large continues section in two parts. This will be improved in a followup patch.

Implements:
- P2713R1 Escaping improvements in std::format
- LWG3965 Incorrect example in [format.string.escaped] p3 for formatting of 
combining characters

Before
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped95696 ns95459 ns 7341
BM_unicode_escaped  89311 ns89088 ns 7835
BM_cyrillic_escaped 58633 ns58494 ns11964
BM_japanese_escaped 44500 ns44382 ns15780
BM_emoji_escaped99156 ns98911 ns 7075
BM_ascii_escaped 92245 ns92017 ns 7592
BM_unicode_escaped   80970 ns80747 ns 8651
BM_cyrillic_escaped  51253 ns51112 ns13729
BM_japanese_escaped  37252 ns37156 ns18758
BM_emoji_escaped 96226 ns95961 ns 7270

After
---
Benchmark Time CPU   Iterations
---
BM_ascii_escaped   110704 ns   110696 ns 6206
BM_unicode_escaped 101371 ns   101374 ns 6862
BM_cyrillic_escaped 63329 ns63327 ns11013
BM_japanese_escaped 41223 ns41225 ns16938
BM_emoji_escaped   111022 ns   111021 ns 6304
BM_ascii_escaped112441 ns   112443 ns 6231
BM_unicode_escaped  102776 ns   102779 ns 6813
BM_cyrillic_escaped  58977 ns58975 ns11868
BM_japanese_escaped  36885 ns36886 ns18975
BM_emoji_escaped115885 ns   115881 ns 6051

---

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


8 Files Affected:

- (modified) libcxx/docs/ReleaseNotes/19.rst (+2) 
- (modified) libcxx/docs/Status/Cxx23Papers.csv (+1-1) 
- (modified) libcxx/docs/Status/Cxx2cIssues.csv (+1-1) 
- (modified) libcxx/docs/Status/FormatIssues.csv (+1-1) 
- (modified) libcxx/include/__format/escaped_output_table.h (+1082-900) 
- (modified) libcxx/include/__format/write_escaped.h (+22-6) 
- (modified) 
libcxx/test/std/utilities/format/format.functions/escaped_output.unicode.pass.cpp
 (+22-20) 
- (modified) libcxx/utils/generate_escaped_output_table.py (+20-30) 


``diff
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index 81c05b9112bd26..4d654b94ae1773 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -47,6 +47,8 @@ Implemented Papers
 - P3142R0 - Printing Blank Lines with ``println`` (as DR against C++23)
 - P2302R4 - ``std::ranges::contains``
 - P1659R3 - ``std::ranges::starts_with`` and ``std::ranges::ends_with``
+- P2713R1 - Escaping improvements in ``std::format``
+
 
 Improvements and New Features
 -
diff --git a/libcxx/docs/Status/Cxx23Papers.csv 
b/libcxx/docs/Status/Cxx23Papers.csv
index 065db97a0b0b15..7edcb45800bbb0 100644
--- a/libcxx/docs/Status/Cxx23Papers.csv
+++ b/libcxx/docs/Status/Cxx23Papers.csv
@@ -108,7 +108,7 @@
 "`P2164R9 `__","LWG", 
"``views::enumerate``","February 2023","","","|ranges|"
 "`P2711R1 `__","LWG", "Making multi-param 
constructors of ``views`` ``explicit``","February 2023","|In Progress| 
[#note-P2711R1]_","","|ranges|"
 "`P2609R3 `__","LWG", "Relaxing Ranges Just A 
Smidge","February 2023","","","|ranges|"
-"`P2713R1 `__","LWG", "Escaping improvements in 
``std::format``","February 2023","","","|format|"
+"`P2713R1 `__","LWG", "Escaping improvements in 
``std::format``","February 2023","|Complete|","19.0","|format|"
 "`P2675R1 `__","LWG", "``format``'s width 
estimation is too approximate and not forward compatible","February 
2023","|Complete|","17.0","|format|"
 "`P2572R1 `__","LWG", "``std::format`` fill 
character allowances","February 2023","|Complete|","17.0","|format|"
 "`P2693R1 `__","LWG", "Formatting ``thread::id`` 
and ``stacktrace`

[llvm-branch-commits] [libcxx] [libc++][TZDB] Improves time zone format specifiers. (PR #85797)

2024-04-10 Thread Mark de Wever via llvm-branch-commits

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

>From cb87ecc505cf538eaa657a7cc3b1b282e3e7298d Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Improves time zone format specifiers.

Per [tab:time.format.spec]
%z  The offset from UTC as specified in ISO 8601-1:2019, subclause
5.3.4.1. For example -0430 refers to 4 hours 30 minutes behind UTC.
If the offset is zero, + is used. The modified commands %Ez and
%Oz insert a : between the hours and minutes: -04:30. If the offset
information is not available, an exception of type format_error is
thrown.

Typically the modified versions Oz or Ez would have wording like

  The modified command %OS produces the locale's alternative
  representation.

In this case the modified version does not depend on the locale.

This change is a preparation for formatting sys_info which has time zone
information. The function time_put<_CharT>::put() does not have proper
time zone support, therefore it's a manual implementation.

Fixes https://github.com/llvm/llvm-project/issues/78184
---
 libcxx/include/__chrono/formatter.h   | 50 ++-
 .../time.syn/formatter.file_time.pass.cpp | 39 ++-
 .../time/time.syn/formatter.sys_time.pass.cpp | 39 ++-
 3 files changed, 56 insertions(+), 72 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index b64cae529a294d..8b8592041a1fb9 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -10,6 +10,7 @@
 #ifndef _LIBCPP___CHRONO_FORMATTER_H
 #define _LIBCPP___CHRONO_FORMATTER_H
 
+#include <__algorithm/ranges_copy.h>
 #include <__chrono/calendar.h>
 #include <__chrono/concepts.h>
 #include <__chrono/convert_to_tm.h>
@@ -170,10 +171,45 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_century(basic_stringstream<_CharT>& __sstr,
   __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century);
 }
 
+// Implements the %z format specifier according to [tab:time.format.spec], 
where
+// '__modifier' signals %Oz or %Ez were used. (Both modifiers behave the same,
+// so there is no need to distinguish between them.)
+template 
+_LIBCPP_HIDE_FROM_ABI void
+__format_zone_offset(basic_stringstream<_CharT>& __sstr, chrono::seconds 
__offset, bool __modifier) {
+  if (__offset < 0s) {
+__sstr << _CharT('-');
+__offset = -__offset;
+  } else
+__sstr << _CharT('+');
+
+  chrono::hh_mm_ss __hms{__offset};
+  std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  if (__modifier)
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
+  else
+std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+}
+
+// Helper to store the time zone information needed for formatting.
+struct _LIBCPP_HIDE_FROM_ABI __time_zone {
+  // Typically these abbreviations as short and fit in the string's internal
+  // buffer.
+  string __abbrev{"UTC"};
+  chrono::seconds __offset{0};
+};
+
+template 
+_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
+  __time_zone __result;
+  return __result;
+}
+
 template 
 _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
 basic_stringstream<_CharT>& __sstr, const _Tp& __value, 
basic_string_view<_CharT> __chrono_specs) {
   tm __t  = std::__convert_to_tm(__value);
+  __time_zone __z = __formatter::__convert_to_time_zone(__value);
   const auto& __facet = std::use_facet>(__sstr.getloc());
   for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); 
++__it) {
 if (*__it == _CharT('%')) {
@@ -296,9 +332,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
   {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
   } break;
 
+  case _CharT('z'):
+__formatter::__format_zone_offset(__sstr, __z.__offset, false);
+break;
+
   case _CharT('Z'):
-// TODO FMT Add proper timezone support.
-__sstr << _LIBCPP_STATICALLY_WIDEN(_CharT, "UTC");
+// __abbrev is always a char so the copy may convert.
+ranges::copy(__z.__abbrev, std::ostreambuf_iterator<_CharT>{__sstr});
 break;
 
   case _CharT('O'):
@@ -314,9 +354,15 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 break;
   }
 }
+
+// Oz produces the same output as Ez below.
 [[fallthrough]];
   case _CharT('E'):
 ++__it;
+if (*__it == 'z') {
+  __formatter::__format_zone_offset(__sstr, __z.__offset, true);
+  break;
+}
 [[fallthrough]];
   default:
 __facet.put(
diff --git a/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp 
b/libcxx/test/std/time/time.syn/formatter.file_time.pass.cpp
index b07282593d

[llvm-branch-commits] [mlir] ee3842f - Revert "Fix complex log1p accuracy with large abs values. (#88260)"

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

Author: Mehdi Amini
Date: 2024-04-10T18:24:25+02:00
New Revision: ee3842f82072f80020ec4449a26b6bc6bb44573b

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

LOG: Revert "Fix complex log1p accuracy with large abs values. (#88260)"

This reverts commit 49ef12a08c4c7d7ae4765929e72fe2320a12b08c.

Added: 


Modified: 
mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp
mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp 
b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp
index 0aa1de5fa5d9a1..9c3c4d96a301ef 100644
--- a/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp
+++ b/mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp
@@ -570,39 +570,37 @@ struct Log1pOpConversion : public 
OpConversionPattern {
   ConversionPatternRewriter &rewriter) const override {
 auto type = cast(adaptor.getComplex().getType());
 auto elementType = cast(type.getElementType());
-arith::FastMathFlags fmf = op.getFastMathFlagsAttr().getValue();
+arith::FastMathFlagsAttr fmf = op.getFastMathFlagsAttr();
 mlir::ImplicitLocOpBuilder b(op.getLoc(), rewriter);
 
-Value real = b.create(adaptor.getComplex());
-Value imag = b.create(adaptor.getComplex());
+Value real = b.create(elementType, adaptor.getComplex());
+Value imag = b.create(elementType, adaptor.getComplex());
 
 Value half = b.create(elementType,
  b.getFloatAttr(elementType, 0.5));
 Value one = b.create(elementType,
 b.getFloatAttr(elementType, 1));
-Value realPlusOne = b.create(real, one, fmf);
-Value absRealPlusOne = b.create(realPlusOne, fmf);
-Value absImag = b.create(imag, fmf);
-
-Value maxAbs = b.create(absRealPlusOne, absImag, fmf);
-Value minAbs = b.create(absRealPlusOne, absImag, fmf);
-
-Value maxAbsOfRealPlusOneAndImagMinusOne = b.create(
-b.create(arith::CmpFPredicate::OGT, realPlusOne, 
absImag,
-fmf),
-real, b.create(maxAbs, one, fmf));
-Value minMaxRatio = b.create(minAbs, maxAbs, fmf);
-Value logOfMaxAbsOfRealPlusOneAndImag =
-b.create(maxAbsOfRealPlusOneAndImagMinusOne, fmf);
-Value logOfSqrtPart = b.create(
-b.create(minMaxRatio, minMaxRatio, fmf), fmf);
-Value r = b.create(
-b.create(half, logOfSqrtPart, fmf),
-logOfMaxAbsOfRealPlusOneAndImag, fmf);
-Value resultReal = b.create(
-b.create(arith::CmpFPredicate::UNO, r, r, fmf), minAbs,
-r);
-Value resultImag = b.create(imag, realPlusOne, fmf);
+Value two = b.create(elementType,
+b.getFloatAttr(elementType, 2));
+
+// log1p(a+bi) = .5*log((a+1)^2+b^2) + i*atan2(b, a + 1)
+// log((a+1)+bi) = .5*log(a*a + 2*a + 1 + b*b) + i*atan2(b, a+1)
+// log((a+1)+bi) = .5*log1p(a*a + 2*a + b*b) + i*atan2(b, a+1)
+Value sumSq = b.create(real, real, fmf.getValue());
+sumSq = b.create(
+sumSq, b.create(real, two, fmf.getValue()),
+fmf.getValue());
+sumSq = b.create(
+sumSq, b.create(imag, imag, fmf.getValue()),
+fmf.getValue());
+Value logSumSq =
+b.create(elementType, sumSq, fmf.getValue());
+Value resultReal = b.create(logSumSq, half, fmf.getValue());
+
+Value realPlusOne = b.create(real, one, fmf.getValue());
+
+Value resultImag =
+b.create(elementType, imag, realPlusOne, 
fmf.getValue());
 rewriter.replaceOpWithNewOp(op, type, resultReal,
resultImag);
 return success();

diff  --git a/mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir 
b/mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir
index 43918904a09f40..f5d9499eadda48 100644
--- a/mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir
+++ b/mlir/test/Conversion/ComplexToStandard/convert-to-standard.mlir
@@ -300,22 +300,15 @@ func.func @complex_log1p(%arg: complex) -> 
complex {
 // CHECK: %[[IMAG:.*]] = complex.im %[[ARG]] : complex
 // CHECK: %[[ONE_HALF:.*]] = arith.constant 5.00e-01 : f32
 // CHECK: %[[ONE:.*]] = arith.constant 1.00e+00 : f32
+// CHECK: %[[TWO:.*]] = arith.constant 2.00e+00 : f32
+// CHECK: %[[SQ_SUM_0:.*]] = arith.mulf %[[REAL]], %[[REAL]] : f32
+// CHECK: %[[TWO_REAL:.*]] = arith.mulf %[[REAL]], %[[TWO]] : f32
+// CHECK: %[[SQ_SUM_1:.*]] = arith.addf %[[SQ_SUM_0]], %[[TWO_REAL]] : f32
+// CHECK: %[[SQ_IMAG:.*]] = arith.mulf %[[IMAG]], %[[IMAG]] : f32
+// CHECK: %[[SQ_SUM_2:.*]] = arith.addf %[[SQ_SUM_1]], %[[SQ_IMAG]] : f32
+// CHECK: %[[LOG_SQ_SUM:.*]] 

[llvm-branch-commits] [libcxx] [libc++][chrono] Improves date formatting. (PR #86127)

2024-04-10 Thread Mark de Wever via llvm-branch-commits

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

>From 677956d0923c499f8f6d1f13035f5f60d48ea7c8 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 21 Mar 2024 15:22:13 +0100
Subject: [PATCH] [libc++][chrono] Improves date formatting.

The formatting of years has been done manually since the results of %Y
outside the "typical" range may produce unexpected values. The same
applies to %F which is identical to %Y-%m-%d. Note of these conversion
specifiers is affected by the locale used. So it's trivial to manually
handle this case.

This removes several platform specific ifdefs from the tests.
---
 libcxx/include/__chrono/formatter.h   | 16 -
 .../time.cal.ymd.nonmembers/ostream.pass.cpp  | 34 ---
 .../sys_date.ostream.pass.cpp | 34 ---
 .../formatter.year_month_day.pass.cpp | 24 -
 4 files changed, 7 insertions(+), 101 deletions(-)

diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..217979e88c93db 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -322,15 +322,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
-  case _CharT('F'): {
-int __year = __t.tm_year + 1900;
-if (__year < 1000) {
-  __formatter::__format_year(__sstr, __year);
-  __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
-} else
-  __facet.put(
-  {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
-  } break;
+  case _CharT('F'):
+// Depending on the platform's libc the range of supported years is
+// limited. Intead of of testing all conditions use the internal
+// implementation unconditionally.
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
+__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
+break;
 
   case _CharT('z'):
 __formatter::__format_zone_offset(__sstr, __z.__offset, false);
diff --git 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
index ffc737fcad5dd2..20ffb165558e31 100644
--- 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
+++ 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
@@ -13,9 +13,6 @@
 // TODO FMT This test should not require std::to_chars(floating-point)
 // XFAIL: availability-fp_to_chars-missing
 
-// TODO FMT Investigate Windows issues.
-// XFAIL: msvc
-
 // REQUIRES: locale.fr_FR.UTF-8
 // REQUIRES: locale.ja_JP.UTF-8
 
@@ -89,20 +86,9 @@ static void test() {
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-
-#if defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else //  defined(_AIX)
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{-32'768}, 
std::chrono::month{1}, std::chrono::day{1}}),
@@ -122,19 +108,9 @@ static void test() {
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-#if defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else // defined(_AIX)
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST

[llvm-branch-commits] [flang] [llvm] [mlir] [MLIR][Flang][OpenMP] Make omp.simdloop into a loop wrapper (PR #87365)

2024-04-10 Thread Krzysztof Parzyszek via llvm-branch-commits


@@ -521,7 +521,7 @@ struct OpWithBodyGenInfo {
 /// \param [in]   op - the operation the body belongs to.
 /// \param [in] info - options controlling code-gen for the construction.
 template 
-static void createBodyOfOp(Op &op, OpWithBodyGenInfo &info) {
+static void createBodyOfOp(mlir::Operation &op, OpWithBodyGenInfo &info) {

kparzysz wrote:

The new version doesn't take any parameters or return any values with the type 
in the template arguments, so there is no compelling reason to keep it as a 
template, expecially given its size.

I suggest converting it to a non-template, with an extra parameter "isLoop" 
passed from outside.  We can have "is_loop" trait to make it easy.

https://github.com/llvm/llvm-project/pull/87365
___
llvm-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] 7ddd848 - Revert "[clang][dataflow] Propagate locations from result objects to initiali…"

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

Author: martinboehme
Date: 2024-04-10T21:26:23+02:00
New Revision: 7ddd8485884c9df50def3297d51c458cf9d4c32e

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

LOG: Revert "[clang][dataflow] Propagate locations from result objects to 
initiali…"

This reverts commit 21009f466ece9f21b18e1bb03bd74b566188bae5.

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 706664d7db1c25..9a65f76cdf56bc 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -30,7 +30,6 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
-#include 
 #include 
 #include 
 
@@ -345,6 +344,17 @@ class Environment {
   /// location of the result object to pass in `this`, even though prvalues are
   /// otherwise not associated with storage locations.
   ///
+  /// FIXME: Currently, this simply returns a stable storage location for `E`,
+  /// but this doesn't do the right thing in scenarios like the following:
+  /// ```
+  /// MyClass c = some_condition()? MyClass(foo) : MyClass(bar);
+  /// ```
+  /// Here, `MyClass(foo)` and `MyClass(bar)` will have two 
diff erent storage
+  /// locations, when in fact their storage locations should be the same.
+  /// Eventually, we want to propagate storage locations from result objects
+  /// down to the prvalues that initialize them, similar to the way that this 
is
+  /// done in Clang's CodeGen.
+  ///
   /// Requirements:
   ///  `E` must be a prvalue of record type.
   RecordStorageLocation &
@@ -452,13 +462,7 @@ class Environment {
   /// Initializes the fields (including synthetic fields) of `Loc` with values,
   /// unless values of the field type are not supported or we hit one of the
   /// limits at which we stop producing values.
-  /// If `Type` is provided, initializes only those fields that are modeled for
-  /// `Type`; this is intended for use in cases where `Loc` is a derived type
-  /// and we only want to initialize the fields of a base type.
-  void initializeFieldsWithValues(RecordStorageLocation &Loc, QualType Type);
-  void initializeFieldsWithValues(RecordStorageLocation &Loc) {
-initializeFieldsWithValues(Loc, Loc.getType());
-  }
+  void initializeFieldsWithValues(RecordStorageLocation &Loc);
 
   /// Assigns `Val` as the value of `Loc` in the environment.
   void setValue(const StorageLocation &Loc, Value &Val);
@@ -649,9 +653,6 @@ class Environment {
   LLVM_DUMP_METHOD void dump(raw_ostream &OS) const;
 
 private:
-  using PrValueToResultObject =
-  llvm::DenseMap;
-
   // The copy-constructor is for use in fork() only.
   Environment(const Environment &) = default;
 
@@ -681,10 +682,8 @@ class Environment {
   /// Initializes the fields (including synthetic fields) of `Loc` with values,
   /// unless values of the field type are not supported or we hit one of the
   /// limits at which we stop producing values (controlled by `Visited`,
-  /// `Depth`, and `CreatedValuesCount`). If `Type` is 
diff erent from
-  /// `Loc.getType()`, initializes only those fields that are modeled for
-  /// `Type`.
-  void initializeFieldsWithValues(RecordStorageLocation &Loc, QualType Type,
+  /// `Depth`, and `CreatedValuesCount`).
+  void initializeFieldsWithValues(RecordStorageLocation &Loc,
   llvm::DenseSet &Visited, int Depth,
   int &CreatedValuesCount);
 
@@ -703,45 +702,22 @@ class Environment {
   /// and functions referenced in `FuncDecl`. `FuncDecl` must have a body.
   void initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl);
 
-  static PrValueToResultObject
-  buildResultObjectMap(DataflowAnalysisContext *DACtx,
-   const FunctionDecl *FuncDecl,
-   RecordStorageLocation *ThisPointeeLoc,
-   RecordStorageLocation *LocForRecordReturnVal);
-
   // `DACtx` is not null and not owned by this object.
   DataflowAnalysisContext *DACtx;
 
-  // FIXME: move the fields `CallStack`, `ResultObjectMap`, `ReturnVal`,
-  // `ReturnLoc` and `ThisPointeeLoc` into a separate call-context object,
-  // shared between environments in the same call.
+  // FIXME: move the fields 

[llvm-branch-commits] [llvm] [BOLT][BAT] Fix handling of split functions (PR #87569)

2024-04-10 Thread Maksim Panchenko via llvm-branch-commits


@@ -245,14 +245,12 @@ class DataAggregator : public DataReader {
   /// disassembled BinaryFunctions
   BinaryFunction *getBinaryFunctionContainingAddress(uint64_t Address) const;
 
+  /// Perform BAT translation for a given \p Func and return the parent
+  /// BinaryFunction or nullptr.
+  BinaryFunction *getParentFunction(const BinaryFunction &Func) const;

maksfb wrote:

If the function is BAT-specific, it should be clear from the name.

https://github.com/llvm/llvm-project/pull/87569
___
llvm-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][BAT] Fix handling of split functions (PR #87569)

2024-04-10 Thread Maksim Panchenko via llvm-branch-commits


@@ -59,10 +59,29 @@
 # RUN: llvm-bolt %t.exe -o %t.bat2 --data %t.fdata --funcs=main,func \
 # RUN:   --split-functions --split-strategy=all --split-all-cold --enable-bat
 
+# Prepare pre-aggregated profile using %t.bat

maksfb wrote:

Nit: use double `#`s.

https://github.com/llvm/llvm-project/pull/87569
___
llvm-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] Cover all call sites in writeBATYAML (PR #87743)

2024-04-10 Thread Maksim Panchenko via llvm-branch-commits


@@ -38,10 +38,63 @@
 # RUN: llvm-bolt %t.exe -o %t.bat --data %t.fdata --funcs=func \
 # RUN:   --split-functions --split-strategy=all --split-all-cold --enable-bat
 
+# Prepare pre-aggregated profile using %t.bat

maksfb wrote:

Use double `#`s.

https://github.com/llvm/llvm-project/pull/87743
___
llvm-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] Cover all call sites in writeBATYAML (PR #87743)

2024-04-10 Thread Maksim Panchenko via llvm-branch-commits


@@ -2341,86 +2341,62 @@ std::error_code 
DataAggregator::writeBATYAML(BinaryContext &BC,
   YamlBF.NumBasicBlocks = BAT->getNumBasicBlocks(FuncAddress);
   const BoltAddressTranslation::BBHashMapTy &BlockMap =
   BAT->getBBHashMap(FuncAddress);
+  YamlBF.Blocks.resize(YamlBF.NumBasicBlocks);
 
-  auto addSuccProfile = [&](yaml::bolt::BinaryBasicBlockProfile &YamlBB,
-uint64_t SuccOffset, unsigned SuccDataIdx) {
+  for (auto &&[Idx, YamlBB] : llvm::enumerate(YamlBF.Blocks))
+YamlBB.Index = Idx;
+
+  for (auto BI = BlockMap.begin(), BE = BlockMap.end(); BI != BE; ++BI)
+YamlBF.Blocks[BI->second.getBBIndex()].Hash = BI->second.getBBHash();
+
+  auto getSuccessorInfo = [&](uint32_t SuccOffset, unsigned SuccDataIdx) {
 const llvm::bolt::BranchInfo &BI = Branches.Data.at(SuccDataIdx);
 yaml::bolt::SuccessorInfo SI;
 SI.Index = BlockMap.getBBIndex(SuccOffset);
 SI.Count = BI.Branches;
 SI.Mispreds = BI.Mispreds;
-YamlBB.Successors.emplace_back(SI);
+return SI;
   };
 
-  std::unordered_map> BFBranches =
-  BAT->getBFBranches(FuncAddress);
-
-  auto addCallsProfile = [&](yaml::bolt::BinaryBasicBlockProfile &YamlBB,
- uint64_t Offset) {
-// Iterate over BRANCHENTRY records in the current block
-for (uint32_t BranchOffset : BFBranches[Offset]) {
-  if (!Branches.InterIndex.contains(BranchOffset))
-continue;
-  for (const auto &[CallToLoc, CallToIdx] :
-   Branches.InterIndex.at(BranchOffset)) {
-const llvm::bolt::BranchInfo &BI = Branches.Data.at(CallToIdx);
-yaml::bolt::CallSiteInfo YamlCSI;
-YamlCSI.DestId = 0; // designated for unknown functions
-YamlCSI.EntryDiscriminator = 0;
-YamlCSI.Count = BI.Branches;
-YamlCSI.Mispreds = BI.Mispreds;
-YamlCSI.Offset = BranchOffset - Offset;
-BinaryData *CallTargetBD = BC.getBinaryDataByName(CallToLoc.Name);
-if (!CallTargetBD) {
-  YamlBB.CallSites.emplace_back(YamlCSI);
-  continue;
-}
-uint64_t CallTargetAddress = CallTargetBD->getAddress();
-BinaryFunction *CallTargetBF =
-BC.getBinaryFunctionAtAddress(CallTargetAddress);
-if (!CallTargetBF) {
-  YamlBB.CallSites.emplace_back(YamlCSI);
-  continue;
-}
-// Calls between hot and cold fragments must be handled in
-// fixupBATProfile.
-assert(CallTargetBF != BF && "invalid CallTargetBF");
-YamlCSI.DestId = CallTargetBF->getFunctionNumber();
-if (CallToLoc.Offset) {
-  if (BAT->isBATFunction(CallTargetAddress)) {
-LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Unsupported secondary "
- "entry point in BAT function "
-  << CallToLoc.Name << '\n');
-  } else if (const BinaryBasicBlock *CallTargetBB =
- CallTargetBF->getBasicBlockAtOffset(
- CallToLoc.Offset)) {
-// Only record true call information, ignoring returns 
(normally
-// won't have a target basic block) and jumps to the landing
-// pads (not an entry point).
-if (CallTargetBB->isEntryPoint()) {
-  YamlCSI.EntryDiscriminator =
-  CallTargetBF->getEntryIDForSymbol(
-  CallTargetBB->getLabel());
-}
-  }
-}
-YamlBB.CallSites.emplace_back(YamlCSI);
-  }
-}
+  auto getCallSiteInfo = [&](Location CallToLoc, unsigned CallToIdx,
+ uint32_t Offset) {
+const llvm::bolt::BranchInfo &BI = Branches.Data.at(CallToIdx);
+yaml::bolt::CallSiteInfo CSI;
+CSI.DestId = 0; // designated for unknown functions
+CSI.EntryDiscriminator = 0;
+CSI.Count = BI.Branches;
+CSI.Mispreds = BI.Mispreds;
+CSI.Offset = Offset;
+if (BinaryData *BD = BC.getBinaryDataByName(CallToLoc.Name))
+  YAMLProfileWriter::setCSIDestination(BC, CSI, BD->getSymbol(), BAT,
+   CallToLoc.Offset);
+return CSI;
   };
 
   for (const auto &[FromOffset, SuccKV] : Branches.IntraIndex) {
-yaml::bolt::BinaryBasicBlockProfile YamlBB;
 if (!BlockMap.isInputBlock(FromOffset))
   continue;
-YamlBB.Index = BlockMap.getBBIndex(FromOffset);
-YamlBB.Hash = BlockMap.getBBHash(FromOffset);
+unsigned Index = BlockMap.getBBIndex(FromOffset);
+yaml::bolt::BinaryBasicBlockProfile &YamlBB = YamlBF.Blocks[Index];
 for (const aut

[llvm-branch-commits] [llvm] [BOLT] Cover all call sites in writeBATYAML (PR #87743)

2024-04-10 Thread Maksim Panchenko via llvm-branch-commits


@@ -2341,86 +2341,62 @@ std::error_code 
DataAggregator::writeBATYAML(BinaryContext &BC,
   YamlBF.NumBasicBlocks = BAT->getNumBasicBlocks(FuncAddress);
   const BoltAddressTranslation::BBHashMapTy &BlockMap =
   BAT->getBBHashMap(FuncAddress);
+  YamlBF.Blocks.resize(YamlBF.NumBasicBlocks);
 
-  auto addSuccProfile = [&](yaml::bolt::BinaryBasicBlockProfile &YamlBB,
-uint64_t SuccOffset, unsigned SuccDataIdx) {
+  for (auto &&[Idx, YamlBB] : llvm::enumerate(YamlBF.Blocks))
+YamlBB.Index = Idx;
+
+  for (auto BI = BlockMap.begin(), BE = BlockMap.end(); BI != BE; ++BI)
+YamlBF.Blocks[BI->second.getBBIndex()].Hash = BI->second.getBBHash();
+
+  auto getSuccessorInfo = [&](uint32_t SuccOffset, unsigned SuccDataIdx) {
 const llvm::bolt::BranchInfo &BI = Branches.Data.at(SuccDataIdx);
 yaml::bolt::SuccessorInfo SI;
 SI.Index = BlockMap.getBBIndex(SuccOffset);
 SI.Count = BI.Branches;
 SI.Mispreds = BI.Mispreds;
-YamlBB.Successors.emplace_back(SI);
+return SI;
   };
 
-  std::unordered_map> BFBranches =
-  BAT->getBFBranches(FuncAddress);
-
-  auto addCallsProfile = [&](yaml::bolt::BinaryBasicBlockProfile &YamlBB,
- uint64_t Offset) {
-// Iterate over BRANCHENTRY records in the current block
-for (uint32_t BranchOffset : BFBranches[Offset]) {
-  if (!Branches.InterIndex.contains(BranchOffset))
-continue;
-  for (const auto &[CallToLoc, CallToIdx] :
-   Branches.InterIndex.at(BranchOffset)) {
-const llvm::bolt::BranchInfo &BI = Branches.Data.at(CallToIdx);
-yaml::bolt::CallSiteInfo YamlCSI;
-YamlCSI.DestId = 0; // designated for unknown functions
-YamlCSI.EntryDiscriminator = 0;
-YamlCSI.Count = BI.Branches;
-YamlCSI.Mispreds = BI.Mispreds;
-YamlCSI.Offset = BranchOffset - Offset;
-BinaryData *CallTargetBD = BC.getBinaryDataByName(CallToLoc.Name);
-if (!CallTargetBD) {
-  YamlBB.CallSites.emplace_back(YamlCSI);
-  continue;
-}
-uint64_t CallTargetAddress = CallTargetBD->getAddress();
-BinaryFunction *CallTargetBF =
-BC.getBinaryFunctionAtAddress(CallTargetAddress);
-if (!CallTargetBF) {
-  YamlBB.CallSites.emplace_back(YamlCSI);
-  continue;
-}
-// Calls between hot and cold fragments must be handled in
-// fixupBATProfile.
-assert(CallTargetBF != BF && "invalid CallTargetBF");
-YamlCSI.DestId = CallTargetBF->getFunctionNumber();
-if (CallToLoc.Offset) {
-  if (BAT->isBATFunction(CallTargetAddress)) {
-LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Unsupported secondary "
- "entry point in BAT function "
-  << CallToLoc.Name << '\n');
-  } else if (const BinaryBasicBlock *CallTargetBB =
- CallTargetBF->getBasicBlockAtOffset(
- CallToLoc.Offset)) {
-// Only record true call information, ignoring returns 
(normally
-// won't have a target basic block) and jumps to the landing
-// pads (not an entry point).
-if (CallTargetBB->isEntryPoint()) {
-  YamlCSI.EntryDiscriminator =
-  CallTargetBF->getEntryIDForSymbol(
-  CallTargetBB->getLabel());
-}
-  }
-}
-YamlBB.CallSites.emplace_back(YamlCSI);
-  }
-}
+  auto getCallSiteInfo = [&](Location CallToLoc, unsigned CallToIdx,
+ uint32_t Offset) {
+const llvm::bolt::BranchInfo &BI = Branches.Data.at(CallToIdx);
+yaml::bolt::CallSiteInfo CSI;
+CSI.DestId = 0; // designated for unknown functions
+CSI.EntryDiscriminator = 0;
+CSI.Count = BI.Branches;
+CSI.Mispreds = BI.Mispreds;
+CSI.Offset = Offset;
+if (BinaryData *BD = BC.getBinaryDataByName(CallToLoc.Name))
+  YAMLProfileWriter::setCSIDestination(BC, CSI, BD->getSymbol(), BAT,
+   CallToLoc.Offset);
+return CSI;
   };
 
   for (const auto &[FromOffset, SuccKV] : Branches.IntraIndex) {
-yaml::bolt::BinaryBasicBlockProfile YamlBB;
 if (!BlockMap.isInputBlock(FromOffset))
   continue;
-YamlBB.Index = BlockMap.getBBIndex(FromOffset);
-YamlBB.Hash = BlockMap.getBBHash(FromOffset);
+unsigned Index = BlockMap.getBBIndex(FromOffset);
+yaml::bolt::BinaryBasicBlockProfile &YamlBB = YamlBF.Blocks[Index];
 for (const aut

[llvm-branch-commits] [llvm] release/18.x: [ConstantRange] Fix off by 1 bugs in UIToFP and SIToFP handling. (#86041) (PR #86153)

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

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

>From 557b12052ca9a4c63e408cf1b0e33f300791623e Mon Sep 17 00:00:00 2001
From: Craig Topper 
Date: Wed, 20 Mar 2024 17:05:17 -0700
Subject: [PATCH 1/2] [Float2Int] Pre-commit test for SIToFP/UIToFP
 ConstantRange bug. NFC

The range for these operations is being constructed without the
maximum value for the range due to an incorrect usage of the
ConstantRange constructor.

This causes Float2Int to think the range for 'uitofp i1' only
contains 0 instead of 0 and 1.

(cherry picked from commit 6295e677220bb6ec1fa8abe2f4a94b513b91b786)
---
 llvm/test/Transforms/Float2Int/pr79158.ll | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 llvm/test/Transforms/Float2Int/pr79158.ll

diff --git a/llvm/test/Transforms/Float2Int/pr79158.ll 
b/llvm/test/Transforms/Float2Int/pr79158.ll
new file mode 100644
index 00..d041e01a4b5997
--- /dev/null
+++ b/llvm/test/Transforms/Float2Int/pr79158.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt < %s -passes=float2int -S | FileCheck %s
+
+define i32 @pr79158(i32 %x) {
+; CHECK-LABEL: define i32 @pr79158(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[X]], 0
+; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i32
+; CHECK-NEXT:[[MUL1:%.*]] = mul i32 [[TMP0]], 2147483647
+; CHECK-NEXT:ret i32 [[MUL1]]
+;
+entry:
+  %cmp = icmp sgt i32 %x, 0
+  %conv = uitofp i1 %cmp to double
+  %mul = fmul double %conv, 0x41EFFFE0
+  %conv1 = fptoui double %mul to i32
+  ret i32 %conv1
+}

>From 00668c8a4709e73eede5a814bb9461dddcad983f Mon Sep 17 00:00:00 2001
From: Craig Topper 
Date: Thu, 21 Mar 2024 09:25:13 -0700
Subject: [PATCH 2/2] [ConstantRange] Fix off by 1 bugs in UIToFP and SIToFP
 handling. (#86041)

We were passing the min and max values of the range to the ConstantRange
constructor, but the constructor expects the upper bound to 1 more than
the max value so we need to add 1.

We also need to use getNonEmpty so that passing 0, 0 to the constructor
creates a full range rather than an empty range. And passing smin,
smax+1 doesn't cause an assertion.

I believe this fixes at least some of the reason #79158 was reverted.

(cherry picked from commit 12836467b76c56872b4c22a6fd44bcda696ea720)
---
 llvm/lib/IR/ConstantRange.cpp |  4 ++--
 llvm/test/Transforms/Float2Int/pr79158.ll |  7 ---
 llvm/unittests/IR/ConstantRangeTest.cpp   | 18 ++
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index cbb64b299e648e..f105bdb4816aa0 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -746,7 +746,7 @@ ConstantRange ConstantRange::castOp(Instruction::CastOps 
CastOp,
   Min = Min.zext(ResultBitWidth);
   Max = Max.zext(ResultBitWidth);
 }
-return ConstantRange(std::move(Min), std::move(Max));
+return getNonEmpty(std::move(Min), std::move(Max) + 1);
   }
   case Instruction::SIToFP: {
 // TODO: use input range if available
@@ -757,7 +757,7 @@ ConstantRange ConstantRange::castOp(Instruction::CastOps 
CastOp,
   SMin = SMin.sext(ResultBitWidth);
   SMax = SMax.sext(ResultBitWidth);
 }
-return ConstantRange(std::move(SMin), std::move(SMax));
+return getNonEmpty(std::move(SMin), std::move(SMax) + 1);
   }
   case Instruction::FPTrunc:
   case Instruction::FPExt:
diff --git a/llvm/test/Transforms/Float2Int/pr79158.ll 
b/llvm/test/Transforms/Float2Int/pr79158.ll
index d041e01a4b5997..5e78cc0bc66fdb 100644
--- a/llvm/test/Transforms/Float2Int/pr79158.ll
+++ b/llvm/test/Transforms/Float2Int/pr79158.ll
@@ -6,9 +6,10 @@ define i32 @pr79158(i32 %x) {
 ; CHECK-SAME: i32 [[X:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[X]], 0
-; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i32
-; CHECK-NEXT:[[MUL1:%.*]] = mul i32 [[TMP0]], 2147483647
-; CHECK-NEXT:ret i32 [[MUL1]]
+; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i64
+; CHECK-NEXT:[[MUL1:%.*]] = mul i64 [[TMP0]], 4294967295
+; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[MUL1]] to i32
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
 entry:
   %cmp = icmp sgt i32 %x, 0
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp 
b/llvm/unittests/IR/ConstantRangeTest.cpp
index e505af5d3275ef..f60bb4c135bec3 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -2479,6 +2479,24 @@ TEST_F(ConstantRangeTest, castOps) {
   ConstantRange IntToPtr = A.castOp(Instruction::IntToPtr, 64);
   EXPECT_EQ(64u, IntToPtr.getBitWidth());
   EXPECT_TRUE(IntToPtr.isFullSet());
+
+  ConstantRange UIToFP = A.castOp(Instruction::UIToFP, 16);
+  EXPECT_EQ(16u, UIToFP.getBitWidth());
+  EXPECT_TRUE(UIToFP.isFullSet());
+
+  ConstantRange UIToFP2 = A.castOp(Instru

[llvm-branch-commits] [llvm] Bump version to 18.1.4 (PR #87715)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/87715
___
llvm-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] daca56d - Bump version to 18.1.4 (#87715)

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

Author: Tom Stellard
Date: 2024-04-10T14:18:52-07:00
New Revision: daca56d8e16233e6fd7dadebb6d3fa1555d586a4

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

LOG: Bump version to 18.1.4 (#87715)

Added: 


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

Removed: 




diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 253f3943c3b51f..98dbab810bacbf 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 3)
+  set(LLVM_VERSION_PATCH 4)
 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 9165056a56bd4d..fcf4a9d8b5f398 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, 3)
+__versioninfo__ = (18, 1, 4)
 __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] [lldb] 27a49dc - Revert "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into lldb-enume…"

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

Author: Chelsea Cassanova
Date: 2024-04-10T14:50:39-07:00
New Revision: 27a49dc1d37f3e7ffa855ed7a536a796fa2e1642

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

LOG: Revert "[lldb][sbdebugger] Move SBDebugger Broadcast bit enum into 
lldb-enume…"

This reverts commit af7c196fb8d10f58a704b5a8d142feacf2f0236d.

Added: 


Modified: 
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/lldb-enumerations.h

lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py

lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
lldb/test/API/macosx/rosetta/TestRosetta.py

Removed: 




diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index cf5409a12a056a..62b2f91f5076d5 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -42,6 +42,13 @@ class LLDB_API SBInputReader {
 
 class LLDB_API SBDebugger {
 public:
+  FLAGS_ANONYMOUS_ENUM(){
+  eBroadcastBitProgress = (1 << 0),
+  eBroadcastBitWarning = (1 << 1),
+  eBroadcastBitError = (1 << 2),
+  eBroadcastBitProgressCategory = (1 << 3),
+  };
+
   SBDebugger();
 
   SBDebugger(const lldb::SBDebugger &rhs);

diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index f3b07ea6d20395..646f7bfda98475 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1339,14 +1339,6 @@ enum AddressMaskRange {
   eAddressMaskRangeAll = eAddressMaskRangeAny,
 };
 
-/// Used by the debugger to indicate which events are being broadcasted.
-enum DebuggerBroadcastBit {
-  eBroadcastBitProgress = (1 << 0),
-  eBroadcastBitWarning = (1 << 1),
-  eBroadcastBitError = (1 << 2),
-  eBroadcastBitProgressCategory = (1 << 3),
-};
-
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H

diff  --git 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
index 6353e3e8cbedbd..36a3be695628f5 100644
--- 
a/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
+++ 
b/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
@@ -15,7 +15,7 @@ def setUp(self):
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
 self.broadcaster,
-lldb.eBroadcastBitWarning | lldb.eBroadcastBitError,
+lldb.SBDebugger.eBroadcastBitWarning | 
lldb.SBDebugger.eBroadcastBitError,
 )
 
 def test_dwarf_symbol_loading_diagnostic_report(self):

diff  --git 
a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py 
b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
index 98988d7624da3c..9af53845ca1b77 100644
--- a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -13,7 +13,7 @@ def setUp(self):
 TestBase.setUp(self)
 self.broadcaster = self.dbg.GetBroadcaster()
 self.listener = lldbutil.start_listening_from(
-self.broadcaster, lldb.eBroadcastBitProgress
+self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress
 )
 
 def test_dwarf_symbol_loading_progress_report(self):

diff  --git 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
index 33c7c269c081e4..228f676aedf6ac 100644
--- 
a/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
+++ 
b/lldb/test/API/functionalities/progress_reporting/clang_modules/TestClangModuleBuildProgress.py
@@ -34,7 +34,7 @@ def test_clang_module_build_progress_report(self):
 # other unrelated progress events.
 broadcaster = self.dbg.GetBroadcaster()
 listener = lldbutil.start_listening_from(
-broadcaster, lldb.eBroadcastBitProgress
+broadcaster, lldb.SBDebugger.eBroadcastBitProgress
 )
 
 # Trigger module builds.

diff  --git a/lldb/test/API/macosx/rosetta/TestRosetta.py 
b/lldb/test/API/macosx/rosetta/TestRosetta.py
index 669db95a1624c6..ce40de475ef16c 100644
--- a/lldb/test/API/macosx/rosetta/TestRosetta.py
+++ b/lldb/test/API/macosx/rosetta/TestRosetta.py
@@ -49,7 +49,7 @@ def test_rosetta(self):
 if rosetta_debugserver_installed():
 broadcaster = self.dbg.GetBroadcaster()
 listener = lldbutil.start_listening_from

[llvm-branch-commits] [llvm] release/18.x: [ConstantRange] Fix off by 1 bugs in UIToFP and SIToFP handling. (#86041) (PR #86153)

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

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

>From e4259b583c92244e2c49c664fad0fbc1bdaa800b Mon Sep 17 00:00:00 2001
From: Craig Topper 
Date: Wed, 20 Mar 2024 17:05:17 -0700
Subject: [PATCH 1/2] [Float2Int] Pre-commit test for SIToFP/UIToFP
 ConstantRange bug. NFC

The range for these operations is being constructed without the
maximum value for the range due to an incorrect usage of the
ConstantRange constructor.

This causes Float2Int to think the range for 'uitofp i1' only
contains 0 instead of 0 and 1.

(cherry picked from commit 6295e677220bb6ec1fa8abe2f4a94b513b91b786)
---
 llvm/test/Transforms/Float2Int/pr79158.ll | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 llvm/test/Transforms/Float2Int/pr79158.ll

diff --git a/llvm/test/Transforms/Float2Int/pr79158.ll 
b/llvm/test/Transforms/Float2Int/pr79158.ll
new file mode 100644
index 00..d041e01a4b5997
--- /dev/null
+++ b/llvm/test/Transforms/Float2Int/pr79158.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt < %s -passes=float2int -S | FileCheck %s
+
+define i32 @pr79158(i32 %x) {
+; CHECK-LABEL: define i32 @pr79158(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[X]], 0
+; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i32
+; CHECK-NEXT:[[MUL1:%.*]] = mul i32 [[TMP0]], 2147483647
+; CHECK-NEXT:ret i32 [[MUL1]]
+;
+entry:
+  %cmp = icmp sgt i32 %x, 0
+  %conv = uitofp i1 %cmp to double
+  %mul = fmul double %conv, 0x41EFFFE0
+  %conv1 = fptoui double %mul to i32
+  ret i32 %conv1
+}

>From feba8727f80566074518c9dbb5e90c8f2371c08d Mon Sep 17 00:00:00 2001
From: Craig Topper 
Date: Thu, 21 Mar 2024 09:25:13 -0700
Subject: [PATCH 2/2] [ConstantRange] Fix off by 1 bugs in UIToFP and SIToFP
 handling. (#86041)

We were passing the min and max values of the range to the ConstantRange
constructor, but the constructor expects the upper bound to 1 more than
the max value so we need to add 1.

We also need to use getNonEmpty so that passing 0, 0 to the constructor
creates a full range rather than an empty range. And passing smin,
smax+1 doesn't cause an assertion.

I believe this fixes at least some of the reason #79158 was reverted.

(cherry picked from commit 12836467b76c56872b4c22a6fd44bcda696ea720)
---
 llvm/lib/IR/ConstantRange.cpp |  4 ++--
 llvm/test/Transforms/Float2Int/pr79158.ll |  7 ---
 llvm/unittests/IR/ConstantRangeTest.cpp   | 18 ++
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index cbb64b299e648e..f105bdb4816aa0 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -746,7 +746,7 @@ ConstantRange ConstantRange::castOp(Instruction::CastOps 
CastOp,
   Min = Min.zext(ResultBitWidth);
   Max = Max.zext(ResultBitWidth);
 }
-return ConstantRange(std::move(Min), std::move(Max));
+return getNonEmpty(std::move(Min), std::move(Max) + 1);
   }
   case Instruction::SIToFP: {
 // TODO: use input range if available
@@ -757,7 +757,7 @@ ConstantRange ConstantRange::castOp(Instruction::CastOps 
CastOp,
   SMin = SMin.sext(ResultBitWidth);
   SMax = SMax.sext(ResultBitWidth);
 }
-return ConstantRange(std::move(SMin), std::move(SMax));
+return getNonEmpty(std::move(SMin), std::move(SMax) + 1);
   }
   case Instruction::FPTrunc:
   case Instruction::FPExt:
diff --git a/llvm/test/Transforms/Float2Int/pr79158.ll 
b/llvm/test/Transforms/Float2Int/pr79158.ll
index d041e01a4b5997..5e78cc0bc66fdb 100644
--- a/llvm/test/Transforms/Float2Int/pr79158.ll
+++ b/llvm/test/Transforms/Float2Int/pr79158.ll
@@ -6,9 +6,10 @@ define i32 @pr79158(i32 %x) {
 ; CHECK-SAME: i32 [[X:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[X]], 0
-; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i32
-; CHECK-NEXT:[[MUL1:%.*]] = mul i32 [[TMP0]], 2147483647
-; CHECK-NEXT:ret i32 [[MUL1]]
+; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i64
+; CHECK-NEXT:[[MUL1:%.*]] = mul i64 [[TMP0]], 4294967295
+; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[MUL1]] to i32
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
 entry:
   %cmp = icmp sgt i32 %x, 0
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp 
b/llvm/unittests/IR/ConstantRangeTest.cpp
index e505af5d3275ef..f60bb4c135bec3 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -2479,6 +2479,24 @@ TEST_F(ConstantRangeTest, castOps) {
   ConstantRange IntToPtr = A.castOp(Instruction::IntToPtr, 64);
   EXPECT_EQ(64u, IntToPtr.getBitWidth());
   EXPECT_TRUE(IntToPtr.isFullSet());
+
+  ConstantRange UIToFP = A.castOp(Instruction::UIToFP, 16);
+  EXPECT_EQ(16u, UIToFP.getBitWidth());
+  EXPECT_TRUE(UIToFP.isFullSet());
+
+  ConstantRange UIToFP2 = A.castOp(Instru

[llvm-branch-commits] [llvm] e4259b5 - [Float2Int] Pre-commit test for SIToFP/UIToFP ConstantRange bug. NFC

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

Author: Craig Topper
Date: 2024-04-10T14:55:38-07:00
New Revision: e4259b583c92244e2c49c664fad0fbc1bdaa800b

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

LOG: [Float2Int] Pre-commit test for SIToFP/UIToFP ConstantRange bug. NFC

The range for these operations is being constructed without the
maximum value for the range due to an incorrect usage of the
ConstantRange constructor.

This causes Float2Int to think the range for 'uitofp i1' only
contains 0 instead of 0 and 1.

(cherry picked from commit 6295e677220bb6ec1fa8abe2f4a94b513b91b786)

Added: 
llvm/test/Transforms/Float2Int/pr79158.ll

Modified: 


Removed: 




diff  --git a/llvm/test/Transforms/Float2Int/pr79158.ll 
b/llvm/test/Transforms/Float2Int/pr79158.ll
new file mode 100644
index 00..d041e01a4b5997
--- /dev/null
+++ b/llvm/test/Transforms/Float2Int/pr79158.ll
@@ -0,0 +1,19 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt < %s -passes=float2int -S | FileCheck %s
+
+define i32 @pr79158(i32 %x) {
+; CHECK-LABEL: define i32 @pr79158(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[X]], 0
+; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i32
+; CHECK-NEXT:[[MUL1:%.*]] = mul i32 [[TMP0]], 2147483647
+; CHECK-NEXT:ret i32 [[MUL1]]
+;
+entry:
+  %cmp = icmp sgt i32 %x, 0
+  %conv = uitofp i1 %cmp to double
+  %mul = fmul double %conv, 0x41EFFFE0
+  %conv1 = fptoui double %mul to i32
+  ret i32 %conv1
+}



___
llvm-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] feba872 - [ConstantRange] Fix off by 1 bugs in UIToFP and SIToFP handling. (#86041)

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

Author: Craig Topper
Date: 2024-04-10T14:55:38-07:00
New Revision: feba8727f80566074518c9dbb5e90c8f2371c08d

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

LOG: [ConstantRange] Fix off by 1 bugs in UIToFP and SIToFP handling. (#86041)

We were passing the min and max values of the range to the ConstantRange
constructor, but the constructor expects the upper bound to 1 more than
the max value so we need to add 1.

We also need to use getNonEmpty so that passing 0, 0 to the constructor
creates a full range rather than an empty range. And passing smin,
smax+1 doesn't cause an assertion.

I believe this fixes at least some of the reason #79158 was reverted.

(cherry picked from commit 12836467b76c56872b4c22a6fd44bcda696ea720)

Added: 


Modified: 
llvm/lib/IR/ConstantRange.cpp
llvm/test/Transforms/Float2Int/pr79158.ll
llvm/unittests/IR/ConstantRangeTest.cpp

Removed: 




diff  --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index cbb64b299e648e..f105bdb4816aa0 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -746,7 +746,7 @@ ConstantRange ConstantRange::castOp(Instruction::CastOps 
CastOp,
   Min = Min.zext(ResultBitWidth);
   Max = Max.zext(ResultBitWidth);
 }
-return ConstantRange(std::move(Min), std::move(Max));
+return getNonEmpty(std::move(Min), std::move(Max) + 1);
   }
   case Instruction::SIToFP: {
 // TODO: use input range if available
@@ -757,7 +757,7 @@ ConstantRange ConstantRange::castOp(Instruction::CastOps 
CastOp,
   SMin = SMin.sext(ResultBitWidth);
   SMax = SMax.sext(ResultBitWidth);
 }
-return ConstantRange(std::move(SMin), std::move(SMax));
+return getNonEmpty(std::move(SMin), std::move(SMax) + 1);
   }
   case Instruction::FPTrunc:
   case Instruction::FPExt:

diff  --git a/llvm/test/Transforms/Float2Int/pr79158.ll 
b/llvm/test/Transforms/Float2Int/pr79158.ll
index d041e01a4b5997..5e78cc0bc66fdb 100644
--- a/llvm/test/Transforms/Float2Int/pr79158.ll
+++ b/llvm/test/Transforms/Float2Int/pr79158.ll
@@ -6,9 +6,10 @@ define i32 @pr79158(i32 %x) {
 ; CHECK-SAME: i32 [[X:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[X]], 0
-; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i32
-; CHECK-NEXT:[[MUL1:%.*]] = mul i32 [[TMP0]], 2147483647
-; CHECK-NEXT:ret i32 [[MUL1]]
+; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i64
+; CHECK-NEXT:[[MUL1:%.*]] = mul i64 [[TMP0]], 4294967295
+; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[MUL1]] to i32
+; CHECK-NEXT:ret i32 [[TMP1]]
 ;
 entry:
   %cmp = icmp sgt i32 %x, 0

diff  --git a/llvm/unittests/IR/ConstantRangeTest.cpp 
b/llvm/unittests/IR/ConstantRangeTest.cpp
index e505af5d3275ef..f60bb4c135bec3 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -2479,6 +2479,24 @@ TEST_F(ConstantRangeTest, castOps) {
   ConstantRange IntToPtr = A.castOp(Instruction::IntToPtr, 64);
   EXPECT_EQ(64u, IntToPtr.getBitWidth());
   EXPECT_TRUE(IntToPtr.isFullSet());
+
+  ConstantRange UIToFP = A.castOp(Instruction::UIToFP, 16);
+  EXPECT_EQ(16u, UIToFP.getBitWidth());
+  EXPECT_TRUE(UIToFP.isFullSet());
+
+  ConstantRange UIToFP2 = A.castOp(Instruction::UIToFP, 64);
+  ConstantRange B(APInt(64, 0), APInt(64, 65536));
+  EXPECT_EQ(64u, UIToFP2.getBitWidth());
+  EXPECT_EQ(B, UIToFP2);
+
+  ConstantRange SIToFP = A.castOp(Instruction::SIToFP, 16);
+  EXPECT_EQ(16u, SIToFP.getBitWidth());
+  EXPECT_TRUE(SIToFP.isFullSet());
+
+  ConstantRange SIToFP2 = A.castOp(Instruction::SIToFP, 64);
+  ConstantRange C(APInt(64, -32768), APInt(64, 32768));
+  EXPECT_EQ(64u, SIToFP2.getBitWidth());
+  EXPECT_EQ(C, SIToFP2);
 }
 
 TEST_F(ConstantRangeTest, binaryAnd) {



___
llvm-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: [ConstantRange] Fix off by 1 bugs in UIToFP and SIToFP handling. (#86041) (PR #86153)

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

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


[llvm-branch-commits] [clang] release/18.x: [Headers] Don't declare unreachable() from stddef.h in C++ (#86748) (PR #87696)

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

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

>From 429d62872525e0ad7556e0258236911b4b3624ae Mon Sep 17 00:00:00 2001
From: Ian Anderson 
Date: Thu, 4 Apr 2024 13:01:49 -0700
Subject: [PATCH] [Headers] Don't declare unreachable() from stddef.h in C++
 (#86748)

Even if __need_unreachable is set, stddef.h should not declare
unreachable() in C++ because it conflicts with the declaration in
\.

(cherry picked from commit df69a305253f1d1b4a4066055a07101a4cc03e55)
---
 clang/lib/Headers/__stddef_unreachable.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Headers/__stddef_unreachable.h 
b/clang/lib/Headers/__stddef_unreachable.h
index 518580c92d3f5d..61df43e9732f8a 100644
--- a/clang/lib/Headers/__stddef_unreachable.h
+++ b/clang/lib/Headers/__stddef_unreachable.h
@@ -7,6 +7,8 @@
  *===---===
  */
 
+#ifndef __cplusplus
+
 /*
  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  * and needs to behave as if it was textual.
@@ -15,3 +17,5 @@
 (__has_feature(modules) && !__building_module(_Builtin_stddef))
 #define unreachable() __builtin_unreachable()
 #endif
+
+#endif

___
llvm-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] 429d628 - [Headers] Don't declare unreachable() from stddef.h in C++ (#86748)

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

Author: Ian Anderson
Date: 2024-04-10T14:59:00-07:00
New Revision: 429d62872525e0ad7556e0258236911b4b3624ae

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

LOG: [Headers] Don't declare unreachable() from stddef.h in C++ (#86748)

Even if __need_unreachable is set, stddef.h should not declare
unreachable() in C++ because it conflicts with the declaration in
\.

(cherry picked from commit df69a305253f1d1b4a4066055a07101a4cc03e55)

Added: 


Modified: 
clang/lib/Headers/__stddef_unreachable.h

Removed: 




diff  --git a/clang/lib/Headers/__stddef_unreachable.h 
b/clang/lib/Headers/__stddef_unreachable.h
index 518580c92d3f5d..61df43e9732f8a 100644
--- a/clang/lib/Headers/__stddef_unreachable.h
+++ b/clang/lib/Headers/__stddef_unreachable.h
@@ -7,6 +7,8 @@
  *===---===
  */
 
+#ifndef __cplusplus
+
 /*
  * When -fbuiltin-headers-in-system-modules is set this is a non-modular header
  * and needs to behave as if it was textual.
@@ -15,3 +17,5 @@
 (__has_feature(modules) && !__building_module(_Builtin_stddef))
 #define unreachable() __builtin_unreachable()
 #endif
+
+#endif



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


[llvm-branch-commits] [clang] release/18.x: [Headers] Don't declare unreachable() from stddef.h in C++ (#86748) (PR #87696)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/87696
___
llvm-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 of empty ctors/dtors (#82097) (PR #87735)

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

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

>From 3ceccbdb19959ae3068710cbcb99c41342c0774c Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Mon, 19 Feb 2024 12:41:22 -0800
Subject: [PATCH] [clang-format] Correctly annotate braces of empty ctors/dtors
 (#82097)

Also reformat Polly.

Fixes #79834.

(cherry picked from commit 8de230093f585b64fcd642b46e6560131e95b394)
---
 clang/lib/Format/TokenAnnotator.cpp   | 20 +--
 clang/unittests/Format/TokenAnnotatorTest.cpp | 14 +
 polly/lib/Exchange/JSONExporter.cpp   |  2 +-
 polly/lib/Transform/DeLICM.cpp|  2 +-
 polly/lib/Transform/FlattenSchedule.cpp   |  2 +-
 polly/lib/Transform/ForwardOpTree.cpp |  2 +-
 6 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index d0c4273cfc7e58..4d482e6543d6f5 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3450,10 +3450,11 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
   for (AnnotatedLine *ChildLine : Line.Children)
 calculateFormattingInformation(*ChildLine);
 
-  Line.First->TotalLength =
-  Line.First->IsMultiline ? Style.ColumnLimit
-  : Line.FirstStartColumn + 
Line.First->ColumnWidth;
-  FormatToken *Current = Line.First->Next;
+  auto *First = Line.First;
+  First->TotalLength = First->IsMultiline
+   ? Style.ColumnLimit
+   : Line.FirstStartColumn + First->ColumnWidth;
+  FormatToken *Current = First->Next;
   bool InFunctionDecl = Line.MightBeFunctionDecl;
   bool AlignArrayOfStructures =
   (Style.AlignArrayOfStructures != FormatStyle::AIAS_None &&
@@ -3475,16 +3476,15 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
 if (const bool IsCtorOrDtor = Tok->is(TT_CtorDtorDeclName);
 IsCtorOrDtor ||
 isFunctionDeclarationName(Style.isCpp(), *Tok, Line, ClosingParen)) {
-  if (!IsCtorOrDtor) {
-LineIsFunctionDeclaration = true;
+  if (!IsCtorOrDtor)
 Tok->setFinalizedType(TT_FunctionDeclarationName);
-  }
+  LineIsFunctionDeclaration = true;
   SeenName = true;
   break;
 }
   }
 
-  if (IsCpp && LineIsFunctionDeclaration &&
+  if (IsCpp && (LineIsFunctionDeclaration || First->is(TT_CtorDtorDeclName)) &&
   Line.endsWith(tok::semi, tok::r_brace)) {
 auto *Tok = Line.Last->Previous;
 while (Tok->isNot(tok::r_brace))
@@ -3507,7 +3507,7 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
   if (IsCpp) {
 if (!LineIsFunctionDeclaration) {
   // Annotate */&/&& in `operator` function calls as binary operators.
-  for (const auto *Tok = Line.First; Tok; Tok = Tok->Next) {
+  for (const auto *Tok = First; Tok; Tok = Tok->Next) {
 if (Tok->isNot(tok::kw_operator))
   continue;
 do {
@@ -3644,7 +3644,7 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
 
   calculateUnbreakableTailLengths(Line);
   unsigned IndentLevel = Line.Level;
-  for (Current = Line.First; Current; Current = Current->Next) {
+  for (Current = First; Current; Current = Current->Next) {
 if (Current->Role)
   Current->Role->precomputeFormattingInfos(Current);
 if (Current->MatchingParen &&
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 67678c18963b1f..c72c9384ff91d6 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2595,6 +2595,20 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
   EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_FunctionLBrace);
   EXPECT_BRACE_KIND(Tokens[4], BK_Block);
   EXPECT_BRACE_KIND(Tokens[6], BK_Block);
+
+  Tokens = annotate("struct Foo {\n"
+"  Foo() {};\n"
+"  ~Foo() {};\n"
+"};");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::identifier, TT_CtorDtorDeclName);
+  EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_FunctionLBrace);
+  EXPECT_BRACE_KIND(Tokens[6], BK_Block);
+  EXPECT_BRACE_KIND(Tokens[7], BK_Block);
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_CtorDtorDeclName);
+  EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_FunctionLBrace);
+  EXPECT_BRACE_KIND(Tokens[13], BK_Block);
+  EXPECT_BRACE_KIND(Tokens[14], BK_Block);
 }
 
 TEST_F(TokenAnnotatorTest, StreamOperator) {
diff --git a/polly/lib/Exchange/JSONExporter.cpp 
b/polly/lib/Exchange/JSONExporter.cpp
index 74d4e6c7993fa3..63fb06a634cc12 100644
--- a/polly/lib/Exchange/JSONExporter.cpp
+++ b/polly/lib/Exchange/JSONExporter.cpp
@@ -842,7 +842,7 @@ class JSONImporterPrinterLegacyPass final : public ScopPass 
{
 public:
   static char ID;
 
-  JSONImporterPrinterLegacyPass() : JSONImp

[llvm-branch-commits] [polly] 3ceccbd - [clang-format] Correctly annotate braces of empty ctors/dtors (#82097)

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

Author: Owen Pan
Date: 2024-04-10T15:00:37-07:00
New Revision: 3ceccbdb19959ae3068710cbcb99c41342c0774c

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

LOG: [clang-format] Correctly annotate braces of empty ctors/dtors (#82097)

Also reformat Polly.

Fixes #79834.

(cherry picked from commit 8de230093f585b64fcd642b46e6560131e95b394)

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp
polly/lib/Exchange/JSONExporter.cpp
polly/lib/Transform/DeLICM.cpp
polly/lib/Transform/FlattenSchedule.cpp
polly/lib/Transform/ForwardOpTree.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index d0c4273cfc7e58..4d482e6543d6f5 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3450,10 +3450,11 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
   for (AnnotatedLine *ChildLine : Line.Children)
 calculateFormattingInformation(*ChildLine);
 
-  Line.First->TotalLength =
-  Line.First->IsMultiline ? Style.ColumnLimit
-  : Line.FirstStartColumn + 
Line.First->ColumnWidth;
-  FormatToken *Current = Line.First->Next;
+  auto *First = Line.First;
+  First->TotalLength = First->IsMultiline
+   ? Style.ColumnLimit
+   : Line.FirstStartColumn + First->ColumnWidth;
+  FormatToken *Current = First->Next;
   bool InFunctionDecl = Line.MightBeFunctionDecl;
   bool AlignArrayOfStructures =
   (Style.AlignArrayOfStructures != FormatStyle::AIAS_None &&
@@ -3475,16 +3476,15 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
 if (const bool IsCtorOrDtor = Tok->is(TT_CtorDtorDeclName);
 IsCtorOrDtor ||
 isFunctionDeclarationName(Style.isCpp(), *Tok, Line, ClosingParen)) {
-  if (!IsCtorOrDtor) {
-LineIsFunctionDeclaration = true;
+  if (!IsCtorOrDtor)
 Tok->setFinalizedType(TT_FunctionDeclarationName);
-  }
+  LineIsFunctionDeclaration = true;
   SeenName = true;
   break;
 }
   }
 
-  if (IsCpp && LineIsFunctionDeclaration &&
+  if (IsCpp && (LineIsFunctionDeclaration || First->is(TT_CtorDtorDeclName)) &&
   Line.endsWith(tok::semi, tok::r_brace)) {
 auto *Tok = Line.Last->Previous;
 while (Tok->isNot(tok::r_brace))
@@ -3507,7 +3507,7 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
   if (IsCpp) {
 if (!LineIsFunctionDeclaration) {
   // Annotate */&/&& in `operator` function calls as binary operators.
-  for (const auto *Tok = Line.First; Tok; Tok = Tok->Next) {
+  for (const auto *Tok = First; Tok; Tok = Tok->Next) {
 if (Tok->isNot(tok::kw_operator))
   continue;
 do {
@@ -3644,7 +3644,7 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
 
   calculateUnbreakableTailLengths(Line);
   unsigned IndentLevel = Line.Level;
-  for (Current = Line.First; Current; Current = Current->Next) {
+  for (Current = First; Current; Current = Current->Next) {
 if (Current->Role)
   Current->Role->precomputeFormattingInfos(Current);
 if (Current->MatchingParen &&

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 67678c18963b1f..c72c9384ff91d6 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2595,6 +2595,20 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
   EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_FunctionLBrace);
   EXPECT_BRACE_KIND(Tokens[4], BK_Block);
   EXPECT_BRACE_KIND(Tokens[6], BK_Block);
+
+  Tokens = annotate("struct Foo {\n"
+"  Foo() {};\n"
+"  ~Foo() {};\n"
+"};");
+  ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::identifier, TT_CtorDtorDeclName);
+  EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_FunctionLBrace);
+  EXPECT_BRACE_KIND(Tokens[6], BK_Block);
+  EXPECT_BRACE_KIND(Tokens[7], BK_Block);
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_CtorDtorDeclName);
+  EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_FunctionLBrace);
+  EXPECT_BRACE_KIND(Tokens[13], BK_Block);
+  EXPECT_BRACE_KIND(Tokens[14], BK_Block);
 }
 
 TEST_F(TokenAnnotatorTest, StreamOperator) {

diff  --git a/polly/lib/Exchange/JSONExporter.cpp 
b/polly/lib/Exchange/JSONExporter.cpp
index 74d4e6c7993fa3..63fb06a634cc12 100644
--- a/polly/lib/Exchange/JSONExporter.cpp
+++ b/polly/lib/Exchange/JSONExporter.cpp
@@ -842,7 +842,7 @@ class JSONImporterPrinterLegacyPass final : public ScopPass 
{
 public:
   static char ID;
 
-  JSONIm

[llvm-branch-commits] [clang] [polly] release/18.x: [clang-format] Correctly annotate braces of empty ctors/dtors (#82097) (PR #87735)

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

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


[llvm-branch-commits] [libcxx] release/18.x: [libcxx] coerce formatter precision to int (#87738) (PR #87801)

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

tstellar wrote:

Is it OK to merge this with the failing test?

https://github.com/llvm/llvm-project/pull/87801
___
llvm-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: [lit][ci] Publish lit wheels (#88072) (PR #88155)

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

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

>From 9899a2d76c8f7a974c54a66b719752285dd177ef Mon Sep 17 00:00:00 2001
From: Schuyler Eldridge 
Date: Tue, 9 Apr 2024 11:55:17 -0400
Subject: [PATCH] [lit][ci] Publish lit wheels (#88072)

Add wheel publishing in addition to existing source distribution
publishing of lit.

Fixes #63369. This also uses the exact fix proposed by @EFord36 in
#63369.

Signed-off-by: Schuyler Eldridge 
(cherry picked from commit 8a8ab8f70cbb5507d1aa55efcd9c6e61ad4e891c)
---
 .github/workflows/release-lit.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/release-lit.yml 
b/.github/workflows/release-lit.yml
index 36b0b6edd518fc..0316ba406041d6 100644
--- a/.github/workflows/release-lit.yml
+++ b/.github/workflows/release-lit.yml
@@ -58,7 +58,7 @@ jobs:
   cd llvm/utils/lit
   # Remove 'dev' suffix from lit version.
   sed -i 's/ + "dev"//g' lit/__init__.py
-  python3 setup.py sdist
+  python3 setup.py sdist bdist_wheel
 
   - name: Upload lit to test.pypi.org
 uses: pypa/gh-action-pypi-publish@release/v1

___
llvm-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: [lit][ci] Publish lit wheels (#88072) (PR #88155)

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

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


[llvm-branch-commits] [libcxx] release/18.x: [libc++] Simplify the implementation of (#86843) (PR #87374)

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

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

>From bffecba7ce4cf4e3e8b9961fb6dc84d6cf8f680e Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Tue, 2 Apr 2024 08:14:04 -0400
Subject: [PATCH] [libc++] Simplify the implementation of  (#86843)

Libc++'s own  is complicated by the need to handle various
platform-specific macros and to support duplicate inclusion. In reality,
we only need to add a declaration of nullptr_t to it, so we can simply
include the underlying  outside of our guards to let it handle
re-inclusion itself.

(cherry picked from commit 2950283dddab03c183c1be2d7de9d4999cc86131)
---
 libcxx/include/stddef.h | 25 -
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h
index 887776b150e49d..470b5408336c6d 100644
--- a/libcxx/include/stddef.h
+++ b/libcxx/include/stddef.h
@@ -7,18 +7,6 @@
 //
 
//===--===//
 
-#if defined(__need_ptrdiff_t) || defined(__need_size_t) || 
defined(__need_wchar_t) || defined(__need_NULL) ||  \
-defined(__need_wint_t)
-
-#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#  endif
-
-#  include_next 
-
-#elif !defined(_LIBCPP_STDDEF_H)
-#  define _LIBCPP_STDDEF_H
-
 /*
 stddef.h synopsis
 
@@ -36,16 +24,19 @@
 
 */
 
-#  include <__config>
+#include <__config>
+
+// Note: This include is outside of header guards because we sometimes get 
included multiple times
+//   with different defines and the underlying  will know how to 
deal with that.
+#include_next 
+
+#ifndef _LIBCPP_STDDEF_H
+#  define _LIBCPP_STDDEF_H
 
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #  endif
 
-#  if __has_include_next()
-#include_next 
-#  endif
-
 #  ifdef __cplusplus
 typedef decltype(nullptr) nullptr_t;
 #  endif

___
llvm-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] bffecba - [libc++] Simplify the implementation of (#86843)

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

Author: Louis Dionne
Date: 2024-04-10T15:09:27-07:00
New Revision: bffecba7ce4cf4e3e8b9961fb6dc84d6cf8f680e

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

LOG: [libc++] Simplify the implementation of  (#86843)

Libc++'s own  is complicated by the need to handle various
platform-specific macros and to support duplicate inclusion. In reality,
we only need to add a declaration of nullptr_t to it, so we can simply
include the underlying  outside of our guards to let it handle
re-inclusion itself.

(cherry picked from commit 2950283dddab03c183c1be2d7de9d4999cc86131)

Added: 


Modified: 
libcxx/include/stddef.h

Removed: 




diff  --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h
index 887776b150e49d..470b5408336c6d 100644
--- a/libcxx/include/stddef.h
+++ b/libcxx/include/stddef.h
@@ -7,18 +7,6 @@
 //
 
//===--===//
 
-#if defined(__need_ptr
diff _t) || defined(__need_size_t) || defined(__need_wchar_t) || 
defined(__need_NULL) ||  \
-defined(__need_wint_t)
-
-#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#  endif
-
-#  include_next 
-
-#elif !defined(_LIBCPP_STDDEF_H)
-#  define _LIBCPP_STDDEF_H
-
 /*
 stddef.h synopsis
 
@@ -36,16 +24,19 @@
 
 */
 
-#  include <__config>
+#include <__config>
+
+// Note: This include is outside of header guards because we sometimes get 
included multiple times
+//   with 
diff erent defines and the underlying  will know how to deal with 
that.
+#include_next 
+
+#ifndef _LIBCPP_STDDEF_H
+#  define _LIBCPP_STDDEF_H
 
 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #  endif
 
-#  if __has_include_next()
-#include_next 
-#  endif
-
 #  ifdef __cplusplus
 typedef decltype(nullptr) nullptr_t;
 #  endif



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


[llvm-branch-commits] [libcxx] release/18.x: [libc++] Simplify the implementation of (#86843) (PR #87374)

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

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/87374
___
llvm-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: [SLP]Fix a crash if the argument of call was affected by minbitwidth analysis (PR #86731)

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

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

>From a382bc2d50a9a3379fe9f5f104b75ddbcbb6ad03 Mon Sep 17 00:00:00 2001
From: Alexey Bataev 
Date: Thu, 21 Mar 2024 17:05:50 -0700
Subject: [PATCH] [SLP]Fix a crash if the argument of call was affected by
 minbitwidth analysis.

Need to support proper type conversion for function arguments to avoid
compiler crash.
---
 .../Transforms/Vectorize/SLPVectorizer.cpp| 21 -
 .../X86/call-arg-reduced-by-minbitwidth.ll| 82 +++
 2 files changed, 102 insertions(+), 1 deletion(-)
 create mode 100644 
llvm/test/Transforms/SLPVectorizer/X86/call-arg-reduced-by-minbitwidth.ll

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 0a9e2c7f49f55f..1fbd69e38eaeec 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11653,12 +11653,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool 
PostponedPHIs) {
   if (UseIntrinsic && isVectorIntrinsicWithOverloadTypeAtArg(ID, -1))
 TysForDecl.push_back(
 FixedVectorType::get(CI->getType(), E->Scalars.size()));
+  auto *CEI = cast(VL0);
   for (unsigned I : seq(0, CI->arg_size())) {
 ValueList OpVL;
 // Some intrinsics have scalar arguments. This argument should not be
 // vectorized.
 if (UseIntrinsic && isVectorIntrinsicWithScalarOpAtArg(ID, I)) {
-  CallInst *CEI = cast(VL0);
   ScalarArg = CEI->getArgOperand(I);
   OpVecs.push_back(CEI->getArgOperand(I));
   if (isVectorIntrinsicWithOverloadTypeAtArg(ID, I))
@@ -11671,6 +11671,25 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool 
PostponedPHIs) {
   LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n");
   return E->VectorizedValue;
 }
+auto GetOperandSignedness = [&](unsigned Idx) {
+  const TreeEntry *OpE = getOperandEntry(E, Idx);
+  bool IsSigned = false;
+  auto It = MinBWs.find(OpE);
+  if (It != MinBWs.end())
+IsSigned = It->second.second;
+  else
+IsSigned = any_of(OpE->Scalars, [&](Value *R) {
+  return !isKnownNonNegative(R, SimplifyQuery(*DL));
+});
+  return IsSigned;
+};
+ScalarArg = CEI->getArgOperand(I);
+if (cast(OpVec->getType())->getElementType() !=
+ScalarArg->getType()) {
+  auto *CastTy = FixedVectorType::get(ScalarArg->getType(),
+  VecTy->getNumElements());
+  OpVec = Builder.CreateIntCast(OpVec, CastTy, 
GetOperandSignedness(I));
+}
 LLVM_DEBUG(dbgs() << "SLP: OpVec[" << I << "]: " << *OpVec << "\n");
 OpVecs.push_back(OpVec);
 if (UseIntrinsic && isVectorIntrinsicWithOverloadTypeAtArg(ID, I))
diff --git 
a/llvm/test/Transforms/SLPVectorizer/X86/call-arg-reduced-by-minbitwidth.ll 
b/llvm/test/Transforms/SLPVectorizer/X86/call-arg-reduced-by-minbitwidth.ll
new file mode 100644
index 00..49e89feb475b95
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/X86/call-arg-reduced-by-minbitwidth.ll
@@ -0,0 +1,82 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-pc-windows-msvc19.34.0 < 
%s | FileCheck %s
+
+define void @test(ptr %0, i8 %1, i1 %cmp12.i) {
+; CHECK-LABEL: define void @test(
+; CHECK-SAME: ptr [[TMP0:%.*]], i8 [[TMP1:%.*]], i1 [[CMP12_I:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP2:%.*]] = insertelement <8 x i1> poison, i1 [[CMP12_I]], 
i32 0
+; CHECK-NEXT:[[TMP3:%.*]] = shufflevector <8 x i1> [[TMP2]], <8 x i1> 
poison, <8 x i32> zeroinitializer
+; CHECK-NEXT:[[TMP4:%.*]] = insertelement <8 x i8> poison, i8 [[TMP1]], 
i32 0
+; CHECK-NEXT:[[TMP5:%.*]] = shufflevector <8 x i8> [[TMP4]], <8 x i8> 
poison, <8 x i32> zeroinitializer
+; CHECK-NEXT:br label [[PRE:%.*]]
+; CHECK:   pre:
+; CHECK-NEXT:[[TMP6:%.*]] = zext <8 x i8> [[TMP5]] to <8 x i32>
+; CHECK-NEXT:[[TMP7:%.*]] = call <8 x i32> @llvm.umax.v8i32(<8 x i32> 
[[TMP6]], <8 x i32> )
+; CHECK-NEXT:[[TMP8:%.*]] = add <8 x i32> [[TMP7]], 
+; CHECK-NEXT:[[TMP9:%.*]] = select <8 x i1> [[TMP3]], <8 x i32> [[TMP8]], 
<8 x i32> [[TMP6]]
+; CHECK-NEXT:[[TMP10:%.*]] = trunc <8 x i32> [[TMP9]] to <8 x i8>
+; CHECK-NEXT:store <8 x i8> [[TMP10]], ptr [[TMP0]], align 1
+; CHECK-NEXT:br label [[PRE]]
+;
+entry:
+  %idx11 = getelementptr i8, ptr %0, i64 1
+  %idx22 = getelementptr i8, ptr %0, i64 2
+  %idx33 = getelementptr i8, ptr %0, i64 3
+  %idx44 = getelementptr i8, ptr %0, i64 4
+  %idx55 = getelementptr i8, ptr %0, i64 5
+  %idx66 = getelementptr i8, ptr %0, i64 6
+  %idx77 = getelementptr i8, ptr %0, i64 7
+  br label %pre
+
+pre:
+  %conv.i = zext i8 %1 to i32
+  %2 = tail call i

[llvm-branch-commits] [libcxx] release/18.x: [libcxx] coerce formatter precision to int (#87738) (PR #87801)

2024-04-10 Thread Brian Cain via llvm-branch-commits

androm3da wrote:

> Is it OK to merge this with the failing test?

is it possible this was a fix for an XFAIL @mordante ?

https://github.com/llvm/llvm-project/pull/87801
___
llvm-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: [SPARC] Implement L and H inline asm argument modifiers (#87259) (PR #87714)

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

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

>From b6ebea7972cd05a8e4dcf0d5a54f2c79395a Mon Sep 17 00:00:00 2001
From: Koakuma 
Date: Fri, 5 Apr 2024 04:34:07 +0700
Subject: [PATCH] [SPARC] Implement L and H inline asm argument modifiers
 (#87259)

This adds support for using the L and H argument modifiers for twinword
operands in inline asm code, such as in:

```
%1 = tail call i64 asm sideeffect "rd %pc, ${0:L} ; srlx ${0:L}, 32, ${0:H}", 
"={o4}"()
```

This is needed by the Linux kernel.

(cherry picked from commit 697dd93ae30f489e5bcdac74c2ef2d876e3ca064)
---
 llvm/docs/LangRef.rst |  2 ++
 llvm/lib/Target/Sparc/SparcAsmPrinter.cpp | 44 +++
 llvm/test/CodeGen/SPARC/inlineasm-bad.ll  |  9 +
 llvm/test/CodeGen/SPARC/inlineasm.ll  |  9 +
 4 files changed, 64 insertions(+)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7a7ddc59ba985d..74b0439da7fc58 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5499,6 +5499,8 @@ RISC-V:
 
 Sparc:
 
+- ``L``: Print the low-order register of a two-register operand.
+- ``H``: Print the high-order register of a two-register operand.
 - ``r``: No effect.
 
 SystemZ:
diff --git a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp 
b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
index 215a8ea8319046..6855471840e9db 100644
--- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
+++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
@@ -434,6 +434,50 @@ bool SparcAsmPrinter::PrintAsmOperand(const MachineInstr 
*MI, unsigned OpNo,
 default:
   // See if this is a generic print operand
   return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, O);
+case 'L': // Low order register of a twin word register operand
+case 'H': // High order register of a twin word register operand
+{
+  const SparcSubtarget &Subtarget = MF->getSubtarget();
+  const MachineOperand &MO = MI->getOperand(OpNo);
+  const SparcRegisterInfo *RegisterInfo = Subtarget.getRegisterInfo();
+  Register MOReg = MO.getReg();
+
+  Register HiReg, LoReg;
+  if (!SP::IntPairRegClass.contains(MOReg)) {
+// If we aren't given a register pair already, find out which pair it
+// belongs to. Note that here, the specified register operand, which
+// refers to the high part of the twinword, needs to be an 
even-numbered
+// register.
+MOReg = RegisterInfo->getMatchingSuperReg(MOReg, SP::sub_even,
+  &SP::IntPairRegClass);
+if (!MOReg) {
+  SMLoc Loc;
+  OutContext.reportError(
+  Loc, "Hi part of pair should point to an even-numbered 
register");
+  OutContext.reportError(
+  Loc, "(note that in some cases it might be necessary to manually 
"
+   "bind the input/output registers instead of relying on "
+   "automatic allocation)");
+  return true;
+}
+  }
+
+  HiReg = RegisterInfo->getSubReg(MOReg, SP::sub_even);
+  LoReg = RegisterInfo->getSubReg(MOReg, SP::sub_odd);
+
+  Register Reg;
+  switch (ExtraCode[0]) {
+  case 'L':
+Reg = LoReg;
+break;
+  case 'H':
+Reg = HiReg;
+break;
+  }
+
+  O << '%' << SparcInstPrinter::getRegisterName(Reg);
+  return false;
+}
 case 'f':
 case 'r':
  break;
diff --git a/llvm/test/CodeGen/SPARC/inlineasm-bad.ll 
b/llvm/test/CodeGen/SPARC/inlineasm-bad.ll
index 5bf2adbeb75c95..07eb67df6e5f7e 100644
--- a/llvm/test/CodeGen/SPARC/inlineasm-bad.ll
+++ b/llvm/test/CodeGen/SPARC/inlineasm-bad.ll
@@ -11,3 +11,12 @@ entry:
   tail call void asm sideeffect "faddq $0,$1,$2", "{f38},{f0},{f0}"(fp128 
0xL0, fp128 0xL0, fp128 0xL0)
   ret void
 }
+
+; CHECK-label:test_twinword_error
+; CHECK: error: Hi part of pair should point to an even-numbered register
+; CHECK: error: (note that in some cases it might be necessary to manually 
bind the input/output registers instead of relying on automatic allocation)
+
+define i64 @test_twinword_error(){
+  %1 = tail call i64 asm sideeffect "rd %asr5, ${0:L} \0A\09 srlx ${0:L}, 32, 
${0:H}", "={i1}"()
+  ret i64 %1
+}
diff --git a/llvm/test/CodeGen/SPARC/inlineasm.ll 
b/llvm/test/CodeGen/SPARC/inlineasm.ll
index 8bf34bf1609c18..efb7f7c15220c2 100644
--- a/llvm/test/CodeGen/SPARC/inlineasm.ll
+++ b/llvm/test/CodeGen/SPARC/inlineasm.ll
@@ -143,3 +143,12 @@ entry:
   %1 = call double asm sideeffect "faddd $1, $2, $0", "=f,f,e"(i64 0, i64 0)
   ret void
 }
+
+; CHECK-label:test_twinword
+; CHECK: rd  %asr5, %i1
+; CHECK: srlx %i1, 32, %i0
+
+define i64 @test_twinword(){
+  %1 = tail call i64 asm sideeffect "rd %asr5, ${0:L} \0A\09 srlx ${0:L}, 32, 
${0:H}", "={i0}"()
+  ret i64 %1
+}

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

[llvm-branch-commits] [llvm] b6ebea7 - [SPARC] Implement L and H inline asm argument modifiers (#87259)

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

Author: Koakuma
Date: 2024-04-10T15:20:57-07:00
New Revision: b6ebea7972cd05a8e4dcf0d5a54f2c79395a

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

LOG: [SPARC] Implement L and H inline asm argument modifiers (#87259)

This adds support for using the L and H argument modifiers for twinword
operands in inline asm code, such as in:

```
%1 = tail call i64 asm sideeffect "rd %pc, ${0:L} ; srlx ${0:L}, 32, ${0:H}", 
"={o4}"()
```

This is needed by the Linux kernel.

(cherry picked from commit 697dd93ae30f489e5bcdac74c2ef2d876e3ca064)

Added: 


Modified: 
llvm/docs/LangRef.rst
llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
llvm/test/CodeGen/SPARC/inlineasm-bad.ll
llvm/test/CodeGen/SPARC/inlineasm.ll

Removed: 




diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 7a7ddc59ba985d..74b0439da7fc58 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5499,6 +5499,8 @@ RISC-V:
 
 Sparc:
 
+- ``L``: Print the low-order register of a two-register operand.
+- ``H``: Print the high-order register of a two-register operand.
 - ``r``: No effect.
 
 SystemZ:

diff  --git a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp 
b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
index 215a8ea8319046..6855471840e9db 100644
--- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
+++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
@@ -434,6 +434,50 @@ bool SparcAsmPrinter::PrintAsmOperand(const MachineInstr 
*MI, unsigned OpNo,
 default:
   // See if this is a generic print operand
   return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, O);
+case 'L': // Low order register of a twin word register operand
+case 'H': // High order register of a twin word register operand
+{
+  const SparcSubtarget &Subtarget = MF->getSubtarget();
+  const MachineOperand &MO = MI->getOperand(OpNo);
+  const SparcRegisterInfo *RegisterInfo = Subtarget.getRegisterInfo();
+  Register MOReg = MO.getReg();
+
+  Register HiReg, LoReg;
+  if (!SP::IntPairRegClass.contains(MOReg)) {
+// If we aren't given a register pair already, find out which pair it
+// belongs to. Note that here, the specified register operand, which
+// refers to the high part of the twinword, needs to be an 
even-numbered
+// register.
+MOReg = RegisterInfo->getMatchingSuperReg(MOReg, SP::sub_even,
+  &SP::IntPairRegClass);
+if (!MOReg) {
+  SMLoc Loc;
+  OutContext.reportError(
+  Loc, "Hi part of pair should point to an even-numbered 
register");
+  OutContext.reportError(
+  Loc, "(note that in some cases it might be necessary to manually 
"
+   "bind the input/output registers instead of relying on "
+   "automatic allocation)");
+  return true;
+}
+  }
+
+  HiReg = RegisterInfo->getSubReg(MOReg, SP::sub_even);
+  LoReg = RegisterInfo->getSubReg(MOReg, SP::sub_odd);
+
+  Register Reg;
+  switch (ExtraCode[0]) {
+  case 'L':
+Reg = LoReg;
+break;
+  case 'H':
+Reg = HiReg;
+break;
+  }
+
+  O << '%' << SparcInstPrinter::getRegisterName(Reg);
+  return false;
+}
 case 'f':
 case 'r':
  break;

diff  --git a/llvm/test/CodeGen/SPARC/inlineasm-bad.ll 
b/llvm/test/CodeGen/SPARC/inlineasm-bad.ll
index 5bf2adbeb75c95..07eb67df6e5f7e 100644
--- a/llvm/test/CodeGen/SPARC/inlineasm-bad.ll
+++ b/llvm/test/CodeGen/SPARC/inlineasm-bad.ll
@@ -11,3 +11,12 @@ entry:
   tail call void asm sideeffect "faddq $0,$1,$2", "{f38},{f0},{f0}"(fp128 
0xL0, fp128 0xL0, fp128 0xL0)
   ret void
 }
+
+; CHECK-label:test_twinword_error
+; CHECK: error: Hi part of pair should point to an even-numbered register
+; CHECK: error: (note that in some cases it might be necessary to manually 
bind the input/output registers instead of relying on automatic allocation)
+
+define i64 @test_twinword_error(){
+  %1 = tail call i64 asm sideeffect "rd %asr5, ${0:L} \0A\09 srlx ${0:L}, 32, 
${0:H}", "={i1}"()
+  ret i64 %1
+}

diff  --git a/llvm/test/CodeGen/SPARC/inlineasm.ll 
b/llvm/test/CodeGen/SPARC/inlineasm.ll
index 8bf34bf1609c18..efb7f7c15220c2 100644
--- a/llvm/test/CodeGen/SPARC/inlineasm.ll
+++ b/llvm/test/CodeGen/SPARC/inlineasm.ll
@@ -143,3 +143,12 @@ entry:
   %1 = call double asm sideeffect "faddd $1, $2, $0", "=f,f,e"(i64 0, i64 0)
   ret void
 }
+
+; CHECK-label:test_twinword
+; CHECK: rd  %asr5, %i1
+; CHECK: srlx %i1, 32, %i0
+
+define i64 @test_twinword(){
+  %1 = tail call i64 asm sideeffect "rd %asr5, ${0:L} \0A\09 srlx ${0:L}, 32, 
${0:H}", "={i0}"()
+  ret i64 %1
+}



___
llvm-branch-c

[llvm-branch-commits] [llvm] release/18.x: [SPARC] Implement L and H inline asm argument modifiers (#87259) (PR #87714)

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

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


[llvm-branch-commits] [libcxx] release/18.x: [libc++] Simplify the implementation of (#86843) (PR #87374)

2024-04-10 Thread Nico Weber via llvm-branch-commits

nico wrote:

As mentioned on #86843, this breaks using `-pedantic` in code that includes 
libc++ headers. Since this got cherry-picked (…why? doesn't seem urgent?), we 
also must cherry-pick #88214.

https://github.com/llvm/llvm-project/pull/87374
___
llvm-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: [lit][ci] Publish lit wheels (#88072) (PR #88155)

2024-04-10 Thread Schuyler Eldridge via llvm-branch-commits

seldridge wrote:

Thanks for getting this in @tru and @tstellar!

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


[llvm-branch-commits] [libcxx] release/18.x: [libc++] Simplify the implementation of (#86843) (PR #87374)

2024-04-10 Thread Ian Anderson via llvm-branch-commits

ian-twilightcoder wrote:

Well, I wish I would've known that. We cherry-picked it because it's a 
regression that was introduced in LLVM 18, and I am worried that it will cause 
issues on some platforms.

https://github.com/llvm/llvm-project/pull/87374
___
llvm-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: [MIPS] Fix the opcode of max.fmt and mina.fmt (#85609) (PR #88337)

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

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

Backport 8b859c6e4a8e9ab9969582267bbdc04ed6bfa535

Requested by: @brad0

>From 0c42fff26e09d719c8f67e3e5d812fe7d70af984 Mon Sep 17 00:00:00 2001
From: Cinhi Young 
Date: Wed, 3 Apr 2024 10:14:02 +0800
Subject: [PATCH] [MIPS] Fix the opcode of max.fmt and mina.fmt (#85609)

- The opcode of the mina.fmt and max.fmt is documented wrong, the
  object code compiled from the same assembly with LLVM behaves
  differently than one compiled with GCC and Binutils.
- Modify the opcodes to match Binutils. The actual opcodes are as
follows:

  {5,3} | bits {2,0} of func
   |...   | 100  | 101| 110   | 111
  -+-+-+-+-+-
   010  |   ...   |  min  | mina | max  | maxa

(cherry picked from commit 8b859c6e4a8e9ab9969582267bbdc04ed6bfa535)
---
 llvm/lib/Target/Mips/Mips32r6InstrInfo.td | 8 
 .../MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt   | 8 
 .../test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt | 8 
 .../MC/Disassembler/Mips/mips64r6/valid-mips64r6-el.txt   | 8 
 .../test/MC/Disassembler/Mips/mips64r6/valid-mips64r6.txt | 8 
 llvm/test/MC/Mips/mips32r6/valid.s| 8 
 llvm/test/MC/Mips/mips64r6/valid.s| 8 
 7 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/llvm/lib/Target/Mips/Mips32r6InstrInfo.td 
b/llvm/lib/Target/Mips/Mips32r6InstrInfo.td
index 854563ab32bd8e..3ef04e488f016f 100644
--- a/llvm/lib/Target/Mips/Mips32r6InstrInfo.td
+++ b/llvm/lib/Target/Mips/Mips32r6InstrInfo.td
@@ -152,15 +152,15 @@ class SELNEZ_ENC : SPECIAL_3R_FM<0b0, 0b110111>;
 
 class LWPC_ENC   : PCREL19_FM;
 
-class MAX_S_ENC : COP1_3R_FM<0b011101, FIELD_FMT_S>;
-class MAX_D_ENC : COP1_3R_FM<0b011101, FIELD_FMT_D>;
+class MAX_S_ENC : COP1_3R_FM<0b00, FIELD_FMT_S>;
+class MAX_D_ENC : COP1_3R_FM<0b00, FIELD_FMT_D>;
 class MIN_S_ENC : COP1_3R_FM<0b011100, FIELD_FMT_S>;
 class MIN_D_ENC : COP1_3R_FM<0b011100, FIELD_FMT_D>;
 
 class MAXA_S_ENC : COP1_3R_FM<0b01, FIELD_FMT_S>;
 class MAXA_D_ENC : COP1_3R_FM<0b01, FIELD_FMT_D>;
-class MINA_S_ENC : COP1_3R_FM<0b00, FIELD_FMT_S>;
-class MINA_D_ENC : COP1_3R_FM<0b00, FIELD_FMT_D>;
+class MINA_S_ENC : COP1_3R_FM<0b011101, FIELD_FMT_S>;
+class MINA_D_ENC : COP1_3R_FM<0b011101, FIELD_FMT_D>;
 
 class SELEQZ_S_ENC : COP1_3R_FM<0b010100, FIELD_FMT_S>;
 class SELEQZ_D_ENC : COP1_3R_FM<0b010100, FIELD_FMT_D>;
diff --git a/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt 
b/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt
index 1a73178a1f6a7e..d6f10e96d4769f 100644
--- a/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt
+++ b/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt
@@ -116,14 +116,14 @@
 0x10 0x08 0x02 0x46 # CHECK: sel.s $f0, $f1, $f2
 0x35 0x10 0x64 0x00 # CHECK: seleqz $2, $3, $4
 0x37 0x10 0x64 0x00 # CHECK: selnez $2, $3, $4
-0x1d 0x10 0x04 0x46 # CHECK: max.s $f0, $f2, $f4
-0x1d 0x10 0x24 0x46 # CHECK: max.d $f0, $f2, $f4
 0x1c 0x10 0x04 0x46 # CHECK: min.s $f0, $f2, $f4
 0x1c 0x10 0x24 0x46 # CHECK: min.d $f0, $f2, $f4
+0x1d 0x10 0x04 0x46 # CHECK: mina.s $f0, $f2, $f4
+0x1d 0x10 0x24 0x46 # CHECK: mina.d $f0, $f2, $f4
+0x1e 0x10 0x04 0x46 # CHECK: max.s $f0, $f2, $f4
+0x1e 0x10 0x24 0x46 # CHECK: max.d $f0, $f2, $f4
 0x1f 0x10 0x04 0x46 # CHECK: maxa.s $f0, $f2, $f4
 0x1f 0x10 0x24 0x46 # CHECK: maxa.d $f0, $f2, $f4
-0x1e 0x10 0x04 0x46 # CHECK: mina.s $f0, $f2, $f4
-0x1e 0x10 0x24 0x46 # CHECK: mina.d $f0, $f2, $f4
 0x04 0x00 0x42 0x34 # CHECK: ori $2, $2, 4
 0x14 0x10 0x04 0x46 # CHECK: seleqz.s $f0, $f2, $f4
 0x14 0x10 0x24 0x46 # CHECK: seleqz.d $f0, $f2, $f4
diff --git a/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt 
b/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt
index 53ea0258e1c4bc..e1ba009f3c4c8c 100644
--- a/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt
+++ b/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt
@@ -92,8 +92,8 @@
 0x46 0x04 0x10 0x14 # CHECK: seleqz.s $f0, $f2, $f4
 0x46 0x04 0x10 0x17 # CHECK: selnez.s $f0, $f2, $f4
 0x46 0x04 0x10 0x1c # CHECK: min.s $f0, $f2, $f4
-0x46 0x04 0x10 0x1d # CHECK: max.s $f0, $f2, $f4
-0x46 0x04 0x10 0x1e # CHECK: mina.s $f0, $f2, $f4
+0x46 0x04 0x10 0x1d # CHECK: mina.s $f0, $f2, $f4
+0x46 0x04 0x10 0x1e # CHECK: max.s $f0, $f2, $f4
 0x46 0x04 0x10 0x1f # CHECK: maxa.s $f0, $f2, $f4
 0x46 0x04 0x18 0x98 # CHECK: maddf.s $f2, $f3, $f4
 0x46 0x04 0x18 0x99 # CHECK: msubf.s $f2, $f3, $f4
@@ -103,8 +103,8 @@
 0x46 0x24 0x10 0x14 # CHECK: seleqz.d $f0, $f2, $f4
 0x46 0x24 0x10 0x17 # CHECK: selnez.d $f0, $f2, $f4
 0x46 0x24 0x10 0x1c # CHECK: min.d $f0, $f2, $f4
-0x46 0x24 0x10 0x1d # CHECK: max.d $f0, $f2, $f4
-0x46 0x24 0x10 0x1e # CHECK: mina.d $f0, $f2, $f4
+0x46 0x24 0x10 0x1d # CHECK: mina.d $f0, $f2, $f4
+0x46 0x24 0x10 0x1e # CHECK: max.d $f0, $f2, $

[llvm-branch-commits] [llvm] release/18.x: [MIPS] Fix the opcode of max.fmt and mina.fmt (#85609) (PR #88337)

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

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/88337
___
llvm-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: [MIPS] Fix the opcode of max.fmt and mina.fmt (#85609) (PR #88337)

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

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: None (llvmbot)


Changes

Backport 8b859c6e4a8e9ab9969582267bbdc04ed6bfa535

Requested by: @brad0

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


7 Files Affected:

- (modified) llvm/lib/Target/Mips/Mips32r6InstrInfo.td (+4-4) 
- (modified) llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt 
(+4-4) 
- (modified) llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt (+4-4) 
- (modified) llvm/test/MC/Disassembler/Mips/mips64r6/valid-mips64r6-el.txt 
(+4-4) 
- (modified) llvm/test/MC/Disassembler/Mips/mips64r6/valid-mips64r6.txt (+4-4) 
- (modified) llvm/test/MC/Mips/mips32r6/valid.s (+4-4) 
- (modified) llvm/test/MC/Mips/mips64r6/valid.s (+4-4) 


``diff
diff --git a/llvm/lib/Target/Mips/Mips32r6InstrInfo.td 
b/llvm/lib/Target/Mips/Mips32r6InstrInfo.td
index 854563ab32bd8e..3ef04e488f016f 100644
--- a/llvm/lib/Target/Mips/Mips32r6InstrInfo.td
+++ b/llvm/lib/Target/Mips/Mips32r6InstrInfo.td
@@ -152,15 +152,15 @@ class SELNEZ_ENC : SPECIAL_3R_FM<0b0, 0b110111>;
 
 class LWPC_ENC   : PCREL19_FM;
 
-class MAX_S_ENC : COP1_3R_FM<0b011101, FIELD_FMT_S>;
-class MAX_D_ENC : COP1_3R_FM<0b011101, FIELD_FMT_D>;
+class MAX_S_ENC : COP1_3R_FM<0b00, FIELD_FMT_S>;
+class MAX_D_ENC : COP1_3R_FM<0b00, FIELD_FMT_D>;
 class MIN_S_ENC : COP1_3R_FM<0b011100, FIELD_FMT_S>;
 class MIN_D_ENC : COP1_3R_FM<0b011100, FIELD_FMT_D>;
 
 class MAXA_S_ENC : COP1_3R_FM<0b01, FIELD_FMT_S>;
 class MAXA_D_ENC : COP1_3R_FM<0b01, FIELD_FMT_D>;
-class MINA_S_ENC : COP1_3R_FM<0b00, FIELD_FMT_S>;
-class MINA_D_ENC : COP1_3R_FM<0b00, FIELD_FMT_D>;
+class MINA_S_ENC : COP1_3R_FM<0b011101, FIELD_FMT_S>;
+class MINA_D_ENC : COP1_3R_FM<0b011101, FIELD_FMT_D>;
 
 class SELEQZ_S_ENC : COP1_3R_FM<0b010100, FIELD_FMT_S>;
 class SELEQZ_D_ENC : COP1_3R_FM<0b010100, FIELD_FMT_D>;
diff --git a/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt 
b/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt
index 1a73178a1f6a7e..d6f10e96d4769f 100644
--- a/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt
+++ b/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt
@@ -116,14 +116,14 @@
 0x10 0x08 0x02 0x46 # CHECK: sel.s $f0, $f1, $f2
 0x35 0x10 0x64 0x00 # CHECK: seleqz $2, $3, $4
 0x37 0x10 0x64 0x00 # CHECK: selnez $2, $3, $4
-0x1d 0x10 0x04 0x46 # CHECK: max.s $f0, $f2, $f4
-0x1d 0x10 0x24 0x46 # CHECK: max.d $f0, $f2, $f4
 0x1c 0x10 0x04 0x46 # CHECK: min.s $f0, $f2, $f4
 0x1c 0x10 0x24 0x46 # CHECK: min.d $f0, $f2, $f4
+0x1d 0x10 0x04 0x46 # CHECK: mina.s $f0, $f2, $f4
+0x1d 0x10 0x24 0x46 # CHECK: mina.d $f0, $f2, $f4
+0x1e 0x10 0x04 0x46 # CHECK: max.s $f0, $f2, $f4
+0x1e 0x10 0x24 0x46 # CHECK: max.d $f0, $f2, $f4
 0x1f 0x10 0x04 0x46 # CHECK: maxa.s $f0, $f2, $f4
 0x1f 0x10 0x24 0x46 # CHECK: maxa.d $f0, $f2, $f4
-0x1e 0x10 0x04 0x46 # CHECK: mina.s $f0, $f2, $f4
-0x1e 0x10 0x24 0x46 # CHECK: mina.d $f0, $f2, $f4
 0x04 0x00 0x42 0x34 # CHECK: ori $2, $2, 4
 0x14 0x10 0x04 0x46 # CHECK: seleqz.s $f0, $f2, $f4
 0x14 0x10 0x24 0x46 # CHECK: seleqz.d $f0, $f2, $f4
diff --git a/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt 
b/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt
index 53ea0258e1c4bc..e1ba009f3c4c8c 100644
--- a/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt
+++ b/llvm/test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt
@@ -92,8 +92,8 @@
 0x46 0x04 0x10 0x14 # CHECK: seleqz.s $f0, $f2, $f4
 0x46 0x04 0x10 0x17 # CHECK: selnez.s $f0, $f2, $f4
 0x46 0x04 0x10 0x1c # CHECK: min.s $f0, $f2, $f4
-0x46 0x04 0x10 0x1d # CHECK: max.s $f0, $f2, $f4
-0x46 0x04 0x10 0x1e # CHECK: mina.s $f0, $f2, $f4
+0x46 0x04 0x10 0x1d # CHECK: mina.s $f0, $f2, $f4
+0x46 0x04 0x10 0x1e # CHECK: max.s $f0, $f2, $f4
 0x46 0x04 0x10 0x1f # CHECK: maxa.s $f0, $f2, $f4
 0x46 0x04 0x18 0x98 # CHECK: maddf.s $f2, $f3, $f4
 0x46 0x04 0x18 0x99 # CHECK: msubf.s $f2, $f3, $f4
@@ -103,8 +103,8 @@
 0x46 0x24 0x10 0x14 # CHECK: seleqz.d $f0, $f2, $f4
 0x46 0x24 0x10 0x17 # CHECK: selnez.d $f0, $f2, $f4
 0x46 0x24 0x10 0x1c # CHECK: min.d $f0, $f2, $f4
-0x46 0x24 0x10 0x1d # CHECK: max.d $f0, $f2, $f4
-0x46 0x24 0x10 0x1e # CHECK: mina.d $f0, $f2, $f4
+0x46 0x24 0x10 0x1d # CHECK: mina.d $f0, $f2, $f4
+0x46 0x24 0x10 0x1e # CHECK: max.d $f0, $f2, $f4
 0x46 0x24 0x10 0x1f # CHECK: maxa.d $f0, $f2, $f4
 0x46 0x24 0x18 0x98 # CHECK: maddf.d $f2, $f3, $f4
 0x46 0x24 0x18 0x99 # CHECK: msubf.d $f2, $f3, $f4
diff --git a/llvm/test/MC/Disassembler/Mips/mips64r6/valid-mips64r6-el.txt 
b/llvm/test/MC/Disassembler/Mips/mips64r6/valid-mips64r6-el.txt
index 9aeea45472aebb..a7dfbd209b4e48 100644
--- a/llvm/test/MC/Disassembler/Mips/mips64r6/valid-mips64r6-el.txt
+++ b/llvm/test/MC/Disassembler/Mips/mips64r6/valid-mips64r6-el.txt
@@ -140,15 +140,15 @@
 0x43 0x00 0x50 0xec # CHECK: lwupc $2, 268
 0x98 0x18 0x24 0x46 # CHECK: maddf.d $f2, $f3, $f4
 0x98 0x18 0x04 0x46 # CHECK: maddf.s $f2, $f3, $f4
-0x1d 0x1

[llvm-branch-commits] [llvm] release/18.x: [InstSimplify] Make sure the simplified value doesn't generate poison in threadBinOpOverSelect (#87075) (PR #88353)

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

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

Backport 3197f9d8b0efc3efdc531421bd11c16305d9b1ff

Requested by: @dtcxzyw

>From 48de8d747178760702f12bb681b1e35c92f21376 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Thu, 11 Apr 2024 12:48:52 +0800
Subject: [PATCH] [InstSimplify] Make sure the simplified value doesn't
 generate poison in threadBinOpOverSelect (#87075)

Alive2: https://alive2.llvm.org/ce/z/y_Jmdn
Fix https://github.com/llvm/llvm-project/issues/87042.

(cherry picked from commit 3197f9d8b0efc3efdc531421bd11c16305d9b1ff)
---
 llvm/lib/Analysis/InstructionSimplify.cpp|  3 +-
 llvm/test/Transforms/InstSimplify/pr87042.ll | 42 
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/Transforms/InstSimplify/pr87042.ll

diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp 
b/llvm/lib/Analysis/InstructionSimplify.cpp
index d0c27cae0dff99..72b6dfa181e86d 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -439,7 +439,8 @@ static Value *threadBinOpOverSelect(Instruction::BinaryOps 
Opcode, Value *LHS,
 // Check that the simplified value has the form "X op Y" where "op" is the
 // same as the original operation.
 Instruction *Simplified = dyn_cast(FV ? FV : TV);
-if (Simplified && Simplified->getOpcode() == unsigned(Opcode)) {
+if (Simplified && Simplified->getOpcode() == unsigned(Opcode) &&
+!Simplified->hasPoisonGeneratingFlags()) {
   // The value that didn't simplify is "UnsimplifiedLHS op 
UnsimplifiedRHS".
   // We already know that "op" is the same as for the simplified value.  
See
   // if the operands match too.  If so, return the simplified value.
diff --git a/llvm/test/Transforms/InstSimplify/pr87042.ll 
b/llvm/test/Transforms/InstSimplify/pr87042.ll
new file mode 100644
index 00..800d27c9e65043
--- /dev/null
+++ b/llvm/test/Transforms/InstSimplify/pr87042.ll
@@ -0,0 +1,42 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
+
+; %or2 cannot be folded into %or1 because %or1 has disjoint.
+; TODO: Can we move the logic into InstCombine and drop the disjoint flag?
+define i64 @test(i1 %cond, i64 %x) {
+; CHECK-LABEL: define i64 @test(
+; CHECK-SAME: i1 [[COND:%.*]], i64 [[X:%.*]]) {
+; CHECK-NEXT:[[OR1:%.*]] = or disjoint i64 [[X]], 7
+; CHECK-NEXT:[[SEL1:%.*]] = select i1 [[COND]], i64 [[OR1]], i64 [[X]]
+; CHECK-NEXT:[[OR2:%.*]] = or i64 [[SEL1]], 7
+; CHECK-NEXT:ret i64 [[OR2]]
+;
+  %or1 = or disjoint i64 %x, 7
+  %sel1 = select i1 %cond, i64 %or1, i64 %x
+  %or2 = or i64 %sel1, 7
+  ret i64 %or2
+}
+
+define i64 @pr87042(i64 %x) {
+; CHECK-LABEL: define i64 @pr87042(
+; CHECK-SAME: i64 [[X:%.*]]) {
+; CHECK-NEXT:[[AND1:%.*]] = and i64 [[X]], 65535
+; CHECK-NEXT:[[CMP1:%.*]] = icmp eq i64 [[AND1]], 0
+; CHECK-NEXT:[[OR1:%.*]] = or disjoint i64 [[X]], 7
+; CHECK-NEXT:[[SEL1:%.*]] = select i1 [[CMP1]], i64 [[OR1]], i64 [[X]]
+; CHECK-NEXT:[[AND2:%.*]] = and i64 [[SEL1]], 16776960
+; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i64 [[AND2]], 0
+; CHECK-NEXT:[[OR2:%.*]] = or i64 [[SEL1]], 7
+; CHECK-NEXT:[[SEL2:%.*]] = select i1 [[CMP2]], i64 [[OR2]], i64 [[SEL1]]
+; CHECK-NEXT:ret i64 [[SEL2]]
+;
+  %and1 = and i64 %x, 65535
+  %cmp1 = icmp eq i64 %and1, 0
+  %or1 = or disjoint i64 %x, 7
+  %sel1 = select i1 %cmp1, i64 %or1, i64 %x
+  %and2 = and i64 %sel1, 16776960
+  %cmp2 = icmp eq i64 %and2, 0
+  %or2 = or i64 %sel1, 7
+  %sel2 = select i1 %cmp2, i64 %or2, i64 %sel1
+  ret i64 %sel2
+}

___
llvm-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: [InstSimplify] Make sure the simplified value doesn't generate poison in threadBinOpOverSelect (#87075) (PR #88353)

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

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/88353
___
llvm-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: [InstSimplify] Make sure the simplified value doesn't generate poison in threadBinOpOverSelect (#87075) (PR #88353)

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

llvmbot wrote:

@nikic What do you think about merging this PR to the release branch?

https://github.com/llvm/llvm-project/pull/88353
___
llvm-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: [InstSimplify] Make sure the simplified value doesn't generate poison in threadBinOpOverSelect (#87075) (PR #88353)

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

llvmbot wrote:



@llvm/pr-subscribers-llvm-analysis

@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

Backport 3197f9d8b0efc3efdc531421bd11c16305d9b1ff

Requested by: @dtcxzyw

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


2 Files Affected:

- (modified) llvm/lib/Analysis/InstructionSimplify.cpp (+2-1) 
- (added) llvm/test/Transforms/InstSimplify/pr87042.ll (+42) 


``diff
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp 
b/llvm/lib/Analysis/InstructionSimplify.cpp
index d0c27cae0dff99..72b6dfa181e86d 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -439,7 +439,8 @@ static Value *threadBinOpOverSelect(Instruction::BinaryOps 
Opcode, Value *LHS,
 // Check that the simplified value has the form "X op Y" where "op" is the
 // same as the original operation.
 Instruction *Simplified = dyn_cast(FV ? FV : TV);
-if (Simplified && Simplified->getOpcode() == unsigned(Opcode)) {
+if (Simplified && Simplified->getOpcode() == unsigned(Opcode) &&
+!Simplified->hasPoisonGeneratingFlags()) {
   // The value that didn't simplify is "UnsimplifiedLHS op 
UnsimplifiedRHS".
   // We already know that "op" is the same as for the simplified value.  
See
   // if the operands match too.  If so, return the simplified value.
diff --git a/llvm/test/Transforms/InstSimplify/pr87042.ll 
b/llvm/test/Transforms/InstSimplify/pr87042.ll
new file mode 100644
index 00..800d27c9e65043
--- /dev/null
+++ b/llvm/test/Transforms/InstSimplify/pr87042.ll
@@ -0,0 +1,42 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
+
+; %or2 cannot be folded into %or1 because %or1 has disjoint.
+; TODO: Can we move the logic into InstCombine and drop the disjoint flag?
+define i64 @test(i1 %cond, i64 %x) {
+; CHECK-LABEL: define i64 @test(
+; CHECK-SAME: i1 [[COND:%.*]], i64 [[X:%.*]]) {
+; CHECK-NEXT:[[OR1:%.*]] = or disjoint i64 [[X]], 7
+; CHECK-NEXT:[[SEL1:%.*]] = select i1 [[COND]], i64 [[OR1]], i64 [[X]]
+; CHECK-NEXT:[[OR2:%.*]] = or i64 [[SEL1]], 7
+; CHECK-NEXT:ret i64 [[OR2]]
+;
+  %or1 = or disjoint i64 %x, 7
+  %sel1 = select i1 %cond, i64 %or1, i64 %x
+  %or2 = or i64 %sel1, 7
+  ret i64 %or2
+}
+
+define i64 @pr87042(i64 %x) {
+; CHECK-LABEL: define i64 @pr87042(
+; CHECK-SAME: i64 [[X:%.*]]) {
+; CHECK-NEXT:[[AND1:%.*]] = and i64 [[X]], 65535
+; CHECK-NEXT:[[CMP1:%.*]] = icmp eq i64 [[AND1]], 0
+; CHECK-NEXT:[[OR1:%.*]] = or disjoint i64 [[X]], 7
+; CHECK-NEXT:[[SEL1:%.*]] = select i1 [[CMP1]], i64 [[OR1]], i64 [[X]]
+; CHECK-NEXT:[[AND2:%.*]] = and i64 [[SEL1]], 16776960
+; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i64 [[AND2]], 0
+; CHECK-NEXT:[[OR2:%.*]] = or i64 [[SEL1]], 7
+; CHECK-NEXT:[[SEL2:%.*]] = select i1 [[CMP2]], i64 [[OR2]], i64 [[SEL1]]
+; CHECK-NEXT:ret i64 [[SEL2]]
+;
+  %and1 = and i64 %x, 65535
+  %cmp1 = icmp eq i64 %and1, 0
+  %or1 = or disjoint i64 %x, 7
+  %sel1 = select i1 %cmp1, i64 %or1, i64 %x
+  %and2 = and i64 %sel1, 16776960
+  %cmp2 = icmp eq i64 %and2, 0
+  %or2 = or i64 %sel1, 7
+  %sel2 = select i1 %cmp2, i64 %or2, i64 %sel1
+  ret i64 %sel2
+}

``




https://github.com/llvm/llvm-project/pull/88353
___
llvm-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][Interfaces][WIP] `Variable` abstraction for `ValueBoundsOpInterface` (PR #87980)

2024-04-10 Thread Jacques Pienaar via llvm-branch-commits

https://github.com/jpienaar edited 
https://github.com/llvm/llvm-project/pull/87980
___
llvm-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][Interfaces][WIP] `Variable` abstraction for `ValueBoundsOpInterface` (PR #87980)

2024-04-10 Thread Jacques Pienaar via llvm-branch-commits


@@ -67,6 +73,83 @@ static std::optional 
getConstantIntValue(OpFoldResult ofr) {
   return std::nullopt;
 }
 
+ValueBoundsConstraintSet::Variable::Variable(OpFoldResult ofr)
+: Variable(ofr, std::nullopt) {}
+
+ValueBoundsConstraintSet::Variable::Variable(Value indexValue)
+: Variable(static_cast(indexValue)) {}
+
+ValueBoundsConstraintSet::Variable::Variable(Value shapedValue, int64_t dim)
+: Variable(static_cast(shapedValue), std::optional(dim)) {}
+
+ValueBoundsConstraintSet::Variable::Variable(OpFoldResult ofr,
+ std::optional dim) {
+  Builder b(ofr.getContext());
+  if (auto constInt = ::getConstantIntValue(ofr)) {
+assert(!dim && "expected no dim for index-typed values");
+map = AffineMap::get(/*dimCount=*/0, /*symbolCount=*/0,
+ b.getAffineConstantExpr(*constInt));
+return;
+  }
+  Value value = cast(ofr);
+#ifndef NDEBUG
+  if (dim) {
+assert(isa(value.getType()) && "expected shaped type");
+  } else {
+assert(value.getType().isIndex() && "expected index type");
+  }
+#endif // NDEBUG
+  map = AffineMap::get(/*dimCount=*/0, /*symbolCount=*/1,
+   b.getAffineSymbolExpr(0));
+  mapOperands.emplace_back(value, dim);
+}
+
+ValueBoundsConstraintSet::Variable::Variable(AffineMap map,
+ ArrayRef mapOperands) {
+  assert(map.getNumResults() == 1 && "expected single result");
+
+  // Turn all dims into symbols.
+  Builder b(map.getContext());
+  SmallVector dimReplacements, symReplacements;
+  for (int64_t i = 0; i < map.getNumDims(); ++i)

jpienaar wrote:

Nit: LLVM style is to avoid checking end condition by querying end state unless 
where the iteration space could change during iteration.

https://github.com/llvm/llvm-project/pull/87980
___
llvm-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][Interfaces][WIP] `Variable` abstraction for `ValueBoundsOpInterface` (PR #87980)

2024-04-10 Thread Jacques Pienaar via llvm-branch-commits

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

Nice refactor, I think easier to read 

https://github.com/llvm/llvm-project/pull/87980
___
llvm-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] Adds sys_info formatter. (PR #85896)

2024-04-10 Thread Mark de Wever via llvm-branch-commits

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

>From de4ba883c354ab8510fb0e5e4ad2a09d93000c30 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Sun, 10 Mar 2024 17:49:39 +0100
Subject: [PATCH] [libc++][TZDB] Adds sys_info formatter.

Implements parts of:
- P0355 Extending  to Calendars and Time Zones
- P1361 Integration of chrono with text formatting
---
 libcxx/docs/Status/FormatPaper.csv|   2 +-
 libcxx/include/__chrono/convert_to_tm.h   |   5 +
 libcxx/include/__chrono/formatter.h   |  44 +-
 libcxx/include/__chrono/ostream.h |  20 +++
 libcxx/include/__chrono/sys_info.h|   2 +-
 libcxx/include/chrono |   5 +
 .../time.zone.info.sys/ostream.pass.cpp   |  74 ++
 .../time/time.syn/formatter.sys_info.pass.cpp | 137 ++
 .../time.zone.info.sys/ostream.pass.cpp   |  52 +++
 .../concept.formattable.compile.pass.cpp  |   2 +-
 10 files changed, 337 insertions(+), 6 deletions(-)
 create mode 100644 
libcxx/test/libcxx/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp
 create mode 100644 libcxx/test/std/time/time.syn/formatter.sys_info.pass.cpp
 create mode 100644 
libcxx/test/std/time/time.zone/time.zone.info/time.zone.info.sys/ostream.pass.cpp

diff --git a/libcxx/docs/Status/FormatPaper.csv 
b/libcxx/docs/Status/FormatPaper.csv
index e9d407e79e2539..8ace18815f5375 100644
--- a/libcxx/docs/Status/FormatPaper.csv
+++ b/libcxx/docs/Status/FormatPaper.csv
@@ -24,7 +24,7 @@ Section,Description,Dependencies,Assignee,Status,First 
released version
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::year_month_weekday_last``",,Mark de Wever,|Complete|,16.0
 `[time.syn] `_,"Formatter 
``chrono::hh_mm_ss>``",,Mark de Wever,|Complete|,17.0
-`[time.syn] `_,"Formatter ``chrono::sys_info``",A 
 implementation,Mark de Wever,,
+`[time.syn] `_,"Formatter 
``chrono::sys_info``",,Mark de Wever,|Complete|,19.0
 `[time.syn] `_,"Formatter 
``chrono::local_info``",A  implementation,Mark de Wever,,
 `[time.syn] `_,"Formatter 
``chrono::zoned_time``",A  
implementation,Mark de Wever,,
 
diff --git a/libcxx/include/__chrono/convert_to_tm.h 
b/libcxx/include/__chrono/convert_to_tm.h
index 1301cd6f1f1ada..d2c5cf922ba671 100644
--- a/libcxx/include/__chrono/convert_to_tm.h
+++ b/libcxx/include/__chrono/convert_to_tm.h
@@ -20,6 +20,7 @@
 #include <__chrono/month_weekday.h>
 #include <__chrono/monthday.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -171,6 +172,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& 
__value) {
   if (__value.hours().count() > 
std::numeric_limits::max())
 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour 
overflow");
 __result.tm_hour = __value.hours().count();
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
+  } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
+// Has no time information.
+#  endif
   } else
 static_assert(sizeof(_ChronoT) == 0, "Add the missing type 
specialization");
 
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 217979e88c93db..79192fa103fbdb 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -24,6 +24,7 @@
 #include <__chrono/ostream.h>
 #include <__chrono/parser_std_format_spec.h>
 #include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
 #include <__chrono/system_clock.h>
 #include <__chrono/time_point.h>
 #include <__chrono/weekday.h>
@@ -185,10 +186,11 @@ __format_zone_offset(basic_stringstream<_CharT>& __sstr, 
chrono::seconds __offse
 
   chrono::hh_mm_ss __hms{__offset};
   std::ostreambuf_iterator<_CharT> __out_it{__sstr};
+  // Note HMS does not allow formatting hours > 23, but the offset is not 
limited to 24H.
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.hours().count());
   if (__modifier)
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H:%M}"), 
__hms);
-  else
-std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:%H%M}"), 
__hms);
+__sstr << _CharT(':');
+  std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), 
__hms.minutes().count());
 }
 
 // Helper to store the time zone information needed for formatting.
@@ -202,6 +204,12 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
 template 
 _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] 
const _Tp& __value) {
   __time_zone __result;
+#  if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)