[llvm-branch-commits] [mlir] [mlir][Transforms] Dialect conversion: Build unresolved materialization for replaced ops (PR #101514)

2024-08-01 Thread Jakub Kuderski via llvm-branch-commits


@@ -2459,10 +2457,42 @@ OperationConverter::finalize(ConversionPatternRewriter 
&rewriter) {
 return failure();
   DenseMap> inverseMapping =
   rewriterImpl.mapping.getInverse();
+  if (failed(legalizeConvertedOpResultTypes(rewriter, rewriterImpl,
+inverseMapping)))
+return failure();
   if (failed(legalizeUnresolvedMaterializations(rewriter, rewriterImpl,
 inverseMapping)))
 return failure();
+  return success();
+}
 
+/// Finds a user of the given value, or of any other value that the given value
+/// replaced, that was not replaced in the conversion process.
+static Operation *findLiveUserOfReplaced(
+Value initialValue, ConversionPatternRewriterImpl &rewriterImpl,
+const DenseMap> &inverseMapping) {
+  SmallVector worklist(1, initialValue);

kuhar wrote:

nit
```suggestion
  SmallVector worklist = {initialValue};
```

https://github.com/llvm/llvm-project/pull/101514
___
llvm-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][Transforms] Dialect conversion: Build unresolved materialization for replaced ops (PR #101514)

2024-08-01 Thread Jakub Kuderski via llvm-branch-commits

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


https://github.com/llvm/llvm-project/pull/101514
___
llvm-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 Jakub Kuderski via llvm-branch-commits


@@ -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 = std::function /*dim*/, ValueBoundsConstraintSet &cstr)>;

kuhar wrote:

This comment is not directly related to the changes in this PR, but It's not 
immediately clear to me if which value indicates stop/continuation. I like the 
`walk` function much more which exposes `WalkResult::interrup()` and 
`WalkRedult::advance()`, but I think that changing to `LogicalResult` and 
renaming this could also help.
Would be cool if we could revisit this separately.

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] [mlir] [mlir][Transforms] Dialect conversion: Unify materialization of value replacements (PR #108381)

2024-09-12 Thread Jakub Kuderski via llvm-branch-commits


@@ -2546,87 +2522,61 @@ static Operation *findLiveUserOfReplaced(
   return nullptr;
 }
 
-LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
-ConversionPatternRewriter &rewriter,
-ConversionPatternRewriterImpl &rewriterImpl,
-DenseMap> &inverseMapping) {
-  // Process requested operation replacements.
-  for (unsigned i = 0; i < rewriterImpl.rewrites.size(); ++i) {
-auto *opReplacement =
-dyn_cast(rewriterImpl.rewrites[i].get());
-if (!opReplacement)
-  continue;
-Operation *op = opReplacement->getOperation();
-for (OpResult result : op->getResults()) {
-  // If the type of this op result changed and the result is still live,
-  // we need to materialize a conversion.
-  if (rewriterImpl.mapping.lookupOrNull(result, result.getType()))
+/// Helper function that returns the replaced values and the type converter if
+/// the given rewrite object is an "operation replacement" or a "block type
+/// conversion" (which corresponds to a "block replacement"). Otherwise, return
+/// an empty ValueRange and a null type converter pointer.
+static std::pair
+getReplacedValues(IRRewrite *rewrite) {
+  if (auto *opRewrite = dyn_cast(rewrite))
+return std::make_pair(opRewrite->getOperation()->getResults(),
+  opRewrite->getConverter());
+  if (auto *blockRewrite = dyn_cast(rewrite))
+return std::make_pair(blockRewrite->getOrigBlock()->getArguments(),
+  blockRewrite->getConverter());
+  return std::make_pair(ValueRange(), nullptr);

kuhar wrote:

nit
```suggestion
return {opRewrite->getOperation()->getResults(),
  opRewrite->getConverter()};
  if (auto *blockRewrite = dyn_cast(rewrite))
return {blockRewrite->getOrigBlock()->getArguments(),
  blockRewrite->getConverter()};
  return {};
```
```suggestion
return std::make_pair(opRewrite->getOperation()->getResults(),
  opRewrite->getConverter());
  if (auto *blockRewrite = dyn_cast(rewrite))
return std::make_pair(blockRewrite->getOrigBlock()->getArguments(),
  blockRewrite->getConverter());
  return std::make_pair(ValueRange(), nullptr);
```

https://github.com/llvm/llvm-project/pull/108381
___
llvm-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][Transforms] Dialect conversion: Unify materialization of value replacements (PR #108381)

2024-09-12 Thread Jakub Kuderski via llvm-branch-commits

https://github.com/kuhar edited https://github.com/llvm/llvm-project/pull/108381
___
llvm-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][Transforms] Dialect conversion: Unify materialization of value replacements (PR #108381)

2024-09-12 Thread Jakub Kuderski via llvm-branch-commits


@@ -2546,87 +2522,61 @@ static Operation *findLiveUserOfReplaced(
   return nullptr;
 }
 
-LogicalResult OperationConverter::legalizeConvertedOpResultTypes(
-ConversionPatternRewriter &rewriter,
-ConversionPatternRewriterImpl &rewriterImpl,
-DenseMap> &inverseMapping) {
-  // Process requested operation replacements.
-  for (unsigned i = 0; i < rewriterImpl.rewrites.size(); ++i) {
-auto *opReplacement =
-dyn_cast(rewriterImpl.rewrites[i].get());
-if (!opReplacement)
-  continue;
-Operation *op = opReplacement->getOperation();
-for (OpResult result : op->getResults()) {
-  // If the type of this op result changed and the result is still live,
-  // we need to materialize a conversion.
-  if (rewriterImpl.mapping.lookupOrNull(result, result.getType()))
+/// Helper function that returns the replaced values and the type converter if
+/// the given rewrite object is an "operation replacement" or a "block type
+/// conversion" (which corresponds to a "block replacement"). Otherwise, return
+/// an empty ValueRange and a null type converter pointer.
+static std::pair
+getReplacedValues(IRRewrite *rewrite) {
+  if (auto *opRewrite = dyn_cast(rewrite))
+return std::make_pair(opRewrite->getOperation()->getResults(),
+  opRewrite->getConverter());
+  if (auto *blockRewrite = dyn_cast(rewrite))
+return std::make_pair(blockRewrite->getOrigBlock()->getArguments(),
+  blockRewrite->getConverter());
+  return std::make_pair(ValueRange(), nullptr);
+}
+
+LogicalResult
+OperationConverter::finalize(ConversionPatternRewriter &rewriter) {
+  ConversionPatternRewriterImpl &rewriterImpl = rewriter.getImpl();
+  DenseMap> inverseMapping =
+  rewriterImpl.mapping.getInverse();
+
+  // Process requested value replacements.
+  for (unsigned i = 0, e = rewriterImpl.rewrites.size(); i < e; ++i) {

kuhar wrote:

Nit: use range for? I don't see `i` being use outside of indexing into 
`rewriters`.

https://github.com/llvm/llvm-project/pull/108381
___
llvm-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] [ADT] Use range-based helper functions in SmallSet (PR #108585)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits

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

Nice

https://github.com/llvm/llvm-project/pull/108585
___
llvm-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] [ADT] Use range-based helper functions in SmallSet (PR #108585)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits

https://github.com/kuhar edited https://github.com/llvm/llvm-project/pull/108585
___
llvm-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] [ADT] Use range-based helper functions in SmallSet (PR #108585)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits


@@ -206,11 +196,12 @@ class SmallSet {
   bool erase(const T &V) {
 if (!isSmall())
   return Set.erase(V);
-for (mutable_iterator I = Vector.begin(), E = Vector.end(); I != E; ++I)
-  if (*I == V) {
-Vector.erase(I);
-return true;
-  }
+
+auto It = llvm::find(Vector, V);
+if (It != Vector.end()) {

kuhar wrote:

nit: this is not used outside of the `if`
```suggestion
if (auto It = llvm::find(Vector, V); It != Vector.end()) {
```

https://github.com/llvm/llvm-project/pull/108585
___
llvm-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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits

https://github.com/kuhar edited https://github.com/llvm/llvm-project/pull/108590
___
llvm-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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits


@@ -231,6 +215,31 @@ class SmallSet {
 
 private:
   bool isSmall() const { return Set.empty(); }
+
+  template 
+  std::pair insertImpl(ArgType &&V) {
+static_assert(std::is_convertible_v,
+  "ArgType must be convertible to T!");
+if (!isSmall()) {
+  auto [I, Inserted] = Set.insert(std::forward(V));
+  return std::make_pair(const_iterator(I), Inserted);

kuhar wrote:

```suggestion
  return {const_iterator(I), Inserted};
```

https://github.com/llvm/llvm-project/pull/108590
___
llvm-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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits

https://github.com/kuhar commented:

Could you add a test showing the values are forwarded?

https://github.com/llvm/llvm-project/pull/108590
___
llvm-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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits


@@ -231,6 +215,31 @@ class SmallSet {
 
 private:
   bool isSmall() const { return Set.empty(); }
+
+  template 
+  std::pair insertImpl(ArgType &&V) {
+static_assert(std::is_convertible_v,
+  "ArgType must be convertible to T!");
+if (!isSmall()) {
+  auto [I, Inserted] = Set.insert(std::forward(V));
+  return std::make_pair(const_iterator(I), Inserted);
+}
+
+auto I = llvm::find(Vector, V);
+if (I != Vector.end()) // Don't reinsert if it already exists.
+  return std::make_pair(const_iterator(I), false);

kuhar wrote:

```suggestion
  return {const_iterator(I), false};
```

https://github.com/llvm/llvm-project/pull/108590
___
llvm-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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits


@@ -231,6 +215,31 @@ class SmallSet {
 
 private:
   bool isSmall() const { return Set.empty(); }
+
+  template 
+  std::pair insertImpl(ArgType &&V) {
+static_assert(std::is_convertible_v,
+  "ArgType must be convertible to T!");
+if (!isSmall()) {
+  auto [I, Inserted] = Set.insert(std::forward(V));
+  return std::make_pair(const_iterator(I), Inserted);
+}
+
+auto I = llvm::find(Vector, V);
+if (I != Vector.end()) // Don't reinsert if it already exists.
+  return std::make_pair(const_iterator(I), false);
+if (Vector.size() < N) {
+  Vector.push_back(std::forward(V));
+  return std::make_pair(const_iterator(std::prev(Vector.end())), true);

kuhar wrote:

```suggestion
  return{const_iterator(std::prev(Vector.end())), true};
```

https://github.com/llvm/llvm-project/pull/108590
___
llvm-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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits


@@ -231,6 +215,31 @@ class SmallSet {
 
 private:
   bool isSmall() const { return Set.empty(); }
+
+  template 
+  std::pair insertImpl(ArgType &&V) {
+static_assert(std::is_convertible_v,
+  "ArgType must be convertible to T!");
+if (!isSmall()) {
+  auto [I, Inserted] = Set.insert(std::forward(V));
+  return std::make_pair(const_iterator(I), Inserted);
+}
+
+auto I = llvm::find(Vector, V);
+if (I != Vector.end()) // Don't reinsert if it already exists.

kuhar wrote:

```suggestion
if (auto I = llvm::find(Vector, V); I != Vector.end()) // Don't reinsert if 
it already exists.
```

https://github.com/llvm/llvm-project/pull/108590
___
llvm-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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-13 Thread Jakub Kuderski via llvm-branch-commits


@@ -231,6 +215,31 @@ class SmallSet {
 
 private:
   bool isSmall() const { return Set.empty(); }
+
+  template 
+  std::pair insertImpl(ArgType &&V) {
+static_assert(std::is_convertible_v,
+  "ArgType must be convertible to T!");
+if (!isSmall()) {
+  auto [I, Inserted] = Set.insert(std::forward(V));
+  return std::make_pair(const_iterator(I), Inserted);
+}
+
+auto I = llvm::find(Vector, V);
+if (I != Vector.end()) // Don't reinsert if it already exists.
+  return std::make_pair(const_iterator(I), false);
+if (Vector.size() < N) {
+  Vector.push_back(std::forward(V));
+  return std::make_pair(const_iterator(std::prev(Vector.end())), true);
+}
+
+// Otherwise, grow from vector to set.
+Set.insert(std::make_move_iterator(Vector.begin()),
+   std::make_move_iterator(Vector.end()));
+Vector.clear();
+return std::make_pair(
+const_iterator(Set.insert(std::forward(V)).first), true);

kuhar wrote:

```suggestion
return {const_iterator(Set.insert(std::forward(V)).first), true};
```

https://github.com/llvm/llvm-project/pull/108590
___
llvm-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] [ADT] Use range-based helper functions in SmallSet (PR #108585)

2024-09-17 Thread Jakub Kuderski via llvm-branch-commits


@@ -234,19 +225,12 @@ class SmallSet {
   /// Check if the SmallSet contains the given element.
   bool contains(const T &V) const {
 if (isSmall())
-  return vfind(V) != Vector.end();
-return Set.find(V) != Set.end();
+  return llvm::is_contained(Vector, V);
+return llvm::is_contained(Set, V);

kuhar wrote:

I'd expect it to call `set::find`: 
https://github.com/llvm/llvm-project/blob/49a754a43d5592e08ef177db794126ddc676d6b5/llvm/include/llvm/ADT/STLExtras.h#L1890-L1891

https://github.com/llvm/llvm-project/pull/108585
___
llvm-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] [ADT] Use perfect forwarding in SmallSet::insert() (PR #108590)

2024-09-17 Thread Jakub Kuderski via llvm-branch-commits

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


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


[llvm-branch-commits] [clang-tools-extra-branch] r303524 - [clang-tidy] Fix PR32896, PR33058: detect initializer lists in modernize-use-empalce

2017-05-22 Thread Jakub Kuderski via llvm-branch-commits
Author: kuhar
Date: Sun May 21 20:56:33 2017
New Revision: 303524

URL: http://llvm.org/viewvc/llvm-project?rev=303524&view=rev
Log:
[clang-tidy] Fix PR32896, PR33058: detect initializer lists in 
modernize-use-empalce

Summary:
The patch is backported from: r302281 to fix the 4.0.1 release blocker PR33058.
This patch fixes [[ https://bugs.llvm.org/show_bug.cgi?id=32896 | PR32896 ]].

The problem was that modernize-use-emplace incorrectly removed changed 
push_back into emplace_back, removing explicit constructor call with 
initializer list parameter, resulting in compiler error after applying fixits.
modernize-use-emplace used to check if matched constructor had InitListExpr, 
but didn't check against CXXStdInitializerListExpr.

Eg.

```
std::vector> v;
  v.push_back(std::vector({1})); // --> v.emplace_back({1});
```

Reviewers: Prazek, alexfh, aaron.ballman

Reviewed By: Prazek, alexfh, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D32767


Modified:

clang-tools-extra/branches/release_40/clang-tidy/modernize/UseEmplaceCheck.cpp

clang-tools-extra/branches/release_40/test/clang-tidy/modernize-use-emplace.cpp

Modified: 
clang-tools-extra/branches/release_40/clang-tidy/modernize/UseEmplaceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/branches/release_40/clang-tidy/modernize/UseEmplaceCheck.cpp?rev=303524&r1=303523&r2=303524&view=diff
==
--- 
clang-tools-extra/branches/release_40/clang-tidy/modernize/UseEmplaceCheck.cpp 
(original)
+++ 
clang-tools-extra/branches/release_40/clang-tidy/modernize/UseEmplaceCheck.cpp 
Sun May 21 20:56:33 2017
@@ -20,6 +20,14 @@ static const auto DefaultContainersWithP
 static const auto DefaultSmartPointers =
 "::std::shared_ptr; ::std::unique_ptr; ::std::auto_ptr; ::std::weak_ptr";
 
+namespace {
+namespace impl {
+// FIXME: This matcher should be replaced by a matcher from ASTMatcher.h
+const ast_matchers::internal::VariadicDynCastAllOfMatcher cxxStdInitializerListExpr;
+} // namespace impl
+} // namespace
+
 UseEmplaceCheck::UseEmplaceCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   ContainersWithPushBack(utils::options::parseStringList(Options.get(
@@ -69,7 +77,11 @@ void UseEmplaceCheck::registerMatchers(M
   // emplace_back can't access private constructor.
   auto isPrivateCtor = hasDeclaration(cxxConstructorDecl(isPrivate()));
 
-  auto hasInitList = has(ignoringImplicit(initListExpr()));
+  auto hasInitList = anyOf(has(ignoringImplicit(initListExpr())),
+   has(impl::cxxStdInitializerListExpr()));
+  // FIXME: Replace internal C++ initializer list matcher with one from
+  // ASTMatchers.h
+
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.
   auto soughtConstructExpr =

Modified: 
clang-tools-extra/branches/release_40/test/clang-tidy/modernize-use-emplace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/branches/release_40/test/clang-tidy/modernize-use-emplace.cpp?rev=303524&r1=303523&r2=303524&view=diff
==
--- 
clang-tools-extra/branches/release_40/test/clang-tidy/modernize-use-emplace.cpp 
(original)
+++ 
clang-tools-extra/branches/release_40/test/clang-tidy/modernize-use-emplace.cpp 
Sun May 21 20:56:33 2017
@@ -4,9 +4,19 @@
 // RUN:   value: '::std::vector; ::std::list; ::std::deque; 
llvm::LikeASmallVector'}]}" -- -std=c++11
 
 namespace std {
+template 
+class initializer_list
+{
+public:
+  initializer_list() noexcept {}
+};
+
 template 
 class vector {
 public:
+  vector() = default;
+  vector(initializer_list) {}
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
@@ -422,3 +432,16 @@ void testWithDtor() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
   // CHECK-FIXES: v.emplace_back(42);
 }
+
+void testInitializerList() {
+  std::vector> v;
+  v.push_back(std::vector({1}));
+  // Test against the bug reported in PR32896.
+
+  v.push_back({{2}});
+
+  using PairIntVector = std::pair>;
+  std::vector x;
+  x.push_back(PairIntVector(3, {4}));
+  x.push_back({5, {6}});
+}


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


[llvm-branch-commits] [llvm] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits

https://github.com/kuhar edited https://github.com/llvm/llvm-project/pull/108601
___
llvm-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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits


@@ -147,6 +148,22 @@ class SmallSet {
   using const_iterator = SmallSetIterator;
 
   SmallSet() = default;
+  SmallSet(const SmallSet &) = default;
+  SmallSet(SmallSet &&) = default;
+
+  template  SmallSet(IterT Begin, IterT End) {
+insert(Begin, End);
+  }
+
+  template 
+  explicit SmallSet(const iterator_range &R) {
+insert(R.begin(), R.end());
+  }
+
+  SmallSet(std::initializer_list L) { this->insert(L.begin(), L.end()); }

kuhar wrote:

One remaining `this->`

https://github.com/llvm/llvm-project/pull/108601
___
llvm-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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/108601
___
llvm-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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits


@@ -17,6 +17,66 @@
 
 using namespace llvm;
 
+TEST(SmallSetTest, ConstructorIteratorPair) {
+  auto L = {1, 2, 3, 4, 5};
+  SmallSet S(std::begin(L), std::end(L));
+  for (int Value : L)
+EXPECT_TRUE(S.contains(Value));

kuhar wrote:

You can also do `EXPECT_THAT(S, UnorderedElementsAreArray(L));`. This prints 
nice error messages.
Also elsewhere below.

https://github.com/llvm/llvm-project/pull/108601
___
llvm-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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits


@@ -147,6 +148,22 @@ class SmallSet {
   using const_iterator = SmallSetIterator;
 
   SmallSet() = default;
+  SmallSet(const SmallSet &) = default;
+  SmallSet(SmallSet &&) = default;
+
+  template  SmallSet(IterT Begin, IterT End) {
+this->insert(Begin, End);
+  }
+
+  template 
+  explicit SmallSet(const iterator_range &R) {
+this->insert(R.begin(), R.end());
+  }
+
+  SmallSet(std::initializer_list L) { this->insert(L.begin(), L.end()); }

kuhar wrote:

The rest of the code in the class doesn't use `this->` for member functions

https://github.com/llvm/llvm-project/pull/108601
___
llvm-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] [ADT] Add more useful methods to SmallSet API (PR #108601)

2024-09-24 Thread Jakub Kuderski via llvm-branch-commits


@@ -17,6 +17,66 @@
 
 using namespace llvm;
 
+TEST(SmallSetTest, ConstructorIteratorPair) {
+  auto L = {1, 2, 3, 4, 5};

kuhar wrote:

Could you make the type explicit, both here and everywhere else below. Either 
initializer list or some other vector type is fine.

https://github.com/llvm/llvm-project/pull/108601
___
llvm-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] [AMDGPU][MLIR] Replace gfx940 and gfx941 with gfx942 in MLIR (PR #125836)

2025-02-11 Thread Jakub Kuderski via llvm-branch-commits

https://github.com/kuhar commented:

Since this essentially breaks logic for gfx940 and gfx941, should we assert in 
code like `Chipset` that these are not used and silently miscompiled?

https://github.com/llvm/llvm-project/pull/125836
___
llvm-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][IR] Remove `isF...()` type API for low-precision FP types (PR #123326)

2025-01-17 Thread Jakub Kuderski via llvm-branch-commits

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

Nice!

https://github.com/llvm/llvm-project/pull/123326
___
llvm-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] Use `getSingleElement`/`hasSingleElement` in various places (PR #131460)

2025-03-16 Thread Jakub Kuderski via llvm-branch-commits

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

LGTM % formatting

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