[llvm-branch-commits] [clang] PR for llvm/llvm-project#78892 (PR #80259)

2024-02-01 Thread via llvm-branch-commits

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

resolves llvm/llvm-project#78892

>From 97d44dc7b5e24df15ae5df670bceede60f419dde Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Wed, 31 Jan 2024 20:20:26 -0800
Subject: [PATCH] [clang-format] Simplify the AfterPlacementOperator option
 (#79796)

Change AfterPlacementOperator to a boolean and deprecate SBPO_Never,
which meant never inserting a space except when after new/delete.

Fixes #78892.

(cherry picked from commit 908fd09a13b2e89a52282478544f7f70cf0a887f)
---
 clang/docs/ClangFormatStyleOptions.rst | 42 +
 clang/include/clang/Format/Format.h| 43 ++
 clang/lib/Format/Format.cpp| 23 +---
 clang/lib/Format/TokenAnnotator.cpp|  9 +
 clang/unittests/Format/ConfigParseTest.cpp | 19 +-
 clang/unittests/Format/FormatTest.cpp  | 32 +++-
 6 files changed, 38 insertions(+), 130 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4dc0de3a90f26..0b887288fe2cb 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5277,15 +5277,9 @@ the configuration (without a prefix: ``Auto``).
   Possible values:
 
   * ``SBPO_Never`` (in configuration: ``Never``)
-Never put a space before opening parentheses.
-
-.. code-block:: c++
-
-   void f() {
- if(true) {
-   f();
- }
-   }
+This is **deprecated** and replaced by ``Custom`` below, with all
+``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
+``false``.
 
   * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``)
 Put a space before opening parentheses only after control statement
@@ -5425,32 +5419,14 @@ the configuration (without a prefix: ``Auto``).
void operator++ (int a);vs.void operator++(int a);
object.operator++ (10);object.operator++(10);
 
-  * ``AfterPlacementOperatorStyle AfterPlacementOperator`` 
:versionbadge:`clang-format 18`
-
-Defines in which cases to put a space between ``new/delete`` operators
-and opening parentheses.
-
-Possible values:
-
-* ``APO_Never`` (in configuration: ``Never``)
-  Remove space after ``new/delete`` operators and before ``(``.
-
-  .. code-block:: c++
-
- new(buf) T;
- delete(buf) T;
-
-* ``APO_Always`` (in configuration: ``Always``)
-  Always add space after ``new/delete`` operators and before ``(``.
+  * ``bool AfterPlacementOperator`` If ``true``, put a space between operator 
``new``/``delete`` and opening
+parenthesis.
 
-  .. code-block:: c++
-
- new (buf) T;
- delete (buf) T;
-
-* ``APO_Leave`` (in configuration: ``Leave``)
-  Leave placement ``new/delete`` expressions as they are.
+.. code-block:: c++
 
+   true:  false:
+   new (buf) T;vs.new(buf) T;
+   delete (buf) T;delete(buf) T;
 
   * ``bool AfterRequiresInClause`` If ``true``, put space between requires 
keyword in a requires clause and
 opening parentheses, if there is one.
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index bc9eecd42f9eb..efcb4e1d87ea4 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4157,14 +4157,9 @@ struct FormatStyle {
 
   /// Different ways to put a space before opening parentheses.
   enum SpaceBeforeParensStyle : int8_t {
-/// Never put a space before opening parentheses.
-/// \code
-///void f() {
-///  if(true) {
-///f();
-///  }
-///}
-/// \endcode
+/// This is **deprecated** and replaced by ``Custom`` below, with all
+/// ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
+/// ``false``.
 SBPO_Never,
 /// Put a space before opening parentheses only after control statement
 /// keywords (``for/if/while...``).
@@ -4273,28 +4268,14 @@ struct FormatStyle {
 ///object.operator++ (10);object.operator++(10);
 /// \endcode
 bool AfterOverloadedOperator;
-/// Styles for adding spacing between ``new/delete`` operators and opening
-/// parentheses.
-enum AfterPlacementOperatorStyle : int8_t {
-  /// Remove space after ``new/delete`` operators and before ``(``.
-  /// \code
-  ///new(buf) T;
-  ///delete(buf) T;
-  /// \endcode
-  APO_Never,
-  /// Always add space after ``new/delete`` operators and before ``(``.
-  /// \code
-  ///new (buf) T;
-  ///delete (buf) T;
-  /// \endcode
-  APO_Always,
-  /// Leave placement ``new/delete`` expressions as they are.
-  APO_Leave,
-};
-/// Defines in which cases to put a space between ``new/delete`

[llvm-branch-commits] [clang] PR for llvm/llvm-project#78892 (PR #80259)

2024-02-01 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80259
___
llvm-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] PR for llvm/llvm-project#78892 (PR #80259)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/80259
___
llvm-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] PR for llvm/llvm-project#78892 (PR #80259)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#78892

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


6 Files Affected:

- (modified) clang/docs/ClangFormatStyleOptions.rst (+9-33) 
- (modified) clang/include/clang/Format/Format.h (+12-31) 
- (modified) clang/lib/Format/Format.cpp (+1-22) 
- (modified) clang/lib/Format/TokenAnnotator.cpp (+1-8) 
- (modified) clang/unittests/Format/ConfigParseTest.cpp (+1-18) 
- (modified) clang/unittests/Format/FormatTest.cpp (+14-18) 


``diff
diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4dc0de3a90f26..0b887288fe2cb 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5277,15 +5277,9 @@ the configuration (without a prefix: ``Auto``).
   Possible values:
 
   * ``SBPO_Never`` (in configuration: ``Never``)
-Never put a space before opening parentheses.
-
-.. code-block:: c++
-
-   void f() {
- if(true) {
-   f();
- }
-   }
+This is **deprecated** and replaced by ``Custom`` below, with all
+``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
+``false``.
 
   * ``SBPO_ControlStatements`` (in configuration: ``ControlStatements``)
 Put a space before opening parentheses only after control statement
@@ -5425,32 +5419,14 @@ the configuration (without a prefix: ``Auto``).
void operator++ (int a);vs.void operator++(int a);
object.operator++ (10);object.operator++(10);
 
-  * ``AfterPlacementOperatorStyle AfterPlacementOperator`` 
:versionbadge:`clang-format 18`
-
-Defines in which cases to put a space between ``new/delete`` operators
-and opening parentheses.
-
-Possible values:
-
-* ``APO_Never`` (in configuration: ``Never``)
-  Remove space after ``new/delete`` operators and before ``(``.
-
-  .. code-block:: c++
-
- new(buf) T;
- delete(buf) T;
-
-* ``APO_Always`` (in configuration: ``Always``)
-  Always add space after ``new/delete`` operators and before ``(``.
+  * ``bool AfterPlacementOperator`` If ``true``, put a space between operator 
``new``/``delete`` and opening
+parenthesis.
 
-  .. code-block:: c++
-
- new (buf) T;
- delete (buf) T;
-
-* ``APO_Leave`` (in configuration: ``Leave``)
-  Leave placement ``new/delete`` expressions as they are.
+.. code-block:: c++
 
+   true:  false:
+   new (buf) T;vs.new(buf) T;
+   delete (buf) T;delete(buf) T;
 
   * ``bool AfterRequiresInClause`` If ``true``, put space between requires 
keyword in a requires clause and
 opening parentheses, if there is one.
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index bc9eecd42f9eb..efcb4e1d87ea4 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4157,14 +4157,9 @@ struct FormatStyle {
 
   /// Different ways to put a space before opening parentheses.
   enum SpaceBeforeParensStyle : int8_t {
-/// Never put a space before opening parentheses.
-/// \code
-///void f() {
-///  if(true) {
-///f();
-///  }
-///}
-/// \endcode
+/// This is **deprecated** and replaced by ``Custom`` below, with all
+/// ``SpaceBeforeParensOptions`` but ``AfterPlacementOperator`` set to
+/// ``false``.
 SBPO_Never,
 /// Put a space before opening parentheses only after control statement
 /// keywords (``for/if/while...``).
@@ -4273,28 +4268,14 @@ struct FormatStyle {
 ///object.operator++ (10);object.operator++(10);
 /// \endcode
 bool AfterOverloadedOperator;
-/// Styles for adding spacing between ``new/delete`` operators and opening
-/// parentheses.
-enum AfterPlacementOperatorStyle : int8_t {
-  /// Remove space after ``new/delete`` operators and before ``(``.
-  /// \code
-  ///new(buf) T;
-  ///delete(buf) T;
-  /// \endcode
-  APO_Never,
-  /// Always add space after ``new/delete`` operators and before ``(``.
-  /// \code
-  ///new (buf) T;
-  ///delete (buf) T;
-  /// \endcode
-  APO_Always,
-  /// Leave placement ``new/delete`` expressions as they are.
-  APO_Leave,
-};
-/// Defines in which cases to put a space between ``new/delete`` operators
-/// and opening parentheses.
-/// \version 18
-AfterPlacementOperatorStyle AfterPlacementOperator;
+/// If ``true``, put a space between operator ``new``/``delete`` and 
opening
+/// parenthesis.
+/// \code
+///true:  false:
+///new (buf) T;vs.new(buf) T;
+///delete (buf) T;  

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#78621 (PR #80260)

2024-02-01 Thread via llvm-branch-commits

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

resolves llvm/llvm-project#78621

>From 30a5358002a45585cb0613bb02be922eb447aafb Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Wed, 24 Jan 2024 11:56:02 +
Subject: [PATCH 1/2] [ConstraintElim] Add tests for #78621.

Tests with umin where the result may be poison for
https://github.com/llvm/llvm-project/issues/78621.

(cherry picked from commit c83180c1248615cf6ea8842eb4e0cebebba4ab57)
---
 .../umin-result-may-be-poison.ll  | 60 +++
 1 file changed, 60 insertions(+)
 create mode 100644 
llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll

diff --git 
a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll 
b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
new file mode 100644
index 0..35ac72e54d189
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
@@ -0,0 +1,60 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -p constraint-elimination -S %s | FileCheck %s
+
+; Tests for https://github.com/llvm/llvm-project/issues/78621.
+
+define i1 @umin_not_used(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_not_used(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+define i1 @umin_poison_is_UB_via_call(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_poison_is_UB_via_call(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  call void @noundef(i32 noundef %min)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+define i1 @umin_poison_call_before_UB(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_poison_call_before_UB(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:call void @fn()
+; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  call void @fn()
+  call void @noundef(i32 noundef %min)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+declare i32 @llvm.umin.i32(i32, i32) #0
+
+declare void @noundef(i32 noundef)
+declare void @fn()

>From 3f72627fe6bab34b15e6b4a664cb410f04b77c0e Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Wed, 24 Jan 2024 14:25:54 +
Subject: [PATCH 2/2] [ConstraintElim] Make sure min/max intrinsic results are
 not poison.

The result of umin may be poison and in that case the added constraints
are not be valid in contexts where poison doesn't cause UB. Only queue
facts for min/max intrinsics if the result is guaranteed to not be
poison.

This could be improved in the future, by only adding the fact when
solving conditions using the result value.

Fixes https://github.com/llvm/llvm-project/issues/78621.

(cherry picked from commit 3d91d9613e294b242d853039209b40a0cb7853f2)
---
 llvm/lib/Transforms/Scalar/ConstraintElimination.cpp   | 7 ++-
 llvm/test/Transforms/ConstraintElimination/minmax.ll   | 4 +++-
 .../ConstraintElimination/umin-result-may-be-poison.ll | 6 --
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 8f09569d0d9cc..7b672e89b67aa 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1061,11 +1061,16 @@ void State::addInfoFor(BasicBlock &BB) {
   FactOrCheck::getCheck(DT.getNode(&BB), cast(&I)));
   break;
 // Enqueue the intrinsics to add extra info.
-case Intrinsic::abs:
 case Intrinsic::umin:
 case Intrinsic::umax:
 case Intrinsic::smin:
 case Intrinsic::smax:
+  // TODO: Check if it is possible to instead only added the min/max facts
+  // when simplifying uses of the min/max intrinsics.
+  if (!isGuaranteedNotToBePoison(&I))
+break;
+  [[fallthrough]];
+case Intrinsic::abs:
   Wor

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#78621 (PR #80260)

2024-02-01 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80260
___
llvm-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] PR for llvm/llvm-project#78621 (PR #80260)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#78621

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


3 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/ConstraintElimination.cpp (+6-1) 
- (modified) llvm/test/Transforms/ConstraintElimination/minmax.ll (+3-1) 
- (added) 
llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll (+62) 


``diff
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp 
b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 8f09569d0d9cc..7b672e89b67aa 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -1061,11 +1061,16 @@ void State::addInfoFor(BasicBlock &BB) {
   FactOrCheck::getCheck(DT.getNode(&BB), cast(&I)));
   break;
 // Enqueue the intrinsics to add extra info.
-case Intrinsic::abs:
 case Intrinsic::umin:
 case Intrinsic::umax:
 case Intrinsic::smin:
 case Intrinsic::smax:
+  // TODO: Check if it is possible to instead only added the min/max facts
+  // when simplifying uses of the min/max intrinsics.
+  if (!isGuaranteedNotToBePoison(&I))
+break;
+  [[fallthrough]];
+case Intrinsic::abs:
   WorkList.push_back(FactOrCheck::getInstFact(DT.getNode(&BB), &I));
   break;
 }
diff --git a/llvm/test/Transforms/ConstraintElimination/minmax.ll 
b/llvm/test/Transforms/ConstraintElimination/minmax.ll
index a31cf6845ad67..82b932f14c4ff 100644
--- a/llvm/test/Transforms/ConstraintElimination/minmax.ll
+++ b/llvm/test/Transforms/ConstraintElimination/minmax.ll
@@ -306,7 +306,9 @@ define i1 @smin_branchless(i32 %x, i32 %y) {
 ; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]]) {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.smin.i32(i32 [[X]], i32 [[Y]])
-; CHECK-NEXT:[[RET:%.*]] = xor i1 true, false
+; CHECK-NEXT:[[CMP1:%.*]] = icmp sle i32 [[MIN]], [[X]]
+; CHECK-NEXT:[[CMP2:%.*]] = icmp sgt i32 [[MIN]], [[X]]
+; CHECK-NEXT:[[RET:%.*]] = xor i1 [[CMP1]], [[CMP2]]
 ; CHECK-NEXT:ret i1 [[RET]]
 ;
 entry:
diff --git 
a/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll 
b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
new file mode 100644
index 0..6d1d95ec4fdba
--- /dev/null
+++ b/llvm/test/Transforms/ConstraintElimination/umin-result-may-be-poison.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -p constraint-elimination -S %s | FileCheck %s
+
+; Tests for https://github.com/llvm/llvm-project/issues/78621.
+
+define i1 @umin_not_used(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_not_used(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[ICMP:%.*]] = icmp slt i32 [[ARG]], 0
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 [[ICMP]]
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+define i1 @umin_poison_is_UB_via_call(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_poison_is_UB_via_call(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 false
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  call void @noundef(i32 noundef %min)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+define i1 @umin_poison_call_before_UB(i32 %arg) {
+; CHECK-LABEL: define i1 @umin_poison_call_before_UB(
+; CHECK-SAME: i32 [[ARG:%.*]]) {
+; CHECK-NEXT:[[ICMP:%.*]] = icmp slt i32 [[ARG]], 0
+; CHECK-NEXT:[[SHL:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:[[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL]], i32 80)
+; CHECK-NEXT:call void @fn()
+; CHECK-NEXT:call void @noundef(i32 noundef [[MIN]])
+; CHECK-NEXT:[[CMP2:%.*]] = shl nuw nsw i32 [[ARG]], 3
+; CHECK-NEXT:ret i1 [[ICMP]]
+;
+  %icmp = icmp slt i32 %arg, 0
+  %shl = shl nuw nsw i32 %arg, 3
+  %min = call i32 @llvm.umin.i32(i32 %shl, i32 80)
+  call void @fn()
+  call void @noundef(i32 noundef %min)
+  %cmp2 = shl nuw nsw i32 %arg, 3
+  ret i1 %icmp
+}
+
+declare i32 @llvm.umin.i32(i32, i32) #0
+
+declare void @noundef(i32 noundef)
+declare void @fn()

``




https://github.com/llvm/llvm-project/pull/80260
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://l

[llvm-branch-commits] [clang] [compiler-rt] [llvm] [flang] [libcxx] [libc] [RISCV] Support select optimization (PR #80124)

2024-02-01 Thread Wang Pengcheng via llvm-branch-commits

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


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


[llvm-branch-commits] [compiler-rt] [llvm] [clang] [libc] [libcxx] [flang] [RISCV] Support select optimization (PR #80124)

2024-02-01 Thread Wang Pengcheng via llvm-branch-commits

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


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


[llvm-branch-commits] [compiler-rt] [llvm] [clang] [libc] [libcxx] [flang] [RISCV] Support select optimization (PR #80124)

2024-02-01 Thread Wang Pengcheng via llvm-branch-commits


@@ -0,0 +1,873 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -select-optimize -mtriple=riscv64 -S < %s \
+; RUN:   | FileCheck %s --check-prefix=CHECK-SELECT
+; RUN: opt -select-optimize -mtriple=riscv64 -mattr=+enable-select-opt -S < %s 
\
+; RUN:   | FileCheck %s --check-prefix=CHECK-BRANCH
+; RUN: opt -select-optimize -mtriple=riscv64 
-mattr=+enable-select-opt,+predictable-select-expensive -S < %s \
+; RUN:   | FileCheck %s --check-prefix=CHECK-BRANCH
+
+%struct.st = type { i32, i64, ptr, ptr, i16, ptr, ptr, i64, i64 }
+
+; This test has a select at the end of if.then, which is better transformed to 
a branch on OoO cores.
+
+define void @replace(ptr nocapture noundef %newst, ptr noundef %t, ptr noundef 
%h, i64 noundef %c, i64 noundef %rc, i64 noundef %ma, i64 noundef %n) {

wangpc-pp wrote:

Thanks a lot! This methodology of adding ` llvm_unreachable()` is really 
useful! I have reduced the tests. cc @davemgreen 

https://github.com/llvm/llvm-project/pull/80124
___
llvm-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] [VPlan] Consistently use (Part, 0) for first lane scalar values (PR #80271)

2024-02-01 Thread Florian Hahn via llvm-branch-commits

https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/80271

At the moment, some VPInstructions create only a single scalar value, but use 
VPTransformatState's 'vector' storage for this value. Those values are 
effectively uniform-per-VF (or in some cases uniform-across-VF-and-UF). Using 
the vector/per-part storage doesn't interact well with other recipes, that more 
accurately using (Part, Lane) to look up scalar values and prevents 
VPInstructions creating scalars from interacting with other recipes working 
with scalars.

This PR tries to unify handling of scalars by using (Part, 0) for scalar values 
where only the first lane is demanded. This allows using VPInstructions with 
other recipes like VPScalarCastRecipe and is also needed when using 
VPInstructions in more cases otuside the vector loop region to generate scalars.

The patch is still a bit rough around the edges, but hopefully serves as start 
for a discussion how to model more scalar recipes. A potential alternative 
would be to split off the opcodes that generate scalars only to a separate 
recipe.

>From b08e8920ea23f2b4ce3bfe85af8878c81dfce28f Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Wed, 31 Jan 2024 15:08:29 +
Subject: [PATCH] [VPlan] Consistently use (Part, 0) for first lane scalar
 values

At the moment, some VPInstructions create only a single scalar value,
but use VPTransformatState's 'vector' storage for this value. Those
values are effectively uniform-per-VF (or in some cases
uniform-across-VF-and-UF). Using the vector/per-part storage doesn't
interact well with other recipes, that more accurately using (Part,
Lane) to look up scalar values and prevents VPInstructions creating
scalars from interacting with other recipes working with scalars.

This PR tries to unify handling of scalars by using (Part, 0) for scalar
values where only the first lane is demanded. This allows using
VPInstructions with other recipes like VPScalarCastRecipe and is also
needed when using VPInstructions in more cases otuside the vector loop
region to generate scalars.

The patch is still a bit rough around the edges, but hopefully serves as
start for a discussion how to model more scalar recipes. A potential
alternative would be to split off the opcodes that generate scalars only
to a separate recipe.
---
 llvm/lib/Transforms/Vectorize/VPlan.cpp   | 18 --
 llvm/lib/Transforms/Vectorize/VPlan.h |  7 +++
 .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 36 ---
 .../LoopVectorize/AArch64/masked-call.ll  | 25 +++-
 .../LoopVectorize/first-order-recurrence.ll   | 62 +--
 5 files changed, 87 insertions(+), 61 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 1ca2cfef447f6..7ed07fe5f413a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -213,8 +213,13 @@ VPBasicBlock::iterator VPBasicBlock::getFirstNonPhi() {
 }
 
 Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
-  if (Def->isLiveIn())
-return Def->getLiveInIRValue();
+  if (Def->isLiveIn()) {
+if (Value *V = Def->getLiveInIRValue())
+  return V;
+if (hasScalarValue(Def, VPIteration(0, 0))) {
+  return Data.PerPartScalars[Def][0][0];
+}
+  }
 
   if (hasScalarValue(Def, Instance)) {
 return Data
@@ -794,7 +799,7 @@ void VPlan::prepareToExecute(Value *TripCountV, Value 
*VectorTripCountV,
   // FIXME: Model VF * UF computation completely in VPlan.
   State.set(&VFxUF,
 createStepForVF(Builder, TripCountV->getType(), State.VF, 
State.UF),
-0);
+VPIteration(0, 0));
 
   // When vectorizing the epilogue loop, the canonical induction start value
   // needs to be changed from zero to the value after the main vector loop.
@@ -883,8 +888,11 @@ void VPlan::execute(VPTransformState *State) {
 
 for (unsigned Part = 0; Part < LastPartForNewPhi; ++Part) {
   Value *Phi = State->get(PhiR, Part);
-  Value *Val = State->get(PhiR->getBackedgeValue(),
-  SinglePartNeeded ? State->UF - 1 : Part);
+  Value *Val =
+  isa(PhiR)
+  ? State->get(PhiR->getBackedgeValue(), VPIteration(Part, 0))
+  : State->get(PhiR->getBackedgeValue(),
+   SinglePartNeeded ? State->UF - 1 : Part);
   cast(Phi)->addIncoming(Val, VectorLatchBB);
 }
   }
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index 30dc521947b3b..97035146a2f4d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1388,6 +1388,13 @@ class VPScalarCastRecipe : public VPSingleDefRecipe {
 
   /// Returns the result type of the cast.
   Type *getResultType() const { return ResultTy; }
+
+  bool onlyFirstLaneUsed(const VPValue *Op) const override {
+// At the moment, only scalar codegen is implemented.

[llvm-branch-commits] [llvm] [VPlan] Consistently use (Part, 0) for first lane scalar values (PR #80271)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Florian Hahn (fhahn)


Changes

At the moment, some VPInstructions create only a single scalar value, but use 
VPTransformatState's 'vector' storage for this value. Those values are 
effectively uniform-per-VF (or in some cases uniform-across-VF-and-UF). Using 
the vector/per-part storage doesn't interact well with other recipes, that more 
accurately using (Part, Lane) to look up scalar values and prevents 
VPInstructions creating scalars from interacting with other recipes working 
with scalars.

This PR tries to unify handling of scalars by using (Part, 0) for scalar values 
where only the first lane is demanded. This allows using VPInstructions with 
other recipes like VPScalarCastRecipe and is also needed when using 
VPInstructions in more cases otuside the vector loop region to generate scalars.

The patch is still a bit rough around the edges, but hopefully serves as start 
for a discussion how to model more scalar recipes. A potential alternative 
would be to split off the opcodes that generate scalars only to a separate 
recipe.

---

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


5 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/VPlan.cpp (+13-5) 
- (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+7) 
- (modified) llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp (+27-9) 
- (modified) llvm/test/Transforms/LoopVectorize/AArch64/masked-call.ll (+10-15) 
- (modified) llvm/test/Transforms/LoopVectorize/first-order-recurrence.ll 
(+30-32) 


``diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 1ca2cfef447f6..7ed07fe5f413a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -213,8 +213,13 @@ VPBasicBlock::iterator VPBasicBlock::getFirstNonPhi() {
 }
 
 Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
-  if (Def->isLiveIn())
-return Def->getLiveInIRValue();
+  if (Def->isLiveIn()) {
+if (Value *V = Def->getLiveInIRValue())
+  return V;
+if (hasScalarValue(Def, VPIteration(0, 0))) {
+  return Data.PerPartScalars[Def][0][0];
+}
+  }
 
   if (hasScalarValue(Def, Instance)) {
 return Data
@@ -794,7 +799,7 @@ void VPlan::prepareToExecute(Value *TripCountV, Value 
*VectorTripCountV,
   // FIXME: Model VF * UF computation completely in VPlan.
   State.set(&VFxUF,
 createStepForVF(Builder, TripCountV->getType(), State.VF, 
State.UF),
-0);
+VPIteration(0, 0));
 
   // When vectorizing the epilogue loop, the canonical induction start value
   // needs to be changed from zero to the value after the main vector loop.
@@ -883,8 +888,11 @@ void VPlan::execute(VPTransformState *State) {
 
 for (unsigned Part = 0; Part < LastPartForNewPhi; ++Part) {
   Value *Phi = State->get(PhiR, Part);
-  Value *Val = State->get(PhiR->getBackedgeValue(),
-  SinglePartNeeded ? State->UF - 1 : Part);
+  Value *Val =
+  isa(PhiR)
+  ? State->get(PhiR->getBackedgeValue(), VPIteration(Part, 0))
+  : State->get(PhiR->getBackedgeValue(),
+   SinglePartNeeded ? State->UF - 1 : Part);
   cast(Phi)->addIncoming(Val, VectorLatchBB);
 }
   }
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index 30dc521947b3b..97035146a2f4d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1388,6 +1388,13 @@ class VPScalarCastRecipe : public VPSingleDefRecipe {
 
   /// Returns the result type of the cast.
   Type *getResultType() const { return ResultTy; }
+
+  bool onlyFirstLaneUsed(const VPValue *Op) const override {
+// At the moment, only scalar codegen is implemented.
+assert(is_contained(operands(), Op) &&
+   "Op must be an operand of the recipe");
+return true;
+  }
 };
 
 /// A recipe for widening Call instructions.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp 
b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 21b8d1eb77bf9..77f2cf899b085 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -279,11 +279,17 @@ Value 
*VPInstruction::generateInstruction(VPTransformState &State,
   Builder.SetCurrentDebugLocation(getDebugLoc());
 
   if (Instruction::isBinaryOp(getOpcode())) {
+bool OnlyFirstLaneUsed = vputils::onlyFirstLaneUsed(this);
 if (Part != 0 && vputils::onlyFirstPartUsed(this))
-  return State.get(this, 0);
-
-Value *A = State.get(getOperand(0), Part);
-Value *B = State.get(getOperand(1), Part);
+  return OnlyFirstLaneUsed ? State.get(this, VPIteration(0, 0))
+   : State.get(this, 0);
+
+Value *A = OnlyFirstLaneUsed
+   ? State.get

[llvm-branch-commits] [llvm] [VPlan] Explicitly handle scalar pointer inductions. (PR #80273)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Florian Hahn (fhahn)


Changes

Add a new PtrAdd opcode to VPInstruction that corresponds to
IRBuilder::CreatePtrAdd, which creates a GEP with source element type
i8.

This is then used to model scalarizing VPWidenPointerInductionRecipe by
introducing scalar-steps to model the index increment followed by a
PtrAdd.

Note that PtrAdd needs to be able to generate code for only the first
lane or for all lanes. This may warrant introducing a separate recipe
for scalarizing that can be created without relying on the underlying
IR.


---

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


18 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+2-33) 
- (modified) llvm/lib/Transforms/Vectorize/VPlan.cpp (+1-1) 
- (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+11-1) 
- (modified) llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp (+2) 
- (modified) llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp (+25-2) 
- (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp (+38-8) 
- (modified) 
llvm/test/Transforms/LoopVectorize/AArch64/epilog-vectorization-widen-inductions.ll
 (+49-51) 
- (modified) llvm/test/Transforms/LoopVectorize/AArch64/sve-epilog-vect.ll 
(+73-75) 
- (modified) 
llvm/test/Transforms/LoopVectorize/AArch64/sve-live-out-pointer-induction.ll 
(+37-37) 
- (modified) llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll 
(+24-25) 
- (modified) llvm/test/Transforms/LoopVectorize/X86/gather_scatter.ll (+75-79) 
- (modified) 
llvm/test/Transforms/LoopVectorize/X86/interleave-opaque-pointers.ll (+9-10) 
- (modified) llvm/test/Transforms/LoopVectorize/X86/small-size.ll (+83-95) 
- (modified) llvm/test/Transforms/LoopVectorize/first-order-recurrence.ll 
(+49-60) 
- (modified) llvm/test/Transforms/LoopVectorize/pointer-induction-unroll.ll 
(+31-30) 
- (modified) llvm/test/Transforms/LoopVectorize/pointer-induction.ll (+34-37) 
- (modified) 
llvm/test/Transforms/LoopVectorize/tail-folding-vectorization-factor-1.ll 
(+32-35) 
- (modified) llvm/test/Transforms/LoopVectorize/vplan-sink-scalars-and-merge.ll 
(+5-3) 


``diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 17a0d01f18072..4ee878358f9bc 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9233,42 +9233,11 @@ void 
VPWidenPointerInductionRecipe::execute(VPTransformState &State) {
  "Not a pointer induction according to InductionDescriptor!");
   assert(cast(getUnderlyingInstr())->getType()->isPointerTy() &&
  "Unexpected type.");
+  assert(!onlyScalarsGenerated(State.VF.isScalable()) &&
+ "Recipe should have been replaced");
 
   auto *IVR = getParent()->getPlan()->getCanonicalIV();
   PHINode *CanonicalIV = cast(State.get(IVR, 0));
-
-  if (onlyScalarsGenerated(State.VF)) {
-// This is the normalized GEP that starts counting at zero.
-Value *PtrInd = State.Builder.CreateSExtOrTrunc(
-CanonicalIV, IndDesc.getStep()->getType());
-// Determine the number of scalars we need to generate for each unroll
-// iteration. If the instruction is uniform, we only need to generate the
-// first lane. Otherwise, we generate all VF values.
-bool IsUniform = vputils::onlyFirstLaneUsed(this);
-assert((IsUniform || !State.VF.isScalable()) &&
-   "Cannot scalarize a scalable VF");
-unsigned Lanes = IsUniform ? 1 : State.VF.getFixedValue();
-
-for (unsigned Part = 0; Part < State.UF; ++Part) {
-  Value *PartStart =
-  createStepForVF(State.Builder, PtrInd->getType(), State.VF, Part);
-
-  for (unsigned Lane = 0; Lane < Lanes; ++Lane) {
-Value *Idx = State.Builder.CreateAdd(
-PartStart, ConstantInt::get(PtrInd->getType(), Lane));
-Value *GlobalIdx = State.Builder.CreateAdd(PtrInd, Idx);
-
-Value *Step = State.get(getOperand(1), VPIteration(Part, Lane));
-Value *SclrGep = emitTransformedIndex(
-State.Builder, GlobalIdx, IndDesc.getStartValue(), Step,
-IndDesc.getKind(), IndDesc.getInductionBinOp());
-SclrGep->setName("next.gep");
-State.set(this, SclrGep, VPIteration(Part, Lane));
-  }
-}
-return;
-  }
-
   Type *PhiType = IndDesc.getStep()->getType();
 
   // Build a pointer phi
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 7ed07fe5f413a..51576d9f5364e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -859,7 +859,7 @@ void VPlan::execute(VPTransformState *State) {
 auto *WidenPhi = cast(&R);
 // TODO: Split off the case that all users of a pointer phi are scalar
 // from the VPWidenPointerInductionRecipe.
-if (WidenPhi->onlyScalarsGenerated(Sta

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79175 (PR #80274)

2024-02-01 Thread via llvm-branch-commits

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

resolves llvm/llvm-project#79175

>From ee8c0bd8ff69caca659662961e2b5dfaee907a7a Mon Sep 17 00:00:00 2001
From: Nikita Popov 
Date: Wed, 24 Jan 2024 12:33:57 +0100
Subject: [PATCH 1/3] [Loads] Use BatchAAResults for available value APIs
 (NFCI)

This allows caching AA queries both within and across the calls,
and enables us to use a custom AAQI configuration.

(cherry picked from commit 89dae798cc77789a43e9a60173f647dae03a65fe)
---
 llvm/include/llvm/Analysis/Loads.h   | 12 ++--
 llvm/lib/Analysis/Lint.cpp   |  3 ++-
 llvm/lib/Analysis/Loads.cpp  |  9 -
 .../InstCombine/InstCombineLoadStoreAlloca.cpp   |  3 ++-
 llvm/lib/Transforms/Scalar/JumpThreading.cpp | 11 ++-
 5 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/llvm/include/llvm/Analysis/Loads.h 
b/llvm/include/llvm/Analysis/Loads.h
index 2880ed33a34cb..0926093bba99d 100644
--- a/llvm/include/llvm/Analysis/Loads.h
+++ b/llvm/include/llvm/Analysis/Loads.h
@@ -18,7 +18,7 @@
 
 namespace llvm {
 
-class AAResults;
+class BatchAAResults;
 class AssumptionCache;
 class DataLayout;
 class DominatorTree;
@@ -129,11 +129,10 @@ extern cl::opt DefMaxInstsToScan;
 /// location in memory, as opposed to the value operand of a store.
 ///
 /// \returns The found value, or nullptr if no value is found.
-Value *FindAvailableLoadedValue(LoadInst *Load,
-BasicBlock *ScanBB,
+Value *FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
 BasicBlock::iterator &ScanFrom,
 unsigned MaxInstsToScan = DefMaxInstsToScan,
-AAResults *AA = nullptr,
+BatchAAResults *AA = nullptr,
 bool *IsLoadCSE = nullptr,
 unsigned *NumScanedInst = nullptr);
 
@@ -141,7 +140,8 @@ Value *FindAvailableLoadedValue(LoadInst *Load,
 /// FindAvailableLoadedValue() for the case where we are not interested in
 /// finding the closest clobbering instruction if no available load is found.
 /// This overload cannot be used to scan across multiple blocks.
-Value *FindAvailableLoadedValue(LoadInst *Load, AAResults &AA, bool *IsLoadCSE,
+Value *FindAvailableLoadedValue(LoadInst *Load, BatchAAResults &AA,
+bool *IsLoadCSE,
 unsigned MaxInstsToScan = DefMaxInstsToScan);
 
 /// Scan backwards to see if we have the value of the given pointer available
@@ -170,7 +170,7 @@ Value *FindAvailableLoadedValue(LoadInst *Load, AAResults 
&AA, bool *IsLoadCSE,
 Value *findAvailablePtrLoadStore(const MemoryLocation &Loc, Type *AccessTy,
  bool AtLeastAtomic, BasicBlock *ScanBB,
  BasicBlock::iterator &ScanFrom,
- unsigned MaxInstsToScan, AAResults *AA,
+ unsigned MaxInstsToScan, BatchAAResults *AA,
  bool *IsLoadCSE, unsigned *NumScanedInst);
 
 /// Returns true if a pointer value \p A can be replace with another pointer
diff --git a/llvm/lib/Analysis/Lint.cpp b/llvm/lib/Analysis/Lint.cpp
index 1ebc593016bc0..16635097d20af 100644
--- a/llvm/lib/Analysis/Lint.cpp
+++ b/llvm/lib/Analysis/Lint.cpp
@@ -657,11 +657,12 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk,
 BasicBlock::iterator BBI = L->getIterator();
 BasicBlock *BB = L->getParent();
 SmallPtrSet VisitedBlocks;
+BatchAAResults BatchAA(*AA);
 for (;;) {
   if (!VisitedBlocks.insert(BB).second)
 break;
   if (Value *U =
-  FindAvailableLoadedValue(L, BB, BBI, DefMaxInstsToScan, AA))
+  FindAvailableLoadedValue(L, BB, BBI, DefMaxInstsToScan, 
&BatchAA))
 return findValueImpl(U, OffsetOk, Visited);
   if (BBI != BB->begin())
 break;
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 97d21db86abf2..6bf0d2f56eb4e 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -450,11 +450,10 @@ llvm::DefMaxInstsToScan("available-load-scan-limit", 
cl::init(6), cl::Hidden,
"to scan backward from a given instruction, when searching for "
"available loaded value"));
 
-Value *llvm::FindAvailableLoadedValue(LoadInst *Load,
-  BasicBlock *ScanBB,
+Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
   BasicBlock::iterator &ScanFrom,
   unsigned MaxInstsToScan,
-  AAResults *AA, bool *IsLoad,
+  BatchAAResults *AA, bool *IsLoad,
   unsigned *NumScanedInst) 

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79175 (PR #80274)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/80274
___
llvm-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] PR for llvm/llvm-project#79175 (PR #80274)

2024-02-01 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80274
___
llvm-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] PR for llvm/llvm-project#79175 (PR #80274)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-analysis

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#79175

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


9 Files Affected:

- (modified) llvm/include/llvm/Analysis/AliasAnalysis.h (+7) 
- (modified) llvm/include/llvm/Analysis/BasicAliasAnalysis.h (+10-4) 
- (modified) llvm/include/llvm/Analysis/Loads.h (+6-6) 
- (modified) llvm/lib/Analysis/BasicAliasAnalysis.cpp (+4-2) 
- (modified) llvm/lib/Analysis/Lint.cpp (+2-1) 
- (modified) llvm/lib/Analysis/Loads.cpp (+4-5) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp 
(+2-1) 
- (modified) llvm/lib/Transforms/Scalar/JumpThreading.cpp (+8-5) 
- (added) llvm/test/Transforms/JumpThreading/pr79175.ll (+62) 


``diff
diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index d6f732d35fd4c..e8e4f491be5a3 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -287,6 +287,10 @@ class AAQueryInfo {
   ///   store %l, ...
   bool MayBeCrossIteration = false;
 
+  /// Whether alias analysis is allowed to use the dominator tree, for use by
+  /// passes that lazily update the DT while performing AA queries.
+  bool UseDominatorTree = true;
+
   AAQueryInfo(AAResults &AAR, CaptureInfo *CI) : AAR(AAR), CI(CI) {}
 };
 
@@ -668,6 +672,9 @@ class BatchAAResults {
   void enableCrossIterationMode() {
 AAQI.MayBeCrossIteration = true;
   }
+
+  /// Disable the use of the dominator tree during alias analysis queries.
+  void disableDominatorTree() { AAQI.UseDominatorTree = false; }
 };
 
 /// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
diff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h 
b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
index afc1811239f28..7eca82729430d 100644
--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
@@ -43,20 +43,26 @@ class BasicAAResult : public AAResultBase {
   const Function &F;
   const TargetLibraryInfo &TLI;
   AssumptionCache &AC;
-  DominatorTree *DT;
+  /// Use getDT() instead of accessing this member directly, in order to
+  /// respect the AAQI.UseDominatorTree option.
+  DominatorTree *DT_;
+
+  DominatorTree *getDT(const AAQueryInfo &AAQI) const {
+return AAQI.UseDominatorTree ? DT_ : nullptr;
+  }
 
 public:
   BasicAAResult(const DataLayout &DL, const Function &F,
 const TargetLibraryInfo &TLI, AssumptionCache &AC,
 DominatorTree *DT = nullptr)
-  : DL(DL), F(F), TLI(TLI), AC(AC), DT(DT) {}
+  : DL(DL), F(F), TLI(TLI), AC(AC), DT_(DT) {}
 
   BasicAAResult(const BasicAAResult &Arg)
   : AAResultBase(Arg), DL(Arg.DL), F(Arg.F), TLI(Arg.TLI), AC(Arg.AC),
-DT(Arg.DT) {}
+DT_(Arg.DT_) {}
   BasicAAResult(BasicAAResult &&Arg)
   : AAResultBase(std::move(Arg)), DL(Arg.DL), F(Arg.F), TLI(Arg.TLI),
-AC(Arg.AC), DT(Arg.DT) {}
+AC(Arg.AC), DT_(Arg.DT_) {}
 
   /// Handle invalidation events in the new pass manager.
   bool invalidate(Function &Fn, const PreservedAnalyses &PA,
diff --git a/llvm/include/llvm/Analysis/Loads.h 
b/llvm/include/llvm/Analysis/Loads.h
index 2880ed33a34cb..0926093bba99d 100644
--- a/llvm/include/llvm/Analysis/Loads.h
+++ b/llvm/include/llvm/Analysis/Loads.h
@@ -18,7 +18,7 @@
 
 namespace llvm {
 
-class AAResults;
+class BatchAAResults;
 class AssumptionCache;
 class DataLayout;
 class DominatorTree;
@@ -129,11 +129,10 @@ extern cl::opt DefMaxInstsToScan;
 /// location in memory, as opposed to the value operand of a store.
 ///
 /// \returns The found value, or nullptr if no value is found.
-Value *FindAvailableLoadedValue(LoadInst *Load,
-BasicBlock *ScanBB,
+Value *FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
 BasicBlock::iterator &ScanFrom,
 unsigned MaxInstsToScan = DefMaxInstsToScan,
-AAResults *AA = nullptr,
+BatchAAResults *AA = nullptr,
 bool *IsLoadCSE = nullptr,
 unsigned *NumScanedInst = nullptr);
 
@@ -141,7 +140,8 @@ Value *FindAvailableLoadedValue(LoadInst *Load,
 /// FindAvailableLoadedValue() for the case where we are not interested in
 /// finding the closest clobbering instruction if no available load is found.
 /// This overload cannot be used to scan across multiple blocks.
-Value *FindAvailableLoadedValue(LoadInst *Load, AAResults &AA, bool *IsLoadCSE,
+Value *FindAvailableLoadedValue(LoadInst *Load, BatchAAResults &AA,
+bool *IsLoadCSE,
 unsigned MaxInstsToScan = DefMaxInstsToScan);
 
 /// Scan backwards to see if we have the value of the given pointer available
@@ -170,7 +170,7 @@ Value *FindAvailabl

[llvm-branch-commits] [llvm] PR for llvm/llvm-project#79175 (PR #80274)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#79175

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


9 Files Affected:

- (modified) llvm/include/llvm/Analysis/AliasAnalysis.h (+7) 
- (modified) llvm/include/llvm/Analysis/BasicAliasAnalysis.h (+10-4) 
- (modified) llvm/include/llvm/Analysis/Loads.h (+6-6) 
- (modified) llvm/lib/Analysis/BasicAliasAnalysis.cpp (+4-2) 
- (modified) llvm/lib/Analysis/Lint.cpp (+2-1) 
- (modified) llvm/lib/Analysis/Loads.cpp (+4-5) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp 
(+2-1) 
- (modified) llvm/lib/Transforms/Scalar/JumpThreading.cpp (+8-5) 
- (added) llvm/test/Transforms/JumpThreading/pr79175.ll (+62) 


``diff
diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index d6f732d35fd4c..e8e4f491be5a3 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -287,6 +287,10 @@ class AAQueryInfo {
   ///   store %l, ...
   bool MayBeCrossIteration = false;
 
+  /// Whether alias analysis is allowed to use the dominator tree, for use by
+  /// passes that lazily update the DT while performing AA queries.
+  bool UseDominatorTree = true;
+
   AAQueryInfo(AAResults &AAR, CaptureInfo *CI) : AAR(AAR), CI(CI) {}
 };
 
@@ -668,6 +672,9 @@ class BatchAAResults {
   void enableCrossIterationMode() {
 AAQI.MayBeCrossIteration = true;
   }
+
+  /// Disable the use of the dominator tree during alias analysis queries.
+  void disableDominatorTree() { AAQI.UseDominatorTree = false; }
 };
 
 /// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
diff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h 
b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
index afc1811239f28..7eca82729430d 100644
--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
@@ -43,20 +43,26 @@ class BasicAAResult : public AAResultBase {
   const Function &F;
   const TargetLibraryInfo &TLI;
   AssumptionCache &AC;
-  DominatorTree *DT;
+  /// Use getDT() instead of accessing this member directly, in order to
+  /// respect the AAQI.UseDominatorTree option.
+  DominatorTree *DT_;
+
+  DominatorTree *getDT(const AAQueryInfo &AAQI) const {
+return AAQI.UseDominatorTree ? DT_ : nullptr;
+  }
 
 public:
   BasicAAResult(const DataLayout &DL, const Function &F,
 const TargetLibraryInfo &TLI, AssumptionCache &AC,
 DominatorTree *DT = nullptr)
-  : DL(DL), F(F), TLI(TLI), AC(AC), DT(DT) {}
+  : DL(DL), F(F), TLI(TLI), AC(AC), DT_(DT) {}
 
   BasicAAResult(const BasicAAResult &Arg)
   : AAResultBase(Arg), DL(Arg.DL), F(Arg.F), TLI(Arg.TLI), AC(Arg.AC),
-DT(Arg.DT) {}
+DT_(Arg.DT_) {}
   BasicAAResult(BasicAAResult &&Arg)
   : AAResultBase(std::move(Arg)), DL(Arg.DL), F(Arg.F), TLI(Arg.TLI),
-AC(Arg.AC), DT(Arg.DT) {}
+AC(Arg.AC), DT_(Arg.DT_) {}
 
   /// Handle invalidation events in the new pass manager.
   bool invalidate(Function &Fn, const PreservedAnalyses &PA,
diff --git a/llvm/include/llvm/Analysis/Loads.h 
b/llvm/include/llvm/Analysis/Loads.h
index 2880ed33a34cb..0926093bba99d 100644
--- a/llvm/include/llvm/Analysis/Loads.h
+++ b/llvm/include/llvm/Analysis/Loads.h
@@ -18,7 +18,7 @@
 
 namespace llvm {
 
-class AAResults;
+class BatchAAResults;
 class AssumptionCache;
 class DataLayout;
 class DominatorTree;
@@ -129,11 +129,10 @@ extern cl::opt DefMaxInstsToScan;
 /// location in memory, as opposed to the value operand of a store.
 ///
 /// \returns The found value, or nullptr if no value is found.
-Value *FindAvailableLoadedValue(LoadInst *Load,
-BasicBlock *ScanBB,
+Value *FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
 BasicBlock::iterator &ScanFrom,
 unsigned MaxInstsToScan = DefMaxInstsToScan,
-AAResults *AA = nullptr,
+BatchAAResults *AA = nullptr,
 bool *IsLoadCSE = nullptr,
 unsigned *NumScanedInst = nullptr);
 
@@ -141,7 +140,8 @@ Value *FindAvailableLoadedValue(LoadInst *Load,
 /// FindAvailableLoadedValue() for the case where we are not interested in
 /// finding the closest clobbering instruction if no available load is found.
 /// This overload cannot be used to scan across multiple blocks.
-Value *FindAvailableLoadedValue(LoadInst *Load, AAResults &AA, bool *IsLoadCSE,
+Value *FindAvailableLoadedValue(LoadInst *Load, BatchAAResults &AA,
+bool *IsLoadCSE,
 unsigned MaxInstsToScan = DefMaxInstsToScan);
 
 /// Scan backwards to see if we have the value of the given pointer available
@@ -170,7 +170,7 @@ Value *FindAvaila

[llvm-branch-commits] [llvm] [VPlan] Explicitly handle scalar pointer inductions. (PR #80273)

2024-02-01 Thread Florian Hahn via llvm-branch-commits

https://github.com/fhahn edited https://github.com/llvm/llvm-project/pull/80273
___
llvm-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] [VPlan] Consistently use (Part, 0) for first lane scalar values (PR #80271)

2024-02-01 Thread Florian Hahn via llvm-branch-commits

https://github.com/fhahn edited https://github.com/llvm/llvm-project/pull/80271
___
llvm-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] PR for llvm/llvm-project#79175 (PR #80274)

2024-02-01 Thread via llvm-branch-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff d3aeedcd47cb9ac29769716c1eed6d5b80b45728 
9a7c70234b1730815f89f4a68030e62f7cd75cdc -- 
llvm/include/llvm/Analysis/AliasAnalysis.h 
llvm/include/llvm/Analysis/BasicAliasAnalysis.h 
llvm/include/llvm/Analysis/Loads.h llvm/lib/Analysis/BasicAliasAnalysis.cpp 
llvm/lib/Analysis/Lint.cpp llvm/lib/Analysis/Loads.cpp 
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp 
llvm/lib/Transforms/Scalar/JumpThreading.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 1254a05002..da72a7b201 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -1033,7 +1033,8 @@ Instruction *InstCombinerImpl::visitLoadInst(LoadInst 
&LI) {
   // separated by a few arithmetic operations.
   bool IsLoadCSE = false;
   BatchAAResults BatchAA(*AA);
-  if (Value *AvailableVal = FindAvailableLoadedValue(&LI, BatchAA, 
&IsLoadCSE)) {
+  if (Value *AvailableVal =
+  FindAvailableLoadedValue(&LI, BatchAA, &IsLoadCSE)) {
 if (IsLoadCSE)
   combineMetadataForCSE(cast(AvailableVal), &LI, false);
 

``




https://github.com/llvm/llvm-project/pull/80274
___
llvm-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] PR for llvm/llvm-project#79175 (PR #80274)

2024-02-01 Thread Nikita Popov via llvm-branch-commits

nikic wrote:

Note that this is an API and ABI breaking fix, so should be backported sooner 
rather than later.

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


[llvm-branch-commits] [clang] [Clang][RISCV] Refactor builtins to TableGen (PR #80280)

2024-02-01 Thread Wang Pengcheng via llvm-branch-commits

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/80280

This mechanism is introduced by #68324.

This refactor makes the prototype and attributes clear.



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


[llvm-branch-commits] [clang] [Clang][RISCV] Refactor builtins to TableGen (PR #80280)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-risc-v

Author: Wang Pengcheng (wangpc-pp)


Changes

This mechanism is introduced by #68324.

This refactor makes the prototype and attributes clear.


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


6 Files Affected:

- (removed) clang/include/clang/Basic/BuiltinsRISCV.def (-93) 
- (added) clang/include/clang/Basic/BuiltinsRISCV.td (+148) 
- (modified) clang/include/clang/Basic/CMakeLists.txt (+4) 
- (modified) clang/include/clang/Basic/TargetBuiltins.h (+1-1) 
- (modified) clang/include/module.modulemap (-1) 
- (modified) clang/lib/Basic/Targets/RISCV.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
deleted file mode 100644
index 1528b18c82ead..0
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ /dev/null
@@ -1,93 +0,0 @@
-//==- BuiltinsRISCV.def - RISC-V Builtin function database ---*- C++ 
-*-==//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file defines the RISC-V-specific builtin function database.  Users of
-// this file must define the BUILTIN macro to make use of this information.
-//
-//===--===//
-
-#if defined(BUILTIN) && !defined(TARGET_BUILTIN)
-#   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
-#endif
-
-// Zbb extension
-TARGET_BUILTIN(__builtin_riscv_orc_b_32, "UiUi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_orc_b_64, "UWiUWi", "nc", "zbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_clz_32, "UiUi", "nc", "zbb|xtheadbb")
-TARGET_BUILTIN(__builtin_riscv_clz_64, "UiUWi", "nc", "zbb|xtheadbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_ctz_32, "UiUi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_ctz_64, "UiUWi", "nc", "zbb,64bit")
-
-// Zbc or Zbkc extension
-TARGET_BUILTIN(__builtin_riscv_clmul_32, "UiUiUi", "nc", "zbc|zbkc")
-TARGET_BUILTIN(__builtin_riscv_clmul_64, "UWiUWiUWi", "nc", "zbc|zbkc,64bit")
-TARGET_BUILTIN(__builtin_riscv_clmulh_32, "UiUiUi", "nc", "zbc|zbkc,32bit")
-TARGET_BUILTIN(__builtin_riscv_clmulh_64, "UWiUWiUWi", "nc", "zbc|zbkc,64bit")
-TARGET_BUILTIN(__builtin_riscv_clmulr_32, "UiUiUi", "nc", "zbc,32bit")
-TARGET_BUILTIN(__builtin_riscv_clmulr_64, "UWiUWiUWi", "nc", "zbc,64bit")
-
-// Zbkx
-TARGET_BUILTIN(__builtin_riscv_xperm4_32, "UiUiUi", "nc", "zbkx,32bit")
-TARGET_BUILTIN(__builtin_riscv_xperm4_64, "UWiUWiUWi", "nc", "zbkx,64bit")
-TARGET_BUILTIN(__builtin_riscv_xperm8_32, "UiUiUi", "nc", "zbkx,32bit")
-TARGET_BUILTIN(__builtin_riscv_xperm8_64, "UWiUWiUWi", "nc", "zbkx,64bit")
-
-// Zbkb extension
-TARGET_BUILTIN(__builtin_riscv_brev8_32, "UiUi", "nc", "zbkb")
-TARGET_BUILTIN(__builtin_riscv_brev8_64, "UWiUWi", "nc", "zbkb,64bit")
-TARGET_BUILTIN(__builtin_riscv_zip_32, "UiUi", "nc", "zbkb,32bit")
-TARGET_BUILTIN(__builtin_riscv_unzip_32, "UiUi", "nc", "zbkb,32bit")
-
-// Zknd extension
-TARGET_BUILTIN(__builtin_riscv_aes32dsi, "UiUiUiIUi", "nc", "zknd,32bit")
-TARGET_BUILTIN(__builtin_riscv_aes32dsmi, "UiUiUiIUi", "nc", "zknd,32bit")
-TARGET_BUILTIN(__builtin_riscv_aes64ds, "UWiUWiUWi", "nc", "zknd,64bit")
-TARGET_BUILTIN(__builtin_riscv_aes64dsm, "UWiUWiUWi", "nc", "zknd,64bit")
-TARGET_BUILTIN(__builtin_riscv_aes64im, "UWiUWi", "nc", "zknd,64bit")
-
-// Zknd & Zkne
-TARGET_BUILTIN(__builtin_riscv_aes64ks1i, "UWiUWiIUi", "nc", "zknd|zkne,64bit")
-TARGET_BUILTIN(__builtin_riscv_aes64ks2, "UWiUWiUWi", "nc", "zknd|zkne,64bit")
-
-// Zkne extension
-TARGET_BUILTIN(__builtin_riscv_aes32esi, "UiUiUiIUi", "nc", "zkne,32bit")
-TARGET_BUILTIN(__builtin_riscv_aes32esmi, "UiUiUiIUi", "nc", "zkne,32bit")
-TARGET_BUILTIN(__builtin_riscv_aes64es, "UWiUWiUWi", "nc", "zkne,64bit")
-TARGET_BUILTIN(__builtin_riscv_aes64esm, "UWiUWiUWi", "nc", "zkne,64bit")
-
-// Zknh extension
-TARGET_BUILTIN(__builtin_riscv_sha256sig0, "UiUi", "nc", "zknh")
-TARGET_BUILTIN(__builtin_riscv_sha256sig1, "UiUi", "nc", "zknh")
-TARGET_BUILTIN(__builtin_riscv_sha256sum0, "UiUi", "nc", "zknh")
-TARGET_BUILTIN(__builtin_riscv_sha256sum1, "UiUi", "nc", "zknh")
-
-TARGET_BUILTIN(__builtin_riscv_sha512sig0h, "UiUiUi", "nc", "zknh,32bit")
-TARGET_BUILTIN(__builtin_riscv_sha512sig0l, "UiUiUi", "nc", "zknh,32bit")
-TARGET_BUILTIN(__builtin_riscv_sha512sig1h, "UiUiUi", "nc", "zknh,32bit")
-TARGET_BUILTIN(__builtin_riscv_sha512sig1l, "UiUiUi", "nc", "zknh,32bit")
-TARGET_BUILTIN(__builtin_riscv_sha512sum0r, "UiUiUi", "nc", "zknh,32bit")
-TARGET_BUILTIN(__builtin_riscv_sha512sum1r, "UiUiUi", "nc", "zknh,32bit")
-TARGET_BUILTIN(__builtin_riscv_sha512sig0, "UWiUWi", "nc", "zknh,64bit")
-TARGET_BUILTIN(__builtin_riscv_sha512sig1, "UWiUWi", "nc", "zknh,64bit")
-TARGET_BUIL

[llvm-branch-commits] [mlir] [llvm] [OpenMPIRBuilder][MLIR] Pass target-cpu and target-features to outlined functions (PR #80283)

2024-02-01 Thread Sergio Afonso via llvm-branch-commits

https://github.com/skatrak created 
https://github.com/llvm/llvm-project/pull/80283

This patch adds support for forwarding the target-cpu and target-features 
attributes to functions outlined in the OpenMPIRBuilder. This, in turn, results 
in the addition of these attributes for functions created during the 
translation of the `omp.parallel`, `omp.task` and `omp.teams` operations, and 
for the `omp.wsloop` operation when doing codegen for an OpenMP target device.

>From e3ff5c1160106892a07dad4d29868c756891be38 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Thu, 1 Feb 2024 12:00:00 +
Subject: [PATCH] [OpenMPIRBuilder] Pass target-cpu and target-features to
 outlined functions

This patch adds support for forwarding the target-cpu and target-features
attributes to functions outlined in the OpenMPIRBuilder. This, in turn, results
in the addition of these attributes for functions created during the
translation of the `omp.parallel`, `omp.task` and `omp.teams` operations, and
for the `omp.wsloop` operation when doing codegen for an OpenMP target device.
---
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp |  9 
 .../LLVMIR/omptarget-parallel-wsloop.mlir | 15 ++-
 mlir/test/Target/LLVMIR/openmp-llvm.mlir  | 43 +++
 mlir/test/Target/LLVMIR/openmp-teams.mlir | 25 +++
 4 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 8eb8a13686dd3..9c33f387e08fb 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -679,6 +679,15 @@ void OpenMPIRBuilder::finalize(Function *Fn) {
 
 Function *OutlinedFn = Extractor.extractCodeRegion(CEAC);
 
+// Forward target-cpu, target-features attributes to the outlined function.
+if (auto Attr = OuterFn->getFnAttribute("target-cpu");
+Attr.isStringAttribute())
+  OutlinedFn->addFnAttr(Attr);
+
+if (auto Attr = OuterFn->getFnAttribute("target-features");
+Attr.isStringAttribute())
+  OutlinedFn->addFnAttr(Attr);
+
 LLVM_DEBUG(dbgs() << "After  outlining: " << *OuterFn << "\n");
 LLVM_DEBUG(dbgs() << "   Outlined function: " << *OutlinedFn << "\n");
 assert(OutlinedFn->getReturnType()->isVoidTy() &&
diff --git a/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir 
b/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
index 43d0934d3a931..8ab50f05f0716 100644
--- a/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
+++ b/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
@@ -4,7 +4,10 @@
 // for nested omp do loop inside omp target region
 
 module attributes {dlti.dl_spec = 
#dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui32>>, 
llvm.data_layout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8",
 llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, 
omp.is_target_device = true } {
-  llvm.func @target_parallel_wsloop(%arg0: !llvm.ptr ){
+  llvm.func @target_parallel_wsloop(%arg0: !llvm.ptr) attributes {
+target_cpu = "gfx90a",
+target_features = #llvm.target_features<["+gfx9-insts", 
"+wavefrontsize64"]>
+  } {
 omp.parallel {
   %loop_ub = llvm.mlir.constant(9 : i32) : i32
   %loop_lb = llvm.mlir.constant(0 : i32) : i32
@@ -29,8 +32,16 @@ module attributes {dlti.dl_spec = 
#dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memo
 // CHECK:  define internal void @[[PARALLEL_FUNC]]
 // CHECK-SAME:  (ptr noalias noundef %[[TID_ADDR:.*]], ptr noalias noundef 
%[[ZERO_ADDR:.*]],
 // CHECK-SAME:  ptr %[[ARG_PTR:.*]])
+// CHECK-SAME:  #[[ATTRS1:[0-9]+]]
 // CHECK: call void @__kmpc_for_static_loop_4u(ptr addrspacecast (ptr 
addrspace(1) @[[GLOB]] to ptr),
 // CHECK-SAME:   ptr @[[LOOP_BODY_FUNC:.*]], ptr %[[LOO_BODY_FUNC_ARG:.*]], 
i32 10,
 // CHECK-SAME:   i32 %[[THREAD_NUM:.*]], i32 0)
 
-// CHECK:  define internal void @[[LOOP_BODY_FUNC]](i32 %[[CNT:.*]], ptr 
%[[LOOP_BODY_ARG_PTR:.*]]) {
+// CHECK:  define internal void @[[LOOP_BODY_FUNC]](i32 %[[CNT:.*]], ptr 
%[[LOOP_BODY_ARG_PTR:.*]]) #[[ATTRS2:[0-9]+]] {
+
+// CHECK:  attributes #[[ATTRS2]] = {
+// CHECK-SAME:  "target-cpu"="gfx90a"
+// CHECK-SAME:  "target-features"="+gfx9-insts,+wavefrontsize64"
+// CHECK:  attributes #[[ATTRS1]] = {
+// CHECK-SAME:  "target-cpu"="gfx90a"
+// CHECK-SAME:  "target-features"="+gfx9-insts,+wavefrontsize64"
diff --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir 
b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
index 29baa84e7e19d..036367b262f07 100644
--- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -179,6 +179,27 @@ llvm.func @test_omp_parallel_if_1(%arg0: i32) -> () {
 
 // -
 
+// CHECK-LABEL: define void @test_omp_parallel_attrs()
+llvm.func @test_omp_parallel_attrs() -> () 

[llvm-branch-commits] [mlir] [llvm] [OpenMPIRBuilder][MLIR] Pass target-cpu and target-features to outlined functions (PR #80283)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: Sergio Afonso (skatrak)


Changes

This patch adds support for forwarding the target-cpu and target-features 
attributes to functions outlined in the OpenMPIRBuilder. This, in turn, results 
in the addition of these attributes for functions created during the 
translation of the `omp.parallel`, `omp.task` and `omp.teams` operations, and 
for the `omp.wsloop` operation when doing codegen for an OpenMP target device.

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


4 Files Affected:

- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+9) 
- (modified) mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir (+13-2) 
- (modified) mlir/test/Target/LLVMIR/openmp-llvm.mlir (+43) 
- (modified) mlir/test/Target/LLVMIR/openmp-teams.mlir (+25) 


``diff
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 8eb8a13686dd3..9c33f387e08fb 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -679,6 +679,15 @@ void OpenMPIRBuilder::finalize(Function *Fn) {
 
 Function *OutlinedFn = Extractor.extractCodeRegion(CEAC);
 
+// Forward target-cpu, target-features attributes to the outlined function.
+if (auto Attr = OuterFn->getFnAttribute("target-cpu");
+Attr.isStringAttribute())
+  OutlinedFn->addFnAttr(Attr);
+
+if (auto Attr = OuterFn->getFnAttribute("target-features");
+Attr.isStringAttribute())
+  OutlinedFn->addFnAttr(Attr);
+
 LLVM_DEBUG(dbgs() << "After  outlining: " << *OuterFn << "\n");
 LLVM_DEBUG(dbgs() << "   Outlined function: " << *OutlinedFn << "\n");
 assert(OutlinedFn->getReturnType()->isVoidTy() &&
diff --git a/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir 
b/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
index 43d0934d3a931..8ab50f05f0716 100644
--- a/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
+++ b/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
@@ -4,7 +4,10 @@
 // for nested omp do loop inside omp target region
 
 module attributes {dlti.dl_spec = 
#dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui32>>, 
llvm.data_layout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8",
 llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, 
omp.is_target_device = true } {
-  llvm.func @target_parallel_wsloop(%arg0: !llvm.ptr ){
+  llvm.func @target_parallel_wsloop(%arg0: !llvm.ptr) attributes {
+target_cpu = "gfx90a",
+target_features = #llvm.target_features<["+gfx9-insts", 
"+wavefrontsize64"]>
+  } {
 omp.parallel {
   %loop_ub = llvm.mlir.constant(9 : i32) : i32
   %loop_lb = llvm.mlir.constant(0 : i32) : i32
@@ -29,8 +32,16 @@ module attributes {dlti.dl_spec = 
#dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memo
 // CHECK:  define internal void @[[PARALLEL_FUNC]]
 // CHECK-SAME:  (ptr noalias noundef %[[TID_ADDR:.*]], ptr noalias noundef 
%[[ZERO_ADDR:.*]],
 // CHECK-SAME:  ptr %[[ARG_PTR:.*]])
+// CHECK-SAME:  #[[ATTRS1:[0-9]+]]
 // CHECK: call void @__kmpc_for_static_loop_4u(ptr addrspacecast (ptr 
addrspace(1) @[[GLOB]] to ptr),
 // CHECK-SAME:   ptr @[[LOOP_BODY_FUNC:.*]], ptr %[[LOO_BODY_FUNC_ARG:.*]], 
i32 10,
 // CHECK-SAME:   i32 %[[THREAD_NUM:.*]], i32 0)
 
-// CHECK:  define internal void @[[LOOP_BODY_FUNC]](i32 %[[CNT:.*]], ptr 
%[[LOOP_BODY_ARG_PTR:.*]]) {
+// CHECK:  define internal void @[[LOOP_BODY_FUNC]](i32 %[[CNT:.*]], ptr 
%[[LOOP_BODY_ARG_PTR:.*]]) #[[ATTRS2:[0-9]+]] {
+
+// CHECK:  attributes #[[ATTRS2]] = {
+// CHECK-SAME:  "target-cpu"="gfx90a"
+// CHECK-SAME:  "target-features"="+gfx9-insts,+wavefrontsize64"
+// CHECK:  attributes #[[ATTRS1]] = {
+// CHECK-SAME:  "target-cpu"="gfx90a"
+// CHECK-SAME:  "target-features"="+gfx9-insts,+wavefrontsize64"
diff --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir 
b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
index 29baa84e7e19d..036367b262f07 100644
--- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -179,6 +179,27 @@ llvm.func @test_omp_parallel_if_1(%arg0: i32) -> () {
 
 // -
 
+// CHECK-LABEL: define void @test_omp_parallel_attrs()
+llvm.func @test_omp_parallel_attrs() -> () attributes {
+  target_cpu = "x86-64",
+  target_features = #llvm.target_features<["+mmx", "+sse"]>
+} {
+  // CHECK: call void{{.*}}@__kmpc_fork_call{{.*}}@[[OMP_OUTLINED_FN:.*]])
+  omp.parallel {
+omp.barrier
+omp.terminator
+  }
+
+  llvm.return
+}
+
+// CHECK: define {{.*}} @[[OMP_OUTLINED_FN]]{{.*}} #[[ATTRS:[0-9]+]]
+// CHECK: attributes #[[ATTRS]] = {
+// CHECK-SAME: "target-cpu"="x86-64"
+// CHECK-SAME: "target-features"="+mmx,+sse"
+
+// -
+
 // CHECK-LABEL: define void @test_omp_parallel_3()
 llvm.func @test_omp_pa

[llvm-branch-commits] [mlir] [llvm] [OpenMPIRBuilder][MLIR] Pass target-cpu and target-features to outlined functions (PR #80283)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-llvm

Author: Sergio Afonso (skatrak)


Changes

This patch adds support for forwarding the target-cpu and target-features 
attributes to functions outlined in the OpenMPIRBuilder. This, in turn, results 
in the addition of these attributes for functions created during the 
translation of the `omp.parallel`, `omp.task` and `omp.teams` operations, and 
for the `omp.wsloop` operation when doing codegen for an OpenMP target device.

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


4 Files Affected:

- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+9) 
- (modified) mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir (+13-2) 
- (modified) mlir/test/Target/LLVMIR/openmp-llvm.mlir (+43) 
- (modified) mlir/test/Target/LLVMIR/openmp-teams.mlir (+25) 


``diff
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 8eb8a13686dd3..9c33f387e08fb 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -679,6 +679,15 @@ void OpenMPIRBuilder::finalize(Function *Fn) {
 
 Function *OutlinedFn = Extractor.extractCodeRegion(CEAC);
 
+// Forward target-cpu, target-features attributes to the outlined function.
+if (auto Attr = OuterFn->getFnAttribute("target-cpu");
+Attr.isStringAttribute())
+  OutlinedFn->addFnAttr(Attr);
+
+if (auto Attr = OuterFn->getFnAttribute("target-features");
+Attr.isStringAttribute())
+  OutlinedFn->addFnAttr(Attr);
+
 LLVM_DEBUG(dbgs() << "After  outlining: " << *OuterFn << "\n");
 LLVM_DEBUG(dbgs() << "   Outlined function: " << *OutlinedFn << "\n");
 assert(OutlinedFn->getReturnType()->isVoidTy() &&
diff --git a/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir 
b/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
index 43d0934d3a931..8ab50f05f0716 100644
--- a/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
+++ b/mlir/test/Target/LLVMIR/omptarget-parallel-wsloop.mlir
@@ -4,7 +4,10 @@
 // for nested omp do loop inside omp target region
 
 module attributes {dlti.dl_spec = 
#dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui32>>, 
llvm.data_layout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8",
 llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, 
omp.is_target_device = true } {
-  llvm.func @target_parallel_wsloop(%arg0: !llvm.ptr ){
+  llvm.func @target_parallel_wsloop(%arg0: !llvm.ptr) attributes {
+target_cpu = "gfx90a",
+target_features = #llvm.target_features<["+gfx9-insts", 
"+wavefrontsize64"]>
+  } {
 omp.parallel {
   %loop_ub = llvm.mlir.constant(9 : i32) : i32
   %loop_lb = llvm.mlir.constant(0 : i32) : i32
@@ -29,8 +32,16 @@ module attributes {dlti.dl_spec = 
#dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memo
 // CHECK:  define internal void @[[PARALLEL_FUNC]]
 // CHECK-SAME:  (ptr noalias noundef %[[TID_ADDR:.*]], ptr noalias noundef 
%[[ZERO_ADDR:.*]],
 // CHECK-SAME:  ptr %[[ARG_PTR:.*]])
+// CHECK-SAME:  #[[ATTRS1:[0-9]+]]
 // CHECK: call void @__kmpc_for_static_loop_4u(ptr addrspacecast (ptr 
addrspace(1) @[[GLOB]] to ptr),
 // CHECK-SAME:   ptr @[[LOOP_BODY_FUNC:.*]], ptr %[[LOO_BODY_FUNC_ARG:.*]], 
i32 10,
 // CHECK-SAME:   i32 %[[THREAD_NUM:.*]], i32 0)
 
-// CHECK:  define internal void @[[LOOP_BODY_FUNC]](i32 %[[CNT:.*]], ptr 
%[[LOOP_BODY_ARG_PTR:.*]]) {
+// CHECK:  define internal void @[[LOOP_BODY_FUNC]](i32 %[[CNT:.*]], ptr 
%[[LOOP_BODY_ARG_PTR:.*]]) #[[ATTRS2:[0-9]+]] {
+
+// CHECK:  attributes #[[ATTRS2]] = {
+// CHECK-SAME:  "target-cpu"="gfx90a"
+// CHECK-SAME:  "target-features"="+gfx9-insts,+wavefrontsize64"
+// CHECK:  attributes #[[ATTRS1]] = {
+// CHECK-SAME:  "target-cpu"="gfx90a"
+// CHECK-SAME:  "target-features"="+gfx9-insts,+wavefrontsize64"
diff --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir 
b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
index 29baa84e7e19d..036367b262f07 100644
--- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -179,6 +179,27 @@ llvm.func @test_omp_parallel_if_1(%arg0: i32) -> () {
 
 // -
 
+// CHECK-LABEL: define void @test_omp_parallel_attrs()
+llvm.func @test_omp_parallel_attrs() -> () attributes {
+  target_cpu = "x86-64",
+  target_features = #llvm.target_features<["+mmx", "+sse"]>
+} {
+  // CHECK: call void{{.*}}@__kmpc_fork_call{{.*}}@[[OMP_OUTLINED_FN:.*]])
+  omp.parallel {
+omp.barrier
+omp.terminator
+  }
+
+  llvm.return
+}
+
+// CHECK: define {{.*}} @[[OMP_OUTLINED_FN]]{{.*}} #[[ATTRS:[0-9]+]]
+// CHECK: attributes #[[ATTRS]] = {
+// CHECK-SAME: "target-cpu"="x86-64"
+// CHECK-SAME: "target-features"="+mmx,+sse"
+
+// -
+
 // CHECK-LABEL: define void @test_omp_parallel_3()
 llvm.func @test_o

[llvm-branch-commits] [mlir] [llvm] [OpenMPIRBuilder][MLIR] Pass target-cpu and target-features to outlined functions (PR #80283)

2024-02-01 Thread Kiran Chandramohan via llvm-branch-commits

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

LG. 

https://github.com/llvm/llvm-project/pull/80283
___
llvm-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] [llvm] [OpenMPIRBuilder][MLIR] Pass target-cpu and target-features to outlined functions (PR #80283)

2024-02-01 Thread Dominik Adamski via llvm-branch-commits

https://github.com/DominikAdamski edited 
https://github.com/llvm/llvm-project/pull/80283
___
llvm-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] [llvm] [OpenMPIRBuilder][MLIR] Pass target-cpu and target-features to outlined functions (PR #80283)

2024-02-01 Thread Dominik Adamski via llvm-branch-commits


@@ -679,6 +679,15 @@ void OpenMPIRBuilder::finalize(Function *Fn) {
 
 Function *OutlinedFn = Extractor.extractCodeRegion(CEAC);
 
+// Forward target-cpu, target-features attributes to the outlined function.
+if (auto Attr = OuterFn->getFnAttribute("target-cpu");
+Attr.isStringAttribute())

DominikAdamski wrote:

Nit:
```
auto CpuAttr  = OuterFn->getFnAttribute("target-cpu");
if (CpuAttr.isStringAttribute()) 
```

https://github.com/llvm/llvm-project/pull/80283
___
llvm-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] [llvm] [OpenMPIRBuilder][MLIR] Pass target-cpu and target-features to outlined functions (PR #80283)

2024-02-01 Thread Dominik Adamski via llvm-branch-commits

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

LGTM

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


[llvm-branch-commits] [openmp] PR for llvm/llvm-project#80117 (PR #80291)

2024-02-01 Thread via llvm-branch-commits

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


[llvm-branch-commits] [openmp] PR for llvm/llvm-project#80117 (PR #80291)

2024-02-01 Thread via llvm-branch-commits

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

resolves llvm/llvm-project#80117

>From db865342e024daf3f3e0a0efe89e4c97f9b84057 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <37383324+aga...@users.noreply.github.com>
Date: Thu, 1 Feb 2024 08:14:05 -0500
Subject: [PATCH] [openmp] On Windows, fix standalone cmake build (#80174)

This fixes: https://github.com/llvm/llvm-project/issues/80117

(cherry picked from commit d2565bb11308f6cf98d838e828d9bcbe2d51e0e4)
---
 openmp/cmake/HandleOpenMPOptions.cmake | 8 
 1 file changed, 8 insertions(+)

diff --git a/openmp/cmake/HandleOpenMPOptions.cmake 
b/openmp/cmake/HandleOpenMPOptions.cmake
index 201aeabbd3df9..71346201129b6 100644
--- a/openmp/cmake/HandleOpenMPOptions.cmake
+++ b/openmp/cmake/HandleOpenMPOptions.cmake
@@ -9,6 +9,14 @@ if (NOT COMMAND append_if)
   endfunction()
 endif()
 
+if (NOT COMMAND append)
+  function(append value)
+foreach(variable ${ARGN})
+  set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
+endforeach(variable)
+  endfunction()
+endif()
+
 # MSVC and clang-cl in compatibility mode map -Wall to -Weverything.
 # TODO: LLVM adds /W4 instead, check if that works for the OpenMP runtimes.
 if (NOT MSVC)

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


[llvm-branch-commits] [openmp] PR for llvm/llvm-project#80117 (PR #80291)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:

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

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


[llvm-branch-commits] [openmp] PR for llvm/llvm-project#80117 (PR #80291)

2024-02-01 Thread Joseph Huber via llvm-branch-commits

jhuber6 wrote:

Merge

https://github.com/llvm/llvm-project/pull/80291
___
llvm-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] [compiler-rt] [flang] [clang] [libcxx] [libc] [RISCV] Support select optimization (PR #80124)

2024-02-01 Thread Philip Reames via llvm-branch-commits

preames wrote:

JFYI, I don't find the AArch64 data particularly convincing for RISCV.  The 
magnitude of the change even on AArch64 is small, and could easily be swung one 
direction or the other by differences in implementation between the backends.  

https://github.com/llvm/llvm-project/pull/80124
___
llvm-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] PR for llvm/llvm-project#79860 (PR #79969)

2024-02-01 Thread via llvm-branch-commits

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

>From 692f465456fa9e3690bd9b9b28a789f3979ffbe0 Mon Sep 17 00:00:00 2001
From: David Green 
Date: Mon, 29 Jan 2024 16:46:22 +
Subject: [PATCH] [AArch64] Don't generate neon integer complex numbers with
 +sve2. NFC (#79829)

The condition for allowing integer complex number support could also
allow neon fixed length complex numbers if +sve2 was specified. This
tightens the condition to only allow integer complex number support for
scalable vectors.

We could generalize this in the future to generate SVE intrinsics for
fixed-length vectors, but for the moment this opts for the simpler fix.

(cherry picked from commit 9520773c46777adbc1d489f831d6c93b8287ca0e)
---
 .../Target/AArch64/AArch64ISelLowering.cpp|  4 +--
 .../AArch64/complex-deinterleaving-f16-add.ll | 27 +++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index a59b1f2ec3c1c..e97f5e3220148 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -26915,7 +26915,7 @@ bool 
AArch64TargetLowering::isComplexDeinterleavingOperationSupported(
 return false;
 
   // If the vector is scalable, SVE is enabled, implying support for complex
-  // numbers. Otherwirse, we need to ensure complex number support is avaialble
+  // numbers. Otherwise, we need to ensure complex number support is available
   if (!VTy->isScalableTy() && !Subtarget->hasComplxNum())
 return false;
 
@@ -26931,7 +26931,7 @@ bool 
AArch64TargetLowering::isComplexDeinterleavingOperationSupported(
   !llvm::isPowerOf2_32(VTyWidth))
 return false;
 
-  if (ScalarTy->isIntegerTy() && Subtarget->hasSVE2()) {
+  if (ScalarTy->isIntegerTy() && Subtarget->hasSVE2() && VTy->isScalableTy()) {
 unsigned ScalarWidth = ScalarTy->getScalarSizeInBits();
 return 8 <= ScalarWidth && ScalarWidth <= 64;
   }
diff --git a/llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll 
b/llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll
index 93497f38063d2..7b8448de2331b 100644
--- a/llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll
+++ b/llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll
@@ -1,6 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s --mattr=+complxnum,+neon,+fullfp16 -o - | FileCheck %s
 ; RUN: llc < %s --mattr=+complxnum,+neon,+fullfp16,+sve -o - | FileCheck %s
+; RUN: llc < %s --mattr=+complxnum,+neon,+fullfp16,+sve2 -o - | FileCheck %s
 
 target triple = "aarch64"
 
@@ -158,6 +159,32 @@ entry:
   ret <16 x half> %interleaved.vec
 }
 
+
+; Expected not to transform as it is integer
+define <16 x i16> @complex_add_v16i16(<16 x i16> %a, <16 x i16> %b) {
+; CHECK-LABEL: complex_add_v16i16:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:uzp1 v4.8h, v2.8h, v3.8h
+; CHECK-NEXT:uzp1 v5.8h, v0.8h, v1.8h
+; CHECK-NEXT:uzp2 v0.8h, v0.8h, v1.8h
+; CHECK-NEXT:uzp2 v1.8h, v2.8h, v3.8h
+; CHECK-NEXT:sub v2.8h, v4.8h, v0.8h
+; CHECK-NEXT:add v1.8h, v1.8h, v5.8h
+; CHECK-NEXT:zip1 v0.8h, v2.8h, v1.8h
+; CHECK-NEXT:zip2 v1.8h, v2.8h, v1.8h
+; CHECK-NEXT:ret
+entry:
+  %a.real = shufflevector <16 x i16> %a, <16 x i16> zeroinitializer, <8 x i32> 

+  %a.imag = shufflevector <16 x i16> %a, <16 x i16> zeroinitializer, <8 x i32> 

+  %b.real = shufflevector <16 x i16> %b, <16 x i16> zeroinitializer, <8 x i32> 

+  %b.imag = shufflevector <16 x i16> %b, <16 x i16> zeroinitializer, <8 x i32> 

+  %0 = sub <8 x i16> %b.real, %a.imag
+  %1 = add <8 x i16> %b.imag, %a.real
+  %interleaved.vec = shufflevector <8 x i16> %0, <8 x i16> %1, <16 x i32> 
+  ret <16 x i16> %interleaved.vec
+}
+
+
 declare { <2 x half>, <2 x half> } 
@llvm.experimental.vector.deinterleave2.v4f16(<4 x half>)
 declare <4 x half> @llvm.experimental.vector.interleave2.v4f16(<2 x half>, <2 
x half>)
 

___
llvm-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] 692f465 - [AArch64] Don't generate neon integer complex numbers with +sve2. NFC (#79829)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

Author: David Green
Date: 2024-02-01T12:50:10-08:00
New Revision: 692f465456fa9e3690bd9b9b28a789f3979ffbe0

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

LOG: [AArch64] Don't generate neon integer complex numbers with +sve2. NFC 
(#79829)

The condition for allowing integer complex number support could also
allow neon fixed length complex numbers if +sve2 was specified. This
tightens the condition to only allow integer complex number support for
scalable vectors.

We could generalize this in the future to generate SVE intrinsics for
fixed-length vectors, but for the moment this opts for the simpler fix.

(cherry picked from commit 9520773c46777adbc1d489f831d6c93b8287ca0e)

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index a59b1f2ec3c1c..e97f5e3220148 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -26915,7 +26915,7 @@ bool 
AArch64TargetLowering::isComplexDeinterleavingOperationSupported(
 return false;
 
   // If the vector is scalable, SVE is enabled, implying support for complex
-  // numbers. Otherwirse, we need to ensure complex number support is avaialble
+  // numbers. Otherwise, we need to ensure complex number support is available
   if (!VTy->isScalableTy() && !Subtarget->hasComplxNum())
 return false;
 
@@ -26931,7 +26931,7 @@ bool 
AArch64TargetLowering::isComplexDeinterleavingOperationSupported(
   !llvm::isPowerOf2_32(VTyWidth))
 return false;
 
-  if (ScalarTy->isIntegerTy() && Subtarget->hasSVE2()) {
+  if (ScalarTy->isIntegerTy() && Subtarget->hasSVE2() && VTy->isScalableTy()) {
 unsigned ScalarWidth = ScalarTy->getScalarSizeInBits();
 return 8 <= ScalarWidth && ScalarWidth <= 64;
   }

diff  --git a/llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll 
b/llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll
index 93497f38063d2..7b8448de2331b 100644
--- a/llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll
+++ b/llvm/test/CodeGen/AArch64/complex-deinterleaving-f16-add.ll
@@ -1,6 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc < %s --mattr=+complxnum,+neon,+fullfp16 -o - | FileCheck %s
 ; RUN: llc < %s --mattr=+complxnum,+neon,+fullfp16,+sve -o - | FileCheck %s
+; RUN: llc < %s --mattr=+complxnum,+neon,+fullfp16,+sve2 -o - | FileCheck %s
 
 target triple = "aarch64"
 
@@ -158,6 +159,32 @@ entry:
   ret <16 x half> %interleaved.vec
 }
 
+
+; Expected not to transform as it is integer
+define <16 x i16> @complex_add_v16i16(<16 x i16> %a, <16 x i16> %b) {
+; CHECK-LABEL: complex_add_v16i16:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:uzp1 v4.8h, v2.8h, v3.8h
+; CHECK-NEXT:uzp1 v5.8h, v0.8h, v1.8h
+; CHECK-NEXT:uzp2 v0.8h, v0.8h, v1.8h
+; CHECK-NEXT:uzp2 v1.8h, v2.8h, v3.8h
+; CHECK-NEXT:sub v2.8h, v4.8h, v0.8h
+; CHECK-NEXT:add v1.8h, v1.8h, v5.8h
+; CHECK-NEXT:zip1 v0.8h, v2.8h, v1.8h
+; CHECK-NEXT:zip2 v1.8h, v2.8h, v1.8h
+; CHECK-NEXT:ret
+entry:
+  %a.real = shufflevector <16 x i16> %a, <16 x i16> zeroinitializer, <8 x i32> 

+  %a.imag = shufflevector <16 x i16> %a, <16 x i16> zeroinitializer, <8 x i32> 

+  %b.real = shufflevector <16 x i16> %b, <16 x i16> zeroinitializer, <8 x i32> 

+  %b.imag = shufflevector <16 x i16> %b, <16 x i16> zeroinitializer, <8 x i32> 

+  %0 = sub <8 x i16> %b.real, %a.imag
+  %1 = add <8 x i16> %b.imag, %a.real
+  %interleaved.vec = shufflevector <8 x i16> %0, <8 x i16> %1, <16 x i32> 
+  ret <16 x i16> %interleaved.vec
+}
+
+
 declare { <2 x half>, <2 x half> } 
@llvm.experimental.vector.deinterleave2.v4f16(<4 x half>)
 declare <4 x half> @llvm.experimental.vector.interleave2.v4f16(<2 x half>, <2 
x half>)
 



___
llvm-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] PR for llvm/llvm-project#79860 (PR #79969)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79969
___
llvm-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] PR for llvm/llvm-project#79992 (PR #79997)

2024-02-01 Thread via llvm-branch-commits

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

>From 0eb163cc2717b99f83aa4304628b19291f9ffe53 Mon Sep 17 00:00:00 2001
From: Andrey Ali Khan Bolshakov
 <32954549+bolshako...@users.noreply.github.com>
Date: Tue, 30 Jan 2024 15:03:55 +0300
Subject: [PATCH] Fix analyzer crash on 'StructuralValue' (#79764)

`OpaqueValueExpr` doesn't necessarily contain a source expression.
Particularly, after #78041, it is used to carry the type and the value
kind of a non-type template argument of floating-point type or referring
to a subobject (those are so called `StructuralValue` arguments).

This fixes #79575.

(cherry picked from commit ef67f63fa5f950f4056b5783e92e137342805d74)
---
 clang/lib/Sema/SemaDecl.cpp |  3 ++-
 clang/lib/StaticAnalyzer/Core/Environment.cpp   |  8 +---
 clang/test/Analysis/templates.cpp   | 13 +
 .../SemaTemplate/temp_arg_nontype_cxx20.cpp | 17 +
 4 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f9bf1d14bdc4f..a300badc6d026 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12752,7 +12752,8 @@ namespace {
   }
 
   if (OpaqueValueExpr *OVE = dyn_cast(E)) {
-HandleValue(OVE->getSourceExpr());
+if (Expr *SE = OVE->getSourceExpr())
+  HandleValue(SE);
 return;
   }
 
diff --git a/clang/lib/StaticAnalyzer/Core/Environment.cpp 
b/clang/lib/StaticAnalyzer/Core/Environment.cpp
index 4f989ed59bee3..427f51109853b 100644
--- a/clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -40,8 +40,11 @@ static const Expr *ignoreTransparentExprs(const Expr *E) {
 
   switch (E->getStmtClass()) {
   case Stmt::OpaqueValueExprClass:
-E = cast(E)->getSourceExpr();
-break;
+if (const Expr *SE = cast(E)->getSourceExpr()) {
+  E = SE;
+  break;
+}
+return E;
   case Stmt::ExprWithCleanupsClass:
 E = cast(E)->getSubExpr();
 break;
@@ -98,7 +101,6 @@ SVal Environment::getSVal(const EnvironmentEntry &Entry,
   case Stmt::CXXBindTemporaryExprClass:
   case Stmt::ExprWithCleanupsClass:
   case Stmt::GenericSelectionExprClass:
-  case Stmt::OpaqueValueExprClass:
   case Stmt::ConstantExprClass:
   case Stmt::ParenExprClass:
   case Stmt::SubstNonTypeTemplateParmExprClass:
diff --git a/clang/test/Analysis/templates.cpp 
b/clang/test/Analysis/templates.cpp
index 061c19fe7e044..6da1821b70f26 100644
--- a/clang/test/Analysis/templates.cpp
+++ b/clang/test/Analysis/templates.cpp
@@ -68,3 +68,16 @@ namespace rdar13954714 {
   // force instantiation
   template void blockWithStatic();
 }
+
+namespace structural_value_crash {
+  constexpr char abc[] = "abc";
+
+  template 
+  void use_template_param() {
+const char *p = in;
+  }
+
+  void force_instantiate() {
+use_template_param();
+  }
+}
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
index 834174cdf6a32..ad73daa8e214c 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -354,3 +354,20 @@ namespace ReportedRegression1 {
 return dummy.exit_code();
   }
 }
+
+namespace ReportedRegression2 {
+  const char str[] = "dummy";
+
+  struct S {
+S operator+(const char*) const;
+  };
+
+  template 
+  void fn() {
+auto s = S{} + in;
+  }
+
+  void use() {
+fn();
+  }
+}

___
llvm-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] 0eb163c - Fix analyzer crash on 'StructuralValue' (#79764)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

Author: Andrey Ali Khan Bolshakov
Date: 2024-02-01T12:55:47-08:00
New Revision: 0eb163cc2717b99f83aa4304628b19291f9ffe53

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

LOG: Fix analyzer crash on 'StructuralValue' (#79764)

`OpaqueValueExpr` doesn't necessarily contain a source expression.
Particularly, after #78041, it is used to carry the type and the value
kind of a non-type template argument of floating-point type or referring
to a subobject (those are so called `StructuralValue` arguments).

This fixes #79575.

(cherry picked from commit ef67f63fa5f950f4056b5783e92e137342805d74)

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/lib/StaticAnalyzer/Core/Environment.cpp
clang/test/Analysis/templates.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f9bf1d14bdc4f..a300badc6d026 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12752,7 +12752,8 @@ namespace {
   }
 
   if (OpaqueValueExpr *OVE = dyn_cast(E)) {
-HandleValue(OVE->getSourceExpr());
+if (Expr *SE = OVE->getSourceExpr())
+  HandleValue(SE);
 return;
   }
 

diff  --git a/clang/lib/StaticAnalyzer/Core/Environment.cpp 
b/clang/lib/StaticAnalyzer/Core/Environment.cpp
index 4f989ed59bee3..427f51109853b 100644
--- a/clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -40,8 +40,11 @@ static const Expr *ignoreTransparentExprs(const Expr *E) {
 
   switch (E->getStmtClass()) {
   case Stmt::OpaqueValueExprClass:
-E = cast(E)->getSourceExpr();
-break;
+if (const Expr *SE = cast(E)->getSourceExpr()) {
+  E = SE;
+  break;
+}
+return E;
   case Stmt::ExprWithCleanupsClass:
 E = cast(E)->getSubExpr();
 break;
@@ -98,7 +101,6 @@ SVal Environment::getSVal(const EnvironmentEntry &Entry,
   case Stmt::CXXBindTemporaryExprClass:
   case Stmt::ExprWithCleanupsClass:
   case Stmt::GenericSelectionExprClass:
-  case Stmt::OpaqueValueExprClass:
   case Stmt::ConstantExprClass:
   case Stmt::ParenExprClass:
   case Stmt::SubstNonTypeTemplateParmExprClass:

diff  --git a/clang/test/Analysis/templates.cpp 
b/clang/test/Analysis/templates.cpp
index 061c19fe7e044..6da1821b70f26 100644
--- a/clang/test/Analysis/templates.cpp
+++ b/clang/test/Analysis/templates.cpp
@@ -68,3 +68,16 @@ namespace rdar13954714 {
   // force instantiation
   template void blockWithStatic();
 }
+
+namespace structural_value_crash {
+  constexpr char abc[] = "abc";
+
+  template 
+  void use_template_param() {
+const char *p = in;
+  }
+
+  void force_instantiate() {
+use_template_param();
+  }
+}

diff  --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
index 834174cdf6a32..ad73daa8e214c 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -354,3 +354,20 @@ namespace ReportedRegression1 {
 return dummy.exit_code();
   }
 }
+
+namespace ReportedRegression2 {
+  const char str[] = "dummy";
+
+  struct S {
+S operator+(const char*) const;
+  };
+
+  template 
+  void fn() {
+auto s = S{} + in;
+  }
+
+  void use() {
+fn();
+  }
+}



___
llvm-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] PR for llvm/llvm-project#79992 (PR #79997)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79997
___
llvm-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] PR for llvm/llvm-project#80024 (PR #80025)

2024-02-01 Thread via llvm-branch-commits

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

>From 284570a985e95e3d8118cde2b0198bbbdc9b19ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 30 Jan 2024 17:00:28 +0100
Subject: [PATCH] [llvm-jitlink] Fix detectStubKind() for big endian systems
 (#79970)

This function is used in `jitlink-check` lines in LIT tests. In #78371 I
missed to swap initial instruction bytes for systems that store the
constants as big-endian.

(cherry picked from commit 8a5bdd899f3cb57024d92b96c16e805ca9924ac7)
---
 llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp 
b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index b2a133860197d..769ed17ac4cbd 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -1294,10 +1294,11 @@ class MemoryMatcher {
 };
 
 static StringRef detectStubKind(const Session::MemoryRegionInfo &Stub) {
-  constexpr uint32_t Armv7MovWTle = 0xe300c000;
-  constexpr uint32_t Armv7BxR12le = 0xe12fff1c;
-  constexpr uint32_t Thumbv7MovWTle = 0x0c00f240;
-  constexpr uint16_t Thumbv7BxR12le = 0x4760;
+  using namespace support::endian;
+  auto Armv7MovWTle = byte_swap(0xe300c000);
+  auto Armv7BxR12le = byte_swap(0xe12fff1c);
+  auto Thumbv7MovWTle = byte_swap(0x0c00f240);
+  auto Thumbv7BxR12le = byte_swap(0x4760);
 
   MemoryMatcher M(Stub.getContent());
   if (M.matchMask(Thumbv7MovWTle)) {

___
llvm-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] 284570a - [llvm-jitlink] Fix detectStubKind() for big endian systems (#79970)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

Author: Stefan Gränitz
Date: 2024-02-01T13:42:56-08:00
New Revision: 284570a985e95e3d8118cde2b0198bbbdc9b19ad

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

LOG: [llvm-jitlink] Fix detectStubKind() for big endian systems (#79970)

This function is used in `jitlink-check` lines in LIT tests. In #78371 I
missed to swap initial instruction bytes for systems that store the
constants as big-endian.

(cherry picked from commit 8a5bdd899f3cb57024d92b96c16e805ca9924ac7)

Added: 


Modified: 
llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Removed: 




diff  --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp 
b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index b2a133860197d..769ed17ac4cbd 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -1294,10 +1294,11 @@ class MemoryMatcher {
 };
 
 static StringRef detectStubKind(const Session::MemoryRegionInfo &Stub) {
-  constexpr uint32_t Armv7MovWTle = 0xe300c000;
-  constexpr uint32_t Armv7BxR12le = 0xe12fff1c;
-  constexpr uint32_t Thumbv7MovWTle = 0x0c00f240;
-  constexpr uint16_t Thumbv7BxR12le = 0x4760;
+  using namespace support::endian;
+  auto Armv7MovWTle = byte_swap(0xe300c000);
+  auto Armv7BxR12le = byte_swap(0xe12fff1c);
+  auto Thumbv7MovWTle = byte_swap(0x0c00f240);
+  auto Thumbv7BxR12le = byte_swap(0x4760);
 
   MemoryMatcher M(Stub.getContent());
   if (M.matchMask(Thumbv7MovWTle)) {



___
llvm-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] PR for llvm/llvm-project#80024 (PR #80025)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80025
___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

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

resolves llvm/llvm-project#80285

>From ce2dd202c4e8276a21fdba2d8dd9f8075ed357c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hana=20Dus=C3=ADkov=C3=A1?= 
Date: Thu, 1 Feb 2024 23:31:32 +0100
Subject: [PATCH] [coverage] fix crash in code coverage and `if constexpr` with
 `ExprWithCleanups` (#80292)

Fixes https://github.com/llvm/llvm-project/issues/80285

(cherry picked from commit bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd)
---
 clang/lib/CodeGen/CoverageMappingGen.cpp |  6 +++--
 clang/test/CoverageMapping/if.cpp| 29 
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 5eca00f22bb83..0c43317642bca 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder
 assert(S->isConstexpr());
 
 // evaluate constant condition...
-const auto *E = cast(S->getCond());
-const bool isTrue = E->getResultAsAPSInt().getExtValue();
+const bool isTrue =
+S->getCond()
+->EvaluateKnownConstInt(CVM.getCodeGenModule().getContext())
+.getBoolValue();
 
 extendRegion(S);
 
diff --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 3045ffe43948c..445cdfc20e2af 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) {   
// CHECK-NEXT: [[@LINE
   return i;
 }
 
+struct false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+template  struct dependable_false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+// GH-80285
+void should_not_crash() {
+  if constexpr (false_value{}) { };
+}
+
+template  void should_not_crash_dependable() {
+  if constexpr (dependable_false_value{}) { };
+}
+
+void should_not_crash_with_template_instance() {
+  should_not_crash_dependable();
+}
+
+void should_not_crash_with_requires_expr() {
+  if constexpr (requires {42;}) { };
+}
+
 int instantiate_consteval(int i) {
   i *= check_consteval_with_else_discarded_then(i);
   i *= check_notconsteval_with_else_discarded_else(i);

___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/80356
___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/80356
___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80285

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+4-2) 
- (modified) clang/test/CoverageMapping/if.cpp (+29) 


``diff
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 5eca00f22bb83..0c43317642bca 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder
 assert(S->isConstexpr());
 
 // evaluate constant condition...
-const auto *E = cast(S->getCond());
-const bool isTrue = E->getResultAsAPSInt().getExtValue();
+const bool isTrue =
+S->getCond()
+->EvaluateKnownConstInt(CVM.getCodeGenModule().getContext())
+.getBoolValue();
 
 extendRegion(S);
 
diff --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 3045ffe43948c..445cdfc20e2af 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) {   
// CHECK-NEXT: [[@LINE
   return i;
 }
 
+struct false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+template  struct dependable_false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+// GH-80285
+void should_not_crash() {
+  if constexpr (false_value{}) { };
+}
+
+template  void should_not_crash_dependable() {
+  if constexpr (dependable_false_value{}) { };
+}
+
+void should_not_crash_with_template_instance() {
+  should_not_crash_dependable();
+}
+
+void should_not_crash_with_requires_expr() {
+  if constexpr (requires {42;}) { };
+}
+
 int instantiate_consteval(int i) {
   i *= check_consteval_with_else_discarded_then(i);
   i *= check_notconsteval_with_else_discarded_else(i);

``




https://github.com/llvm/llvm-project/pull/80356
___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80285

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+4-2) 
- (modified) clang/test/CoverageMapping/if.cpp (+29) 


``diff
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 5eca00f22bb83..0c43317642bca 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder
 assert(S->isConstexpr());
 
 // evaluate constant condition...
-const auto *E = cast(S->getCond());
-const bool isTrue = E->getResultAsAPSInt().getExtValue();
+const bool isTrue =
+S->getCond()
+->EvaluateKnownConstInt(CVM.getCodeGenModule().getContext())
+.getBoolValue();
 
 extendRegion(S);
 
diff --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 3045ffe43948c..445cdfc20e2af 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) {   
// CHECK-NEXT: [[@LINE
   return i;
 }
 
+struct false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+template  struct dependable_false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+// GH-80285
+void should_not_crash() {
+  if constexpr (false_value{}) { };
+}
+
+template  void should_not_crash_dependable() {
+  if constexpr (dependable_false_value{}) { };
+}
+
+void should_not_crash_with_template_instance() {
+  should_not_crash_dependable();
+}
+
+void should_not_crash_with_requires_expr() {
+  if constexpr (requires {42;}) { };
+}
+
 int instantiate_consteval(int i) {
   i *= check_consteval_with_else_discarded_then(i);
   i *= check_notconsteval_with_else_discarded_else(i);

``




https://github.com/llvm/llvm-project/pull/80356
___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

cor3ntin wrote:

This fixes a regression introduced in clang 18, ship it

https://github.com/llvm/llvm-project/pull/80356
___
llvm-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] Refactor recomputeLiveIns to operate on whole CFG (#79498) (PR #79641)

2024-02-01 Thread Oskar Wirga via llvm-branch-commits

https://github.com/oskarwirga edited 
https://github.com/llvm/llvm-project/pull/79641
___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

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


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


[llvm-branch-commits] [lld] PR for llvm/llvm-project#79960 (PR #79961)

2024-02-01 Thread via llvm-branch-commits

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

>From 2fe0bca91041eeaedd5ea530e6863f3af42bc2b0 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Mon, 29 Jan 2024 13:26:33 -0800
Subject: [PATCH] [ELF] --warn-backrefs: --defsym does not make a backward
 reference

The interaction between --warn-backrefs was not tested, but if
--defsym-created reference causes archive member extraction, it seems
reasonable to suppress the diagnostic, which was the behavior before #78944.

(cherry picked from commit 9a1ca245c8bc60b1ca12cd906fb31130801d977e)
---
 lld/ELF/InputFiles.cpp   | 7 ++-
 lld/test/ELF/warn-backrefs.s | 4 
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 75e5ee1d0da4f..a292e873e72f7 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1788,7 +1788,12 @@ void BinaryFile::parse() {
 }
 
 InputFile *elf::createInternalFile(StringRef name) {
-  return make(InputFile::InternalKind, MemoryBufferRef("", name));
+  auto *file =
+  make(InputFile::InternalKind, MemoryBufferRef("", name));
+  // References from an internal file do not lead to --warn-backrefs
+  // diagnostics.
+  file->groupId = 0;
+  return file;
 }
 
 ELFFileBase *elf::createObjFile(MemoryBufferRef mb, StringRef archiveName,
diff --git a/lld/test/ELF/warn-backrefs.s b/lld/test/ELF/warn-backrefs.s
index 1e5c14ed052e6..453017eb1c8ec 100644
--- a/lld/test/ELF/warn-backrefs.s
+++ b/lld/test/ELF/warn-backrefs.s
@@ -100,6 +100,10 @@
 ## -u does not make a backward reference.
 # RUN: ld.lld --fatal-warnings --warn-backrefs -u foo %t2.a %t1.o -o /dev/null
 
+## --defsym does not make a backward reference, but it does not suppress the 
warning due to another file.
+# RUN: ld.lld --fatal-warnings --warn-backrefs --defsym=x=foo -e 0 %t2.a -o 
/dev/null
+# RUN: ld.lld --warn-backrefs --defsym=x=foo %t2.a %t1.o -o /dev/null 2>&1 | 
FileCheck %s
+
 # RUN: not ld.lld --warn-backrefs-exclude='[' 2>&1 | FileCheck 
--check-prefix=INVALID %s
 # INVALID: error: --warn-backrefs-exclude: invalid glob pattern, unmatched 
'[': [
 

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


[llvm-branch-commits] [lld] 2fe0bca - [ELF] --warn-backrefs: --defsym does not make a backward reference

2024-02-01 Thread Tom Stellard via llvm-branch-commits

Author: Fangrui Song
Date: 2024-02-01T17:40:45-08:00
New Revision: 2fe0bca91041eeaedd5ea530e6863f3af42bc2b0

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

LOG: [ELF] --warn-backrefs: --defsym does not make a backward reference

The interaction between --warn-backrefs was not tested, but if
--defsym-created reference causes archive member extraction, it seems
reasonable to suppress the diagnostic, which was the behavior before #78944.

(cherry picked from commit 9a1ca245c8bc60b1ca12cd906fb31130801d977e)

Added: 


Modified: 
lld/ELF/InputFiles.cpp
lld/test/ELF/warn-backrefs.s

Removed: 




diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 75e5ee1d0da4f..a292e873e72f7 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1788,7 +1788,12 @@ void BinaryFile::parse() {
 }
 
 InputFile *elf::createInternalFile(StringRef name) {
-  return make(InputFile::InternalKind, MemoryBufferRef("", name));
+  auto *file =
+  make(InputFile::InternalKind, MemoryBufferRef("", name));
+  // References from an internal file do not lead to --warn-backrefs
+  // diagnostics.
+  file->groupId = 0;
+  return file;
 }
 
 ELFFileBase *elf::createObjFile(MemoryBufferRef mb, StringRef archiveName,

diff  --git a/lld/test/ELF/warn-backrefs.s b/lld/test/ELF/warn-backrefs.s
index 1e5c14ed052e6..453017eb1c8ec 100644
--- a/lld/test/ELF/warn-backrefs.s
+++ b/lld/test/ELF/warn-backrefs.s
@@ -100,6 +100,10 @@
 ## -u does not make a backward reference.
 # RUN: ld.lld --fatal-warnings --warn-backrefs -u foo %t2.a %t1.o -o /dev/null
 
+## --defsym does not make a backward reference, but it does not suppress the 
warning due to another file.
+# RUN: ld.lld --fatal-warnings --warn-backrefs --defsym=x=foo -e 0 %t2.a -o 
/dev/null
+# RUN: ld.lld --warn-backrefs --defsym=x=foo %t2.a %t1.o -o /dev/null 2>&1 | 
FileCheck %s
+
 # RUN: not ld.lld --warn-backrefs-exclude='[' 2>&1 | FileCheck 
--check-prefix=INVALID %s
 # INVALID: error: --warn-backrefs-exclude: invalid glob pattern, unmatched 
'[': [
 



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


[llvm-branch-commits] [lld] PR for llvm/llvm-project#79960 (PR #79961)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79961
___
llvm-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++] Fix missing and incorrect push/pop macros (#79204) (PR #79497)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/79497
___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

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

>From 52eda804ee7b112f221b37339cb05156342dac25 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hana=20Dus=C3=ADkov=C3=A1?= 
Date: Thu, 1 Feb 2024 23:31:32 +0100
Subject: [PATCH] [coverage] fix crash in code coverage and `if constexpr` with
 `ExprWithCleanups` (#80292)

Fixes https://github.com/llvm/llvm-project/issues/80285

(cherry picked from commit bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd)
---
 clang/lib/CodeGen/CoverageMappingGen.cpp |  6 +++--
 clang/test/CoverageMapping/if.cpp| 29 
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 5eca00f22bb83..0c43317642bca 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder
 assert(S->isConstexpr());
 
 // evaluate constant condition...
-const auto *E = cast(S->getCond());
-const bool isTrue = E->getResultAsAPSInt().getExtValue();
+const bool isTrue =
+S->getCond()
+->EvaluateKnownConstInt(CVM.getCodeGenModule().getContext())
+.getBoolValue();
 
 extendRegion(S);
 
diff --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 3045ffe43948c..445cdfc20e2af 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) {   
// CHECK-NEXT: [[@LINE
   return i;
 }
 
+struct false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+template  struct dependable_false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+// GH-80285
+void should_not_crash() {
+  if constexpr (false_value{}) { };
+}
+
+template  void should_not_crash_dependable() {
+  if constexpr (dependable_false_value{}) { };
+}
+
+void should_not_crash_with_template_instance() {
+  should_not_crash_dependable();
+}
+
+void should_not_crash_with_requires_expr() {
+  if constexpr (requires {42;}) { };
+}
+
 int instantiate_consteval(int i) {
   i *= check_consteval_with_else_discarded_then(i);
   i *= check_notconsteval_with_else_discarded_else(i);

___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread via llvm-branch-commits

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

>From 3eaa7f3c44597e1027e29ffecb83e374fb7fa52c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hana=20Dus=C3=ADkov=C3=A1?= 
Date: Thu, 1 Feb 2024 23:31:32 +0100
Subject: [PATCH] [coverage] fix crash in code coverage and `if constexpr` with
 `ExprWithCleanups` (#80292)

Fixes https://github.com/llvm/llvm-project/issues/80285

(cherry picked from commit bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd)
---
 clang/lib/CodeGen/CoverageMappingGen.cpp |  6 +++--
 clang/test/CoverageMapping/if.cpp| 29 
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 5eca00f22bb83..0c43317642bca 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder
 assert(S->isConstexpr());
 
 // evaluate constant condition...
-const auto *E = cast(S->getCond());
-const bool isTrue = E->getResultAsAPSInt().getExtValue();
+const bool isTrue =
+S->getCond()
+->EvaluateKnownConstInt(CVM.getCodeGenModule().getContext())
+.getBoolValue();
 
 extendRegion(S);
 
diff --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 3045ffe43948c..445cdfc20e2af 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) {   
// CHECK-NEXT: [[@LINE
   return i;
 }
 
+struct false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+template  struct dependable_false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+// GH-80285
+void should_not_crash() {
+  if constexpr (false_value{}) { };
+}
+
+template  void should_not_crash_dependable() {
+  if constexpr (dependable_false_value{}) { };
+}
+
+void should_not_crash_with_template_instance() {
+  should_not_crash_dependable();
+}
+
+void should_not_crash_with_requires_expr() {
+  if constexpr (requires {42;}) { };
+}
+
 int instantiate_consteval(int i) {
   i *= check_consteval_with_else_discarded_then(i);
   i *= check_notconsteval_with_else_discarded_else(i);

___
llvm-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] 3eaa7f3 - [coverage] fix crash in code coverage and `if constexpr` with `ExprWithCleanups` (#80292)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

Author: Hana Dusíková
Date: 2024-02-01T17:53:25-08:00
New Revision: 3eaa7f3c44597e1027e29ffecb83e374fb7fa52c

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

LOG: [coverage] fix crash in code coverage and `if constexpr` with 
`ExprWithCleanups` (#80292)

Fixes https://github.com/llvm/llvm-project/issues/80285

(cherry picked from commit bfc6eaa26326e4d0d20d1f4a1f0064c6df0135bd)

Added: 


Modified: 
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/test/CoverageMapping/if.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 5eca00f22bb83..0c43317642bca 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1812,8 +1812,10 @@ struct CounterCoverageMappingBuilder
 assert(S->isConstexpr());
 
 // evaluate constant condition...
-const auto *E = cast(S->getCond());
-const bool isTrue = E->getResultAsAPSInt().getExtValue();
+const bool isTrue =
+S->getCond()
+->EvaluateKnownConstInt(CVM.getCodeGenModule().getContext())
+.getBoolValue();
 
 extendRegion(S);
 

diff  --git a/clang/test/CoverageMapping/if.cpp 
b/clang/test/CoverageMapping/if.cpp
index 3045ffe43948c..445cdfc20e2af 100644
--- a/clang/test/CoverageMapping/if.cpp
+++ b/clang/test/CoverageMapping/if.cpp
@@ -234,6 +234,35 @@ constexpr int check_macro_consteval_if_skipped(int i) {   
// CHECK-NEXT: [[@LINE
   return i;
 }
 
+struct false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+template  struct dependable_false_value {
+  constexpr operator bool() {
+return false;
+  }
+};
+
+// GH-80285
+void should_not_crash() {
+  if constexpr (false_value{}) { };
+}
+
+template  void should_not_crash_dependable() {
+  if constexpr (dependable_false_value{}) { };
+}
+
+void should_not_crash_with_template_instance() {
+  should_not_crash_dependable();
+}
+
+void should_not_crash_with_requires_expr() {
+  if constexpr (requires {42;}) { };
+}
+
 int instantiate_consteval(int i) {
   i *= check_consteval_with_else_discarded_then(i);
   i *= check_notconsteval_with_else_discarded_else(i);



___
llvm-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] PR for llvm/llvm-project#80285 (PR #80356)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [openmp] PR for llvm/llvm-project#80117 (PR #80291)

2024-02-01 Thread via llvm-branch-commits

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

>From 1cfd46f1343c8dcd866d29ce28ac0a4a71bd7968 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <37383324+aga...@users.noreply.github.com>
Date: Thu, 1 Feb 2024 08:14:05 -0500
Subject: [PATCH] [openmp] On Windows, fix standalone cmake build (#80174)

This fixes: https://github.com/llvm/llvm-project/issues/80117

(cherry picked from commit d2565bb11308f6cf98d838e828d9bcbe2d51e0e4)
---
 openmp/cmake/HandleOpenMPOptions.cmake | 8 
 1 file changed, 8 insertions(+)

diff --git a/openmp/cmake/HandleOpenMPOptions.cmake 
b/openmp/cmake/HandleOpenMPOptions.cmake
index 201aeabbd3df9..71346201129b6 100644
--- a/openmp/cmake/HandleOpenMPOptions.cmake
+++ b/openmp/cmake/HandleOpenMPOptions.cmake
@@ -9,6 +9,14 @@ if (NOT COMMAND append_if)
   endfunction()
 endif()
 
+if (NOT COMMAND append)
+  function(append value)
+foreach(variable ${ARGN})
+  set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
+endforeach(variable)
+  endfunction()
+endif()
+
 # MSVC and clang-cl in compatibility mode map -Wall to -Weverything.
 # TODO: LLVM adds /W4 instead, check if that works for the OpenMP runtimes.
 if (NOT MSVC)

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


[llvm-branch-commits] [openmp] 1cfd46f - [openmp] On Windows, fix standalone cmake build (#80174)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

Author: Alexandre Ganea
Date: 2024-02-01T17:54:51-08:00
New Revision: 1cfd46f1343c8dcd866d29ce28ac0a4a71bd7968

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

LOG: [openmp] On Windows, fix standalone cmake build (#80174)

This fixes: https://github.com/llvm/llvm-project/issues/80117

(cherry picked from commit d2565bb11308f6cf98d838e828d9bcbe2d51e0e4)

Added: 


Modified: 
openmp/cmake/HandleOpenMPOptions.cmake

Removed: 




diff  --git a/openmp/cmake/HandleOpenMPOptions.cmake 
b/openmp/cmake/HandleOpenMPOptions.cmake
index 201aeabbd3df9..71346201129b6 100644
--- a/openmp/cmake/HandleOpenMPOptions.cmake
+++ b/openmp/cmake/HandleOpenMPOptions.cmake
@@ -9,6 +9,14 @@ if (NOT COMMAND append_if)
   endfunction()
 endif()
 
+if (NOT COMMAND append)
+  function(append value)
+foreach(variable ${ARGN})
+  set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
+endforeach(variable)
+  endfunction()
+endif()
+
 # MSVC and clang-cl in compatibility mode map -Wall to -Weverything.
 # TODO: LLVM adds /W4 instead, check if that works for the OpenMP runtimes.
 if (NOT MSVC)



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


[llvm-branch-commits] [openmp] PR for llvm/llvm-project#80117 (PR #80291)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar closed 
https://github.com/llvm/llvm-project/pull/80291
___
llvm-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] PR for llvm/llvm-project#79137 (PR #79561)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

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

https://github.com/llvm/llvm-project/pull/79561
___
llvm-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] PR for llvm/llvm-project#79571 (PR #79572)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

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

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


[llvm-branch-commits] [clang] [clang-tools-extra] Backport '[clang] static operators should evaluate object argument (reland)' to release/18.x (PR #80109)

2024-02-01 Thread Tom Stellard via llvm-branch-commits

tstellar wrote:

@cor3ntin Any thoughts about backporting this?

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


[llvm-branch-commits] [lld] PR for llvm/llvm-project#80390 (PR #80391)

2024-02-01 Thread via llvm-branch-commits

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


[llvm-branch-commits] [lld] PR for llvm/llvm-project#80390 (PR #80391)

2024-02-01 Thread via llvm-branch-commits

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

resolves llvm/llvm-project#80390

>From 1ddb69d220733c545cba77c59b3a27a9ee95767c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 1 Feb 2024 21:20:27 -0800
Subject: [PATCH] [ELF] Fix compareSections assertion failure when OutputDescs
 in sectionCommands are non-contiguous

In a `--defsym y0=0 -T a.lds` link where a.lds contains only INSERT
commands, the `script->sectionCommands` layout may be:
```
orphan sections
SymbolAssignment due to --defsym
sections created by INSERT commands
```

The `OutputDesc` objects are not contiguous in sortInputSections, and
`compareSections` will be called with a SymbolAssignment argument,
leading to an assertion failure.

(cherry picked from commit dee8786f70a3d62b639113343fa36ef55bdbad63)
---
 lld/ELF/Writer.cpp   | 12 ++--
 lld/test/ELF/linkerscript/insert-before.test | 11 ---
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6f66f3615fa4a..501c10f358497 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1518,12 +1518,12 @@ template  void Writer::sortSections() 
{
 if (auto *osd = dyn_cast(cmd))
   osd->osec.sortRank = getSectionRank(osd->osec);
   if (!script->hasSectionsCommand) {
-// We know that all the OutputSections are contiguous in this case.
-auto isSection = [](SectionCommand *cmd) { return isa(cmd); };
-std::stable_sort(
-llvm::find_if(script->sectionCommands, isSection),
-llvm::find_if(llvm::reverse(script->sectionCommands), 
isSection).base(),
-compareSections);
+// OutputDescs are mostly contiguous, but may be interleaved with
+// SymbolAssignments in the presence of INSERT commands.
+auto mid = std::stable_partition(
+script->sectionCommands.begin(), script->sectionCommands.end(),
+[](SectionCommand *cmd) { return isa(cmd); });
+std::stable_sort(script->sectionCommands.begin(), mid, compareSections);
   }
 
   // Process INSERT commands and update output section attributes. From this
diff --git a/lld/test/ELF/linkerscript/insert-before.test 
b/lld/test/ELF/linkerscript/insert-before.test
index e6ed413639827..a72834988007c 100644
--- a/lld/test/ELF/linkerscript/insert-before.test
+++ b/lld/test/ELF/linkerscript/insert-before.test
@@ -24,8 +24,9 @@
 ## without making more layout changes. Address/offset assignments are different
 ## with a main linker script.
 
-# RUN: ld.lld --script %s %t1.o -o %t2
-# RUN: llvm-readelf -S -l %t2 | FileCheck --check-prefix=CHECK2 %s
+## Test non-contiguous OutputDescs in script->sectionCommands.
+# RUN: ld.lld --defsym y0=1 %s --defsym y1=1 %t1.o -o %t2
+# RUN: llvm-readelf -S -l -sX %t2 | FileCheck --check-prefix=CHECK2 %s
 # CHECK2:  Name  Type AddressOff  Size   ES Flg
 # CHECK2-NEXT:   NULL
 # CHECK2-NEXT: .foo.text PROGBITS 0020{{.*}} [[#%x,]] 08 00  AX
@@ -40,9 +41,13 @@
 # CHECK2-NEXT: LOAD  {{.*}} RW  0x1000
 # CHECK2-NEXT: GNU_STACK {{.*}} RW  0
 
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  [[#]] (.foo.text) x0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y1
+
 SECTIONS { .byte : { BYTE(0) } } INSERT BEFORE .data;
 
 SECTIONS { .foo.data : { *(.foo.data) } } INSERT BEFORE .data;
 
 ## The input section .foo.text is an orphan. It will be placed in .foo.text
-SECTIONS { .foo.text : {} } INSERT BEFORE .text;
+SECTIONS { .foo.text : { x0 = .; } } INSERT BEFORE .text;

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


[llvm-branch-commits] [lld] PR for llvm/llvm-project#80390 (PR #80391)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-lld-elf

@llvm/pr-subscribers-lld

Author: None (llvmbot)


Changes

resolves llvm/llvm-project#80390

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


2 Files Affected:

- (modified) lld/ELF/Writer.cpp (+6-6) 
- (modified) lld/test/ELF/linkerscript/insert-before.test (+8-3) 


``diff
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6f66f3615fa4a..501c10f358497 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1518,12 +1518,12 @@ template  void Writer::sortSections() 
{
 if (auto *osd = dyn_cast(cmd))
   osd->osec.sortRank = getSectionRank(osd->osec);
   if (!script->hasSectionsCommand) {
-// We know that all the OutputSections are contiguous in this case.
-auto isSection = [](SectionCommand *cmd) { return isa(cmd); };
-std::stable_sort(
-llvm::find_if(script->sectionCommands, isSection),
-llvm::find_if(llvm::reverse(script->sectionCommands), 
isSection).base(),
-compareSections);
+// OutputDescs are mostly contiguous, but may be interleaved with
+// SymbolAssignments in the presence of INSERT commands.
+auto mid = std::stable_partition(
+script->sectionCommands.begin(), script->sectionCommands.end(),
+[](SectionCommand *cmd) { return isa(cmd); });
+std::stable_sort(script->sectionCommands.begin(), mid, compareSections);
   }
 
   // Process INSERT commands and update output section attributes. From this
diff --git a/lld/test/ELF/linkerscript/insert-before.test 
b/lld/test/ELF/linkerscript/insert-before.test
index e6ed413639827..a72834988007c 100644
--- a/lld/test/ELF/linkerscript/insert-before.test
+++ b/lld/test/ELF/linkerscript/insert-before.test
@@ -24,8 +24,9 @@
 ## without making more layout changes. Address/offset assignments are different
 ## with a main linker script.
 
-# RUN: ld.lld --script %s %t1.o -o %t2
-# RUN: llvm-readelf -S -l %t2 | FileCheck --check-prefix=CHECK2 %s
+## Test non-contiguous OutputDescs in script->sectionCommands.
+# RUN: ld.lld --defsym y0=1 %s --defsym y1=1 %t1.o -o %t2
+# RUN: llvm-readelf -S -l -sX %t2 | FileCheck --check-prefix=CHECK2 %s
 # CHECK2:  Name  Type AddressOff  Size   ES Flg
 # CHECK2-NEXT:   NULL
 # CHECK2-NEXT: .foo.text PROGBITS 0020{{.*}} [[#%x,]] 08 00  AX
@@ -40,9 +41,13 @@
 # CHECK2-NEXT: LOAD  {{.*}} RW  0x1000
 # CHECK2-NEXT: GNU_STACK {{.*}} RW  0
 
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  [[#]] (.foo.text) x0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y1
+
 SECTIONS { .byte : { BYTE(0) } } INSERT BEFORE .data;
 
 SECTIONS { .foo.data : { *(.foo.data) } } INSERT BEFORE .data;
 
 ## The input section .foo.text is an orphan. It will be placed in .foo.text
-SECTIONS { .foo.text : {} } INSERT BEFORE .text;
+SECTIONS { .foo.text : { x0 = .; } } INSERT BEFORE .text;

``




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


[llvm-branch-commits] [lld] PR for llvm/llvm-project#80390 (PR #80391)

2024-02-01 Thread via llvm-branch-commits

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

>From 1970f590fc89fc1701f9dc779d099ed294bb08fe Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 1 Feb 2024 21:20:27 -0800
Subject: [PATCH] [ELF] Fix compareSections assertion failure when OutputDescs
 in sectionCommands are non-contiguous

In a `--defsym y0=0 -T a.lds` link where a.lds contains only INSERT
commands, the `script->sectionCommands` layout may be:
```
orphan sections
SymbolAssignment due to --defsym
sections created by INSERT commands
```

The `OutputDesc` objects are not contiguous in sortInputSections, and
`compareSections` will be called with a SymbolAssignment argument,
leading to an assertion failure.

(cherry picked from commit dee8786f70a3d62b639113343fa36ef55bdbad63)
---
 lld/ELF/Writer.cpp   | 12 ++--
 lld/test/ELF/linkerscript/insert-before.test | 11 ---
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6f66f3615fa4a..501c10f358497 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1518,12 +1518,12 @@ template  void Writer::sortSections() 
{
 if (auto *osd = dyn_cast(cmd))
   osd->osec.sortRank = getSectionRank(osd->osec);
   if (!script->hasSectionsCommand) {
-// We know that all the OutputSections are contiguous in this case.
-auto isSection = [](SectionCommand *cmd) { return isa(cmd); };
-std::stable_sort(
-llvm::find_if(script->sectionCommands, isSection),
-llvm::find_if(llvm::reverse(script->sectionCommands), 
isSection).base(),
-compareSections);
+// OutputDescs are mostly contiguous, but may be interleaved with
+// SymbolAssignments in the presence of INSERT commands.
+auto mid = std::stable_partition(
+script->sectionCommands.begin(), script->sectionCommands.end(),
+[](SectionCommand *cmd) { return isa(cmd); });
+std::stable_sort(script->sectionCommands.begin(), mid, compareSections);
   }
 
   // Process INSERT commands and update output section attributes. From this
diff --git a/lld/test/ELF/linkerscript/insert-before.test 
b/lld/test/ELF/linkerscript/insert-before.test
index e6ed413639827..a72834988007c 100644
--- a/lld/test/ELF/linkerscript/insert-before.test
+++ b/lld/test/ELF/linkerscript/insert-before.test
@@ -24,8 +24,9 @@
 ## without making more layout changes. Address/offset assignments are different
 ## with a main linker script.
 
-# RUN: ld.lld --script %s %t1.o -o %t2
-# RUN: llvm-readelf -S -l %t2 | FileCheck --check-prefix=CHECK2 %s
+## Test non-contiguous OutputDescs in script->sectionCommands.
+# RUN: ld.lld --defsym y0=1 %s --defsym y1=1 %t1.o -o %t2
+# RUN: llvm-readelf -S -l -sX %t2 | FileCheck --check-prefix=CHECK2 %s
 # CHECK2:  Name  Type AddressOff  Size   ES Flg
 # CHECK2-NEXT:   NULL
 # CHECK2-NEXT: .foo.text PROGBITS 0020{{.*}} [[#%x,]] 08 00  AX
@@ -40,9 +41,13 @@
 # CHECK2-NEXT: LOAD  {{.*}} RW  0x1000
 # CHECK2-NEXT: GNU_STACK {{.*}} RW  0
 
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  [[#]] (.foo.text) x0
+# CHECK2:  NOTYPE  GLOBAL DEFAULT  ABS   y1
+
 SECTIONS { .byte : { BYTE(0) } } INSERT BEFORE .data;
 
 SECTIONS { .foo.data : { *(.foo.data) } } INSERT BEFORE .data;
 
 ## The input section .foo.text is an orphan. It will be placed in .foo.text
-SECTIONS { .foo.text : {} } INSERT BEFORE .text;
+SECTIONS { .foo.text : { x0 = .; } } INSERT BEFORE .text;

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


[llvm-branch-commits] [lld] ReleaseNotes: add lld/ELF notes (PR #80393)

2024-02-01 Thread Fangrui Song via llvm-branch-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/80393

None

>From fc64e65d2af33f237a16c55d2730bd615157213c Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Thu, 1 Feb 2024 22:04:49 -0800
Subject: [PATCH] ReleaseNotes: add lld/ELF notes

---
 lld/docs/ReleaseNotes.rst | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 01669543cd50c..824cc6f56f8d5 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -29,8 +29,42 @@ ELF Improvements
 * ``--fat-lto-objects`` option is added to support LLVM FatLTO.
   Without ``--fat-lto-objects``, LLD will link LLVM FatLTO objects using the
   relocatable object file. (`D146778 `_)
+* ``-Bsymbolic-non-weak`` is added to directly bind non-weak definitions.
+  (`D158322 `_)
+* ``--lto-validate-all-vtables-have-type-infos``, which complements
+  ``--lto-whole-program-visibility``, is added to disable unsafe whole-program
+  devirtualization. ``--lto-known-safe-vtables=`` can be used
+  to mark known-safe vtable symbols.
+  (`D155659 `_)
+* ``--no-allow-shlib-undefined`` now reports errors for DSO referencing
+  non-exported definitions.
+  (`#70769 `_)
 * common-page-size can now be larger than the system page-size.
   (`#57618 `_)
+* When call graph profile information is availablue due to instrumentation or
+  sample PGO, input sections are now sorted using the new ``cdsort`` algorithm,
+  better than the previous ``hfsort`` algorithm.
+  (`D152840 `_)
+* Symbol assignments like ``a = DEFINED(a) ? a : 0;`` are now handled.
+  (`#65866 `_)
+* ``OVERLAY`` now supports optional start address and LMA
+  (`#77272 `_)
+* Relocations referencing a symbol defined in ``/DISCARD/`` section now lead to
+  an error.
+  (`#69295 `_)
+* For AArch64 MTE, global variable descriptors have been implemented.
+  (`D152921 `_)
+* ``R_LARCH_PCREL20_S2``/``R_LARCH_ADD6``/``R_LARCH_CALL36`` and extreme code
+  model relocations are now supported.
+* ``--emit-relocs`` is now supported for RISC-V linker relaxation.
+  (`D159082 `_)
+* Call relaxation respects RVC when mixing +c and -c relocatable files.
+  (`#73977 `_)
+* ``R_RISCV_SET_ULEB128``/``R_RISCV_SUB_ULEB128`` relocations are now 
supported.
+  (`#72610 `_)
+  (`#77261 `_)
+* RISC-V TLSDESC is now supported.
+  (`#79239 `_)
 
 Breaking changes
 

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


[llvm-branch-commits] [lld] ReleaseNotes: add lld/ELF notes (PR #80393)

2024-02-01 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-lld

Author: Fangrui Song (MaskRay)


Changes



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


1 Files Affected:

- (modified) lld/docs/ReleaseNotes.rst (+34) 


``diff
diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index 01669543cd50c..824cc6f56f8d5 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -29,8 +29,42 @@ ELF Improvements
 * ``--fat-lto-objects`` option is added to support LLVM FatLTO.
   Without ``--fat-lto-objects``, LLD will link LLVM FatLTO objects using the
   relocatable object file. (`D146778 `_)
+* ``-Bsymbolic-non-weak`` is added to directly bind non-weak definitions.
+  (`D158322 `_)
+* ``--lto-validate-all-vtables-have-type-infos``, which complements
+  ``--lto-whole-program-visibility``, is added to disable unsafe whole-program
+  devirtualization. ``--lto-known-safe-vtables=`` can be used
+  to mark known-safe vtable symbols.
+  (`D155659 `_)
+* ``--no-allow-shlib-undefined`` now reports errors for DSO referencing
+  non-exported definitions.
+  (`#70769 `_)
 * common-page-size can now be larger than the system page-size.
   (`#57618 `_)
+* When call graph profile information is availablue due to instrumentation or
+  sample PGO, input sections are now sorted using the new ``cdsort`` algorithm,
+  better than the previous ``hfsort`` algorithm.
+  (`D152840 `_)
+* Symbol assignments like ``a = DEFINED(a) ? a : 0;`` are now handled.
+  (`#65866 `_)
+* ``OVERLAY`` now supports optional start address and LMA
+  (`#77272 `_)
+* Relocations referencing a symbol defined in ``/DISCARD/`` section now lead to
+  an error.
+  (`#69295 `_)
+* For AArch64 MTE, global variable descriptors have been implemented.
+  (`D152921 `_)
+* ``R_LARCH_PCREL20_S2``/``R_LARCH_ADD6``/``R_LARCH_CALL36`` and extreme code
+  model relocations are now supported.
+* ``--emit-relocs`` is now supported for RISC-V linker relaxation.
+  (`D159082 `_)
+* Call relaxation respects RVC when mixing +c and -c relocatable files.
+  (`#73977 `_)
+* ``R_RISCV_SET_ULEB128``/``R_RISCV_SUB_ULEB128`` relocations are now 
supported.
+  (`#72610 `_)
+  (`#77261 `_)
+* RISC-V TLSDESC is now supported.
+  (`#79239 `_)
 
 Breaking changes
 

``




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


[llvm-branch-commits] [lld] ReleaseNotes: add lld/ELF notes (PR #80393)

2024-02-01 Thread Fangrui Song via llvm-branch-commits

MaskRay wrote:

"""
Merging is blocked
The base branch does not allow updates. [Learn more about protected 
branches.](https://docs.github.com/articles/about-protected-branches/)
"""

Once this is approved, @tstellar I think I'll notify you to merge this into 
`release/18.x`?

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


[llvm-branch-commits] [lld] ReleaseNotes: add lld/ELF notes (PR #80393)

2024-02-01 Thread Alexander Richardson via llvm-branch-commits

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

Lgtm

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


[llvm-branch-commits] [clang-tools-extra] [clang] Backport '[clang] static operators should evaluate object argument (reland)' to release/18.x (PR #80109)

2024-02-01 Thread via llvm-branch-commits

cor3ntin wrote:

Yes, that bug was pretty nasty, we should backport it

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