[llvm-branch-commits] [dse] Skip llvm.allow.{runtime, ubsan}.check() (PR #86067)

2024-03-21 Thread Dmitry Vyukov via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/86067
___
llvm-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] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)

2024-03-21 Thread Bruno Cardoso Lopes via llvm-branch-commits

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


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


[llvm-branch-commits] [mlir] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Delete dead code (PR #86098)

2024-03-21 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer created 
https://github.com/llvm/llvm-project/pull/86098

There is an assertion that the stop condition is not satisfied for the the 
starting point at the beginning of `computeBound`. Therefore, that case does 
not have to be handled later on in that function.

>From 12e7e8880621483918e7a3e2a99bf3eec13eb899 Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Thu, 21 Mar 2024 08:01:01 +
Subject: [PATCH] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Delete
 dead code

There is an assertion that the stop condition is not satisfied for the the 
starting point at the beginning of `computeBound`. Therefore, that case does 
not have to be handled later on in that function.
---
 mlir/lib/Interfaces/ValueBoundsOpInterface.cpp | 12 
 1 file changed, 12 deletions(-)

diff --git a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp 
b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
index 02af3a83166dfb..f2f732f3a21d25 100644
--- a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
+++ b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
@@ -321,18 +321,6 @@ LogicalResult ValueBoundsConstraintSet::computeBound(
   Builder b(value.getContext());
   mapOperands.clear();
 
-  if (stopCondition(value, dim)) {
-// Special case: If the stop condition is satisfied for the input
-// value/dimension, directly return it.
-mapOperands.push_back(std::make_pair(value, dim));
-AffineExpr bound = b.getAffineDimExpr(0);
-if (type == BoundType::UB)
-  bound = bound + ubAdjustment;
-resultMap = AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0,
-   b.getAffineDimExpr(0));
-return success();
-  }
-
   // Process the backward slice of `value` (i.e., reverse use-def chain) until
   // `stopCondition` is met.
   ValueDim valueDim = std::make_pair(value, dim.value_or(kIndexValue));

___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Bruno Cardoso Lopes via llvm-branch-commits


@@ -0,0 +1,46 @@
+//===- CIRTypes.td - CIR dialect types -*- tablegen 
-*-===//

bcardosolopes wrote:

`CIRTypes.td` ->  `CIRDialect.td`

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


[llvm-branch-commits] [mlir] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Delete dead code (PR #86098)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)


Changes

There is an assertion that the stop condition is not satisfied for the the 
starting point at the beginning of `computeBound`. Therefore, that case does 
not have to be handled later on in that function.

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


1 Files Affected:

- (modified) mlir/lib/Interfaces/ValueBoundsOpInterface.cpp (-12) 


``diff
diff --git a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp 
b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
index 02af3a83166dfb..f2f732f3a21d25 100644
--- a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
+++ b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
@@ -321,18 +321,6 @@ LogicalResult ValueBoundsConstraintSet::computeBound(
   Builder b(value.getContext());
   mapOperands.clear();
 
-  if (stopCondition(value, dim)) {
-// Special case: If the stop condition is satisfied for the input
-// value/dimension, directly return it.
-mapOperands.push_back(std::make_pair(value, dim));
-AffineExpr bound = b.getAffineDimExpr(0);
-if (type == BoundType::UB)
-  bound = bound + ubAdjustment;
-resultMap = AffineMap::get(/*dimCount=*/1, /*symbolCount=*/0,
-   b.getAffineDimExpr(0));
-return success();
-  }
-
   // Process the backward slice of `value` (i.e., reverse use-def chain) until
   // `stopCondition` is met.
   ValueDim valueDim = std::make_pair(value, dim.value_or(kIndexValue));

``




https://github.com/llvm/llvm-project/pull/86098
___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Bruno Cardoso Lopes via llvm-branch-commits

https://github.com/bcardosolopes commented:

`CIR/Dialect/IR/CIRDialect.h` should get a comment header too

https://github.com/llvm/llvm-project/pull/86080
___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Bruno Cardoso Lopes via llvm-branch-commits

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


[llvm-branch-commits] [mlir] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Pass stop condition in the constructor (PR #86099)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-mlir-linalg

@llvm/pr-subscribers-mlir-arith

Author: Matthias Springer (matthias-springer)


Changes

This commit changes the API of `ValueBoundsConstraintSet`: the stop condition 
is now passed to the constructor instead of `processWorklist`. That makes it 
easier to add items to the worklist multiple times and process them in a 
consistent manner. The current `ValueBoundsConstraintSet` is passed as a 
reference to the stop function, so that the stop function can be defined before 
the the `ValueBoundsConstraintSet` is constructed.

This change is in preparation of adding support for branches.

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


7 Files Affected:

- (modified) mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h (+10-6) 
- (modified) mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp (+4-2) 
- (modified) mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp (+4-2) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/IR/ValueBoundsOpInterfaceImpl.cpp (+1-1) 
- (modified) mlir/lib/Interfaces/ValueBoundsOpInterface.cpp (+36-24) 
- (modified) mlir/test/lib/Dialect/Affine/TestReifyValueBounds.cpp (+6-3) 


``diff
diff --git a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h 
b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
index 94a8a8b429c801..b79c44162ea8ef 100644
--- a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
+++ b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
@@ -113,8 +113,9 @@ class ValueBoundsConstraintSet {
   ///
   /// The first parameter of the function is the shaped value/index-typed
   /// value. The second parameter is the dimension in case of a shaped value.
-  using StopConditionFn =
-  function_ref /*dim*/)>;
+  /// The third parameter is this constraint set.
+  using StopConditionFn = function_ref /*dim*/, ValueBoundsConstraintSet &cstr)>;
 
   /// Compute a bound for the given index-typed value or shape dimension size.
   /// The computed bound is stored in `resultMap`. The operands of the bound 
are
@@ -263,12 +264,12 @@ class ValueBoundsConstraintSet {
   /// An index-typed value or the dimension of a shaped-type value.
   using ValueDim = std::pair;
 
-  ValueBoundsConstraintSet(MLIRContext *ctx);
+  ValueBoundsConstraintSet(MLIRContext *ctx, StopConditionFn stopCondition);
 
   /// Iteratively process all elements on the worklist until an index-typed
-  /// value or shaped value meets `stopCondition`. Such values are not 
processed
-  /// any further.
-  void processWorklist(StopConditionFn stopCondition);
+  /// value or shaped value meets `currentStopCondition`. Such values are not
+  /// processed any further.
+  void processWorklist();
 
   /// Bound the given column in the underlying constraint set by the given
   /// expression.
@@ -316,6 +317,9 @@ class ValueBoundsConstraintSet {
 
   /// Builder for constructing affine expressions.
   Builder builder;
+
+  /// The current stop condition function.
+  StopConditionFn stopCondition = nullptr;
 };
 
 } // namespace mlir
diff --git a/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp 
b/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
index 37b36f76d4465d..117ee8e8701ad7 100644
--- a/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
@@ -84,7 +84,8 @@ FailureOr 
mlir::affine::reifyShapedValueDimBound(
 OpBuilder &b, Location loc, presburger::BoundType type, Value value,
 int64_t dim, ValueBoundsConstraintSet::StopConditionFn stopCondition,
 bool closedUB) {
-  auto reifyToOperands = [&](Value v, std::optional d) {
+  auto reifyToOperands = [&](Value v, std::optional d,
+ ValueBoundsConstraintSet &cstr) {
 // We are trying to reify a bound for `value` in terms of the owning op's
 // operands. Construct a stop condition that evaluates to "true" for any 
SSA
 // value except for `value`. I.e., the bound will be computed in terms of
@@ -100,7 +101,8 @@ FailureOr 
mlir::affine::reifyShapedValueDimBound(
 FailureOr mlir::affine::reifyIndexValueBound(
 OpBuilder &b, Location loc, presburger::BoundType type, Value value,
 ValueBoundsConstraintSet::StopConditionFn stopCondition, bool closedUB) {
-  auto reifyToOperands = [&](Value v, std::optional d) {
+  auto reifyToOperands = [&](Value v, std::optional d,
+ ValueBoundsConstraintSet &cstr) {
 return v != value;
   };
   return reifyValueBound(b, loc, type, value, /*dim=*/std::nullopt,
diff --git a/mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp 
b/mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp
index 8d9fd1478aa9e6..fad221288f190e 100644
--- a/mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp
+++ b/mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp
@@ -119,7 +119,8 @@ FailureOr 
mlir::arith::reifyShapedValueDimBound(
 

[llvm-branch-commits] [mlir] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Pass stop condition in the constructor (PR #86099)

2024-03-21 Thread Matthias Springer via llvm-branch-commits

https://github.com/matthias-springer created 
https://github.com/llvm/llvm-project/pull/86099

This commit changes the API of `ValueBoundsConstraintSet`: the stop condition 
is now passed to the constructor instead of `processWorklist`. That makes it 
easier to add items to the worklist multiple times and process them in a 
consistent manner. The current `ValueBoundsConstraintSet` is passed as a 
reference to the stop function, so that the stop function can be defined before 
the the `ValueBoundsConstraintSet` is constructed.

This change is in preparation of adding support for branches.

>From db3dde1d9c6e3eb1b85083d1a3545691f47acb7c Mon Sep 17 00:00:00 2001
From: Matthias Springer 
Date: Thu, 21 Mar 2024 08:04:11 +
Subject: [PATCH] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Pass stop
 condition in the constructor

This commit changes the API of `ValueBoundsConstraintSet`: the stop condition 
is now passed to the constructor instead of `processWorklist`. That makes it 
easier to add items to the worklist multiple times and process them in a 
consistent manner. The current `ValueBoundsConstraintSet` is passed as a 
reference to the stop function, so that the stop function can be defined before 
the the `ValueBoundsConstraintSet` is constructed.

This change is in preparation of adding support for branches.
---
 .../mlir/Interfaces/ValueBoundsOpInterface.h  | 16 +++--
 .../Affine/Transforms/ReifyValueBounds.cpp|  6 +-
 .../Arith/Transforms/ReifyValueBounds.cpp |  6 +-
 .../Linalg/Transforms/HoistPadding.cpp|  2 +-
 .../SCF/IR/ValueBoundsOpInterfaceImpl.cpp |  2 +-
 .../lib/Interfaces/ValueBoundsOpInterface.cpp | 60 +++
 .../Dialect/Affine/TestReifyValueBounds.cpp   |  9 ++-
 7 files changed, 62 insertions(+), 39 deletions(-)

diff --git a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h 
b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
index 94a8a8b429c801..b79c44162ea8ef 100644
--- a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
+++ b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
@@ -113,8 +113,9 @@ class ValueBoundsConstraintSet {
   ///
   /// The first parameter of the function is the shaped value/index-typed
   /// value. The second parameter is the dimension in case of a shaped value.
-  using StopConditionFn =
-  function_ref /*dim*/)>;
+  /// The third parameter is this constraint set.
+  using StopConditionFn = function_ref /*dim*/, ValueBoundsConstraintSet &cstr)>;
 
   /// Compute a bound for the given index-typed value or shape dimension size.
   /// The computed bound is stored in `resultMap`. The operands of the bound 
are
@@ -263,12 +264,12 @@ class ValueBoundsConstraintSet {
   /// An index-typed value or the dimension of a shaped-type value.
   using ValueDim = std::pair;
 
-  ValueBoundsConstraintSet(MLIRContext *ctx);
+  ValueBoundsConstraintSet(MLIRContext *ctx, StopConditionFn stopCondition);
 
   /// Iteratively process all elements on the worklist until an index-typed
-  /// value or shaped value meets `stopCondition`. Such values are not 
processed
-  /// any further.
-  void processWorklist(StopConditionFn stopCondition);
+  /// value or shaped value meets `currentStopCondition`. Such values are not
+  /// processed any further.
+  void processWorklist();
 
   /// Bound the given column in the underlying constraint set by the given
   /// expression.
@@ -316,6 +317,9 @@ class ValueBoundsConstraintSet {
 
   /// Builder for constructing affine expressions.
   Builder builder;
+
+  /// The current stop condition function.
+  StopConditionFn stopCondition = nullptr;
 };
 
 } // namespace mlir
diff --git a/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp 
b/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
index 37b36f76d4465d..117ee8e8701ad7 100644
--- a/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
@@ -84,7 +84,8 @@ FailureOr 
mlir::affine::reifyShapedValueDimBound(
 OpBuilder &b, Location loc, presburger::BoundType type, Value value,
 int64_t dim, ValueBoundsConstraintSet::StopConditionFn stopCondition,
 bool closedUB) {
-  auto reifyToOperands = [&](Value v, std::optional d) {
+  auto reifyToOperands = [&](Value v, std::optional d,
+ ValueBoundsConstraintSet &cstr) {
 // We are trying to reify a bound for `value` in terms of the owning op's
 // operands. Construct a stop condition that evaluates to "true" for any 
SSA
 // value except for `value`. I.e., the bound will be computed in terms of
@@ -100,7 +101,8 @@ FailureOr 
mlir::affine::reifyShapedValueDimBound(
 FailureOr mlir::affine::reifyIndexValueBound(
 OpBuilder &b, Location loc, presburger::BoundType type, Value value,
 ValueBoundsConstraintSet::StopConditionFn stopCondition, bool closedUB) {
-  auto reifyToOperands = [&](Value v, std::optional d) {
+  auto reifyToOperands = [&](Value v, std::optional d

[llvm-branch-commits] [mlir] [mlir][SCF] `ValueBoundsConstraintSet`: Support `scf.if` (branches) (PR #85895)

2024-03-21 Thread Matthias Springer via llvm-branch-commits

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


[llvm-branch-commits] [mlir] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Pass stop condition in the constructor (PR #86099)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-scf

Author: Matthias Springer (matthias-springer)


Changes

This commit changes the API of `ValueBoundsConstraintSet`: the stop condition 
is now passed to the constructor instead of `processWorklist`. That makes it 
easier to add items to the worklist multiple times and process them in a 
consistent manner. The current `ValueBoundsConstraintSet` is passed as a 
reference to the stop function, so that the stop function can be defined before 
the the `ValueBoundsConstraintSet` is constructed.

This change is in preparation of adding support for branches.

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


7 Files Affected:

- (modified) mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h (+10-6) 
- (modified) mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp (+4-2) 
- (modified) mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp (+4-2) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/IR/ValueBoundsOpInterfaceImpl.cpp (+1-1) 
- (modified) mlir/lib/Interfaces/ValueBoundsOpInterface.cpp (+36-24) 
- (modified) mlir/test/lib/Dialect/Affine/TestReifyValueBounds.cpp (+6-3) 


``diff
diff --git a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h 
b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
index 94a8a8b429c801..b79c44162ea8ef 100644
--- a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
+++ b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
@@ -113,8 +113,9 @@ class ValueBoundsConstraintSet {
   ///
   /// The first parameter of the function is the shaped value/index-typed
   /// value. The second parameter is the dimension in case of a shaped value.
-  using StopConditionFn =
-  function_ref /*dim*/)>;
+  /// The third parameter is this constraint set.
+  using StopConditionFn = function_ref /*dim*/, ValueBoundsConstraintSet &cstr)>;
 
   /// Compute a bound for the given index-typed value or shape dimension size.
   /// The computed bound is stored in `resultMap`. The operands of the bound 
are
@@ -263,12 +264,12 @@ class ValueBoundsConstraintSet {
   /// An index-typed value or the dimension of a shaped-type value.
   using ValueDim = std::pair;
 
-  ValueBoundsConstraintSet(MLIRContext *ctx);
+  ValueBoundsConstraintSet(MLIRContext *ctx, StopConditionFn stopCondition);
 
   /// Iteratively process all elements on the worklist until an index-typed
-  /// value or shaped value meets `stopCondition`. Such values are not 
processed
-  /// any further.
-  void processWorklist(StopConditionFn stopCondition);
+  /// value or shaped value meets `currentStopCondition`. Such values are not
+  /// processed any further.
+  void processWorklist();
 
   /// Bound the given column in the underlying constraint set by the given
   /// expression.
@@ -316,6 +317,9 @@ class ValueBoundsConstraintSet {
 
   /// Builder for constructing affine expressions.
   Builder builder;
+
+  /// The current stop condition function.
+  StopConditionFn stopCondition = nullptr;
 };
 
 } // namespace mlir
diff --git a/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp 
b/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
index 37b36f76d4465d..117ee8e8701ad7 100644
--- a/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/ReifyValueBounds.cpp
@@ -84,7 +84,8 @@ FailureOr 
mlir::affine::reifyShapedValueDimBound(
 OpBuilder &b, Location loc, presburger::BoundType type, Value value,
 int64_t dim, ValueBoundsConstraintSet::StopConditionFn stopCondition,
 bool closedUB) {
-  auto reifyToOperands = [&](Value v, std::optional d) {
+  auto reifyToOperands = [&](Value v, std::optional d,
+ ValueBoundsConstraintSet &cstr) {
 // We are trying to reify a bound for `value` in terms of the owning op's
 // operands. Construct a stop condition that evaluates to "true" for any 
SSA
 // value except for `value`. I.e., the bound will be computed in terms of
@@ -100,7 +101,8 @@ FailureOr 
mlir::affine::reifyShapedValueDimBound(
 FailureOr mlir::affine::reifyIndexValueBound(
 OpBuilder &b, Location loc, presburger::BoundType type, Value value,
 ValueBoundsConstraintSet::StopConditionFn stopCondition, bool closedUB) {
-  auto reifyToOperands = [&](Value v, std::optional d) {
+  auto reifyToOperands = [&](Value v, std::optional d,
+ ValueBoundsConstraintSet &cstr) {
 return v != value;
   };
   return reifyValueBound(b, loc, type, value, /*dim=*/std::nullopt,
diff --git a/mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp 
b/mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp
index 8d9fd1478aa9e6..fad221288f190e 100644
--- a/mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp
+++ b/mlir/lib/Dialect/Arith/Transforms/ReifyValueBounds.cpp
@@ -119,7 +119,8 @@ FailureOr 
mlir::arith::reifyShapedValueDimBound(
 OpBuilder &b, Location loc, presbur

[llvm-branch-commits] [CostModel] No cost for llvm.allow.{runtime, ubsan}.check() (PR #86064)

2024-03-21 Thread Nikita Popov via llvm-branch-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/86064
___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Thorsten Schütt via llvm-branch-commits


@@ -0,0 +1,46 @@
+//===- CIRTypes.td - CIR dialect types -*- tablegen 
-*-===//
+//
+// 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 declares the CIR dialect.
+//
+//===--===//
+
+#ifndef MLIR_CIR_DIALECT_CIR
+#define MLIR_CIR_DIALECT_CIR

tschuett wrote:

Thanks! Should the include guards start with clang?

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


[llvm-branch-commits] [dse] Skip llvm.allow.{runtime, ubsan}.check() (PR #86067)

2024-03-21 Thread Nikita Popov via llvm-branch-commits

nikic wrote:

I don't think that this change is necessary. The InaccessibleMemOnly modelling 
will take care of it.

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


[llvm-branch-commits] [CostModel] No cost for llvm.allow.{runtime, ubsan}.check() (PR #86064)

2024-03-21 Thread Matt Arsenault via llvm-branch-commits


@@ -714,6 +714,8 @@ class TargetTransformInfoImplBase {
 switch (ICA.getID()) {
 default:
   break;
+case Intrinsic::allow_runtime_check:

arsenm wrote:

This whole function seems to be reinventing isAssumeLikeIntrinsic

https://github.com/llvm/llvm-project/pull/86064
___
llvm-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] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)

2024-03-21 Thread Florian Hahn via llvm-branch-commits

fhahn wrote:

Could you remove the commit-id line from the commit message, as it doesn’t seem 
relevant?

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


[llvm-branch-commits] [clang] release/18.x: backport PR84230 (PR #86106)

2024-03-21 Thread Antonio Frighetto via llvm-branch-commits

https://github.com/antoniofrighetto created 
https://github.com/llvm/llvm-project/pull/86106

Backport b433076fcbacba8a3b91446390bbea5843322bcd.

>From 4d131343c4e18cfffbfbf3ec8006f81542e855af Mon Sep 17 00:00:00 2001
From: Antonio Frighetto 
Date: Thu, 7 Mar 2024 07:49:40 +0100
Subject: [PATCH] [clang][CodeGen] Allow `memcpy` replace with trivial auto var
 init

When emitting the storage (or memory copy operations) for constant
initializers, the decision whether to split a constant structure or
array store into a sequence of field stores or to use `memcpy` is
based upon the optimization level and the size of the initializer.
In afe8b93ffdfef5d8879e1894b9d7dda40dee2b8d, we extended this by
allowing constants to be split when the array (or struct) type does
not match the type of data the address to the object (constant) is
expected to contain. This may happen when `emitStoresForConstant` is
called by `EmitAutoVarInit`, as the element type of the address gets
shrunk. When this occurs, let the initializer be split into a bunch
of stores only under `-ftrivial-auto-var-init=pattern`.

Fixes: https://github.com/llvm/llvm-project/issues/84178.
---
 clang/lib/CodeGen/CGDecl.cpp  | 43 ++-
 clang/test/CodeGen/aapcs-align.cpp|  4 +--
 clang/test/CodeGen/aapcs64-align.cpp  |  8 ++---
 clang/test/CodeGen/attr-counted-by.c  | 24 -
 clang/test/CodeGenCXX/auto-var-init.cpp   | 27 +++---
 clang/test/CodeGenOpenCL/amdgpu-printf.cl |  9 +
 clang/test/OpenMP/bug54082.c  |  4 +--
 7 files changed, 56 insertions(+), 63 deletions(-)

diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index bbe14ef4c17244..aa9997b87ecfa7 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1241,27 +1241,38 @@ static void emitStoresForConstant(CodeGenModule &CGM, 
const VarDecl &D,
 return;
   }
 
-  // If the initializer is small, use a handful of stores.
+  // If the initializer is small or trivialAutoVarInit is set, use a handful of
+  // stores.
+  bool IsTrivialAutoVarInitPattern =
+  CGM.getContext().getLangOpts().getTrivialAutoVarInit() ==
+  LangOptions::TrivialAutoVarInitKind::Pattern;
   if (shouldSplitConstantStore(CGM, ConstantSize)) {
 if (auto *STy = dyn_cast(Ty)) {
-  const llvm::StructLayout *Layout =
-  CGM.getDataLayout().getStructLayout(STy);
-  for (unsigned i = 0; i != constant->getNumOperands(); i++) {
-CharUnits CurOff = 
CharUnits::fromQuantity(Layout->getElementOffset(i));
-Address EltPtr = Builder.CreateConstInBoundsByteGEP(
-Loc.withElementType(CGM.Int8Ty), CurOff);
-emitStoresForConstant(CGM, D, EltPtr, isVolatile, Builder,
-  constant->getAggregateElement(i), IsAutoInit);
+  if (STy == Loc.getElementType() ||
+  (STy != Loc.getElementType() && IsTrivialAutoVarInitPattern)) {
+const llvm::StructLayout *Layout =
+CGM.getDataLayout().getStructLayout(STy);
+for (unsigned i = 0; i != constant->getNumOperands(); i++) {
+  CharUnits CurOff =
+  CharUnits::fromQuantity(Layout->getElementOffset(i));
+  Address EltPtr = Builder.CreateConstInBoundsByteGEP(
+  Loc.withElementType(CGM.Int8Ty), CurOff);
+  emitStoresForConstant(CGM, D, EltPtr, isVolatile, Builder,
+constant->getAggregateElement(i), IsAutoInit);
+}
+return;
   }
-  return;
 } else if (auto *ATy = dyn_cast(Ty)) {
-  for (unsigned i = 0; i != ATy->getNumElements(); i++) {
-Address EltPtr = Builder.CreateConstGEP(
-Loc.withElementType(ATy->getElementType()), i);
-emitStoresForConstant(CGM, D, EltPtr, isVolatile, Builder,
-  constant->getAggregateElement(i), IsAutoInit);
+  if (ATy == Loc.getElementType() ||
+  (ATy != Loc.getElementType() && IsTrivialAutoVarInitPattern)) {
+for (unsigned i = 0; i != ATy->getNumElements(); i++) {
+  Address EltPtr = Builder.CreateConstGEP(
+  Loc.withElementType(ATy->getElementType()), i);
+  emitStoresForConstant(CGM, D, EltPtr, isVolatile, Builder,
+constant->getAggregateElement(i), IsAutoInit);
+}
+return;
   }
-  return;
 }
   }
 
diff --git a/clang/test/CodeGen/aapcs-align.cpp 
b/clang/test/CodeGen/aapcs-align.cpp
index 2886a32974b066..4f393d9e6b7f32 100644
--- a/clang/test/CodeGen/aapcs-align.cpp
+++ b/clang/test/CodeGen/aapcs-align.cpp
@@ -134,8 +134,8 @@ void g6() {
   f6m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define{{.*}} void @g6
-// CHECK: call void @f6(i32 noundef 1, [4 x i32] [i32 6, i32 7, i32 0, i32 0])
-// CHECK: call void @f6m(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 
noundef 4, i32 noundef 5, [4 x i32] [i32 6, i32 7, i32 0, i32 0])
+// CHECK: call void @f6(i32 noundef 1, [4 x i32]

[llvm-branch-commits] [clang] release/18.x: backport PR84230 (PR #86106)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-amdgpu

@llvm/pr-subscribers-clang

Author: Antonio Frighetto (antoniofrighetto)


Changes

Backport b433076fcbacba8a3b91446390bbea5843322bcd.

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


7 Files Affected:

- (modified) clang/lib/CodeGen/CGDecl.cpp (+27-16) 
- (modified) clang/test/CodeGen/aapcs-align.cpp (+2-2) 
- (modified) clang/test/CodeGen/aapcs64-align.cpp (+4-4) 
- (modified) clang/test/CodeGen/attr-counted-by.c (+6-18) 
- (modified) clang/test/CodeGenCXX/auto-var-init.cpp (+15-12) 
- (modified) clang/test/CodeGenOpenCL/amdgpu-printf.cl (+1-8) 
- (modified) clang/test/OpenMP/bug54082.c (+1-3) 


``diff
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index bbe14ef4c17244..aa9997b87ecfa7 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1241,27 +1241,38 @@ static void emitStoresForConstant(CodeGenModule &CGM, 
const VarDecl &D,
 return;
   }
 
-  // If the initializer is small, use a handful of stores.
+  // If the initializer is small or trivialAutoVarInit is set, use a handful of
+  // stores.
+  bool IsTrivialAutoVarInitPattern =
+  CGM.getContext().getLangOpts().getTrivialAutoVarInit() ==
+  LangOptions::TrivialAutoVarInitKind::Pattern;
   if (shouldSplitConstantStore(CGM, ConstantSize)) {
 if (auto *STy = dyn_cast(Ty)) {
-  const llvm::StructLayout *Layout =
-  CGM.getDataLayout().getStructLayout(STy);
-  for (unsigned i = 0; i != constant->getNumOperands(); i++) {
-CharUnits CurOff = 
CharUnits::fromQuantity(Layout->getElementOffset(i));
-Address EltPtr = Builder.CreateConstInBoundsByteGEP(
-Loc.withElementType(CGM.Int8Ty), CurOff);
-emitStoresForConstant(CGM, D, EltPtr, isVolatile, Builder,
-  constant->getAggregateElement(i), IsAutoInit);
+  if (STy == Loc.getElementType() ||
+  (STy != Loc.getElementType() && IsTrivialAutoVarInitPattern)) {
+const llvm::StructLayout *Layout =
+CGM.getDataLayout().getStructLayout(STy);
+for (unsigned i = 0; i != constant->getNumOperands(); i++) {
+  CharUnits CurOff =
+  CharUnits::fromQuantity(Layout->getElementOffset(i));
+  Address EltPtr = Builder.CreateConstInBoundsByteGEP(
+  Loc.withElementType(CGM.Int8Ty), CurOff);
+  emitStoresForConstant(CGM, D, EltPtr, isVolatile, Builder,
+constant->getAggregateElement(i), IsAutoInit);
+}
+return;
   }
-  return;
 } else if (auto *ATy = dyn_cast(Ty)) {
-  for (unsigned i = 0; i != ATy->getNumElements(); i++) {
-Address EltPtr = Builder.CreateConstGEP(
-Loc.withElementType(ATy->getElementType()), i);
-emitStoresForConstant(CGM, D, EltPtr, isVolatile, Builder,
-  constant->getAggregateElement(i), IsAutoInit);
+  if (ATy == Loc.getElementType() ||
+  (ATy != Loc.getElementType() && IsTrivialAutoVarInitPattern)) {
+for (unsigned i = 0; i != ATy->getNumElements(); i++) {
+  Address EltPtr = Builder.CreateConstGEP(
+  Loc.withElementType(ATy->getElementType()), i);
+  emitStoresForConstant(CGM, D, EltPtr, isVolatile, Builder,
+constant->getAggregateElement(i), IsAutoInit);
+}
+return;
   }
-  return;
 }
   }
 
diff --git a/clang/test/CodeGen/aapcs-align.cpp 
b/clang/test/CodeGen/aapcs-align.cpp
index 2886a32974b066..4f393d9e6b7f32 100644
--- a/clang/test/CodeGen/aapcs-align.cpp
+++ b/clang/test/CodeGen/aapcs-align.cpp
@@ -134,8 +134,8 @@ void g6() {
   f6m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define{{.*}} void @g6
-// CHECK: call void @f6(i32 noundef 1, [4 x i32] [i32 6, i32 7, i32 0, i32 0])
-// CHECK: call void @f6m(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 
noundef 4, i32 noundef 5, [4 x i32] [i32 6, i32 7, i32 0, i32 0])
+// CHECK: call void @f6(i32 noundef 1, [4 x i32] [i32 6, i32 7, i32 0, i32 
undef])
+// CHECK: call void @f6m(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 
noundef 4, i32 noundef 5, [4 x i32] [i32 6, i32 7, i32 0, i32 undef])
 // CHECK: declare void @f6(i32 noundef, [4 x i32])
 // CHECK: declare void @f6m(i32 noundef, i32 noundef, i32 noundef, i32 
noundef, i32 noundef, [4 x i32])
 }
diff --git a/clang/test/CodeGen/aapcs64-align.cpp 
b/clang/test/CodeGen/aapcs64-align.cpp
index 759413cbc4b56f..de231f2123b975 100644
--- a/clang/test/CodeGen/aapcs64-align.cpp
+++ b/clang/test/CodeGen/aapcs64-align.cpp
@@ -75,8 +75,8 @@ void g4() {
   f4m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define{{.*}} void @g4()
-// CHECK: call void @f4(i32 noundef 1, [2 x i64] %{{.*}})
-// CHECK: void @f4m(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 
4, i32 noundef 5, [2 x i64] %{{.*}})
+// CHECK: call void @f4(i32 noundef 1, [2 x i64] [i64 30064771078, i64 0])
+// CHECK: void

[llvm-branch-commits] [clang] release/18.x: backport PR84230 (PR #86106)

2024-03-21 Thread Nikita Popov via llvm-branch-commits

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


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


[llvm-branch-commits] [clang] release/18.x: backport PR84230 (PR #86106)

2024-03-21 Thread Aaron Ballman via llvm-branch-commits

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

LGTM!

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


[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

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

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

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

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

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

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

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

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

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

[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)

2024-03-21 Thread Aaron Ballman via llvm-branch-commits

https://github.com/AaronBallman commented:

The changes seem reasonable to me, but I've added the CMake code owners for 
final approval.

https://github.com/llvm/llvm-project/pull/86078
___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Aaron Ballman via llvm-branch-commits

https://github.com/AaronBallman edited 
https://github.com/llvm/llvm-project/pull/86080
___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Aaron Ballman via llvm-branch-commits


@@ -0,0 +1,46 @@
+//===- CIRTypes.td - CIR dialect types -*- tablegen 
-*-===//
+//
+// 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 declares the CIR dialect.
+//
+//===--===//
+
+#ifndef MLIR_CIR_DIALECT_CIR
+#define MLIR_CIR_DIALECT_CIR
+
+include "mlir/IR/OpBase.td"
+
+def CIR_Dialect : Dialect {
+  let name = "cir";
+
+  // A short one-line summary of our dialect.
+  let summary = "A high-level dialect for analyzing and optimizing Clang "
+"supported languages";
+
+  let cppNamespace = "::mlir::cir";
+
+  let useDefaultAttributePrinterParser = 0;
+  let useDefaultTypePrinterParser = 0;

AaronBallman wrote:

Should these follow the usual style guide for naming of member variables (start 
with a capital letter)?

https://github.com/llvm/llvm-project/pull/86080
___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Aaron Ballman via llvm-branch-commits


@@ -0,0 +1,18 @@
+//===-- CIROps.td - CIR dialect definition -*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// Definition of the CIR dialect
+///
+//===--===//
+
+#ifndef MLIR_CIR_DIALECT_CIR_OPS

AaronBallman wrote:

Prefix with `CLANG_` as well?

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


[llvm-branch-commits] [llvm] release/18.x: [SROA]: Only defer trying partial sized ptr or ptr vector types (PR #86114)

2024-03-21 Thread via llvm-branch-commits

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

Backport 1e828f838cc0f15074f3dbbb04929c06ef0c9729

Requested by: @DianQK

>From e20f2dbd538d6f0d96d24624d93d4030bb955260 Mon Sep 17 00:00:00 2001
From: Jeffrey Byrnes 
Date: Mon, 19 Feb 2024 12:59:13 -0800
Subject: [PATCH] [SROA]: Only defer trying partial sized ptr or ptr vector
 types

Change-Id: Ic77f87290905addadd5819dff2d0c62f031022ab
(cherry picked from commit 1e828f838cc0f15074f3dbbb04929c06ef0c9729)
---
 llvm/lib/Transforms/Scalar/SROA.cpp   | 80 ---
 llvm/test/Transforms/SROA/vector-promotion.ll | 62 ++
 2 files changed, 115 insertions(+), 27 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp 
b/llvm/lib/Transforms/Scalar/SROA.cpp
index bdbaf4f55c96d0..17a94f9381bf8e 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -2257,6 +2257,41 @@ checkVectorTypesForPromotion(Partition &P, const 
DataLayout &DL,
   return nullptr;
 }
 
+static VectorType *createAndCheckVectorTypesForPromotion(
+SetVector &OtherTys, ArrayRef CandidateTysCopy,
+function_ref CheckCandidateType, Partition &P,
+const DataLayout &DL, SmallVectorImpl &CandidateTys,
+bool &HaveCommonEltTy, Type *&CommonEltTy, bool &HaveVecPtrTy,
+bool &HaveCommonVecPtrTy, VectorType *&CommonVecPtrTy) {
+  [[maybe_unused]] VectorType *OriginalElt =
+  CandidateTysCopy.size() ? CandidateTysCopy[0] : nullptr;
+  // Consider additional vector types where the element type size is a
+  // multiple of load/store element size.
+  for (Type *Ty : OtherTys) {
+if (!VectorType::isValidElementType(Ty))
+  continue;
+unsigned TypeSize = DL.getTypeSizeInBits(Ty).getFixedValue();
+// Make a copy of CandidateTys and iterate through it, because we
+// might append to CandidateTys in the loop.
+for (VectorType *const VTy : CandidateTysCopy) {
+  // The elements in the copy should remain invariant throughout the loop
+  assert(CandidateTysCopy[0] == OriginalElt && "Different Element");
+  unsigned VectorSize = DL.getTypeSizeInBits(VTy).getFixedValue();
+  unsigned ElementSize =
+  DL.getTypeSizeInBits(VTy->getElementType()).getFixedValue();
+  if (TypeSize != VectorSize && TypeSize != ElementSize &&
+  VectorSize % TypeSize == 0) {
+VectorType *NewVTy = VectorType::get(Ty, VectorSize / TypeSize, false);
+CheckCandidateType(NewVTy);
+  }
+}
+  }
+
+  return checkVectorTypesForPromotion(P, DL, CandidateTys, HaveCommonEltTy,
+  CommonEltTy, HaveVecPtrTy,
+  HaveCommonVecPtrTy, CommonVecPtrTy);
+}
+
 /// Test whether the given alloca partitioning and range of slices can be
 /// promoted to a vector.
 ///
@@ -2271,6 +2306,7 @@ static VectorType *isVectorPromotionViable(Partition &P, 
const DataLayout &DL) {
   // we have different element types.
   SmallVector CandidateTys;
   SetVector LoadStoreTys;
+  SetVector DeferredTys;
   Type *CommonEltTy = nullptr;
   VectorType *CommonVecPtrTy = nullptr;
   bool HaveVecPtrTy = false;
@@ -2314,42 +2350,32 @@ static VectorType *isVectorPromotionViable(Partition 
&P, const DataLayout &DL) {
   Ty = SI->getValueOperand()->getType();
 else
   continue;
+
+auto CandTy = Ty->getScalarType();
+if (CandTy->isPointerTy() && (S.beginOffset() != P.beginOffset() ||
+  S.endOffset() != P.endOffset())) {
+  DeferredTys.insert(Ty);
+  continue;
+}
+
 LoadStoreTys.insert(Ty);
 // Consider any loads or stores that are the exact size of the slice.
 if (S.beginOffset() == P.beginOffset() && S.endOffset() == P.endOffset())
   CheckCandidateType(Ty);
   }
 
-  if (auto *VTy = checkVectorTypesForPromotion(
-  P, DL, CandidateTys, HaveCommonEltTy, CommonEltTy, HaveVecPtrTy,
+  SmallVector CandidateTysCopy = CandidateTys;
+  if (auto *VTy = createAndCheckVectorTypesForPromotion(
+  LoadStoreTys, CandidateTysCopy, CheckCandidateType, P, DL,
+  CandidateTys, HaveCommonEltTy, CommonEltTy, HaveVecPtrTy,
   HaveCommonVecPtrTy, CommonVecPtrTy))
 return VTy;
 
-  // Consider additional vector types where the element type size is a
-  // multiple of load/store element size.
-  for (Type *Ty : LoadStoreTys) {
-if (!VectorType::isValidElementType(Ty))
-  continue;
-unsigned TypeSize = DL.getTypeSizeInBits(Ty).getFixedValue();
-// Make a copy of CandidateTys and iterate through it, because we might
-// append to CandidateTys in the loop.
-SmallVector CandidateTysCopy = CandidateTys;
-CandidateTys.clear();
-for (VectorType *&VTy : CandidateTysCopy) {
-  unsigned VectorSize = DL.getTypeSizeInBits(VTy).getFixedValue();
-  unsigned ElementSize =
-  DL.getTypeSizeInBits(VTy->getElementType()).getFixedValue();
-  if (TypeSize != VectorSize && TypeSize != E

[llvm-branch-commits] [llvm] release/18.x: [SROA]: Only defer trying partial sized ptr or ptr vector types (PR #86114)

2024-03-21 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] release/18.x: [SROA]: Only defer trying partial sized ptr or ptr vector types (PR #86114)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: None (llvmbot)


Changes

Backport 1e828f838cc0f15074f3dbbb04929c06ef0c9729

Requested by: @DianQK

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


2 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/SROA.cpp (+53-27) 
- (modified) llvm/test/Transforms/SROA/vector-promotion.ll (+62) 


``diff
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp 
b/llvm/lib/Transforms/Scalar/SROA.cpp
index bdbaf4f55c96d0..17a94f9381bf8e 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -2257,6 +2257,41 @@ checkVectorTypesForPromotion(Partition &P, const 
DataLayout &DL,
   return nullptr;
 }
 
+static VectorType *createAndCheckVectorTypesForPromotion(
+SetVector &OtherTys, ArrayRef CandidateTysCopy,
+function_ref CheckCandidateType, Partition &P,
+const DataLayout &DL, SmallVectorImpl &CandidateTys,
+bool &HaveCommonEltTy, Type *&CommonEltTy, bool &HaveVecPtrTy,
+bool &HaveCommonVecPtrTy, VectorType *&CommonVecPtrTy) {
+  [[maybe_unused]] VectorType *OriginalElt =
+  CandidateTysCopy.size() ? CandidateTysCopy[0] : nullptr;
+  // Consider additional vector types where the element type size is a
+  // multiple of load/store element size.
+  for (Type *Ty : OtherTys) {
+if (!VectorType::isValidElementType(Ty))
+  continue;
+unsigned TypeSize = DL.getTypeSizeInBits(Ty).getFixedValue();
+// Make a copy of CandidateTys and iterate through it, because we
+// might append to CandidateTys in the loop.
+for (VectorType *const VTy : CandidateTysCopy) {
+  // The elements in the copy should remain invariant throughout the loop
+  assert(CandidateTysCopy[0] == OriginalElt && "Different Element");
+  unsigned VectorSize = DL.getTypeSizeInBits(VTy).getFixedValue();
+  unsigned ElementSize =
+  DL.getTypeSizeInBits(VTy->getElementType()).getFixedValue();
+  if (TypeSize != VectorSize && TypeSize != ElementSize &&
+  VectorSize % TypeSize == 0) {
+VectorType *NewVTy = VectorType::get(Ty, VectorSize / TypeSize, false);
+CheckCandidateType(NewVTy);
+  }
+}
+  }
+
+  return checkVectorTypesForPromotion(P, DL, CandidateTys, HaveCommonEltTy,
+  CommonEltTy, HaveVecPtrTy,
+  HaveCommonVecPtrTy, CommonVecPtrTy);
+}
+
 /// Test whether the given alloca partitioning and range of slices can be
 /// promoted to a vector.
 ///
@@ -2271,6 +2306,7 @@ static VectorType *isVectorPromotionViable(Partition &P, 
const DataLayout &DL) {
   // we have different element types.
   SmallVector CandidateTys;
   SetVector LoadStoreTys;
+  SetVector DeferredTys;
   Type *CommonEltTy = nullptr;
   VectorType *CommonVecPtrTy = nullptr;
   bool HaveVecPtrTy = false;
@@ -2314,42 +2350,32 @@ static VectorType *isVectorPromotionViable(Partition 
&P, const DataLayout &DL) {
   Ty = SI->getValueOperand()->getType();
 else
   continue;
+
+auto CandTy = Ty->getScalarType();
+if (CandTy->isPointerTy() && (S.beginOffset() != P.beginOffset() ||
+  S.endOffset() != P.endOffset())) {
+  DeferredTys.insert(Ty);
+  continue;
+}
+
 LoadStoreTys.insert(Ty);
 // Consider any loads or stores that are the exact size of the slice.
 if (S.beginOffset() == P.beginOffset() && S.endOffset() == P.endOffset())
   CheckCandidateType(Ty);
   }
 
-  if (auto *VTy = checkVectorTypesForPromotion(
-  P, DL, CandidateTys, HaveCommonEltTy, CommonEltTy, HaveVecPtrTy,
+  SmallVector CandidateTysCopy = CandidateTys;
+  if (auto *VTy = createAndCheckVectorTypesForPromotion(
+  LoadStoreTys, CandidateTysCopy, CheckCandidateType, P, DL,
+  CandidateTys, HaveCommonEltTy, CommonEltTy, HaveVecPtrTy,
   HaveCommonVecPtrTy, CommonVecPtrTy))
 return VTy;
 
-  // Consider additional vector types where the element type size is a
-  // multiple of load/store element size.
-  for (Type *Ty : LoadStoreTys) {
-if (!VectorType::isValidElementType(Ty))
-  continue;
-unsigned TypeSize = DL.getTypeSizeInBits(Ty).getFixedValue();
-// Make a copy of CandidateTys and iterate through it, because we might
-// append to CandidateTys in the loop.
-SmallVector CandidateTysCopy = CandidateTys;
-CandidateTys.clear();
-for (VectorType *&VTy : CandidateTysCopy) {
-  unsigned VectorSize = DL.getTypeSizeInBits(VTy).getFixedValue();
-  unsigned ElementSize =
-  DL.getTypeSizeInBits(VTy->getElementType()).getFixedValue();
-  if (TypeSize != VectorSize && TypeSize != ElementSize &&
-  VectorSize % TypeSize == 0) {
-VectorType *NewVTy = VectorType::get(Ty, VectorSize / TypeSize, false);
-CheckCandidateType(NewVTy);
-  }
-}
-  }
-
-  return checkVectorTypesForPromotion(P, DL, CandidateTys, HaveCommonEltTy,
-   

[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Aaron Ballman via llvm-branch-commits

https://github.com/AaronBallman commented:

Generally LGTM as well, but added the CMake code owners for their opinions on 
those bits.

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


[llvm-branch-commits] [CodeGen] Add default lowering for llvm.allow.{runtime, ubsan}.check() (PR #86049)

2024-03-21 Thread Matt Arsenault via llvm-branch-commits


@@ -0,0 +1,30 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc < %s -mtriple=aarch64 | FileCheck %s

arsenm wrote:

Should use explicit -global-isel=0 for the dag test 

https://github.com/llvm/llvm-project/pull/86049
___
llvm-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++][chrono] Improves date formatting. (PR #86127)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)


Changes

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

This removes several platform specific ifdefs from the tests.

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


4 Files Affected:

- (modified) libcxx/include/__chrono/formatter.h (+7-9) 
- (modified) 
libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
 (-31) 
- (modified) 
libcxx/test/std/time/time.clock/time.clock.system/sys_date.ostream.pass.cpp 
(-31) 
- (modified) libcxx/test/std/time/time.syn/formatter.year_month_day.pass.cpp 
(-24) 


``diff
diff --git a/libcxx/include/__chrono/formatter.h 
b/libcxx/include/__chrono/formatter.h
index 8b8592041a1fb9..217979e88c93db 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -322,15 +322,13 @@ _LIBCPP_HIDE_FROM_ABI void 
__format_chrono_using_chrono_specs(
 __formatter::__format_year(__sstr, __t.tm_year + 1900);
 break;
 
-  case _CharT('F'): {
-int __year = __t.tm_year + 1900;
-if (__year < 1000) {
-  __formatter::__format_year(__sstr, __year);
-  __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
-} else
-  __facet.put(
-  {__sstr}, __sstr, _CharT(' '), std::addressof(__t), 
std::to_address(__s), std::to_address(__it + 1));
-  } break;
+  case _CharT('F'):
+// Depending on the platform's libc the range of supported years is
+// limited. Intead of of testing all conditions use the internal
+// implementation unconditionally.
+__formatter::__format_year(__sstr, __t.tm_year + 1900);
+__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, 
"-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
+break;
 
   case _CharT('z'):
 __formatter::__format_zone_offset(__sstr, __z.__offset, false);
diff --git 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
index ffc737fcad5dd2..3a37e75bbcd2e4 100644
--- 
a/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
+++ 
b/libcxx/test/std/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/ostream.pass.cpp
@@ -89,20 +89,9 @@ static void test() {
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-
-#if defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_c_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else //  defined(_AIX)
   TEST_EQUAL(stream_c_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{-32'768}, 
std::chrono::month{1}, std::chrono::day{1}}),
@@ -122,19 +111,9 @@ static void test() {
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, std::chrono::day{29}}),
  SV("2000-02-29"));
-#if defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV("+32767-12-31"));
-#elif defined(_WIN32) // defined(_AIX)
-  TEST_EQUAL(stream_fr_FR_locale(
- std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
- SV(""));
-#else // defined(_AIX)
   TEST_EQUAL(stream_fr_FR_locale(
  std::chrono::year_month_day{std::chrono::year{32'767}, 
std::chrono::month{12}, std::chrono::day{31}}),
  SV("32767-12-31"));
-#endif// defined(_AIX)
 
   TEST_EQUAL(stream_ja_JP_locale(
  std::chrono::year_month_day{std::chrono::year{-32'768}, 
std::chrono::month{1}, std::chrono::day{1}}),
@@ -154,19 +133,9 @@ static void test() {
   TEST_EQUAL(stream_ja_JP_locale(
  std::chrono::year_month_day{std::chrono::year{2000}, 
std::chrono::month{2}, s

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

2024-03-21 Thread Mark de Wever via llvm-branch-commits

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

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

This removes several platform specific ifdefs from the tests.

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

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

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

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

[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)

2024-03-21 Thread Nathan Lanza via llvm-branch-commits

lanza wrote:

> Could you remove the commit-id line from the commit message, as it doesn’t 
> seem relevant?

That's [spr](https://github.com/getcord/spr)'s bookkeeping. It doesn't make it 
into the final commit.

https://github.com/llvm/llvm-project/pull/86072
___
llvm-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] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)

2024-03-21 Thread Aaron Ballman via llvm-branch-commits

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

LGTM!

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


[llvm-branch-commits] [mlir] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Delete dead code (PR #86098)

2024-03-21 Thread Benjamin Maxwell via llvm-branch-commits

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

LGTM :+1: 

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


[llvm-branch-commits] [mlir] [mlir][Interfaces][NFC] `ValueBoundsConstraintSet`: Pass stop condition in the constructor (PR #86099)

2024-03-21 Thread Benjamin Maxwell via llvm-branch-commits


@@ -316,6 +317,9 @@ class ValueBoundsConstraintSet {
 
   /// Builder for constructing affine expressions.
   Builder builder;
+
+  /// The current stop condition function.
+  StopConditionFn stopCondition = nullptr;

MacDue wrote:

Just wondering if this should be a `std::function` instead? `function_ref` 
begin non-owning could lead to some surprises. E.g. by doing 
`ValueBoundsConstraintSet cstr(..., /*stopCondition=*/[&]{ ... })`.

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


[llvm-branch-commits] [llvm] release/18.x: [SROA]: Only defer trying partial sized ptr or ptr vector types (PR #86114)

2024-03-21 Thread Jeffrey Byrnes via llvm-branch-commits

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

LGTM

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


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

2024-03-21 Thread via llvm-branch-commits

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


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

2024-03-21 Thread via llvm-branch-commits

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

Backport 6295e677220bb6ec1fa8abe2f4a94b513b91b786 
12836467b76c56872b4c22a6fd44bcda696ea720

Requested by: @AtariDreams

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

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

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

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

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

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

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

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

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

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

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

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

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-ir

Author: None (llvmbot)


Changes

Backport 6295e677220bb6ec1fa8abe2f4a94b513b91b786 
12836467b76c56872b4c22a6fd44bcda696ea720

Requested by: @AtariDreams

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


3 Files Affected:

- (modified) llvm/lib/IR/ConstantRange.cpp (+2-2) 
- (added) llvm/test/Transforms/Float2Int/pr79158.ll (+20) 
- (modified) llvm/unittests/IR/ConstantRangeTest.cpp (+18) 


``diff
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index cbb64b299e648e..f105bdb4816aa0 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -746,7 +746,7 @@ ConstantRange ConstantRange::castOp(Instruction::CastOps 
CastOp,
   Min = Min.zext(ResultBitWidth);
   Max = Max.zext(ResultBitWidth);
 }
-return ConstantRange(std::move(Min), std::move(Max));
+return getNonEmpty(std::move(Min), std::move(Max) + 1);
   }
   case Instruction::SIToFP: {
 // TODO: use input range if available
@@ -757,7 +757,7 @@ ConstantRange ConstantRange::castOp(Instruction::CastOps 
CastOp,
   SMin = SMin.sext(ResultBitWidth);
   SMax = SMax.sext(ResultBitWidth);
 }
-return ConstantRange(std::move(SMin), std::move(SMax));
+return getNonEmpty(std::move(SMin), std::move(SMax) + 1);
   }
   case Instruction::FPTrunc:
   case Instruction::FPExt:
diff --git a/llvm/test/Transforms/Float2Int/pr79158.ll 
b/llvm/test/Transforms/Float2Int/pr79158.ll
new file mode 100644
index 00..5e78cc0bc66fdb
--- /dev/null
+++ b/llvm/test/Transforms/Float2Int/pr79158.ll
@@ -0,0 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt < %s -passes=float2int -S | FileCheck %s
+
+define i32 @pr79158(i32 %x) {
+; CHECK-LABEL: define i32 @pr79158(
+; CHECK-SAME: i32 [[X:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP:%.*]] = icmp sgt i32 [[X]], 0
+; CHECK-NEXT:[[TMP0:%.*]] = zext i1 [[CMP]] to i64
+; CHECK-NEXT:[[MUL1:%.*]] = mul i64 [[TMP0]], 4294967295
+; CHECK-NEXT:[[TMP1:%.*]] = trunc i64 [[MUL1]] to i32
+; CHECK-NEXT:ret i32 [[TMP1]]
+;
+entry:
+  %cmp = icmp sgt i32 %x, 0
+  %conv = uitofp i1 %cmp to double
+  %mul = fmul double %conv, 0x41EFFFE0
+  %conv1 = fptoui double %mul to i32
+  ret i32 %conv1
+}
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp 
b/llvm/unittests/IR/ConstantRangeTest.cpp
index e505af5d3275ef..f60bb4c135bec3 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -2479,6 +2479,24 @@ TEST_F(ConstantRangeTest, castOps) {
   ConstantRange IntToPtr = A.castOp(Instruction::IntToPtr, 64);
   EXPECT_EQ(64u, IntToPtr.getBitWidth());
   EXPECT_TRUE(IntToPtr.isFullSet());
+
+  ConstantRange UIToFP = A.castOp(Instruction::UIToFP, 16);
+  EXPECT_EQ(16u, UIToFP.getBitWidth());
+  EXPECT_TRUE(UIToFP.isFullSet());
+
+  ConstantRange UIToFP2 = A.castOp(Instruction::UIToFP, 64);
+  ConstantRange B(APInt(64, 0), APInt(64, 65536));
+  EXPECT_EQ(64u, UIToFP2.getBitWidth());
+  EXPECT_EQ(B, UIToFP2);
+
+  ConstantRange SIToFP = A.castOp(Instruction::SIToFP, 16);
+  EXPECT_EQ(16u, SIToFP.getBitWidth());
+  EXPECT_TRUE(SIToFP.isFullSet());
+
+  ConstantRange SIToFP2 = A.castOp(Instruction::SIToFP, 64);
+  ConstantRange C(APInt(64, -32768), APInt(64, 32768));
+  EXPECT_EQ(64u, SIToFP2.getBitWidth());
+  EXPECT_EQ(C, SIToFP2);
 }
 
 TEST_F(ConstantRangeTest, binaryAnd) {

``




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


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

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:

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

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


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

2024-03-21 Thread via llvm-branch-commits

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

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

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

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

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

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

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

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

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

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

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

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

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

2024-03-21 Thread Mark de Wever via llvm-branch-commits

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

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

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

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

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

[llvm-branch-commits] [memoryssa] Exclude llvm.allow.{runtime, ubsan}.check() (PR #86066)

2024-03-21 Thread Alina Sbirlea via llvm-branch-commits

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

lgtm

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


[llvm-branch-commits] [CodeGen] Add default lowering for llvm.allow.{runtime, ubsan}.check() (PR #86049)

2024-03-21 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/86049


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


[llvm-branch-commits] [CodeGen] Add default lowering for llvm.allow.{runtime, ubsan}.check() (PR #86049)

2024-03-21 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/86049


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


[llvm-branch-commits] [llvm] Bump version to 18.1.3 (PR #86168)

2024-03-21 Thread Tom Stellard via llvm-branch-commits

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


[llvm-branch-commits] [llvm] Bump version to 18.1.3 (PR #86168)

2024-03-21 Thread Tom Stellard via llvm-branch-commits

https://github.com/tstellar created 
https://github.com/llvm/llvm-project/pull/86168

None

>From 987a5e62d70d4904b7f057fcd90d1c0c9f6fd9da Mon Sep 17 00:00:00 2001
From: Tom Stellard 
Date: Thu, 21 Mar 2024 11:20:46 -0700
Subject: [PATCH] Bump version to 18.1.3

---
 llvm/CMakeLists.txt| 2 +-
 llvm/utils/lit/lit/__init__.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c5fa66390bba8d..253f3943c3b51f 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -22,7 +22,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 2)
+  set(LLVM_VERSION_PATCH 3)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)
diff --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index 20e245f7161709..9165056a56bd4d 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = "Daniel Dunbar"
 __email__ = "dan...@minormatter.com"
-__versioninfo__ = (18, 1, 0)
+__versioninfo__ = (18, 1, 3)
 __version__ = ".".join(str(v) for v in __versioninfo__) + "dev"
 
 __all__ = []

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


[llvm-branch-commits] [llvm] Bump version to 18.1.3 (PR #86168)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-testing-tools

Author: Tom Stellard (tstellar)


Changes



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


2 Files Affected:

- (modified) llvm/CMakeLists.txt (+1-1) 
- (modified) llvm/utils/lit/lit/__init__.py (+1-1) 


``diff
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c5fa66390bba8d..253f3943c3b51f 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -22,7 +22,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
   set(LLVM_VERSION_MINOR 1)
 endif()
 if(NOT DEFINED LLVM_VERSION_PATCH)
-  set(LLVM_VERSION_PATCH 2)
+  set(LLVM_VERSION_PATCH 3)
 endif()
 if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX)
diff --git a/llvm/utils/lit/lit/__init__.py b/llvm/utils/lit/lit/__init__.py
index 20e245f7161709..9165056a56bd4d 100644
--- a/llvm/utils/lit/lit/__init__.py
+++ b/llvm/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
 
 __author__ = "Daniel Dunbar"
 __email__ = "dan...@minormatter.com"
-__versioninfo__ = (18, 1, 0)
+__versioninfo__ = (18, 1, 3)
 __version__ = ".".join(str(v) for v in __versioninfo__) + "dev"
 
 __all__ = []

``




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


[llvm-branch-commits] [CostModel] No cost for llvm.allow.{runtime, ubsan}.check() (PR #86064)

2024-03-21 Thread Vitaly Buka via llvm-branch-commits


@@ -714,6 +714,8 @@ class TargetTransformInfoImplBase {
 switch (ICA.getID()) {
 default:
   break;
+case Intrinsic::allow_runtime_check:

vitalybuka wrote:

Not sure, probably all assume like should be there,
but `Intrinsic::objectsize` does not look like it.

I guess missing instruction as parameter prevents use of isAssumeLikeIntrinsic

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


[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

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

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

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

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

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

[llvm-branch-commits] [libcxx] [libc++][TZDB] Adds sys_info formatter. (PR #85896)

2024-03-21 Thread Mark de Wever via llvm-branch-commits

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


[llvm-branch-commits] [libc] 23d6e75 - Revert "[libc] Add reverse_iterator comparisons (#86147)"

2024-03-21 Thread via llvm-branch-commits

Author: Guillaume Chatelet
Date: 2024-03-21T20:36:49+01:00
New Revision: 23d6e752ecc1d5a6eecb41a4b8fbfc89a65d2c7b

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

LOG: Revert "[libc] Add reverse_iterator comparisons (#86147)"

This reverts commit c96b61adc33b9d4ab26e2d0e4bce929b31c48768.

Added: 


Modified: 
libc/src/__support/CPP/iterator.h

Removed: 




diff  --git a/libc/src/__support/CPP/iterator.h 
b/libc/src/__support/CPP/iterator.h
index 4d06e181bcf064..c5bfb1912c7b74 100644
--- a/libc/src/__support/CPP/iterator.h
+++ b/libc/src/__support/CPP/iterator.h
@@ -20,7 +20,6 @@ namespace cpp {
 template  struct iterator_traits;
 template  struct iterator_traits {
   using reference = T &;
-  using value_type = T;
 };
 
 template  class reverse_iterator {
@@ -28,8 +27,6 @@ template  class reverse_iterator {
 
 public:
   using reference = typename iterator_traits::reference;
-  using value_type = typename iterator_traits::value_type;
-  using iterator_type = Iter;
 
   LIBC_INLINE reverse_iterator() : current() {}
   LIBC_INLINE constexpr explicit reverse_iterator(Iter it) : current(it) {}
@@ -41,38 +38,6 @@ template  class reverse_iterator {
   LIBC_INLINE constexpr explicit reverse_iterator(const Other &it)
   : current(it) {}
 
-  LIBC_INLINE friend constexpr bool operator==(const reverse_iterator &lhs,
-   const reverse_iterator &rhs) {
-return lhs.base() == rhs.base();
-  }
-
-  LIBC_INLINE friend constexpr bool operator!=(const reverse_iterator &lhs,
-   const reverse_iterator &rhs) {
-return lhs.base() != rhs.base();
-  }
-
-  LIBC_INLINE friend constexpr bool operator<(const reverse_iterator &lhs,
-  const reverse_iterator &rhs) {
-return lhs.base() > rhs.base();
-  }
-
-  LIBC_INLINE friend constexpr bool operator<=(const reverse_iterator &lhs,
-   const reverse_iterator &rhs) {
-return lhs.base() >= rhs.base();
-  }
-
-  LIBC_INLINE friend constexpr bool operator>(const reverse_iterator &lhs,
-  const reverse_iterator &rhs) {
-return lhs.base() < rhs.base();
-  }
-
-  LIBC_INLINE friend constexpr bool operator>=(const reverse_iterator &lhs,
-   const reverse_iterator &rhs) {
-return lhs.base() <= rhs.base();
-  }
-
-  LIBC_INLINE constexpr iterator_type base() const { current; }
-
   LIBC_INLINE constexpr reference operator*() const {
 Iter tmp = current;
 return *--tmp;



___
llvm-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] [Serialization] Code cleanups and polish 83233 (PR #83237)

2024-03-21 Thread Vassil Vassilev via llvm-branch-commits

vgvassilev wrote:

> @ilya-biryukov hi, the functional and performance test on the root side looks 
> good: [root-project/root#14495 
> (comment)](https://github.com/root-project/root/pull/14495#issuecomment-1980589145)
> 
> Could you try to test this within google internals?
> 
> Also if your projects implements new ExternalASTSource, you need to handle 
> that like I did in root: 
> [ChuanqiXu9/root@570fd78](https://github.com/ChuanqiXu9/root/commit/570fd783875671d346c7cdc0d98a8a9afcad05a4)

@ilya-biryukov, can you test this PR on your side. We'd like to move forward.

cc: @dwblaikie 

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


[llvm-branch-commits] [libcxx] release/18.x: Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#86020) (PR #86197)

2024-03-21 Thread via llvm-branch-commits

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

Backport 50801f1095d33e712c3a51fdeef82569bd09007f

Requested by: @mstorsjo

>From f37d5a357ba1ab1006889dfa02e2b6cb3b162437 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Thu, 21 Mar 2024 17:29:15 +0200
Subject: [PATCH] Reapply [libcxx] [modules] Fix relative paths with absolute
 LIBCXX_INSTALL_MODULES_DIR (#86020)

This reapplies 272d1b44efdedb68c194970a610f0ca1b7b769c5 (from #85756),
which was reverted in
407937036fa7640f61f225474b1ea6623a40dbdd.

In the previous attempt, empty CMAKE_INSTALL_PREFIX was handled by
quoting them, in d209d1340b99d4fbd325dffb5e13b757ab8264ea. That made the
calls to cmake_path(ABSOLUTE_PATH) succeed, but the output paths of that
weren't actually absolute, which was required by file(RELATIVE_PATH).

Avoid this issue by constructing a non-empty base directory variable
to use for calculating the relative path.

(cherry picked from commit 50801f1095d33e712c3a51fdeef82569bd09007f)
---
 libcxx/modules/CMakeLists.txt | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 0dea8cfca94ac3..d47d19a4755317 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -206,9 +206,20 @@ add_custom_target(generate-cxx-modules
 # Configure the modules manifest.
 # Use the relative path between the installation and the module in the json
 # file. This allows moving the entire installation to a different location.
+if("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
+  set(BASE_DIRECTORY "/")
+else()
+  set(BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX})
+endif()
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
+  BASE_DIRECTORY ${BASE_DIRECTORY}
+  OUTPUT_VARIABLE ABS_LIBRARY_DIR)
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
+  BASE_DIRECTORY ${BASE_DIRECTORY}
+  OUTPUT_VARIABLE ABS_MODULES_DIR)
 file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
-  ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_LIBRARY_DIR}
-  ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
+  ${ABS_LIBRARY_DIR}
+  ${ABS_MODULES_DIR})
 configure_file(
   "modules.json.in"
   "${LIBCXX_LIBRARY_DIR}/libc++.modules.json"

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


[llvm-branch-commits] [libcxx] release/18.x: Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#86020) (PR #86197)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: None (llvmbot)


Changes

Backport 50801f1095d33e712c3a51fdeef82569bd09007f

Requested by: @mstorsjo

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


1 Files Affected:

- (modified) libcxx/modules/CMakeLists.txt (+13-2) 


``diff
diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 0dea8cfca94ac3..d47d19a4755317 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -206,9 +206,20 @@ add_custom_target(generate-cxx-modules
 # Configure the modules manifest.
 # Use the relative path between the installation and the module in the json
 # file. This allows moving the entire installation to a different location.
+if("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
+  set(BASE_DIRECTORY "/")
+else()
+  set(BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX})
+endif()
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
+  BASE_DIRECTORY ${BASE_DIRECTORY}
+  OUTPUT_VARIABLE ABS_LIBRARY_DIR)
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
+  BASE_DIRECTORY ${BASE_DIRECTORY}
+  OUTPUT_VARIABLE ABS_MODULES_DIR)
 file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
-  ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_LIBRARY_DIR}
-  ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
+  ${ABS_LIBRARY_DIR}
+  ${ABS_MODULES_DIR})
 configure_file(
   "modules.json.in"
   "${LIBCXX_LIBRARY_DIR}/libc++.modules.json"

``




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


[llvm-branch-commits] [libcxx] release/18.x: Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#86020) (PR #86197)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:

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

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


[llvm-branch-commits] [libcxx] release/18.x: Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#86020) (PR #86197)

2024-03-21 Thread via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT] Output basic YAML profile in BAT mode (PR #76910)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT] Output basic YAML profile in BAT mode (PR #76910)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT] Output basic YAML profile in BAT mode (PR #76910)

2024-03-21 Thread Rafael Auler via llvm-branch-commits

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

LG

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


[llvm-branch-commits] [BOLT] Add BB index to BAT (PR #86044)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/86044


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


[llvm-branch-commits] [BOLT] Add BB index to BAT (PR #86044)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/86044


___
llvm-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] release/18.x: [msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142) (PR #86201)

2024-03-21 Thread via llvm-branch-commits

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

Backport af2bf86a372cacf5f536bae06e2f2d3886eefb7b 
58f7251820b14c93168726a24816d8a094599be5

Requested by: @thurstond

>From aa411738d33c1b7eeeba096c9f11d30137b670a4 Mon Sep 17 00:00:00 2001
From: Thurston Dang 
Date: Thu, 14 Mar 2024 16:19:30 -0700
Subject: [PATCH 1/2] [msan] Add 'MappingDesc::ALLOCATOR' type and check it is
 available (#85153)

MSan divides the virtual address space into APP, INVALID, SHADOW and
ORIGIN memory. The allocator usually just steals a bit of the APP
address space: typically the bottom portion of the PIE binaries section,
which works because the Linux kernel maps from the top of the PIE
binaries section. However, if ASLR is very aggressive, the binary may
end up mapped in the same location where the allocator wants to live;
this results in a segfault.

This patch adds in a MappingDesc::ALLOCATOR type and enforces that the
memory range for the allocator is not occupied by anything else.

Since the allocator range information is not readily available in
msan.h, we duplicate the information from msan_allocator.cpp.

Note: aggressive ASLR can also lead to a different type of failure,
where the PIE binaries/libraries are mapped entirely outside of the
APP/ALLOCATOR sections; that will be addressed in a separate patch
(https://github.com/llvm/llvm-project/pull/85142).

(cherry picked from commit af2bf86a372cacf5f536bae06e2f2d3886eefb7b)
---
 compiler-rt/lib/msan/msan.h | 33 +
 compiler-rt/lib/msan/msan_allocator.cpp |  3 +++
 compiler-rt/lib/msan/msan_linux.cpp | 11 ++---
 3 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h
index 710447a3e1a357..00f448fb377d59 100644
--- a/compiler-rt/lib/msan/msan.h
+++ b/compiler-rt/lib/msan/msan.h
@@ -33,12 +33,18 @@ struct MappingDesc {
   uptr start;
   uptr end;
   enum Type {
-INVALID, APP, SHADOW, ORIGIN
+INVALID = 1,
+ALLOCATOR = 2,
+APP = 4,
+SHADOW = 8,
+ORIGIN = 16,
   } type;
   const char *name;
 };
 
-
+// Note: MappingDesc::ALLOCATOR entries are only used to check for memory
+// layout compatibility. The actual allocation settings are in
+// msan_allocator.cpp, which need to be kept in sync.
 #if SANITIZER_LINUX && defined(__mips64)
 
 // MIPS64 maps:
@@ -84,7 +90,8 @@ const MappingDesc kMemoryLayout[] = {
 {0X0B000, 0X0C000, MappingDesc::SHADOW, "shadow-10-13"},
 {0X0C000, 0X0D000, MappingDesc::INVALID, "invalid"},
 {0X0D000, 0X0E000, MappingDesc::ORIGIN, "origin-10-13"},
-{0X0E000, 0X1, MappingDesc::APP, "app-15"},
+{0x0E000, 0x0E400, MappingDesc::ALLOCATOR, "allocator"},
+{0X0E400, 0X1, MappingDesc::APP, "app-15"},
 };
 # define MEM_TO_SHADOW(mem) ((uptr)mem ^ 0xB000ULL)
 # define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x2000ULL)
@@ -106,7 +113,8 @@ const MappingDesc kMemoryLayout[] = {
 {0x5100ULL, 0x6000ULL, MappingDesc::APP, "app-2"},
 {0x6000ULL, 0x6100ULL, MappingDesc::ORIGIN, "origin-1"},
 {0x6100ULL, 0x7000ULL, MappingDesc::INVALID, "invalid"},
-{0x7000ULL, 0x8000ULL, MappingDesc::APP, "app-3"}};
+{0x7000ULL, 0x7400ULL, MappingDesc::ALLOCATOR, 
"allocator"},
+{0x7400ULL, 0x8000ULL, MappingDesc::APP, "app-3"}};
 #  define MEM_TO_SHADOW(mem) (((uptr)(mem)) ^ 0x5000ULL)
 #  define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x1000ULL)
 
@@ -118,7 +126,8 @@ const MappingDesc kMemoryLayout[] = {
 {0x1802ULL, 0x1C00ULL, MappingDesc::INVALID, "invalid"},
 {0x1C00ULL, 0x2C02ULL, MappingDesc::ORIGIN, "origin"},
 {0x2C02ULL, 0x3000ULL, MappingDesc::INVALID, "invalid"},
-{0x3000ULL, 0x8000ULL, MappingDesc::APP, "high memory"}};
+{0x3000ULL, 0x3200ULL, MappingDesc::ALLOCATOR, 
"allocator"},
+{0x3200ULL, 0x8000ULL, MappingDesc::APP, "high memory"}};
 
 // Various kernels use different low end ranges but we can combine them into 
one
 // big range. They also use different high end ranges but we can map them all 
to
@@ -141,7 +150,8 @@ const MappingDesc kMemoryLayout[] = {
 {0x1800ULL, 0x1C00ULL, MappingDesc::INVALID, "invalid"},
 {0x1C00ULL, 0x2C00ULL, MappingDesc::ORIGIN, "origin"},
 {0x2C00ULL, 0x4400ULL, MappingDesc::INVALID, "invalid"},
-{0x4400ULL, 0x5000ULL, MappingDesc::APP, "high memory"}};
+{0x4400ULL, 0x4600ULL, MappingDesc::ALLOCATOR, 
"allocator"},
+{0x4600ULL, 0x5000ULL, MappingDesc::APP, "high memory"}};
 
 #define MEM_TO_SHADOW(mem) \
   uptr)(mem)) & ~0xC000ULL) + 0x080

[llvm-branch-commits] [compiler-rt] release/18.x: [msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142) (PR #86201)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:

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

https://github.com/llvm/llvm-project/pull/86201
___
llvm-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] release/18.x: [msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142) (PR #86201)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (llvmbot)


Changes

Backport af2bf86a372cacf5f536bae06e2f2d3886eefb7b 
58f7251820b14c93168726a24816d8a094599be5

Requested by: @thurstond

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


4 Files Affected:

- (modified) compiler-rt/lib/msan/msan.cpp (+1-1) 
- (modified) compiler-rt/lib/msan/msan.h (+24-11) 
- (modified) compiler-rt/lib/msan/msan_allocator.cpp (+3) 
- (modified) compiler-rt/lib/msan/msan_linux.cpp (+54-13) 


``diff
diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index 3cdf10c149902c..a2fc27de1901b4 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -467,7 +467,7 @@ void __msan_init() {
   __msan_clear_on_return();
   if (__msan_get_track_origins())
 VPrintf(1, "msan_track_origins\n");
-  if (!InitShadow(__msan_get_track_origins())) {
+  if (!InitShadowWithReExec(__msan_get_track_origins())) {
 Printf("FATAL: MemorySanitizer can not mmap the shadow memory.\n");
 Printf("FATAL: Make sure to compile with -fPIE and to link with -pie.\n");
 Printf("FATAL: Disabling ASLR is known to cause this error.\n");
diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h
index 710447a3e1a357..7fb58be67a02cd 100644
--- a/compiler-rt/lib/msan/msan.h
+++ b/compiler-rt/lib/msan/msan.h
@@ -33,12 +33,18 @@ struct MappingDesc {
   uptr start;
   uptr end;
   enum Type {
-INVALID, APP, SHADOW, ORIGIN
+INVALID = 1,
+ALLOCATOR = 2,
+APP = 4,
+SHADOW = 8,
+ORIGIN = 16,
   } type;
   const char *name;
 };
 
-
+// Note: MappingDesc::ALLOCATOR entries are only used to check for memory
+// layout compatibility. The actual allocation settings are in
+// msan_allocator.cpp, which need to be kept in sync.
 #if SANITIZER_LINUX && defined(__mips64)
 
 // MIPS64 maps:
@@ -84,7 +90,8 @@ const MappingDesc kMemoryLayout[] = {
 {0X0B000, 0X0C000, MappingDesc::SHADOW, "shadow-10-13"},
 {0X0C000, 0X0D000, MappingDesc::INVALID, "invalid"},
 {0X0D000, 0X0E000, MappingDesc::ORIGIN, "origin-10-13"},
-{0X0E000, 0X1, MappingDesc::APP, "app-15"},
+{0x0E000, 0x0E400, MappingDesc::ALLOCATOR, "allocator"},
+{0X0E400, 0X1, MappingDesc::APP, "app-15"},
 };
 # define MEM_TO_SHADOW(mem) ((uptr)mem ^ 0xB000ULL)
 # define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x2000ULL)
@@ -106,7 +113,8 @@ const MappingDesc kMemoryLayout[] = {
 {0x5100ULL, 0x6000ULL, MappingDesc::APP, "app-2"},
 {0x6000ULL, 0x6100ULL, MappingDesc::ORIGIN, "origin-1"},
 {0x6100ULL, 0x7000ULL, MappingDesc::INVALID, "invalid"},
-{0x7000ULL, 0x8000ULL, MappingDesc::APP, "app-3"}};
+{0x7000ULL, 0x7400ULL, MappingDesc::ALLOCATOR, 
"allocator"},
+{0x7400ULL, 0x8000ULL, MappingDesc::APP, "app-3"}};
 #  define MEM_TO_SHADOW(mem) (((uptr)(mem)) ^ 0x5000ULL)
 #  define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x1000ULL)
 
@@ -118,7 +126,8 @@ const MappingDesc kMemoryLayout[] = {
 {0x1802ULL, 0x1C00ULL, MappingDesc::INVALID, "invalid"},
 {0x1C00ULL, 0x2C02ULL, MappingDesc::ORIGIN, "origin"},
 {0x2C02ULL, 0x3000ULL, MappingDesc::INVALID, "invalid"},
-{0x3000ULL, 0x8000ULL, MappingDesc::APP, "high memory"}};
+{0x3000ULL, 0x3200ULL, MappingDesc::ALLOCATOR, 
"allocator"},
+{0x3200ULL, 0x8000ULL, MappingDesc::APP, "high memory"}};
 
 // Various kernels use different low end ranges but we can combine them into 
one
 // big range. They also use different high end ranges but we can map them all 
to
@@ -141,7 +150,8 @@ const MappingDesc kMemoryLayout[] = {
 {0x1800ULL, 0x1C00ULL, MappingDesc::INVALID, "invalid"},
 {0x1C00ULL, 0x2C00ULL, MappingDesc::ORIGIN, "origin"},
 {0x2C00ULL, 0x4400ULL, MappingDesc::INVALID, "invalid"},
-{0x4400ULL, 0x5000ULL, MappingDesc::APP, "high memory"}};
+{0x4400ULL, 0x4600ULL, MappingDesc::ALLOCATOR, 
"allocator"},
+{0x4600ULL, 0x5000ULL, MappingDesc::APP, "high memory"}};
 
 #define MEM_TO_SHADOW(mem) \
   uptr)(mem)) & ~0xC000ULL) + 0x0800ULL)
@@ -208,7 +218,8 @@ const MappingDesc kMemoryLayout[] = {
 {0x5100ULL, 0x6000ULL, MappingDesc::APP, "app-2"},
 {0x6000ULL, 0x6100ULL, MappingDesc::ORIGIN, "origin-1"},
 {0x6100ULL, 0x7000ULL, MappingDesc::INVALID, "invalid"},
-{0x7000ULL, 0x8000ULL, MappingDesc::APP, "app-3"}};
+{0x7000ULL, 0x7400ULL, MappingDesc::ALLOCATOR, 
"allocator"},
+{0x7400ULL, 0x800

[llvm-branch-commits] [compiler-rt] release/18.x: [msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142) (PR #86201)

2024-03-21 Thread Vitaly Buka via llvm-branch-commits

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


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


[llvm-branch-commits] [BOLT] Add BB index to BAT (PR #86044)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/86044
___
llvm-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] release/18.x: [msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142) (PR #86201)

2024-03-21 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/86201
___
llvm-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] release/18.x: [msan] Re-exec with no ASLR if memory layout is incompatible on Linux (#85142) (PR #86201)

2024-03-21 Thread Thurston Dang via llvm-branch-commits

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


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


[llvm-branch-commits] [dse] Skip llvm.allow.{runtime, ubsan}.check() (PR #86067)

2024-03-21 Thread Vitaly Buka via llvm-branch-commits

vitalybuka wrote:

> I don't think that this change is necessary. The InaccessibleMemOnly 
> modelling will take care of it.

Thank. That makes sense. As I wrote in description, I tried to trigger code 
difference in tests, but failed for these and for assume.
Converting to draft.

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


[llvm-branch-commits] [dse] Skip llvm.allow.{runtime, ubsan}.check() (PR #86067)

2024-03-21 Thread Vitaly Buka via llvm-branch-commits

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


[llvm-branch-commits] [llvm] [BOLT] Add BB index to BAT (PR #86044)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/86044

>From 2a97ba165c6e5689cdd8c4208d35e042760e7444 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Thu, 21 Mar 2024 14:54:23 -0700
Subject: [PATCH] cleanup

Created using spr 1.3.4
---
 bolt/lib/Profile/BoltAddressTranslation.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp 
b/bolt/lib/Profile/BoltAddressTranslation.cpp
index 03769d127bf6e6..8fe976cc00e53c 100644
--- a/bolt/lib/Profile/BoltAddressTranslation.cpp
+++ b/bolt/lib/Profile/BoltAddressTranslation.cpp
@@ -513,6 +513,11 @@ void BoltAddressTranslation::saveMetadata(BinaryContext 
&BC) {
   }
 }
 
+unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress,
+uint32_t BBInputOffset) const {
+  return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first;
+}
+
 size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress,
  uint32_t BBInputOffset) const {
   return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second;
@@ -522,10 +527,5 @@ size_t BoltAddressTranslation::getBFHash(uint64_t 
OutputAddress) const {
   return FuncHashes.at(OutputAddress).first;
 }
 
-unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress,
-uint32_t BBInputOffset) const {
-  return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first;
-}
-
 } // namespace bolt
 } // namespace llvm

___
llvm-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] [compiler-rt] Allow running tests without installing first (PR #83088)

2024-03-21 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson edited 
https://github.com/llvm/llvm-project/pull/83088
___
llvm-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] [compiler-rt] Allow running tests without installing first (PR #83088)

2024-03-21 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/83088

>From 3c41df9f8fd00d86fe500d9b67e51d15a690209b Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Mon, 26 Feb 2024 16:59:08 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/cmake/Modules/CompilerRTCompile.cmake | 7 ++-
 compiler-rt/test/dfsan/reaches_function.c | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake 
b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
index 64e7acb9afd833..8c804acb44ae4d 100644
--- a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
@@ -70,9 +70,14 @@ function(clang_compile object_file source)
   if (TARGET CompilerRTUnitTestCheckCxx)
 list(APPEND SOURCE_DEPS CompilerRTUnitTestCheckCxx)
   endif()
+  string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
+  if (is_cxx)
+set(compiler ${COMPILER_RT_TEST_COMPILER})
+  else()
+set(compiler ${COMPILER_RT_TEST_CXX_COMPILER})
+  endif()
   if(COMPILER_RT_STANDALONE_BUILD)
 # Only add global flags in standalone build.
-string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
 if(is_cxx)
   string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}")
 else()
diff --git a/compiler-rt/test/dfsan/reaches_function.c 
b/compiler-rt/test/dfsan/reaches_function.c
index 9e2bcee935b2ac..afcd08cee76a0e 100644
--- a/compiler-rt/test/dfsan/reaches_function.c
+++ b/compiler-rt/test/dfsan/reaches_function.c
@@ -32,7 +32,7 @@ void my_dfsan_reaches_function_callback(dfsan_label label, 
dfsan_origin origin,
 __attribute__((noinline)) uint64_t add(uint64_t *a, uint64_t *b) {
 
   return *a + *b;
-  // CHECK: {{.*}}compiler-rt/test/dfsan/reaches_function.c:[[# @LINE - 1]] 
add.dfsan
+  // CHECK: test/dfsan/reaches_function.c:[[# @LINE - 1]] add.dfsan
   // CHECK-ORIGIN-TRACKING: Origin value: 0x1002, Taint value was stored 
to memory at
   // CHECK-ORIGIN-TRACKING: #0 {{.*}} in add.dfsan 
{{.*}}compiler-rt/test/dfsan/reaches_function.c:[[# @LINE - 3]]:{{.*}}
   // CHECK-ORIGIN-TRACKING: Origin value: 0x1, Taint value was created at
@@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
 
   dfsan_set_label(8, &a, sizeof(a));
   uint64_t c = add(&a, &b);
-  // CHECK: {{.*}}compiler-rt/test/dfsan/reaches_function.c:[[# @LINE - 1]] 
main
+  // CHECK: test/dfsan/reaches_function.c:[[# @LINE - 1]] main
   // CHECK-ORIGIN-TRACKING: Origin value: 0x1002, Taint value was stored 
to memory at
   // CHECK-ORIGIN-TRACKING: #0 {{.*}} in add.dfsan 
{{.*}}compiler-rt/test/dfsan/reaches_function.c:{{.*}}
   // CHECK-ORIGIN-TRACKING: Origin value: 0x1, Taint value was created at

>From c4cb96509ce30182f4fecdd21bf36f6dd94e8d68 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Sun, 3 Mar 2024 14:09:59 -0800
Subject: [PATCH 2/2] fix python formatting

Created using spr 1.3.6-beta.1
---
 compiler-rt/test/lit.common.cfg.py|  7 +--
 compiler-rt/test/safestack/lit.cfg.py | 10 --
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/test/lit.common.cfg.py 
b/compiler-rt/test/lit.common.cfg.py
index 5d96bf7e1a58a7..aef07427acf2e4 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -34,6 +34,7 @@ def get_path_from_clang(args, allow_failure):
 lit_config.fatal(msg)
 return path, clang_cmd
 
+
 def find_compiler_libdir():
 """
 Returns the path to library resource directory used
@@ -186,8 +187,10 @@ def push_dynamic_library_lookup_path(config, new_path):
 if test_cc_resource_dir != local_build_resource_dir:
 if config.test_standalone_build_libs and config.compiler_id == "Clang":
 if lit_config.debug:
-lit_config.note(f'Overriding test compiler resource dir to use '
-f'libraries in "{config.compiler_rt_libdir}"')
+lit_config.note(
+f"Overriding test compiler resource dir to use "
+f'libraries in "{config.compiler_rt_libdir}"'
+)
 # Ensure that we use the just-built static libraries when linking by
 # overriding the Clang resource directory. Additionally, we want to use
 # the builtin headers shipped with clang (e.g. stdint.h), so we
diff --git a/compiler-rt/test/safestack/lit.cfg.py 
b/compiler-rt/test/safestack/lit.cfg.py
index bdc316e2f6bc74..aadb8bf0d5c77b 100644
--- a/compiler-rt/test/safestack/lit.cfg.py
+++ b/compiler-rt/test/safestack/lit.cfg.py
@@ -13,10 +13,16 @@
 
 # Add clang substitutions.
 config.substitutions.append(
-("%clang_nosafestack ", config.clang + config.target_cflags + " -O0 
-fno-sanitize=safe-stack ")
+(
+  

[llvm-branch-commits] [compiler-rt] [compiler-rt] Allow running tests without installing first (PR #83088)

2024-03-21 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/83088

>From 3c41df9f8fd00d86fe500d9b67e51d15a690209b Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Mon, 26 Feb 2024 16:59:08 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/cmake/Modules/CompilerRTCompile.cmake | 7 ++-
 compiler-rt/test/dfsan/reaches_function.c | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake 
b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
index 64e7acb9afd833..8c804acb44ae4d 100644
--- a/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTCompile.cmake
@@ -70,9 +70,14 @@ function(clang_compile object_file source)
   if (TARGET CompilerRTUnitTestCheckCxx)
 list(APPEND SOURCE_DEPS CompilerRTUnitTestCheckCxx)
   endif()
+  string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
+  if (is_cxx)
+set(compiler ${COMPILER_RT_TEST_COMPILER})
+  else()
+set(compiler ${COMPILER_RT_TEST_CXX_COMPILER})
+  endif()
   if(COMPILER_RT_STANDALONE_BUILD)
 # Only add global flags in standalone build.
-string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
 if(is_cxx)
   string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}")
 else()
diff --git a/compiler-rt/test/dfsan/reaches_function.c 
b/compiler-rt/test/dfsan/reaches_function.c
index 9e2bcee935b2ac..afcd08cee76a0e 100644
--- a/compiler-rt/test/dfsan/reaches_function.c
+++ b/compiler-rt/test/dfsan/reaches_function.c
@@ -32,7 +32,7 @@ void my_dfsan_reaches_function_callback(dfsan_label label, 
dfsan_origin origin,
 __attribute__((noinline)) uint64_t add(uint64_t *a, uint64_t *b) {
 
   return *a + *b;
-  // CHECK: {{.*}}compiler-rt/test/dfsan/reaches_function.c:[[# @LINE - 1]] 
add.dfsan
+  // CHECK: test/dfsan/reaches_function.c:[[# @LINE - 1]] add.dfsan
   // CHECK-ORIGIN-TRACKING: Origin value: 0x1002, Taint value was stored 
to memory at
   // CHECK-ORIGIN-TRACKING: #0 {{.*}} in add.dfsan 
{{.*}}compiler-rt/test/dfsan/reaches_function.c:[[# @LINE - 3]]:{{.*}}
   // CHECK-ORIGIN-TRACKING: Origin value: 0x1, Taint value was created at
@@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
 
   dfsan_set_label(8, &a, sizeof(a));
   uint64_t c = add(&a, &b);
-  // CHECK: {{.*}}compiler-rt/test/dfsan/reaches_function.c:[[# @LINE - 1]] 
main
+  // CHECK: test/dfsan/reaches_function.c:[[# @LINE - 1]] main
   // CHECK-ORIGIN-TRACKING: Origin value: 0x1002, Taint value was stored 
to memory at
   // CHECK-ORIGIN-TRACKING: #0 {{.*}} in add.dfsan 
{{.*}}compiler-rt/test/dfsan/reaches_function.c:{{.*}}
   // CHECK-ORIGIN-TRACKING: Origin value: 0x1, Taint value was created at

>From c4cb96509ce30182f4fecdd21bf36f6dd94e8d68 Mon Sep 17 00:00:00 2001
From: Alex Richardson 
Date: Sun, 3 Mar 2024 14:09:59 -0800
Subject: [PATCH 2/2] fix python formatting

Created using spr 1.3.6-beta.1
---
 compiler-rt/test/lit.common.cfg.py|  7 +--
 compiler-rt/test/safestack/lit.cfg.py | 10 --
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/test/lit.common.cfg.py 
b/compiler-rt/test/lit.common.cfg.py
index 5d96bf7e1a58a7..aef07427acf2e4 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -34,6 +34,7 @@ def get_path_from_clang(args, allow_failure):
 lit_config.fatal(msg)
 return path, clang_cmd
 
+
 def find_compiler_libdir():
 """
 Returns the path to library resource directory used
@@ -186,8 +187,10 @@ def push_dynamic_library_lookup_path(config, new_path):
 if test_cc_resource_dir != local_build_resource_dir:
 if config.test_standalone_build_libs and config.compiler_id == "Clang":
 if lit_config.debug:
-lit_config.note(f'Overriding test compiler resource dir to use '
-f'libraries in "{config.compiler_rt_libdir}"')
+lit_config.note(
+f"Overriding test compiler resource dir to use "
+f'libraries in "{config.compiler_rt_libdir}"'
+)
 # Ensure that we use the just-built static libraries when linking by
 # overriding the Clang resource directory. Additionally, we want to use
 # the builtin headers shipped with clang (e.g. stdint.h), so we
diff --git a/compiler-rt/test/safestack/lit.cfg.py 
b/compiler-rt/test/safestack/lit.cfg.py
index bdc316e2f6bc74..aadb8bf0d5c77b 100644
--- a/compiler-rt/test/safestack/lit.cfg.py
+++ b/compiler-rt/test/safestack/lit.cfg.py
@@ -13,10 +13,16 @@
 
 # Add clang substitutions.
 config.substitutions.append(
-("%clang_nosafestack ", config.clang + config.target_cflags + " -O0 
-fno-sanitize=safe-stack ")
+(
+  

[llvm-branch-commits] [runtimes] Allow building against an installed LLVM tree (PR #86209)

2024-03-21 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson created 
https://github.com/llvm/llvm-project/pull/86209

I am currently trying to test the LLVM runtimes (including compiler-rt)
against an installed LLVM tree rather than a build tree (since that is
no longer available). Currently, the runtimes build of compiler-rt assumes
that LLVM_BINARY_DIR is writable since it uses configure_file() to write
there during the CMake configure stage. Instead, generate this file inside
CMAKE_CURRENT_BINARY_DIR, which will match LLVM_BINARY_DIR when invoked
from llvm/runtimes/CMakeLists.txt.

I also needed to make a minor change to the hwasan tests: hwasan_symbolize
was previously found in the LLVM_BINARY_DIR, but since it is generated as
part of the compiler-rt build it is now inside the CMake build directory
instead. I fixed this by passing the output directory to lit as
config.compiler_rt_bindir and using llvm_config.add_tool_substitutions().

For testing that we no longer write to the LLVM install directory as
part of testing or configuration, I created a read-only bind mount and
configured the runtimes builds as follows:
```
$ sudo mount --bind --read-only ~/llvm-install /tmp/upstream-llvm-readonly
$ cmake -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_COMPILER=/tmp/upstream-llvm-readonly/bin/clang \
  -DCMAKE_CXX_COMPILER=/tmp/upstream-llvm-readonly/bin/clang++ \
  -DLLVM_INCLUDE_TESTS=TRUE -DLLVM_ENABLE_ASSERTIONS=TRUE \
  -DCOMPILER_RT_INCLUDE_TESTS=TRUE -DCOMPILER_RT_DEBUG=OFF \
  -DLLVM_ENABLE_RUNTIMES=compiler-rt \
  -DLLVM_BINARY_DIR=/tmp/upstream-llvm-readonly \
  -G Ninja -S ~/upstream-llvm-project/runtimes \
  -B ~/upstream-llvm-project/runtimes/cmake-build-debug-llvm-git
```



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


[llvm-branch-commits] [runtimes] Allow building against an installed LLVM tree (PR #86209)

2024-03-21 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Alexander Richardson (arichardson)


Changes

I am currently trying to test the LLVM runtimes (including compiler-rt)
against an installed LLVM tree rather than a build tree (since that is
no longer available). Currently, the runtimes build of compiler-rt assumes
that LLVM_BINARY_DIR is writable since it uses configure_file() to write
there during the CMake configure stage. Instead, generate this file inside
CMAKE_CURRENT_BINARY_DIR, which will match LLVM_BINARY_DIR when invoked
from llvm/runtimes/CMakeLists.txt.

I also needed to make a minor change to the hwasan tests: hwasan_symbolize
was previously found in the LLVM_BINARY_DIR, but since it is generated as
part of the compiler-rt build it is now inside the CMake build directory
instead. I fixed this by passing the output directory to lit as
config.compiler_rt_bindir and using llvm_config.add_tool_substitutions().

For testing that we no longer write to the LLVM install directory as
part of testing or configuration, I created a read-only bind mount and
configured the runtimes builds as follows:
```
$ sudo mount --bind --read-only ~/llvm-install /tmp/upstream-llvm-readonly
$ cmake -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_COMPILER=/tmp/upstream-llvm-readonly/bin/clang \
  -DCMAKE_CXX_COMPILER=/tmp/upstream-llvm-readonly/bin/clang++ \
  -DLLVM_INCLUDE_TESTS=TRUE -DLLVM_ENABLE_ASSERTIONS=TRUE \
  -DCOMPILER_RT_INCLUDE_TESTS=TRUE -DCOMPILER_RT_DEBUG=OFF \
  -DLLVM_ENABLE_RUNTIMES=compiler-rt \
  -DLLVM_BINARY_DIR=/tmp/upstream-llvm-readonly \
  -G Ninja -S ~/upstream-llvm-project/runtimes \
  -B ~/upstream-llvm-project/runtimes/cmake-build-debug-llvm-git
```


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


4 Files Affected:

- (modified) compiler-rt/cmake/Modules/AddCompilerRT.cmake (+1) 
- (modified) compiler-rt/test/hwasan/lit.cfg.py (+7) 
- (modified) compiler-rt/test/lit.common.configured.in (+1) 
- (modified) runtimes/CMakeLists.txt (+18-10) 


``diff
diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 567b123b7abcac..4c3752d14a4789 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -769,6 +769,7 @@ function(configure_compiler_rt_lit_site_cfg input output)
 
   string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} 
COMPILER_RT_RESOLVED_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER})
   string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} 
COMPILER_RT_RESOLVED_OUTPUT_DIR ${COMPILER_RT_OUTPUT_DIR})
+  string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} 
COMPILER_RT_RESOLVED_EXEC_OUTPUT_DIR ${COMPILER_RT_EXEC_OUTPUT_DIR})
   string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} 
COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR ${output_dir})
 
   configure_lit_site_cfg(${input} ${output})
diff --git a/compiler-rt/test/hwasan/lit.cfg.py 
b/compiler-rt/test/hwasan/lit.cfg.py
index 594f3294a84ac1..96cc2f477ad445 100644
--- a/compiler-rt/test/hwasan/lit.cfg.py
+++ b/compiler-rt/test/hwasan/lit.cfg.py
@@ -2,6 +2,9 @@
 
 import os
 
+from lit.llvm import llvm_config
+from lit.llvm.subst import ToolSubst, FindTool
+
 # Setup config name.
 config.name = "HWAddressSanitizer" + getattr(config, "name_suffix", "default")
 
@@ -74,6 +77,10 @@ def build_invocation(compile_flags):
 ("%env_hwasan_opts=", "env HWASAN_OPTIONS=" + default_hwasan_opts_str)
 )
 
+# Ensure that we can use hwasan_symbolize from the expected location
+llvm_config.add_tool_substitutions([ToolSubst("hwasan_symbolize", 
unresolved="fatal")],
+   search_dirs=[config.compiler_rt_bindir])
+
 # Default test suffixes.
 config.suffixes = [".c", ".cpp"]
 
diff --git a/compiler-rt/test/lit.common.configured.in 
b/compiler-rt/test/lit.common.configured.in
index 8955efa3eafd18..e146e847aa00e6 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -28,6 +28,7 @@ set_default("python_executable", "@Python3_EXECUTABLE@")
 set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
 set_default("compiler_rt_intercept_libdispatch", 
@COMPILER_RT_INTERCEPT_LIBDISPATCH_PYBOOL@)
 set_default("compiler_rt_output_dir", "@COMPILER_RT_RESOLVED_OUTPUT_DIR@")
+set_default("compiler_rt_bindir", "@COMPILER_RT_RESOLVED_EXEC_OUTPUT_DIR@")
 set_default("compiler_rt_libdir", "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@")
 set_default("emulator", "@COMPILER_RT_EMULATOR@")
 set_default("asan_shadow_scale", "@COMPILER_RT_ASAN_SHADOW_SCALE@")
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt
index 6f24fbcccec955..3195a293c0adfa 100644
--- a/runtimes/CMakeLists.txt
+++ b/runtimes/CMakeLists.txt
@@ -218,6 +218,22 @@ foreach(entry ${runtimes})
 endforeach()
 
 if(LLVM_INCLUDE_TESTS)
+  # Add lit if needed before adding any runtimes since their CMake tests
+  # configuration might depend on lit being present.
+  if (NOT HAVE_LLV

[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)

2024-03-21 Thread Nathan Lanza via llvm-branch-commits

https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072

>From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001
From: Nathan Lanza 
Date: Thu, 21 Mar 2024 03:24:54 +
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 clang/include/clang/Basic/LangStandard.h|  1 +
 clang/include/clang/Driver/Types.def|  1 +
 clang/lib/Basic/LangStandards.cpp   |  3 +++
 .../Serialization/SymbolGraphSerializer.cpp |  1 +
 clang/lib/Frontend/CompilerInvocation.cpp   | 13 +++--
 clang/lib/Frontend/FrontendActions.cpp  |  1 +
 clang/lib/Frontend/FrontendOptions.cpp  |  1 +
 7 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/LangStandard.h 
b/clang/include/clang/Basic/LangStandard.h
index 199e24c6731603..ed9572672f0563 100644
--- a/clang/include/clang/Basic/LangStandard.h
+++ b/clang/include/clang/Basic/LangStandard.h
@@ -41,6 +41,7 @@ enum class Language : uint8_t {
   RenderScript,
   HIP,
   HLSL,
+  CIR,
   ///@}
 };
 StringRef languageToString(Language L);
diff --git a/clang/include/clang/Driver/Types.def 
b/clang/include/clang/Driver/Types.def
index f72c27e1ee7019..0e0cae5fb7068d 100644
--- a/clang/include/clang/Driver/Types.def
+++ b/clang/include/clang/Driver/Types.def
@@ -90,6 +90,7 @@ TYPE("ir",   LLVM_BC,  INVALID,   
  "bc", phases
 TYPE("lto-ir",   LTO_IR,   INVALID, "s",  
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("lto-bc",   LTO_BC,   INVALID, "o",  
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 
+TYPE("cir",  CIR,  INVALID, "cir",
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 // Misc.
 TYPE("ast",  AST,  INVALID, "ast",
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("ifs",  IFS,  INVALID, "ifs",
phases::IfsMerge)
diff --git a/clang/lib/Basic/LangStandards.cpp 
b/clang/lib/Basic/LangStandards.cpp
index cb2c0772349982..c8c9292abcb22b 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) {
 return "Asm";
   case Language::LLVM_IR:
 return "LLVM IR";
+  case Language::CIR:
+return "ClangIR";
   case Language::C:
 return "C";
   case Language::CXX:
@@ -92,6 +94,7 @@ LangStandard::Kind 
clang::getDefaultLanguageStandard(clang::Language Lang,
   switch (Lang) {
   case Language::Unknown:
   case Language::LLVM_IR:
+  case Language::CIR:
 llvm_unreachable("Invalid input kind!");
   case Language::OpenCL:
 return LangStandard::lang_opencl12;
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 349b93e2a2326f..545860acb7db80 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) {
   case Language::Unknown:
   case Language::Asm:
   case Language::LLVM_IR:
+  case Language::CIR:
 llvm_unreachable("Unsupported language kind");
   }
 
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 0df6a82ccd8933..7bd91d4791ecf0 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions 
&Opts,
 case Language::HLSL:
   Lang = "hlsl";
   break;
+case Language::CIR:
+  Lang = "cir";
+  break;
 }
 
 GenerateArg(Consumer, OPT_x,
@@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
   .Cases("ast", "pcm", "precompiled-header",
  InputKind(Language::Unknown, InputKind::Precompiled))
   .Case("ir", Language::LLVM_IR)
+  .Case("cir", Language::CIR)
   .Default(Language::Unknown);
 
 if (DashX.isUnknown())
@@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK,
   switch (IK.getLanguage()) {
   case Language::Unknown:
   case Language::LLVM_IR:
+  case Language::CIR:
 llvm_unreachable("should not parse language flags for this input");
 
   case Language::C:
@@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) {
 return "Asm";
   case Language::LLVM_IR:
 return "LLVM IR";
+  case Language::CIR:
+return "Clang IR";
 
   case Language::HLSL:
 return "H

[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)

2024-03-21 Thread Nathan Lanza via llvm-branch-commits

https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072

>From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001
From: Nathan Lanza 
Date: Thu, 21 Mar 2024 03:24:54 +
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 clang/include/clang/Basic/LangStandard.h|  1 +
 clang/include/clang/Driver/Types.def|  1 +
 clang/lib/Basic/LangStandards.cpp   |  3 +++
 .../Serialization/SymbolGraphSerializer.cpp |  1 +
 clang/lib/Frontend/CompilerInvocation.cpp   | 13 +++--
 clang/lib/Frontend/FrontendActions.cpp  |  1 +
 clang/lib/Frontend/FrontendOptions.cpp  |  1 +
 7 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/LangStandard.h 
b/clang/include/clang/Basic/LangStandard.h
index 199e24c6731603..ed9572672f0563 100644
--- a/clang/include/clang/Basic/LangStandard.h
+++ b/clang/include/clang/Basic/LangStandard.h
@@ -41,6 +41,7 @@ enum class Language : uint8_t {
   RenderScript,
   HIP,
   HLSL,
+  CIR,
   ///@}
 };
 StringRef languageToString(Language L);
diff --git a/clang/include/clang/Driver/Types.def 
b/clang/include/clang/Driver/Types.def
index f72c27e1ee7019..0e0cae5fb7068d 100644
--- a/clang/include/clang/Driver/Types.def
+++ b/clang/include/clang/Driver/Types.def
@@ -90,6 +90,7 @@ TYPE("ir",   LLVM_BC,  INVALID,   
  "bc", phases
 TYPE("lto-ir",   LTO_IR,   INVALID, "s",  
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("lto-bc",   LTO_BC,   INVALID, "o",  
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 
+TYPE("cir",  CIR,  INVALID, "cir",
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 // Misc.
 TYPE("ast",  AST,  INVALID, "ast",
phases::Compile, phases::Backend, phases::Assemble, phases::Link)
 TYPE("ifs",  IFS,  INVALID, "ifs",
phases::IfsMerge)
diff --git a/clang/lib/Basic/LangStandards.cpp 
b/clang/lib/Basic/LangStandards.cpp
index cb2c0772349982..c8c9292abcb22b 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) {
 return "Asm";
   case Language::LLVM_IR:
 return "LLVM IR";
+  case Language::CIR:
+return "ClangIR";
   case Language::C:
 return "C";
   case Language::CXX:
@@ -92,6 +94,7 @@ LangStandard::Kind 
clang::getDefaultLanguageStandard(clang::Language Lang,
   switch (Lang) {
   case Language::Unknown:
   case Language::LLVM_IR:
+  case Language::CIR:
 llvm_unreachable("Invalid input kind!");
   case Language::OpenCL:
 return LangStandard::lang_opencl12;
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 349b93e2a2326f..545860acb7db80 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) {
   case Language::Unknown:
   case Language::Asm:
   case Language::LLVM_IR:
+  case Language::CIR:
 llvm_unreachable("Unsupported language kind");
   }
 
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 0df6a82ccd8933..7bd91d4791ecf0 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions 
&Opts,
 case Language::HLSL:
   Lang = "hlsl";
   break;
+case Language::CIR:
+  Lang = "cir";
+  break;
 }
 
 GenerateArg(Consumer, OPT_x,
@@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, 
ArgList &Args,
   .Cases("ast", "pcm", "precompiled-header",
  InputKind(Language::Unknown, InputKind::Precompiled))
   .Case("ir", Language::LLVM_IR)
+  .Case("cir", Language::CIR)
   .Default(Language::Unknown);
 
 if (DashX.isUnknown())
@@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK,
   switch (IK.getLanguage()) {
   case Language::Unknown:
   case Language::LLVM_IR:
+  case Language::CIR:
 llvm_unreachable("should not parse language flags for this input");
 
   case Language::C:
@@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) {
 return "Asm";
   case Language::LLVM_IR:
 return "LLVM IR";
+  case Language::CIR:
+return "Clang IR";
 
   case Language::HLSL:
 return "H

[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)

2024-03-21 Thread Nathan Lanza via llvm-branch-commits

https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078

>From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001
From: Nathan Lanza 
Date: Thu, 21 Mar 2024 04:09:56 +
Subject: [PATCH] add lit usage

Created using spr 1.3.5
---
 clang/test/lit.site.cfg.py.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index ef75770a2c3c9a..6641811c588395 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = 
@CLANG_DEFAULT_PIE_ON_LINUX@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
 config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@
+config.clang_enable_cir = @CLANG_ENABLE_CIR@
 config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@

___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Nathan Lanza via llvm-branch-commits

https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080

>From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001
From: Nathan Lanza 
Date: Thu, 21 Mar 2024 04:57:16 +
Subject: [PATCH 1/2] fix MLIRCIROpsIncGen

Created using spr 1.3.5
---
 .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++
 clang/include/clang/CIR/Dialect/IR/CIROps.td  | 18 
 2 files changed, 64 insertions(+)
 create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td

diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td 
b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td
new file mode 100644
index 00..8f756fa422e5f3
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td
@@ -0,0 +1,46 @@
+//===- CIRTypes.td - CIR dialect types -*- tablegen 
-*-===//
+//
+// 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 declares the CIR dialect.
+//
+//===--===//
+
+#ifndef MLIR_CIR_DIALECT_CIR
+#define MLIR_CIR_DIALECT_CIR
+
+include "mlir/IR/OpBase.td"
+
+def CIR_Dialect : Dialect {
+  let name = "cir";
+
+  // A short one-line summary of our dialect.
+  let summary = "A high-level dialect for analyzing and optimizing Clang "
+"supported languages";
+
+  let cppNamespace = "::mlir::cir";
+
+  let useDefaultAttributePrinterParser = 0;
+  let useDefaultTypePrinterParser = 0;
+
+  let extraClassDeclaration = [{
+void registerAttributes();
+void registerTypes();
+
+::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override;
+void printType(::mlir::Type type,
+   ::mlir::DialectAsmPrinter &printer) const override;
+
+::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser,
+ ::mlir::Type type) const override;
+
+void printAttribute(::mlir::Attribute attr,
+::mlir::DialectAsmPrinter &os) const override;
+  }];
+}
+
+#endif // MLIR_CIR_DIALECT_CIR
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index e69de29bb2d1d6..cfc62986b0b9d1 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -0,0 +1,18 @@
+//===-- CIROps.td - CIR dialect definition -*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// Definition of the CIR dialect
+///
+//===--===//
+
+#ifndef MLIR_CIR_DIALECT_CIR_OPS
+#define MLIR_CIR_DIALECT_CIR_OPS
+
+include "clang/CIR/Dialect/IR/CIRDialect.td"
+#endif // MLIR_CIR_DIALECT_CIR_OPS

>From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001
From: Nathan Lanza 
Date: Thu, 21 Mar 2024 05:12:26 +
Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib

Created using spr 1.3.5
---
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++
 clang/lib/CIR/Dialect/IR/CMakeLists.txt |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index e69de29bb2d1d6..8abf39119e04f7 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -0,0 +1,11 @@
+//===- CIRDialect.cpp - MLIR CIR ops implementation 
---===//
+//
+// 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 implements the CIR dialect and its operations.
+//
+//===--===//
diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt 
b/clang/lib/CIR/Dialect/IR/CMakeLists.txt
index e69de29bb2d1d6..0d7476b555705d 100644
--- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt
+++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_clang_library(MLIRCIR
+  CIRDialect.cpp
+  )

___
llvm-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] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)

2024-03-21 Thread Nathan Lanza via llvm-branch-commits

https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080

>From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001
From: Nathan Lanza 
Date: Thu, 21 Mar 2024 04:57:16 +
Subject: [PATCH 1/2] fix MLIRCIROpsIncGen

Created using spr 1.3.5
---
 .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++
 clang/include/clang/CIR/Dialect/IR/CIROps.td  | 18 
 2 files changed, 64 insertions(+)
 create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td

diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td 
b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td
new file mode 100644
index 00..8f756fa422e5f3
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td
@@ -0,0 +1,46 @@
+//===- CIRTypes.td - CIR dialect types -*- tablegen 
-*-===//
+//
+// 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 declares the CIR dialect.
+//
+//===--===//
+
+#ifndef MLIR_CIR_DIALECT_CIR
+#define MLIR_CIR_DIALECT_CIR
+
+include "mlir/IR/OpBase.td"
+
+def CIR_Dialect : Dialect {
+  let name = "cir";
+
+  // A short one-line summary of our dialect.
+  let summary = "A high-level dialect for analyzing and optimizing Clang "
+"supported languages";
+
+  let cppNamespace = "::mlir::cir";
+
+  let useDefaultAttributePrinterParser = 0;
+  let useDefaultTypePrinterParser = 0;
+
+  let extraClassDeclaration = [{
+void registerAttributes();
+void registerTypes();
+
+::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override;
+void printType(::mlir::Type type,
+   ::mlir::DialectAsmPrinter &printer) const override;
+
+::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser,
+ ::mlir::Type type) const override;
+
+void printAttribute(::mlir::Attribute attr,
+::mlir::DialectAsmPrinter &os) const override;
+  }];
+}
+
+#endif // MLIR_CIR_DIALECT_CIR
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index e69de29bb2d1d6..cfc62986b0b9d1 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -0,0 +1,18 @@
+//===-- CIROps.td - CIR dialect definition -*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// Definition of the CIR dialect
+///
+//===--===//
+
+#ifndef MLIR_CIR_DIALECT_CIR_OPS
+#define MLIR_CIR_DIALECT_CIR_OPS
+
+include "clang/CIR/Dialect/IR/CIRDialect.td"
+#endif // MLIR_CIR_DIALECT_CIR_OPS

>From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001
From: Nathan Lanza 
Date: Thu, 21 Mar 2024 05:12:26 +
Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib

Created using spr 1.3.5
---
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++
 clang/lib/CIR/Dialect/IR/CMakeLists.txt |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index e69de29bb2d1d6..8abf39119e04f7 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -0,0 +1,11 @@
+//===- CIRDialect.cpp - MLIR CIR ops implementation 
---===//
+//
+// 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 implements the CIR dialect and its operations.
+//
+//===--===//
diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt 
b/clang/lib/CIR/Dialect/IR/CMakeLists.txt
index e69de29bb2d1d6..0d7476b555705d 100644
--- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt
+++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_clang_library(MLIRCIR
+  CIRDialect.cpp
+  )

___
llvm-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] Fix build race with COMPILER_RT_TEST_STANDALONE_BUILD_LIBS (PR #83650)

2024-03-21 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/83650


___
llvm-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] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)

2024-03-21 Thread Nathan Lanza via llvm-branch-commits

https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078

>From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001
From: Nathan Lanza 
Date: Thu, 21 Mar 2024 04:09:56 +
Subject: [PATCH] add lit usage

Created using spr 1.3.5
---
 clang/test/lit.site.cfg.py.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index ef75770a2c3c9a..6641811c588395 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = 
@CLANG_DEFAULT_PIE_ON_LINUX@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
 config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@
+config.clang_enable_cir = @CLANG_ENABLE_CIR@
 config.clang_examples = @CLANG_BUILD_EXAMPLES@
 config.enable_shared = @ENABLE_SHARED@
 config.enable_backtrace = @ENABLE_BACKTRACES@

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


[llvm-branch-commits] [lld] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-21 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/85817

>From 123c0bdd085169ce7d63c96fc3c62cf6c0bc6d45 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 19 Mar 2024 16:50:05 +
Subject: [PATCH] Remove unrelated whitespace change

Created using spr 1.3.4
---
 lld/ELF/Relocations.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 241a5b82d35f4a..0301041ed48ecc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1280,6 +1280,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
+
   if (oneof(expr) &&
   config->shared) {

___
llvm-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] Fix build race with COMPILER_RT_TEST_STANDALONE_BUILD_LIBS (PR #83650)

2024-03-21 Thread Alexander Richardson via llvm-branch-commits

https://github.com/arichardson updated 
https://github.com/llvm/llvm-project/pull/83650


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


[llvm-branch-commits] [lld] [lld] Fix handling of RISCV TLSDESC relocations (PR #85817)

2024-03-21 Thread Paul Kirth via llvm-branch-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/85817

>From 123c0bdd085169ce7d63c96fc3c62cf6c0bc6d45 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Tue, 19 Mar 2024 16:50:05 +
Subject: [PATCH] Remove unrelated whitespace change

Created using spr 1.3.4
---
 lld/ELF/Relocations.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 241a5b82d35f4a..0301041ed48ecc 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1280,6 +1280,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol 
&sym,
   if (config->emachine == EM_MIPS)
 return handleMipsTlsRelocation(type, sym, c, offset, addend, expr);
   bool isRISCV = config->emachine == EM_RISCV;
+
   if (oneof(expr) &&
   config->shared) {

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


[llvm-branch-commits] [BOLT] Add secondary entry points to BAT (PR #86218)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov created 
https://github.com/llvm/llvm-project/pull/86218

Provide secondary entry points for `EntryDiscriminator` call info field
in YAML profile.

Increases BAT section size to:
- large binary: 39655300 bytes (1.03x the original),
- medium binary: 3834328 bytes (0.65x),
- small binary: 924 bytes (0.64x).

Test Plan: Updated bolt-address-translation{,-yaml}.test



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


[llvm-branch-commits] [BOLT] Use BAT callbacks in YAMLProfileWriter::convert (PR #86219)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov created 
https://github.com/llvm/llvm-project/pull/86219



Test Plan: TBD



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


[llvm-branch-commits] [llvm] [BOLT] Add BB index to BAT (PR #86044)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/86044

>From 2a97ba165c6e5689cdd8c4208d35e042760e7444 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Thu, 21 Mar 2024 14:54:23 -0700
Subject: [PATCH] cleanup

Created using spr 1.3.4
---
 bolt/lib/Profile/BoltAddressTranslation.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp 
b/bolt/lib/Profile/BoltAddressTranslation.cpp
index 03769d127bf6e6..8fe976cc00e53c 100644
--- a/bolt/lib/Profile/BoltAddressTranslation.cpp
+++ b/bolt/lib/Profile/BoltAddressTranslation.cpp
@@ -513,6 +513,11 @@ void BoltAddressTranslation::saveMetadata(BinaryContext 
&BC) {
   }
 }
 
+unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress,
+uint32_t BBInputOffset) const {
+  return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first;
+}
+
 size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress,
  uint32_t BBInputOffset) const {
   return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second;
@@ -522,10 +527,5 @@ size_t BoltAddressTranslation::getBFHash(uint64_t 
OutputAddress) const {
   return FuncHashes.at(OutputAddress).first;
 }
 
-unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress,
-uint32_t BBInputOffset) const {
-  return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first;
-}
-
 } // namespace bolt
 } // namespace llvm

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


[llvm-branch-commits] [llvm] [BOLT] Add BB index to BAT (PR #86044)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/86044

>From 2a97ba165c6e5689cdd8c4208d35e042760e7444 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Thu, 21 Mar 2024 14:54:23 -0700
Subject: [PATCH] cleanup

Created using spr 1.3.4
---
 bolt/lib/Profile/BoltAddressTranslation.cpp | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp 
b/bolt/lib/Profile/BoltAddressTranslation.cpp
index 03769d127bf6e6..8fe976cc00e53c 100644
--- a/bolt/lib/Profile/BoltAddressTranslation.cpp
+++ b/bolt/lib/Profile/BoltAddressTranslation.cpp
@@ -513,6 +513,11 @@ void BoltAddressTranslation::saveMetadata(BinaryContext 
&BC) {
   }
 }
 
+unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress,
+uint32_t BBInputOffset) const {
+  return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first;
+}
+
 size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress,
  uint32_t BBInputOffset) const {
   return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second;
@@ -522,10 +527,5 @@ size_t BoltAddressTranslation::getBFHash(uint64_t 
OutputAddress) const {
   return FuncHashes.at(OutputAddress).first;
 }
 
-unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress,
-uint32_t BBInputOffset) const {
-  return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first;
-}
-
 } // namespace bolt
 } // namespace llvm

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


[llvm-branch-commits] [BOLT] Add number of basic blocks to BAT (PR #86045)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/86045


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


[llvm-branch-commits] [BOLT] Add number of basic blocks to BAT (PR #86045)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/86045


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


[llvm-branch-commits] [BOLT] Emit intra-function control flow in YAMLBAT (PR #76911)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/76911


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


[llvm-branch-commits] [BOLT] Emit intra-function control flow in YAMLBAT (PR #76911)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/76911


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


[llvm-branch-commits] [BOLT] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/82128


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


[llvm-branch-commits] [BOLT] Set EntryDiscriminator in YAML profile for indirect calls (PR #82128)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/82128


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


[llvm-branch-commits] [llvm] [BOLT] Add CallSiteInfo entries in YAMLBAT (PR #76896)

2024-03-21 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/76896

>From 3362e9990ee0334ab7073943b4b682764f52bc8f Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Thu, 4 Jan 2024 10:40:04 -0800
Subject: [PATCH] Assert that a function exists

Created using spr 1.3.4
---
 bolt/lib/Profile/BoltAddressTranslation.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp 
b/bolt/lib/Profile/BoltAddressTranslation.cpp
index dbc9e1702a3016..62f8b777ee91b4 100644
--- a/bolt/lib/Profile/BoltAddressTranslation.cpp
+++ b/bolt/lib/Profile/BoltAddressTranslation.cpp
@@ -521,8 +521,7 @@ std::unordered_map>
 BoltAddressTranslation::getBFBranches(uint64_t OutputAddress) const {
   std::unordered_map> Branches;
   auto FuncIt = Maps.find(OutputAddress);
-  if (FuncIt == Maps.end())
-return Branches;
+  assert(FuncIt != Maps.end());
   std::vector InputOffsets;
   for (const auto &KV : FuncIt->second)
 InputOffsets.emplace_back(KV.second);

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


  1   2   >