Skip to content

[ADT] Add convenience function filter_to_vector #117460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 25, 2024
Merged

Conversation

kuhar
Copy link
Member

@kuhar kuhar commented Nov 24, 2024

This materializes a filter range as a small vector.

Similar to map_to_vector, this new utility function lives in the SmallVectorExtras.h header.

This materializes a filter range as a small vector.

Similar to `map_to_vector`, this new utility function lives in
the `SmallVectorExtras.h` header.
@llvmbot
Copy link
Member

llvmbot commented Nov 24, 2024

@llvm/pr-subscribers-llvm-adt

Author: Jakub Kuderski (kuhar)

Changes

This materializes a filter range as a small vector.

Similar to map_to_vector, this new utility function lives in the SmallVectorExtras.h header.


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

3 Files Affected:

  • (modified) llvm/include/llvm/ADT/SmallVectorExtras.h (+16)
  • (modified) llvm/unittests/ADT/CMakeLists.txt (+1)
  • (added) llvm/unittests/ADT/SmallVectorExtrasTest.cpp (+37)
diff --git a/llvm/include/llvm/ADT/SmallVectorExtras.h b/llvm/include/llvm/ADT/SmallVectorExtras.h
index eea91ca81ca612..061293fae08307 100644
--- a/llvm/include/llvm/ADT/SmallVectorExtras.h
+++ b/llvm/include/llvm/ADT/SmallVectorExtras.h
@@ -19,12 +19,28 @@
 
 namespace llvm {
 
+/// Filter a range to a SmallVector with the element types deduced.
+template <unsigned Size, class ContainerTy, class PredicateFn>
+auto filter_to_vector(ContainerTy &&C, PredicateFn &&Pred) {
+  return to_vector<Size>(make_filter_range(std::forward<ContainerTy>(C),
+                                           std::forward<PredicateFn>(Pred)));
+}
+
+/// Filter a range to a SmallVector with the element types deduced.
+template <class ContainerTy, class PredicateFn>
+auto filter_to_vector(ContainerTy &&C, PredicateFn &&Pred) {
+  return to_vector(make_filter_range(std::forward<ContainerTy>(C),
+                                     std::forward<PredicateFn>(Pred)));
+}
+
 /// Map a range to a SmallVector with element types deduced from the mapping.
 template <unsigned Size, class ContainerTy, class FuncTy>
 auto map_to_vector(ContainerTy &&C, FuncTy &&F) {
   return to_vector<Size>(
       map_range(std::forward<ContainerTy>(C), std::forward<FuncTy>(F)));
 }
+
+/// Map a range to a SmallVector with element types deduced from the mapping.
 template <class ContainerTy, class FuncTy>
 auto map_to_vector(ContainerTy &&C, FuncTy &&F) {
   return to_vector(
diff --git a/llvm/unittests/ADT/CMakeLists.txt b/llvm/unittests/ADT/CMakeLists.txt
index b0077d5b54a3ee..c9bc58f45f08cf 100644
--- a/llvm/unittests/ADT/CMakeLists.txt
+++ b/llvm/unittests/ADT/CMakeLists.txt
@@ -75,6 +75,7 @@ add_llvm_unittest(ADTTests
   SmallPtrSetTest.cpp
   SmallSetTest.cpp
   SmallStringTest.cpp
+  SmallVectorExtrasTest.cpp
   SmallVectorTest.cpp
   SparseBitVectorTest.cpp
   SparseMultiSetTest.cpp
diff --git a/llvm/unittests/ADT/SmallVectorExtrasTest.cpp b/llvm/unittests/ADT/SmallVectorExtrasTest.cpp
new file mode 100644
index 00000000000000..43a51d22b485aa
--- /dev/null
+++ b/llvm/unittests/ADT/SmallVectorExtrasTest.cpp
@@ -0,0 +1,37 @@
+//===- llvm/unittest/ADT/SmallVectorExtrasTest.cpp ------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// SmallVectorExtras unit tests.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/SmallVectorExtras.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include <type_traits>
+#include <vector>
+
+using testing::ElementsAre;
+
+namespace llvm {
+namespace {
+
+TEST(SmallVectorExtrasTest, FilterToVector) {
+  std::vector<int> Numbers = {0, 1, 2, 3, 4};
+  auto Odd = filter_to_vector<2>(Numbers, [](int X) { return (X % 2) != 0; });
+  static_assert(std::is_same_v<decltype(Odd), SmallVector<int, 2>>);
+  EXPECT_THAT(Odd, ElementsAre(1, 3));
+
+  auto Even = filter_to_vector(Numbers, [](int X) { return (X % 2) == 0; });
+  static_assert(std::is_same_v<decltype(Even), SmallVector<int>>);
+  EXPECT_THAT(Even, ElementsAre(0, 2, 4));
+}
+
+} // end namespace
+} // namespace llvm

Copy link
Contributor

@kazutakahirata kazutakahirata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

Copy link

github-actions bot commented Nov 24, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@kuhar kuhar merged commit f9dca5b into llvm:main Nov 25, 2024
6 of 8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 25, 2024

LLVM Buildbot has detected a new failure on builder premerge-monolithic-windows running on premerge-windows-1 while building llvm at step 5 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/35/builds/4019

Here is the relevant piece of the build log for the reference
Step 5 (clean-build-dir) failure: Delete failed. (failure)
Step 7 (build-unified-tree) failure: build (failure)
...
[8397/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\CompilerInstance.cpp.obj
[8398/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\CodeGenOptions.cpp.obj
[8399/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\CompilerInvocation.cpp.obj
[8400/12925] Linking CXX static library lib\FortranSemantics.lib
[8401/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\FrontendOptions.cpp.obj
[8402/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\TextDiagnosticPrinter.cpp.obj
[8403/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\TextDiagnosticBuffer.cpp.obj
[8404/12925] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\Coarray.cpp.obj
[8405/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\TextDiagnostic.cpp.obj
[8406/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\FrontendActions.cpp.obj
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DCLANG_BUILD_STATIC -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Frontend -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Frontend -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\FrontendActions.cpp.obj /Fdtools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\flangFrontend.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Frontend\FrontendActions.cpp
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include\llvm/ADT/DenseMapInfo.h(26): fatal error C1060: compiler is out of heap space
[8407/12925] Building CXX object tools\flang\lib\FrontendTool\CMakeFiles\flangFrontendTool.dir\ExecuteCompilerInvocation.cpp.obj
FAILED: tools/flang/lib/FrontendTool/CMakeFiles/flangFrontendTool.dir/ExecuteCompilerInvocation.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DCLANG_BUILD_STATIC -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\FrontendTool -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\FrontendTool -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\FrontendTool\CMakeFiles\flangFrontendTool.dir\ExecuteCompilerInvocation.cpp.obj /Fdtools\flang\lib\FrontendTool\CMakeFiles\flangFrontendTool.dir\flangFrontendTool.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\FrontendTool\ExecuteCompilerInvocation.cpp
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\inttypes.h(117): fatal error C1060: compiler is out of heap space
[8408/12925] Building CXX object tools\flang\lib\Optimizer\Analysis\CMakeFiles\FIRAnalysis.dir\TBAAForest.cpp.obj
FAILED: tools/flang/lib/Optimizer/Analysis/CMakeFiles/FIRAnalysis.dir/TBAAForest.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Optimizer\Analysis -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Optimizer\Analysis -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Optimizer\Analysis\CMakeFiles\FIRAnalysis.dir\TBAAForest.cpp.obj /Fdtools\flang\lib\Optimizer\Analysis\CMakeFiles\FIRAnalysis.dir\FIRAnalysis.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Optimizer\Analysis\TBAAForest.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\stdexcept(51): fatal error C1060: compiler is out of heap space
[8409/12925] Building CXX object tools\flang\lib\Optimizer\Analysis\CMakeFiles\FIRAnalysis.dir\AliasAnalysis.cpp.obj
FAILED: tools/flang/lib/Optimizer/Analysis/CMakeFiles/FIRAnalysis.dir/AliasAnalysis.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Optimizer\Analysis -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Optimizer\Analysis -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Optimizer\Analysis\CMakeFiles\FIRAnalysis.dir\AliasAnalysis.cpp.obj /Fdtools\flang\lib\Optimizer\Analysis\CMakeFiles\FIRAnalysis.dir\FIRAnalysis.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Optimizer\Analysis\AliasAnalysis.cpp
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include\llvm/ADT/StringRef.h(327): fatal error C1060: compiler is out of heap space
[8410/12925] Building CXX object tools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\FrontendAction.cpp.obj
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendAction.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DCLANG_BUILD_STATIC -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Frontend -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Frontend -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\FrontendAction.cpp.obj /Fdtools\flang\lib\Frontend\CMakeFiles\flangFrontend.dir\flangFrontend.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Frontend\FrontendAction.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\variant(474): fatal error C1060: compiler is out of heap space
[8411/12925] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\Runtime.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/Runtime.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\Runtime.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\Runtime.cpp
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\Runtime.cpp(246): fatal error C1060: compiler is out of heap space
[8412/12925] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenACC.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenACC.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenACC.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\OpenACC.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\variant(1491): fatal error C1060: compiler is out of heap space
[8413/12925] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenMP\Utils.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Utils.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenMP\Utils.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\OpenMP\Utils.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\variant(479): fatal error C1060: compiler is out of heap space
[8414/12925] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\ConvertCall.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/ConvertCall.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\ConvertCall.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\ConvertCall.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\variant(177): fatal error C1060: compiler is out of heap space
[8415/12925] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\Allocatable.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/Allocatable.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\Allocatable.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\Allocatable.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\variant(1538): fatal error C1060: compiler is out of heap space

@dwblaikie
Copy link
Collaborator

I probably had similar feedback on previous *_to_vector - but I do wonder whether these are worthwhile/that much of a benefit compared to composing the two operations when needed?

@kuhar
Copy link
Member Author

kuhar commented Nov 25, 2024

I probably had similar feedback on previous *_to_vector - but I do wonder whether these are worthwhile/that much of a benefit compared to composing the two operations when needed?

I see map_to_vector used a lot across MLIR and downstream in IREE -- this one fewer layer of function calls is often what makes this appealing vs. using a for loop. So I'd argue that the real-world usage and improved readability justify this.

@kuhar
Copy link
Member Author

kuhar commented Nov 25, 2024

My guess is that the reason for that in MLIR specifically is that we have multiple functions/methods that return ranges of IR constructs, e.g., block.getOps<OpT>(), which are difficult to work with until you materialize them. And materializing as a vector is usually the right thing to do as you typically end up passing these to function that take arguments as ArrayRef-like types.

kuhar added a commit to kuhar/iree that referenced this pull request Nov 26, 2024
I recently added this to SmallVectorExtras:
llvm/llvm-project#117460.

Signed-off-by: Jakub Kuderski <[email protected]>
kuhar added a commit to iree-org/iree that referenced this pull request Nov 26, 2024
I recently added this to SmallVectorExtras:
llvm/llvm-project#117460.
kuhar added a commit to kuhar/llvm-project that referenced this pull request Nov 26, 2024
This got recently added to SmallVectorExtras:
llvm#117460.
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 26, 2024

LLVM Buildbot has detected a new failure on builder lld-x86_64-win running on as-worker-93 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/1690

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests.exe/37/87' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-1680-37-87.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=87 GTEST_SHARD_INDEX=37 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied




********************


kuhar added a commit that referenced this pull request Nov 26, 2024
This got recently added to SmallVectorExtras:
#117460.
Groverkss pushed a commit to Groverkss/iree that referenced this pull request Dec 1, 2024
giacs-epic pushed a commit to giacs-epic/iree that referenced this pull request Dec 4, 2024
I recently added this to SmallVectorExtras:
llvm/llvm-project#117460.

Signed-off-by: Giacomo Serafini <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants