[Lldb-commits] [clang] [lldb] [llvm] [mlir] [NFC] Fix formatv() usage in preparation of validation (PR #106454)

2024-08-28 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph approved this pull request.


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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-28 Thread Mehdi Amini via lldb-commits


@@ -143,15 +140,76 @@ formatv_object_base::splitLiteralAndReplacement(StringRef 
Fmt) {
   return std::make_pair(ReplacementItem{Fmt}, StringRef());
 }
 
+#ifndef NDEBUG
+#define ENABLE_VALIDATION 1
+#else
+#define ENABLE_VALIDATION 1 // Convienently enable validation in release mode.

joker-eph wrote:

```suggestion
#define ENABLE_VALIDATION 1 // Conveniently enable validation in release mode.
```

(typo)

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-28 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph approved this pull request.

LGTM

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-28 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/105745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-28 Thread Mehdi Amini via lldb-commits


@@ -655,7 +655,7 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
 
   if (!ContainsDIEOffset(die_offset)) {
 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"GetDIE for DIE {0:x16} is outside of its CU {0:x16}", die_offset,
+"GetDIE for DIE {0:x16} is outside of its CU {1:x16}", die_offset,

joker-eph wrote:

I would push the fixes to main directly ahead of the PR, so that any revert of 
this PR does not lose these fixes :)

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

Having this enabled guarded by NDEBUG seems like a good option. There is 
already some things already like this isn't there? I kind of remember that 
using imbalanced `{` / `}` pair of something like that was checked only in 
assert builds?

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

Possible, let's try it there then

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits


@@ -67,92 +68,123 @@ formatv_object_base::parseReplacementItem(StringRef Spec) {
   StringRef Options;
   size_t Index = 0;
   RepString = RepString.trim();
-  if (RepString.consumeInteger(0, Index)) {
-assert(false && "Invalid replacement sequence index!");
-return ReplacementItem{};
-  }
+  if (RepString.consumeInteger(0, Index))
+return "Invalid replacement sequence index!";
   RepString = RepString.trim();
   if (RepString.consume_front(",")) {
 if (!consumeFieldLayout(RepString, Where, Align, Pad))
-  assert(false && "Invalid replacement field layout specification!");
+  return "Invalid replacement field layout specification!";
   }
   RepString = RepString.trim();
   if (RepString.consume_front(":")) {
 Options = RepString.trim();
 RepString = StringRef();
   }
   RepString = RepString.trim();
-  if (!RepString.empty()) {
-assert(false && "Unexpected characters found in replacement string!");
-  }
-
+  if (!RepString.empty())
+return "Unexpected character found in replacement string!";
   return ReplacementItem{Spec, Index, Align, Where, Pad, Options};
 }
 
-std::pair
-formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
-  while (!Fmt.empty()) {
-// Everything up until the first brace is a literal.
-if (Fmt.front() != '{') {
-  std::size_t BO = Fmt.find_first_of('{');
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO)}, 
Fmt.substr(BO));
-}
-
-StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
-// If there is more than one brace, then some of them are escaped.  Treat
-// these as replacements.
-if (Braces.size() > 1) {
-  size_t NumEscapedBraces = Braces.size() / 2;
-  StringRef Middle = Fmt.take_front(NumEscapedBraces);
-  StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
-  return std::make_pair(ReplacementItem{Middle}, Right);
-}
-// An unterminated open brace is undefined. Assert to indicate that this is
-// undefined and that we consider it an error. When asserts are disabled,
-// build a replacement item with an error message.
-std::size_t BC = Fmt.find_first_of('}');
-if (BC == StringRef::npos) {
-  assert(
-  false &&
-  "Unterminated brace sequence. Escape with {{ for a literal brace.");
-  return std::make_pair(
-  ReplacementItem{"Unterminated brace sequence. Escape with {{ for a "
-  "literal brace."},
-  StringRef());
-}
-
-// Even if there is a closing brace, if there is another open brace before
-// this closing brace, treat this portion as literal, and try again with 
the
-// next one.
-std::size_t BO2 = Fmt.find_first_of('{', 1);
-if (BO2 < BC)
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)},
-Fmt.substr(BO2));
-
-StringRef Spec = Fmt.slice(1, BC);
-StringRef Right = Fmt.substr(BC + 1);
-
-auto RI = parseReplacementItem(Spec);
-if (RI)
-  return std::make_pair(*RI, Right);
+static std::variant, StringRef>
+splitLiteralAndReplacement(StringRef Fmt) {
+  // Everything up until the first brace is a literal.
+  if (Fmt.front() != '{') {
+std::size_t BO = Fmt.find_first_of('{');
+return std::make_pair(ReplacementItem(Fmt.substr(0, BO)), Fmt.substr(BO));
+  }
 
-// If there was an error parsing the replacement item, treat it as an
-// invalid replacement spec, and just continue.
-Fmt = Fmt.drop_front(BC + 1);
+  StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
+  // If there is more than one brace, then some of them are escaped.  Treat
+  // these as replacements.
+  if (Braces.size() > 1) {
+size_t NumEscapedBraces = Braces.size() / 2;
+StringRef Middle = Fmt.take_front(NumEscapedBraces);
+StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
+return std::make_pair(ReplacementItem(Middle), Right);
   }
-  return std::make_pair(ReplacementItem{Fmt}, StringRef());
+  // An unterminated open brace is undefined. Assert to indicate that this is
+  // undefined and that we consider it an error. When asserts are disabled,
+  // build a replacement item with an error message.
+  std::size_t BC = Fmt.find_first_of('}');
+  if (BC == StringRef::npos)
+return "Unterminated brace sequence. Escape with {{ for a literal brace.";
+
+  // Even if there is a closing brace, if there is another open brace before
+  // this closing brace, treat this portion as literal, and try again with the
+  // next one.
+  std::size_t BO2 = Fmt.find_first_of('{', 1);
+  if (BO2 < BC)
+return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)}, 
Fmt.substr(BO2));
+
+  StringRef Spec = Fmt.slice(1, BC);
+  StringRef Right = Fmt.substr(BC + 1);
+
+  auto RI = parseReplacementItem(Spec);
+  if (const StringRef *ErrMsg = std::get_if<1>(&RI))
+return *ErrMsg;
+
+  return std::make_pair(std::get<0>(RI), Right);
 }
 
-SmallVector
-format

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph commented:

Thanks, I'm wondering about the cost of this: what does it do to some 
compile-time tests with clang for example?

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits


@@ -67,92 +68,123 @@ formatv_object_base::parseReplacementItem(StringRef Spec) {
   StringRef Options;
   size_t Index = 0;
   RepString = RepString.trim();
-  if (RepString.consumeInteger(0, Index)) {
-assert(false && "Invalid replacement sequence index!");
-return ReplacementItem{};
-  }
+  if (RepString.consumeInteger(0, Index))
+return "Invalid replacement sequence index!";
   RepString = RepString.trim();
   if (RepString.consume_front(",")) {
 if (!consumeFieldLayout(RepString, Where, Align, Pad))
-  assert(false && "Invalid replacement field layout specification!");
+  return "Invalid replacement field layout specification!";
   }
   RepString = RepString.trim();
   if (RepString.consume_front(":")) {
 Options = RepString.trim();
 RepString = StringRef();
   }
   RepString = RepString.trim();
-  if (!RepString.empty()) {
-assert(false && "Unexpected characters found in replacement string!");
-  }
-
+  if (!RepString.empty())
+return "Unexpected character found in replacement string!";
   return ReplacementItem{Spec, Index, Align, Where, Pad, Options};
 }
 
-std::pair
-formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
-  while (!Fmt.empty()) {
-// Everything up until the first brace is a literal.
-if (Fmt.front() != '{') {
-  std::size_t BO = Fmt.find_first_of('{');
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO)}, 
Fmt.substr(BO));
-}
-
-StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
-// If there is more than one brace, then some of them are escaped.  Treat
-// these as replacements.
-if (Braces.size() > 1) {
-  size_t NumEscapedBraces = Braces.size() / 2;
-  StringRef Middle = Fmt.take_front(NumEscapedBraces);
-  StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
-  return std::make_pair(ReplacementItem{Middle}, Right);
-}
-// An unterminated open brace is undefined. Assert to indicate that this is
-// undefined and that we consider it an error. When asserts are disabled,
-// build a replacement item with an error message.
-std::size_t BC = Fmt.find_first_of('}');
-if (BC == StringRef::npos) {
-  assert(
-  false &&
-  "Unterminated brace sequence. Escape with {{ for a literal brace.");
-  return std::make_pair(
-  ReplacementItem{"Unterminated brace sequence. Escape with {{ for a "
-  "literal brace."},
-  StringRef());
-}
-
-// Even if there is a closing brace, if there is another open brace before
-// this closing brace, treat this portion as literal, and try again with 
the
-// next one.
-std::size_t BO2 = Fmt.find_first_of('{', 1);
-if (BO2 < BC)
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)},
-Fmt.substr(BO2));
-
-StringRef Spec = Fmt.slice(1, BC);
-StringRef Right = Fmt.substr(BC + 1);
-
-auto RI = parseReplacementItem(Spec);
-if (RI)
-  return std::make_pair(*RI, Right);
+static std::variant, StringRef>
+splitLiteralAndReplacement(StringRef Fmt) {
+  // Everything up until the first brace is a literal.
+  if (Fmt.front() != '{') {
+std::size_t BO = Fmt.find_first_of('{');
+return std::make_pair(ReplacementItem(Fmt.substr(0, BO)), Fmt.substr(BO));
+  }
 
-// If there was an error parsing the replacement item, treat it as an
-// invalid replacement spec, and just continue.
-Fmt = Fmt.drop_front(BC + 1);
+  StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
+  // If there is more than one brace, then some of them are escaped.  Treat
+  // these as replacements.
+  if (Braces.size() > 1) {
+size_t NumEscapedBraces = Braces.size() / 2;
+StringRef Middle = Fmt.take_front(NumEscapedBraces);
+StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
+return std::make_pair(ReplacementItem(Middle), Right);
   }
-  return std::make_pair(ReplacementItem{Fmt}, StringRef());
+  // An unterminated open brace is undefined. Assert to indicate that this is
+  // undefined and that we consider it an error. When asserts are disabled,
+  // build a replacement item with an error message.
+  std::size_t BC = Fmt.find_first_of('}');
+  if (BC == StringRef::npos)
+return "Unterminated brace sequence. Escape with {{ for a literal brace.";
+
+  // Even if there is a closing brace, if there is another open brace before
+  // this closing brace, treat this portion as literal, and try again with the
+  // next one.
+  std::size_t BO2 = Fmt.find_first_of('{', 1);
+  if (BO2 < BC)
+return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)}, 
Fmt.substr(BO2));
+
+  StringRef Spec = Fmt.slice(1, BC);
+  StringRef Right = Fmt.substr(BC + 1);
+
+  auto RI = parseReplacementItem(Spec);
+  if (const StringRef *ErrMsg = std::get_if<1>(&RI))
+return *ErrMsg;
+
+  return std::make_pair(std::get<0>(RI), Right);
 }
 
-SmallVector
-format

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/105745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

CI failed FYI.

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-17 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

> It's a sed s/== None/is None/g - what is there to review?

On my I'm not asking for more reviews, this is why I commented that this should 
be **pushed** in multiple commits, I don't even need to see PRs.

Another thing also mentioned above was the problem of reverts.
If there is a problem in one of the project and this needs to be reverted, then 
it'll affect the other projects.
Also imagine that this lands, then someone refactor the python code in MLIR, 
and then LLDB finds an issue and tries to revert. They have now to figure out 
why is there a merge conflicts.

More commits in the history for unrelated projects does not seem like "noise" 
to me.

When I apply automated linter (clang-tidy), I will split these into 1 commit 
per file and push these.


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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-16 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph approved this pull request.

If you can push this to main in separate commits (one per project as it was 
mentioned?), that'd be great!

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


[Lldb-commits] [clang] [compiler-rt] [libc] [libclc] [libcxxabi] [lld] [lldb] [llvm] [mlir] llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:3804: lacking () for c… (PR #90391)

2024-04-28 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

PR should be named according to what they are actually achieving, I'm not sure 
why the GitHub issue title is relevant?

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [lld] [lldb] [llvm] [mlir] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-03-22 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

LGTM overall, but the CI failure looks real.

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


[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits


@@ -104,7 +104,7 @@ static std::recursive_mutex *g_debugger_list_mutex_ptr =
 nullptr; // NOTE: intentional leak to avoid issues with C++ destructor 
chain
 static Debugger::DebuggerList *g_debugger_list_ptr =
 nullptr; // NOTE: intentional leak to avoid issues with C++ destructor 
chain
-static llvm::ThreadPool *g_thread_pool = nullptr;
+static llvm::DefaultThreadPoolThreadPool *g_thread_pool = nullptr;

joker-eph wrote:

Weirdly this issue wasn't caught in CI!

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


[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph closed 
https://github.com/llvm/llvm-project/pull/83702
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/83702

>From d1dc1dfb1bb601fe90289bf29176c74a38ac5697 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Tue, 5 Mar 2024 10:38:41 -0800
Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC)

The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool
in a subsequent commit.
---
 bolt/lib/Core/ParallelUtilities.cpp   |  4 ++--
 bolt/tools/merge-fdata/merge-fdata.cpp|  2 +-
 .../clang-doc/tool/ClangDocMain.cpp   |  2 +-
 .../tool/FindAllSymbolsMain.cpp   |  2 +-
 clang/lib/Tooling/AllTUsExecution.cpp |  2 +-
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  2 +-
 lld/MachO/Writer.cpp  |  2 +-
 lldb/source/Core/Debugger.cpp |  4 ++--
 llvm/docs/ORCv2.rst   |  2 +-
 .../SpeculativeJIT/SpeculativeJIT.cpp |  2 +-
 llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h |  2 +-
 llvm/include/llvm/Support/ThreadPool.h|  7 +++---
 llvm/lib/CodeGen/ParallelCG.cpp   |  2 +-
 llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp  |  2 +-
 .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp  |  2 +-
 llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp  |  2 +-
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp|  4 ++--
 llvm/lib/LTO/LTO.cpp  |  2 +-
 llvm/lib/LTO/LTOBackend.cpp   |  2 +-
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp |  4 ++--
 llvm/lib/Support/BalancedPartitioning.cpp |  2 +-
 llvm/tools/dsymutil/dsymutil.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageExporterJson.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  4 ++--
 .../tools/llvm-debuginfod/llvm-debuginfod.cpp |  2 +-
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 +-
 llvm/tools/llvm-reduce/deltas/Delta.cpp   |  2 +-
 llvm/unittests/ADT/LazyAtomicPointerTest.cpp  |  4 ++--
 llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++---
 llvm/unittests/Support/ParallelTest.cpp   |  2 +-
 llvm/unittests/Support/ThreadPool.cpp | 22 +--
 .../Support/ThreadSafeAllocatorTest.cpp   |  6 ++---
 mlir/include/mlir/IR/MLIRContext.h|  2 +-
 mlir/lib/CAPI/IR/Support.cpp  |  2 +-
 mlir/lib/ExecutionEngine/AsyncRuntime.cpp |  2 +-
 mlir/lib/IR/MLIRContext.cpp   |  4 ++--
 37 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 88d9444a6a2ba7..5f5e96e0e7881c 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -49,7 +49,7 @@ namespace ParallelUtilities {
 
 namespace {
 /// A single thread pool that is used to run parallel tasks
-std::unique_ptr ThreadPoolPtr;
+std::unique_ptr ThreadPoolPtr;
 
 unsigned computeCostFor(const BinaryFunction &BF,
 const PredicateTy &SkipPredicate,
@@ -106,7 +106,7 @@ ThreadPoolInterface &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
-  ThreadPoolPtr = std::make_unique(
+  ThreadPoolPtr = std::make_unique(
   llvm::hardware_concurrency(opts::ThreadCount));
   return *ThreadPoolPtr;
 }
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp 
b/bolt/tools/merge-fdata/merge-fdata.cpp
index c6dfd3cfdc56de..f2ac5ad4492ee5 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl 
&Filenames) {
   // least 4 tasks.
   ThreadPoolStrategy S = optimal_concurrency(
   std::max(Filenames.size() / 4, static_cast(1)));
-  ThreadPool Pool(S);
+  DefaultThreadPool Pool(S);
   DenseMap ParsedProfiles(
   Pool.getMaxConcurrency());
   for (const auto &Filename : Filenames)
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 22bdb5de22d871..21b581fa6df2e1 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -238,7 +238,7 @@ Example usage for a project using a compile commands 
database:
   Error = false;
   llvm::sys::Mutex IndexMutex;
   // ExecutorConcurrency is a flag exposed by AllTUsExecution.h
-  llvm::ThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency));
+  llvm::DefaultThreadPool 
Pool(llvm::hardware_concurrency(ExecutorConcurrency));
   for (auto &Group : USRToBitcode) {
 Pool.async([&]() {
   std::vector> Infos;
diff --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 
b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
index b2d0efecc20692..298b02e77cb0aa 100644
--- 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ 
b/clang-tools-extra/clang-include-fixer/find

[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/83702

>From ea79b6037497230b23caf36024a9e6883d3cac04 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Tue, 5 Mar 2024 10:38:41 -0800
Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC)

The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool
in a subsequent commit.
---
 bolt/lib/Core/ParallelUtilities.cpp   |  4 ++--
 bolt/tools/merge-fdata/merge-fdata.cpp|  2 +-
 .../clang-doc/tool/ClangDocMain.cpp   |  2 +-
 .../tool/FindAllSymbolsMain.cpp   |  2 +-
 clang/lib/Tooling/AllTUsExecution.cpp |  2 +-
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  2 +-
 lld/MachO/Writer.cpp  |  2 +-
 lldb/source/Core/Debugger.cpp |  4 ++--
 llvm/docs/ORCv2.rst   |  2 +-
 .../SpeculativeJIT/SpeculativeJIT.cpp |  2 +-
 llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h |  2 +-
 llvm/include/llvm/Support/ThreadPool.h|  7 +++---
 llvm/lib/CodeGen/ParallelCG.cpp   |  2 +-
 llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp  |  2 +-
 .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp  |  2 +-
 llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp  |  2 +-
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp|  4 ++--
 llvm/lib/LTO/LTO.cpp  |  2 +-
 llvm/lib/LTO/LTOBackend.cpp   |  2 +-
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp |  4 ++--
 llvm/lib/Support/BalancedPartitioning.cpp |  2 +-
 llvm/tools/dsymutil/dsymutil.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageExporterJson.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  4 ++--
 .../tools/llvm-debuginfod/llvm-debuginfod.cpp |  2 +-
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 +-
 llvm/tools/llvm-reduce/deltas/Delta.cpp   |  2 +-
 llvm/unittests/ADT/LazyAtomicPointerTest.cpp  |  4 ++--
 llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++---
 llvm/unittests/Support/ParallelTest.cpp   |  2 +-
 llvm/unittests/Support/ThreadPool.cpp | 22 +--
 .../Support/ThreadSafeAllocatorTest.cpp   |  6 ++---
 mlir/include/mlir/IR/MLIRContext.h|  2 +-
 mlir/lib/CAPI/IR/Support.cpp  |  2 +-
 mlir/lib/ExecutionEngine/AsyncRuntime.cpp |  2 +-
 mlir/lib/IR/MLIRContext.cpp   |  4 ++--
 37 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 88d9444a6a2ba7..5f5e96e0e7881c 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -49,7 +49,7 @@ namespace ParallelUtilities {
 
 namespace {
 /// A single thread pool that is used to run parallel tasks
-std::unique_ptr ThreadPoolPtr;
+std::unique_ptr ThreadPoolPtr;
 
 unsigned computeCostFor(const BinaryFunction &BF,
 const PredicateTy &SkipPredicate,
@@ -106,7 +106,7 @@ ThreadPoolInterface &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
-  ThreadPoolPtr = std::make_unique(
+  ThreadPoolPtr = std::make_unique(
   llvm::hardware_concurrency(opts::ThreadCount));
   return *ThreadPoolPtr;
 }
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp 
b/bolt/tools/merge-fdata/merge-fdata.cpp
index c6dfd3cfdc56de..f2ac5ad4492ee5 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl 
&Filenames) {
   // least 4 tasks.
   ThreadPoolStrategy S = optimal_concurrency(
   std::max(Filenames.size() / 4, static_cast(1)));
-  ThreadPool Pool(S);
+  DefaultThreadPool Pool(S);
   DenseMap ParsedProfiles(
   Pool.getMaxConcurrency());
   for (const auto &Filename : Filenames)
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 22bdb5de22d871..21b581fa6df2e1 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -238,7 +238,7 @@ Example usage for a project using a compile commands 
database:
   Error = false;
   llvm::sys::Mutex IndexMutex;
   // ExecutorConcurrency is a flag exposed by AllTUsExecution.h
-  llvm::ThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency));
+  llvm::DefaultThreadPool 
Pool(llvm::hardware_concurrency(ExecutorConcurrency));
   for (auto &Group : USRToBitcode) {
 Pool.async([&]() {
   std::vector> Infos;
diff --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 
b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
index b2d0efecc20692..298b02e77cb0aa 100644
--- 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ 
b/clang-tools-extra/clang-include-fixer/find

[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/83702

>From 1b407d9d5abc9a1cf58afaf7f32ed40446d55f52 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Tue, 5 Mar 2024 10:38:41 -0800
Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC)

The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool
in a subsequent commit.
---
 bolt/lib/Core/ParallelUtilities.cpp   |  4 ++--
 bolt/tools/merge-fdata/merge-fdata.cpp|  2 +-
 .../clang-doc/tool/ClangDocMain.cpp   |  2 +-
 .../tool/FindAllSymbolsMain.cpp   |  2 +-
 clang/lib/Tooling/AllTUsExecution.cpp |  2 +-
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  2 +-
 lld/MachO/Writer.cpp  |  2 +-
 lldb/source/Core/Debugger.cpp |  4 ++--
 llvm/docs/ORCv2.rst   |  2 +-
 .../SpeculativeJIT/SpeculativeJIT.cpp |  2 +-
 llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h |  2 +-
 llvm/include/llvm/Support/ThreadPool.h|  7 +++---
 llvm/lib/CodeGen/ParallelCG.cpp   |  2 +-
 llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp  |  2 +-
 .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp  |  2 +-
 llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp  |  2 +-
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp|  4 ++--
 llvm/lib/LTO/LTO.cpp  |  2 +-
 llvm/lib/LTO/LTOBackend.cpp   |  2 +-
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp |  4 ++--
 llvm/lib/Support/BalancedPartitioning.cpp |  2 +-
 llvm/tools/dsymutil/dsymutil.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageExporterJson.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  4 ++--
 .../tools/llvm-debuginfod/llvm-debuginfod.cpp |  2 +-
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 +-
 llvm/tools/llvm-reduce/deltas/Delta.cpp   |  2 +-
 llvm/unittests/ADT/LazyAtomicPointerTest.cpp  |  4 ++--
 llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++---
 llvm/unittests/Support/ParallelTest.cpp   |  2 +-
 llvm/unittests/Support/ThreadPool.cpp | 22 +--
 .../Support/ThreadSafeAllocatorTest.cpp   |  6 ++---
 mlir/include/mlir/IR/MLIRContext.h|  2 +-
 mlir/lib/CAPI/IR/Support.cpp  |  2 +-
 mlir/lib/ExecutionEngine/AsyncRuntime.cpp |  2 +-
 mlir/lib/IR/MLIRContext.cpp   |  4 ++--
 37 files changed, 65 insertions(+), 66 deletions(-)

diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 88d9444a6a2ba7..5f5e96e0e7881c 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -49,7 +49,7 @@ namespace ParallelUtilities {
 
 namespace {
 /// A single thread pool that is used to run parallel tasks
-std::unique_ptr ThreadPoolPtr;
+std::unique_ptr ThreadPoolPtr;
 
 unsigned computeCostFor(const BinaryFunction &BF,
 const PredicateTy &SkipPredicate,
@@ -106,7 +106,7 @@ ThreadPoolInterface &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
-  ThreadPoolPtr = std::make_unique(
+  ThreadPoolPtr = std::make_unique(
   llvm::hardware_concurrency(opts::ThreadCount));
   return *ThreadPoolPtr;
 }
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp 
b/bolt/tools/merge-fdata/merge-fdata.cpp
index c6dfd3cfdc56de..f2ac5ad4492ee5 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl 
&Filenames) {
   // least 4 tasks.
   ThreadPoolStrategy S = optimal_concurrency(
   std::max(Filenames.size() / 4, static_cast(1)));
-  ThreadPool Pool(S);
+  DefaultThreadPool Pool(S);
   DenseMap ParsedProfiles(
   Pool.getMaxConcurrency());
   for (const auto &Filename : Filenames)
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 22bdb5de22d871..21b581fa6df2e1 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -238,7 +238,7 @@ Example usage for a project using a compile commands 
database:
   Error = false;
   llvm::sys::Mutex IndexMutex;
   // ExecutorConcurrency is a flag exposed by AllTUsExecution.h
-  llvm::ThreadPool Pool(llvm::hardware_concurrency(ExecutorConcurrency));
+  llvm::DefaultThreadPool 
Pool(llvm::hardware_concurrency(ExecutorConcurrency));
   for (auto &Group : USRToBitcode) {
 Pool.async([&]() {
   std::vector> Infos;
diff --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 
b/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
index b2d0efecc20692..298b02e77cb0aa 100644
--- 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ 
b/clang-tools-extra/clang-include-fixer/find

[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/83702
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

Actually no: the first patch landed already, so `ThreadPoolInterface` is now 
the base class in the codebase. I have some mixup here in that when renaming 
ThreadPool -> DefaultThreadPool, I used the base class ThreadPoolInterface when 
updating some of the uses.

I will push these ahead as a NFC change and rebase, that'll reduce the diff 
here.

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


[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

I did the first part of the renaming @dwblaikie : looks good?

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


[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/83702

>From f961f22a3643673c1f3a040715dcfa2887ee1dca Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Mon, 4 Mar 2024 23:21:04 -0800
Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC)

The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool
in a subsequent commit.
---
 bolt/include/bolt/Core/ParallelUtilities.h|  4 ++--
 bolt/lib/Core/ParallelUtilities.cpp   | 10 -
 bolt/lib/Passes/IdenticalCodeFolding.cpp  |  2 +-
 bolt/lib/Rewrite/DWARFRewriter.cpp|  2 +-
 bolt/tools/merge-fdata/merge-fdata.cpp|  2 +-
 .../clang-doc/tool/ClangDocMain.cpp   |  2 +-
 .../tool/FindAllSymbolsMain.cpp   |  2 +-
 clang/lib/Tooling/AllTUsExecution.cpp |  2 +-
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  2 +-
 lld/MachO/Writer.cpp  |  2 +-
 lldb/source/Core/Debugger.cpp |  4 ++--
 llvm/docs/ORCv2.rst   |  2 +-
 .../SpeculativeJIT/SpeculativeJIT.cpp |  2 +-
 llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h |  2 +-
 llvm/include/llvm/Support/ThreadPool.h|  7 +++---
 llvm/lib/CodeGen/ParallelCG.cpp   |  2 +-
 llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp  |  2 +-
 .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp  |  2 +-
 llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp  |  2 +-
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp|  4 ++--
 llvm/lib/LTO/LTO.cpp  |  2 +-
 llvm/lib/LTO/LTOBackend.cpp   |  2 +-
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp |  4 ++--
 llvm/lib/Support/BalancedPartitioning.cpp |  2 +-
 llvm/tools/dsymutil/dsymutil.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageExporterJson.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  4 ++--
 .../tools/llvm-debuginfod/llvm-debuginfod.cpp |  2 +-
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 +-
 llvm/tools/llvm-reduce/deltas/Delta.cpp   |  6 ++---
 llvm/unittests/ADT/LazyAtomicPointerTest.cpp  |  4 ++--
 llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++---
 llvm/unittests/Support/ParallelTest.cpp   |  2 +-
 llvm/unittests/Support/ThreadPool.cpp | 22 +--
 .../Support/ThreadSafeAllocatorTest.cpp   |  6 ++---
 mlir/include/mlir/IR/MLIRContext.h|  2 +-
 mlir/lib/CAPI/IR/Support.cpp  |  2 +-
 mlir/lib/ExecutionEngine/AsyncRuntime.cpp |  4 ++--
 mlir/lib/IR/MLIRContext.cpp   |  4 ++--
 40 files changed, 75 insertions(+), 76 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index e510525bc51d00..e7b35a79acc78c 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -49,8 +49,8 @@ enum SchedulingPolicy {
   SP_BB_QUADRATIC,   /// cost is estimated by the square of the BB count
 };
 
-/// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+/// Return the managed thread pool and initialize it if not initialized.
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 1a28bc4346ecd5..5f5e96e0e7881c 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -49,7 +49,7 @@ namespace ParallelUtilities {
 
 namespace {
 /// A single thread pool that is used to run parallel tasks
-std::unique_ptr ThreadPoolPtr;
+std::unique_ptr ThreadPoolPtr;
 
 unsigned computeCostFor(const BinaryFunction &BF,
 const PredicateTy &SkipPredicate,
@@ -102,11 +102,11 @@ inline unsigned estimateTotalCost(const BinaryContext &BC,
 
 } // namespace
 
-ThreadPool &getThreadPool() {
+ThreadPoolInterface &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
-  ThreadPoolPtr = std::make_unique(
+  ThreadPoolPtr = std::make_unique(
   llvm::hardware_concurrency(opts::ThreadCount));
   return *ThreadPoolPtr;
 }
@@ -145,7 +145,7 @@ void runOnEachFunction(BinaryContext &BC, SchedulingPolicy 
SchedPolicy,
   TotalCost > BlocksCount ? TotalCost / BlocksCount : 1;
 
   // Divide work into blocks of equal cost
-  ThreadPool &Pool = getThreadPool();
+  ThreadPoolInterface &Pool = getThreadPool();
   auto BlockBegin = BC.getBinaryFunctions().begin();
   unsigned CurrentCost = 0;
 
@@ -202,7 +202,7 @@ void runOnEachFunctionWithUniqueAllocId(
   TotalCost > BlocksCount ? TotalCost / BlocksCount : 1;
 
   // Divide work into blocks of equal cost
-  ThreadPool &Pool = getThreadPool();
+  ThreadPoolInterface &Pool = getThreadPool();
   auto BlockBegin = BC.get

[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/83702

>From 41e5c286c29a4fea65f6116f6844b44a3847f9db Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Mon, 4 Mar 2024 23:21:04 -0800
Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC)

The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool
in a subsequent commit.
---
 bolt/include/bolt/Core/ParallelUtilities.h|  4 ++--
 bolt/lib/Core/ParallelUtilities.cpp   | 10 -
 bolt/lib/Passes/IdenticalCodeFolding.cpp  |  2 +-
 bolt/lib/Rewrite/DWARFRewriter.cpp|  2 +-
 bolt/tools/merge-fdata/merge-fdata.cpp|  2 +-
 .../clang-doc/tool/ClangDocMain.cpp   |  2 +-
 .../tool/FindAllSymbolsMain.cpp   |  2 +-
 clang/lib/Tooling/AllTUsExecution.cpp |  2 +-
 lld/MachO/Writer.cpp  |  2 +-
 lldb/source/Core/Debugger.cpp |  2 +-
 llvm/docs/ORCv2.rst   |  2 +-
 .../SpeculativeJIT/SpeculativeJIT.cpp |  2 +-
 llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h |  2 +-
 llvm/include/llvm/Support/ThreadPool.h|  7 +++---
 llvm/lib/CodeGen/ParallelCG.cpp   |  2 +-
 llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp  |  2 +-
 .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp  |  2 +-
 llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp  |  2 +-
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp|  4 ++--
 llvm/lib/LTO/LTO.cpp  |  2 +-
 llvm/lib/LTO/LTOBackend.cpp   |  2 +-
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp |  4 ++--
 llvm/lib/Support/BalancedPartitioning.cpp |  2 +-
 llvm/tools/dsymutil/dsymutil.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageExporterJson.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  4 ++--
 .../tools/llvm-debuginfod/llvm-debuginfod.cpp |  2 +-
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 +-
 llvm/tools/llvm-reduce/deltas/Delta.cpp   |  6 ++---
 llvm/unittests/ADT/LazyAtomicPointerTest.cpp  |  4 ++--
 llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++---
 llvm/unittests/Support/ParallelTest.cpp   |  2 +-
 llvm/unittests/Support/ThreadPool.cpp | 22 +--
 .../Support/ThreadSafeAllocatorTest.cpp   |  6 ++---
 mlir/lib/CAPI/IR/Support.cpp  |  2 +-
 mlir/lib/ExecutionEngine/AsyncRuntime.cpp |  4 ++--
 mlir/lib/IR/MLIRContext.cpp   |  4 ++--
 38 files changed, 72 insertions(+), 73 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index e510525bc51d00..e7b35a79acc78c 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -49,8 +49,8 @@ enum SchedulingPolicy {
   SP_BB_QUADRATIC,   /// cost is estimated by the square of the BB count
 };
 
-/// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+/// Return the managed thread pool and initialize it if not initialized.
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 1a28bc4346ecd5..5f5e96e0e7881c 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -49,7 +49,7 @@ namespace ParallelUtilities {
 
 namespace {
 /// A single thread pool that is used to run parallel tasks
-std::unique_ptr ThreadPoolPtr;
+std::unique_ptr ThreadPoolPtr;
 
 unsigned computeCostFor(const BinaryFunction &BF,
 const PredicateTy &SkipPredicate,
@@ -102,11 +102,11 @@ inline unsigned estimateTotalCost(const BinaryContext &BC,
 
 } // namespace
 
-ThreadPool &getThreadPool() {
+ThreadPoolInterface &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
-  ThreadPoolPtr = std::make_unique(
+  ThreadPoolPtr = std::make_unique(
   llvm::hardware_concurrency(opts::ThreadCount));
   return *ThreadPoolPtr;
 }
@@ -145,7 +145,7 @@ void runOnEachFunction(BinaryContext &BC, SchedulingPolicy 
SchedPolicy,
   TotalCost > BlocksCount ? TotalCost / BlocksCount : 1;
 
   // Divide work into blocks of equal cost
-  ThreadPool &Pool = getThreadPool();
+  ThreadPoolInterface &Pool = getThreadPool();
   auto BlockBegin = BC.getBinaryFunctions().begin();
   unsigned CurrentCost = 0;
 
@@ -202,7 +202,7 @@ void runOnEachFunctionWithUniqueAllocId(
   TotalCost > BlocksCount ? TotalCost / BlocksCount : 1;
 
   // Divide work into blocks of equal cost
-  ThreadPool &Pool = getThreadPool();
+  ThreadPoolInterface &Pool = getThreadPool();
   auto BlockBegin = BC.getBinaryFunctions().begin();
   unsigned CurrentCost = 0;
   unsigned AllocId = 1;
diff --git a/bolt/lib/Passes/Id

[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/83702
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/83702
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename ThreadPool->DefaultThreadPool and ThreadPoolInterface->ThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/83702

>From 08a5dde36450c99137c7b03bec503daca18bc2d2 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Mon, 4 Mar 2024 23:21:04 -0800
Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC)

The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool
in a subsequent commit.
---
 bolt/include/bolt/Core/ParallelUtilities.h|  4 ++--
 bolt/lib/Core/ParallelUtilities.cpp   | 10 -
 bolt/lib/Passes/IdenticalCodeFolding.cpp  |  2 +-
 bolt/lib/Rewrite/DWARFRewriter.cpp|  2 +-
 bolt/tools/merge-fdata/merge-fdata.cpp|  2 +-
 lld/MachO/Writer.cpp  |  2 +-
 lldb/source/Core/Debugger.cpp |  2 +-
 llvm/docs/ORCv2.rst   |  2 +-
 .../SpeculativeJIT/SpeculativeJIT.cpp |  2 +-
 llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h |  2 +-
 llvm/include/llvm/Support/ThreadPool.h|  7 +++---
 llvm/lib/CodeGen/ParallelCG.cpp   |  2 +-
 llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp  |  2 +-
 .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp  |  2 +-
 llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp  |  2 +-
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp|  4 ++--
 llvm/lib/LTO/LTO.cpp  |  2 +-
 llvm/lib/LTO/LTOBackend.cpp   |  2 +-
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp |  4 ++--
 llvm/lib/Support/BalancedPartitioning.cpp |  2 +-
 llvm/tools/dsymutil/dsymutil.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageExporterJson.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  4 ++--
 .../tools/llvm-debuginfod/llvm-debuginfod.cpp |  2 +-
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 +-
 llvm/tools/llvm-reduce/deltas/Delta.cpp   |  6 ++---
 llvm/unittests/ADT/LazyAtomicPointerTest.cpp  |  4 ++--
 llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++---
 llvm/unittests/Support/ParallelTest.cpp   |  2 +-
 llvm/unittests/Support/ThreadPool.cpp | 22 +--
 .../Support/ThreadSafeAllocatorTest.cpp   |  6 ++---
 mlir/lib/CAPI/IR/Support.cpp  |  2 +-
 mlir/lib/ExecutionEngine/AsyncRuntime.cpp |  4 ++--
 mlir/lib/IR/MLIRContext.cpp   |  4 ++--
 35 files changed, 69 insertions(+), 70 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index e510525bc51d00..e7b35a79acc78c 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -49,8 +49,8 @@ enum SchedulingPolicy {
   SP_BB_QUADRATIC,   /// cost is estimated by the square of the BB count
 };
 
-/// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+/// Return the managed thread pool and initialize it if not initialized.
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 1a28bc4346ecd5..5f5e96e0e7881c 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -49,7 +49,7 @@ namespace ParallelUtilities {
 
 namespace {
 /// A single thread pool that is used to run parallel tasks
-std::unique_ptr ThreadPoolPtr;
+std::unique_ptr ThreadPoolPtr;
 
 unsigned computeCostFor(const BinaryFunction &BF,
 const PredicateTy &SkipPredicate,
@@ -102,11 +102,11 @@ inline unsigned estimateTotalCost(const BinaryContext &BC,
 
 } // namespace
 
-ThreadPool &getThreadPool() {
+ThreadPoolInterface &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
-  ThreadPoolPtr = std::make_unique(
+  ThreadPoolPtr = std::make_unique(
   llvm::hardware_concurrency(opts::ThreadCount));
   return *ThreadPoolPtr;
 }
@@ -145,7 +145,7 @@ void runOnEachFunction(BinaryContext &BC, SchedulingPolicy 
SchedPolicy,
   TotalCost > BlocksCount ? TotalCost / BlocksCount : 1;
 
   // Divide work into blocks of equal cost
-  ThreadPool &Pool = getThreadPool();
+  ThreadPoolInterface &Pool = getThreadPool();
   auto BlockBegin = BC.getBinaryFunctions().begin();
   unsigned CurrentCost = 0;
 
@@ -202,7 +202,7 @@ void runOnEachFunctionWithUniqueAllocId(
   TotalCost > BlocksCount ? TotalCost / BlocksCount : 1;
 
   // Divide work into blocks of equal cost
-  ThreadPool &Pool = getThreadPool();
+  ThreadPoolInterface &Pool = getThreadPool();
   auto BlockBegin = BC.getBinaryFunctions().begin();
   unsigned CurrentCost = 0;
   unsigned AllocId = 1;
diff --git a/bolt/lib/Passes/IdenticalCodeFolding.cpp 
b/bolt/lib/Passes/IdenticalCodeFolding.cpp
index 9f8d82b05ccf48..87eba10354a37b 100644
--- a/bolt/lib/Passes/IdenticalCodeFolding.cpp
+++ b/b

[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename ThreadPool->DefaultThreadPool and ThreadPoolInterface->ThreadPool (NFC) (PR #83702)

2024-03-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/83702

>From 5f657d872a78af9fb0035fc2f04dfa7ead7abadd Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Mon, 4 Mar 2024 23:21:04 -0800
Subject: [PATCH] Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC)

The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool
in a subsequent commit.
---
 bolt/lib/Core/ParallelUtilities.cpp   |  2 +-
 bolt/tools/merge-fdata/merge-fdata.cpp|  2 +-
 lld/MachO/Writer.cpp  |  2 +-
 lldb/source/Core/Debugger.cpp |  2 +-
 llvm/docs/ORCv2.rst   |  2 +-
 .../SpeculativeJIT/SpeculativeJIT.cpp |  2 +-
 llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h |  2 +-
 llvm/include/llvm/Support/ThreadPool.h|  7 +++---
 llvm/lib/CodeGen/ParallelCG.cpp   |  2 +-
 llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp  |  2 +-
 .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp  |  2 +-
 llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp  |  2 +-
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp|  4 ++--
 llvm/lib/LTO/LTO.cpp  |  2 +-
 llvm/lib/LTO/LTOBackend.cpp   |  2 +-
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp |  4 ++--
 llvm/lib/Support/BalancedPartitioning.cpp |  2 +-
 llvm/tools/dsymutil/dsymutil.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageExporterJson.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  4 ++--
 .../tools/llvm-debuginfod/llvm-debuginfod.cpp |  2 +-
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 +-
 llvm/tools/llvm-reduce/deltas/Delta.cpp   |  6 ++---
 llvm/unittests/ADT/LazyAtomicPointerTest.cpp  |  4 ++--
 llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++---
 llvm/unittests/Support/ParallelTest.cpp   |  2 +-
 llvm/unittests/Support/ThreadPool.cpp | 22 +--
 .../Support/ThreadSafeAllocatorTest.cpp   |  6 ++---
 mlir/lib/CAPI/IR/Support.cpp  |  2 +-
 mlir/lib/ExecutionEngine/AsyncRuntime.cpp |  4 ++--
 mlir/lib/IR/MLIRContext.cpp   |  4 ++--
 32 files changed, 61 insertions(+), 62 deletions(-)

diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 1a28bc4346ecd5..1f5ac5655d9f98 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -106,7 +106,7 @@ ThreadPool &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
-  ThreadPoolPtr = std::make_unique(
+  ThreadPoolPtr = std::make_unique(
   llvm::hardware_concurrency(opts::ThreadCount));
   return *ThreadPoolPtr;
 }
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp 
b/bolt/tools/merge-fdata/merge-fdata.cpp
index c6dfd3cfdc56de..f2ac5ad4492ee5 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl 
&Filenames) {
   // least 4 tasks.
   ThreadPoolStrategy S = optimal_concurrency(
   std::max(Filenames.size() / 4, static_cast(1)));
-  ThreadPool Pool(S);
+  DefaultThreadPool Pool(S);
   DenseMap ParsedProfiles(
   Pool.getMaxConcurrency());
   for (const auto &Filename : Filenames)
diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index 65b598d1d7c422..9b0a32c136e8b1 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -66,7 +66,7 @@ class Writer {
 
   template  void run();
 
-  ThreadPool threadPool;
+  DefaultThreadPool threadPool;
   std::unique_ptr &buffer;
   uint64_t addr = 0;
   uint64_t fileOff = 0;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 1b25527abf981f..a28d639fa34050 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -609,7 +609,7 @@ void Debugger::Initialize(LoadPluginCallbackType 
load_plugin_callback) {
  "Debugger::Initialize called more than once!");
   g_debugger_list_mutex_ptr = new std::recursive_mutex();
   g_debugger_list_ptr = new DebuggerList();
-  g_thread_pool = new llvm::ThreadPool(llvm::optimal_concurrency());
+  g_thread_pool = new llvm::DefaultThreadPool(llvm::optimal_concurrency());
   g_load_plugin_callback = load_plugin_callback;
 }
 
diff --git a/llvm/docs/ORCv2.rst b/llvm/docs/ORCv2.rst
index add05e05a80e5f..910ef5b9f3d02f 100644
--- a/llvm/docs/ORCv2.rst
+++ b/llvm/docs/ORCv2.rst
@@ -738,7 +738,7 @@ or creating any Modules attached to it. E.g.
 
 ThreadSafeContext TSCtx(std::make_unique());
 
-ThreadPool TP(NumThreads);
+DefaultThreadPool TP(NumThreads);
 JITStack J;
 
 for (auto &ModulePath : ModulePaths) {
diff --git a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp 
b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
index fdd376d82da5d8..0d97d379d2279e 100644
--- a/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp
+++ b/llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp

[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename ThreadPool->DefaultThreadPool and ThreadPoolInterface->ThreadPool (NFC) (PR #83702)

2024-03-04 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

> One patch ThreadPool->DefaultThreadPool (people get a build error about 
> ThreadPool not being the name of anything, find this patch as the root cause, 
> and rename all their ThreadPool->DefaultThreadPool)

Gotcha, thanks for elaborating, somehow my brain was slow on a Monday.
Will look into this!

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


[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename ThreadPool->DefaultThreadPool and ThreadPoolInterface->ThreadPool (NFC) (PR #83702)

2024-03-04 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

@dwblaikie : how would you split it? I didn't quite get the two renamings you 
have in mind?

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


[Lldb-commits] [lldb] e52650c - Fix LLDB build after renaming the base class for ThreadPool to ThreadPoolInterface

2024-03-02 Thread Mehdi Amini via lldb-commits

Author: Mehdi Amini
Date: 2024-03-02T19:30:33-08:00
New Revision: e52650cfc3aa5d134186c5a8fd6701a6fd0a1051

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

LOG: Fix LLDB build after renaming the base class for ThreadPool to 
ThreadPoolInterface

The header was updated but not the implementation.

Added: 


Modified: 
lldb/source/Core/Debugger.cpp

Removed: 




diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 217474d1060ac2..1b25527abf981f 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2195,7 +2195,7 @@ Status Debugger::RunREPL(LanguageType language, const 
char *repl_options) {
   return err;
 }
 
-llvm::ThreadPool &Debugger::GetThreadPool() {
+llvm::ThreadPoolInterface &Debugger::GetThreadPool() {
   assert(g_thread_pool &&
  "Debugger::GetThreadPool called before Debugger::Initialize");
   return *g_thread_pool;



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


[Lldb-commits] [lld] [lldb] [llvm] [mlir] Rename ThreadPool->DefaultThreadPool and ThreadPoolInterface->ThreadPool (NFC) (PR #83702)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph created 
https://github.com/llvm/llvm-project/pull/83702

This is a breaking change: clients who use to create a ThreadPool must now 
create a DefaultThreadPool.

>From aec355378bcb453adc4d697b02c69af30eb5f0ae Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Tue, 27 Feb 2024 00:31:04 -0800
Subject: [PATCH] Rename ThreadPool->DefaultThreadPool and
 ThreadPoolInterface->ThreadPool (NFC)

---
 bolt/lib/Core/ParallelUtilities.cpp   |  2 +-
 bolt/tools/merge-fdata/merge-fdata.cpp|  2 +-
 lld/MachO/Writer.cpp  |  2 +-
 lldb/include/lldb/Core/Debugger.h |  4 ++--
 lldb/source/Core/Debugger.cpp |  2 +-
 llvm/docs/ORCv2.rst   |  2 +-
 .../SpeculativeJIT/SpeculativeJIT.cpp |  2 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |  6 ++---
 .../llvm/Support/BalancedPartitioning.h   |  7 +++---
 llvm/include/llvm/Support/ThreadPool.h| 19 
 llvm/lib/CodeGen/ParallelCG.cpp   |  2 +-
 llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp  |  2 +-
 .../DWARFLinker/Parallel/DWARFLinkerImpl.cpp  |  2 +-
 llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp  |  2 +-
 llvm/lib/Debuginfod/Debuginfod.cpp|  3 +--
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp|  4 ++--
 llvm/lib/LTO/LTO.cpp  |  2 +-
 llvm/lib/LTO/LTOBackend.cpp   |  2 +-
 llvm/lib/LTO/ThinLTOCodeGenerator.cpp |  4 ++--
 llvm/lib/Support/BalancedPartitioning.cpp |  2 +-
 llvm/lib/Support/ThreadPool.cpp   |  2 +-
 llvm/tools/dsymutil/dsymutil.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageExporterJson.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  4 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |  4 ++--
 .../tools/llvm-debuginfod/llvm-debuginfod.cpp |  2 +-
 llvm/tools/llvm-profdata/llvm-profdata.cpp|  2 +-
 llvm/tools/llvm-reduce/deltas/Delta.cpp   |  2 +-
 llvm/unittests/ADT/LazyAtomicPointerTest.cpp  |  4 ++--
 llvm/unittests/Debuginfod/HTTPServerTests.cpp | 16 +++---
 llvm/unittests/Support/ParallelTest.cpp   |  2 +-
 llvm/unittests/Support/ThreadPool.cpp | 22 +--
 .../Support/ThreadSafeAllocatorTest.cpp   |  6 ++---
 mlir/include/mlir/CAPI/Support.h  |  4 ++--
 mlir/include/mlir/IR/MLIRContext.h|  6 ++---
 mlir/include/mlir/IR/Threading.h  |  2 +-
 mlir/lib/CAPI/IR/Support.cpp  |  2 +-
 mlir/lib/ExecutionEngine/AsyncRuntime.cpp |  2 +-
 mlir/lib/IR/MLIRContext.cpp   | 12 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |  4 ++--
 41 files changed, 87 insertions(+), 90 deletions(-)

diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 1a28bc4346ecd56..1f5ac5655d9f98d 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -106,7 +106,7 @@ ThreadPool &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
-  ThreadPoolPtr = std::make_unique(
+  ThreadPoolPtr = std::make_unique(
   llvm::hardware_concurrency(opts::ThreadCount));
   return *ThreadPoolPtr;
 }
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp 
b/bolt/tools/merge-fdata/merge-fdata.cpp
index c6dfd3cfdc56dea..f2ac5ad4492ee52 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -316,7 +316,7 @@ void mergeLegacyProfiles(const SmallVectorImpl 
&Filenames) {
   // least 4 tasks.
   ThreadPoolStrategy S = optimal_concurrency(
   std::max(Filenames.size() / 4, static_cast(1)));
-  ThreadPool Pool(S);
+  DefaultThreadPool Pool(S);
   DenseMap ParsedProfiles(
   Pool.getMaxConcurrency());
   for (const auto &Filename : Filenames)
diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp
index 65b598d1d7c422a..9b0a32c136e8b17 100644
--- a/lld/MachO/Writer.cpp
+++ b/lld/MachO/Writer.cpp
@@ -66,7 +66,7 @@ class Writer {
 
   template  void run();
 
-  ThreadPool threadPool;
+  DefaultThreadPool threadPool;
   std::unique_ptr &buffer;
   uint64_t addr = 0;
   uint64_t fileOff = 0;
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 418c2403d020f48..9c5ea22242f18d3 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPoolInterface;
+class ThreadPool;
 } // namespace llvm
 
 namespace lldb_private {
@@ -500,7 +500,7 @@ class Debugger : public 
std::enable_shared_from_this,
   }
 
   /// Shared thread pool. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPoolInterface &GetThreadPool();
+  static llvm::ThreadPool &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 217474d1060ac28..c4b3c64e084

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph closed 
https://github.com/llvm/llvm-project/pull/82094
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From 5f47d05b0310ffe5b20b972c507bce09399aec77 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 184 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 116 ++-
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 228 insertions(+), 169 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..e510525bc51d00 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -18,6 +18,7 @@
 
 #include "bolt/Core/MCPlusBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ThreadPool.h"
 
 using namespace llvm;
 
@@ -28,8 +29,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
-
 namespace bolt {
 class BinaryContext;
 class BinaryFunction;
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index b65ec1029ab24b..418c2403d020f4 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
 std::condition_variable cv;
 /// The number of threads that could spawn more threads
@@ -128,7 +128,8 @@ class BalancedPartitioning {
 /// acc

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From 375add7f2ea7c8aa805c022936e7b65fdefe80b6 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 184 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 118 ++-
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 230 insertions(+), 169 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..e510525bc51d00 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -18,6 +18,7 @@
 
 #include "bolt/Core/MCPlusBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ThreadPool.h"
 
 using namespace llvm;
 
@@ -28,8 +29,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
-
 namespace bolt {
 class BinaryContext;
 class BinaryFunction;
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index b65ec1029ab24b..418c2403d020f4 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
 std::condition_variable cv;
 /// The number of threads that could spawn more threads
@@ -128,7 +128,8 @@ class BalancedPartitioning {
 /// acc

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From 6864303679435f51ce899e348e49bfd11eb4146f Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 184 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 112 +++
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 227 insertions(+), 166 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..e510525bc51d00 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -18,6 +18,7 @@
 
 #include "bolt/Core/MCPlusBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ThreadPool.h"
 
 using namespace llvm;
 
@@ -28,8 +29,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
-
 namespace bolt {
 class BinaryContext;
 class BinaryFunction;
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index b65ec1029ab24b..418c2403d020f4 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
 std::condition_variable cv;
 /// The number of threads that could spawn more threads
@@ -128,7 +128,8 @@ class BalancedPartitioning {
 /// acc

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From d39dfe51ee866a9f45337b015e09d307b0ea994e Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 184 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 112 +++
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 227 insertions(+), 166 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..e510525bc51d00 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -18,6 +18,7 @@
 
 #include "bolt/Core/MCPlusBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ThreadPool.h"
 
 using namespace llvm;
 
@@ -28,8 +29,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
-
 namespace bolt {
 class BinaryContext;
 class BinaryFunction;
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
 std::condition_variable cv;
 /// The number of threads that could spawn more threads
@@ -128,7 +128,8 @@ class BalancedPartitioning {
 /// acc

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From 41404ed9b7038d712d18b0e16896fae66a954f87 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 184 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 109 +++
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 225 insertions(+), 165 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..e510525bc51d00 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -18,6 +18,7 @@
 
 #include "bolt/Core/MCPlusBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ThreadPool.h"
 
 using namespace llvm;
 
@@ -28,8 +29,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
-
 namespace bolt {
 class BinaryContext;
 class BinaryFunction;
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
 std::condition_variable cv;
 /// The number of threads that could spawn more threads
@@ -128,7 +128,8 @@ class BalancedPartitioning {
 /// acc

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From 5851f2980e699f7265bf556ea1889a63f080dc4d Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   6 +-
 bolt/lib/Core/ParallelUtilities.cpp   |   2 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 184 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 109 +++
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 17 files changed, 228 insertions(+), 167 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..105bcde32f78b4 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -18,6 +18,7 @@
 
 #include "bolt/Core/MCPlusBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ThreadPool.h"
 
 using namespace llvm;
 
@@ -28,8 +29,7 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
-
+class ThreadPoolInterface;
 namespace bolt {
 class BinaryContext;
 class BinaryFunction;
@@ -51,7 +51,7 @@ enum SchedulingPolicy {
 };
 
 /// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/bolt/lib/Core/ParallelUtilities.cpp 
b/bolt/lib/Core/ParallelUtilities.cpp
index 1a28bc4346ecd5..5c66a841a84630 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -102,7 +102,7 @@ inline unsigned estimateTotalCost(const BinaryContext &BC,
 
 } // namespace
 
-ThreadPool &getThreadPool() {
+ThreadPoolInterface &getThreadPool() {
   if (ThreadPoolPtr.get())
 return *ThreadPoolPtr;
 
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/ll

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From eb630caf1bb9689f23c1f7dfe62a80f4c276da0d Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   6 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 184 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 109 +++
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 227 insertions(+), 166 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..105bcde32f78b4 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -18,6 +18,7 @@
 
 #include "bolt/Core/MCPlusBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ThreadPool.h"
 
 using namespace llvm;
 
@@ -28,8 +29,7 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
-
+class ThreadPoolInterface;
 namespace bolt {
 class BinaryContext;
 class BinaryFunction;
@@ -51,7 +51,7 @@ enum SchedulingPolicy {
 };
 
 /// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// 

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits


@@ -92,30 +104,32 @@ class ThreadPool {
  &Group);
   }
 
-  /// Blocking wait for all the threads to complete and the queue to be empty.
-  /// It is an error to try to add new tasks while blocking on this call.
-  /// Calling wait() from a task would deadlock waiting for itself.
-  void wait();
+private:
+  /// Asynchronous submission of a task to the pool. The returned future can be
+  /// used to wait for the task to finish and is *non-blocking* on destruction.
+  template 
+  std::shared_future asyncImpl(std::function Task,
+  ThreadPoolTaskGroup *Group) {
 
-  /// Blocking wait for only all the threads in the given group to complete.
-  /// It is possible to wait even inside a task, but waiting (directly or
-  /// indirectly) on itself will deadlock. If called from a task running on a
-  /// worker thread, the call may process pending tasks while waiting in order
-  /// not to waste the thread.
-  void wait(ThreadPoolTaskGroup &Group);
+#if LLVM_ENABLE_THREADS
+/// Wrap the Task in a std::function that sets the result of the
+/// corresponding future.
+auto R = createTaskAndFuture(Task);
 
-  // Returns the maximum number of worker threads in the pool, not the current
-  // number of threads!
-  unsigned getMaxConcurrency() const { return MaxThreadCount; }
+asyncEnqueue(std::move(R.first), Group);
+return R.second.share();
 
-  // TODO: misleading legacy name warning!
-  LLVM_DEPRECATED("Use getMaxConcurrency instead", "getMaxConcurrency")
-  unsigned getThreadCount() const { return MaxThreadCount; }
+#else // LLVM_ENABLE_THREADS Disabled

joker-eph wrote:

I'll send a follow-up PR for the renaming!

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits


@@ -140,54 +142,74 @@ class ThreadPool {
 },
 std::move(F)};
   }
+};
+
+/// A ThreadPool implementation using std::threads.
+///
+/// The pool keeps a vector of threads alive, waiting on a condition variable
+/// for some work to become available.
+class StdThreadPool : public ThreadPoolInterface {

joker-eph wrote:

Obsolete now that we test both I think, resolving.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From 75c17b79beeb117dbfc407051bb9a7660b69ee62 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 184 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 109 +++
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 225 insertions(+), 165 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..8a95a486113321 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -28,7 +28,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
 
 namespace bolt {
 class BinaryContext;
@@ -51,7 +50,7 @@ enum SchedulingPolicy {
 };
 
 /// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
  

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-01 Thread Mehdi Amini via lldb-commits


@@ -209,25 +231,66 @@ class ThreadPool {
   /// Number of threads active for tasks in the given group (only non-zero).
   DenseMap ActiveGroups;
 
-#if LLVM_ENABLE_THREADS // avoids warning for unused variable
   /// Signal for the destruction of the pool, asking thread to exit.
   bool EnableFlag = true;
-#endif
 
   const ThreadPoolStrategy Strategy;
 
   /// Maximum number of threads to potentially grow this pool to.
   const unsigned MaxThreadCount;
 };
 
+/// A non-threaded implementation.
+class SingleThreadExecutor : public ThreadPoolInterface {

joker-eph wrote:

I just implemented it: now the unit-tests are ran for both the single thread 
and std::thread implementation (except when LLVM_ENABLE_THREADS=OFF, then only 
the single-thread implementation is tested).

Can you take a look?

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-01 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From fa249b44a8bbcbc7b0da148c51acd5792f393869 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 181 +++---
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 107 +++
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 220 insertions(+), 165 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..8a95a486113321 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -28,7 +28,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
 
 namespace bolt {
 class BinaryContext;
@@ -51,7 +50,7 @@ enum SchedulingPolicy {
 };
 
 /// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
  

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-03-01 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From e2a6d2860c21489445a87bfd4ced85108462f601 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 191 --
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 llvm/unittests/Support/ThreadPool.cpp | 103 ++
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 16 files changed, 235 insertions(+), 156 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..8a95a486113321 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -28,7 +28,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
 
 namespace bolt {
 class BinaryContext;
@@ -51,7 +50,7 @@ enum SchedulingPolicy {
 };
 
 /// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
   

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-28 Thread Mehdi Amini via lldb-commits


@@ -209,25 +231,66 @@ class ThreadPool {
   /// Number of threads active for tasks in the given group (only non-zero).
   DenseMap ActiveGroups;
 
-#if LLVM_ENABLE_THREADS // avoids warning for unused variable
   /// Signal for the destruction of the pool, asking thread to exit.
   bool EnableFlag = true;
-#endif
 
   const ThreadPoolStrategy Strategy;
 
   /// Maximum number of threads to potentially grow this pool to.
   const unsigned MaxThreadCount;
 };
 
+/// A non-threaded implementation.
+class SingleThreadExecutor : public ThreadPoolInterface {

joker-eph wrote:

I was trying to use as little as possible so that the code is always at least 
"parsed" and we are less likely to break it (and also my IDE does not gray this 
entirely as a comment because of the macro).

But this is a weak argument, happy to restore a big `#if LLVM_ENABLE_THREADS` 
`#else` around the two classes.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -227,7 +265,7 @@ class ThreadPool {
 class ThreadPoolTaskGroup {

joker-eph wrote:

> Uniqueness is "guaranteed" through memory addressing. Someone can break 
> uniqueness when going through the public ThreadPool API.


How so?

> Type safety; sure you don't have implicit conversions going on.


There is much more than: the API is constrained to say: "it operates on an 
instance of a TaskGroup object".
This is a very important API: it is explicit in terms of the scope on which it 
operates, and the fact that it care about the **actual instance** of the 
TaskGroup object.


> So what I think is that instead of passing *this you can convert the address 
> to a string/int and pass this instead; hence you don't lose any guarantees. I 
> understand your arguments but I find this a bit more decoupled.

As I said above, I would have strong concerns with this: it is a weak API (it 
is open to any integer and does not carry the semantics I described above) and 
"unsafe", just like using `void*`. 
There is not way for a user to know what integer to pass here for example. As a 
user such API is highly confusing and really I'm not sure what the pattern 
would be other than always casting the address of the task group to an int.



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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/82094
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -227,7 +265,7 @@ class ThreadPool {
 class ThreadPoolTaskGroup {

joker-eph wrote:

 > What you get is probably a cleaner API IMHO
 
 I don't quite get why it would cleaner actually? This makes is for a weaker 
interface that does not guarantee any uniqueness and you lose type safety as 
well.
 I must missing your point here.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -227,7 +265,7 @@ class ThreadPool {
 class ThreadPoolTaskGroup {

joker-eph wrote:

> We could change for example this with a std::string or uint64_t with probably 
> minimal changes to any call site.

How would you get a unique id at runtime if not for the address of the object?


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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -92,30 +104,32 @@ class ThreadPool {
  &Group);
   }
 
-  /// Blocking wait for all the threads to complete and the queue to be empty.
-  /// It is an error to try to add new tasks while blocking on this call.
-  /// Calling wait() from a task would deadlock waiting for itself.
-  void wait();
+private:
+  /// Asynchronous submission of a task to the pool. The returned future can be
+  /// used to wait for the task to finish and is *non-blocking* on destruction.
+  template 
+  std::shared_future asyncImpl(std::function Task,
+  ThreadPoolTaskGroup *Group) {
 
-  /// Blocking wait for only all the threads in the given group to complete.
-  /// It is possible to wait even inside a task, but waiting (directly or
-  /// indirectly) on itself will deadlock. If called from a task running on a
-  /// worker thread, the call may process pending tasks while waiting in order
-  /// not to waste the thread.
-  void wait(ThreadPoolTaskGroup &Group);
+#if LLVM_ENABLE_THREADS
+/// Wrap the Task in a std::function that sets the result of the

joker-eph wrote:

removed

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From f13befdfdb8715c034eed6dd4c04f712d30d043a Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 191 --
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 15 files changed, 174 insertions(+), 114 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..8a95a486113321 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -28,7 +28,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
 
 namespace bolt {
 class BinaryContext;
@@ -51,7 +50,7 @@ enum SchedulingPolicy {
 };
 
 /// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
 std::condition_variable cv;
 /// The number of threads tha

[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -92,30 +104,32 @@ class ThreadPool {
  &Group);
   }
 
-  /// Blocking wait for all the threads to complete and the queue to be empty.
-  /// It is an error to try to add new tasks while blocking on this call.
-  /// Calling wait() from a task would deadlock waiting for itself.
-  void wait();
+private:
+  /// Asynchronous submission of a task to the pool. The returned future can be
+  /// used to wait for the task to finish and is *non-blocking* on destruction.
+  template 
+  std::shared_future asyncImpl(std::function Task,
+  ThreadPoolTaskGroup *Group) {
 
-  /// Blocking wait for only all the threads in the given group to complete.
-  /// It is possible to wait even inside a task, but waiting (directly or
-  /// indirectly) on itself will deadlock. If called from a task running on a
-  /// worker thread, the call may process pending tasks while waiting in order
-  /// not to waste the thread.
-  void wait(ThreadPoolTaskGroup &Group);
+#if LLVM_ENABLE_THREADS
+/// Wrap the Task in a std::function that sets the result of the
+/// corresponding future.
+auto R = createTaskAndFuture(Task);
 
-  // Returns the maximum number of worker threads in the pool, not the current
-  // number of threads!
-  unsigned getMaxConcurrency() const { return MaxThreadCount; }
+asyncEnqueue(std::move(R.first), Group);
+return R.second.share();
 
-  // TODO: misleading legacy name warning!
-  LLVM_DEPRECATED("Use getMaxConcurrency instead", "getMaxConcurrency")
-  unsigned getThreadCount() const { return MaxThreadCount; }
+#else // LLVM_ENABLE_THREADS Disabled
 
-  /// Returns true if the current thread is a worker thread of this thread 
pool.
-  bool isWorkerThread() const;
+// Get a Future with launch::deferred execution using std::async

joker-eph wrote:

I removed this now

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -92,30 +104,32 @@ class ThreadPool {
  &Group);
   }
 
-  /// Blocking wait for all the threads to complete and the queue to be empty.
-  /// It is an error to try to add new tasks while blocking on this call.
-  /// Calling wait() from a task would deadlock waiting for itself.
-  void wait();
+private:
+  /// Asynchronous submission of a task to the pool. The returned future can be
+  /// used to wait for the task to finish and is *non-blocking* on destruction.
+  template 
+  std::shared_future asyncImpl(std::function Task,
+  ThreadPoolTaskGroup *Group) {
 
-  /// Blocking wait for only all the threads in the given group to complete.
-  /// It is possible to wait even inside a task, but waiting (directly or
-  /// indirectly) on itself will deadlock. If called from a task running on a
-  /// worker thread, the call may process pending tasks while waiting in order
-  /// not to waste the thread.
-  void wait(ThreadPoolTaskGroup &Group);
+#if LLVM_ENABLE_THREADS
+/// Wrap the Task in a std::function that sets the result of the
+/// corresponding future.
+auto R = createTaskAndFuture(Task);
 
-  // Returns the maximum number of worker threads in the pool, not the current
-  // number of threads!
-  unsigned getMaxConcurrency() const { return MaxThreadCount; }
+asyncEnqueue(std::move(R.first), Group);
+return R.second.share();
 
-  // TODO: misleading legacy name warning!
-  LLVM_DEPRECATED("Use getMaxConcurrency instead", "getMaxConcurrency")
-  unsigned getThreadCount() const { return MaxThreadCount; }
+#else // LLVM_ENABLE_THREADS Disabled

joker-eph wrote:

I can also squash the renaming here @dwblaikie if you feel it's better to not 
do this separately by the way

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/82094
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -227,7 +265,7 @@ class ThreadPool {
 class ThreadPoolTaskGroup {

joker-eph wrote:

> Wouldn't the implemention for ThreadPoolTaskGroup come in hand with the one 
> for ThreadPool? 

Right now the only thing the TaskGroup provide is a unique ID in the form of 
its own address.
I don't quite get what I would change in the implementation? Would you want the 
group to customize its own `wait()`? Right now it dispatches to the threadpool 
implementation: `wait(ThreadPoolTaskGroup &Group)`.

Customizing the task group would require to change the pattern at every use 
site as well: 
https://github.com/llvm/llvm-project/blob/0e0bee26e7f33c065eebef9a674b2f19bb156414/mlir/include/mlir/IR/Threading.h#L69-L70

Instead of:
```
  llvm::ThreadPool &threadPool = context->getThreadPool();
  llvm::ThreadPoolTaskGroup tasksGroup(threadPool);
```
we would need to use the pool as a factory somehow:
```
  llvm::ThreadPool &threadPool = context->getThreadPool();
  std::unique_ptr tasksGroup = 
threadPool.createTaskGroup();
```

I'm not opposed to this, but that still seems like a separate change, and one 
that would better be done when there is somehow with the need for this.

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -92,30 +104,32 @@ class ThreadPool {
  &Group);
   }
 
-  /// Blocking wait for all the threads to complete and the queue to be empty.
-  /// It is an error to try to add new tasks while blocking on this call.
-  /// Calling wait() from a task would deadlock waiting for itself.
-  void wait();
+private:
+  /// Asynchronous submission of a task to the pool. The returned future can be
+  /// used to wait for the task to finish and is *non-blocking* on destruction.
+  template 
+  std::shared_future asyncImpl(std::function Task,
+  ThreadPoolTaskGroup *Group) {
 
-  /// Blocking wait for only all the threads in the given group to complete.
-  /// It is possible to wait even inside a task, but waiting (directly or
-  /// indirectly) on itself will deadlock. If called from a task running on a
-  /// worker thread, the call may process pending tasks while waiting in order
-  /// not to waste the thread.
-  void wait(ThreadPoolTaskGroup &Group);
+#if LLVM_ENABLE_THREADS
+/// Wrap the Task in a std::function that sets the result of the
+/// corresponding future.
+auto R = createTaskAndFuture(Task);
 
-  // Returns the maximum number of worker threads in the pool, not the current
-  // number of threads!
-  unsigned getMaxConcurrency() const { return MaxThreadCount; }
+asyncEnqueue(std::move(R.first), Group);
+return R.second.share();
 
-  // TODO: misleading legacy name warning!
-  LLVM_DEPRECATED("Use getMaxConcurrency instead", "getMaxConcurrency")
-  unsigned getThreadCount() const { return MaxThreadCount; }
+#else // LLVM_ENABLE_THREADS Disabled

joker-eph wrote:

And here: for the followup renaming: 
https://github.com/llvm/llvm-project/commit/12073a1f3de2552a0b5f48930a755d5119fae9e6

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits


@@ -92,30 +104,32 @@ class ThreadPool {
  &Group);
   }
 
-  /// Blocking wait for all the threads to complete and the queue to be empty.
-  /// It is an error to try to add new tasks while blocking on this call.
-  /// Calling wait() from a task would deadlock waiting for itself.
-  void wait();
+private:
+  /// Asynchronous submission of a task to the pool. The returned future can be
+  /// used to wait for the task to finish and is *non-blocking* on destruction.
+  template 
+  std::shared_future asyncImpl(std::function Task,
+  ThreadPoolTaskGroup *Group) {
 
-  /// Blocking wait for only all the threads in the given group to complete.
-  /// It is possible to wait even inside a task, but waiting (directly or
-  /// indirectly) on itself will deadlock. If called from a task running on a
-  /// worker thread, the call may process pending tasks while waiting in order
-  /// not to waste the thread.
-  void wait(ThreadPoolTaskGroup &Group);
+#if LLVM_ENABLE_THREADS
+/// Wrap the Task in a std::function that sets the result of the
+/// corresponding future.
+auto R = createTaskAndFuture(Task);
 
-  // Returns the maximum number of worker threads in the pool, not the current
-  // number of threads!
-  unsigned getMaxConcurrency() const { return MaxThreadCount; }
+asyncEnqueue(std::move(R.first), Group);
+return R.second.share();
 
-  // TODO: misleading legacy name warning!
-  LLVM_DEPRECATED("Use getMaxConcurrency instead", "getMaxConcurrency")
-  unsigned getThreadCount() const { return MaxThreadCount; }
+#else // LLVM_ENABLE_THREADS Disabled

joker-eph wrote:

I just split the implementations, but still using a static `using ThreadPool = 
` declaration, how does this look?

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


[Lldb-commits] [lldb] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an implementation (PR #82094)

2024-02-27 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph updated 
https://github.com/llvm/llvm-project/pull/82094

>From f9f2e9380b1333b3b2503aebb6ee234b84b8c035 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Fri, 16 Feb 2024 21:55:57 -0800
Subject: [PATCH] Split the llvm::ThreadPool into an abstract base class and an
 implementation

This decouples the public API used to enqueue tasks and wait for completion
from the actual implementation, and opens up the possibility for clients to
set their own thread pool implementation for the pool.

https://discourse.llvm.org/t/construct-threadpool-from-vector-of-existing-threads/76883
---
 bolt/include/bolt/Core/ParallelUtilities.h|   3 +-
 lldb/include/lldb/Core/Debugger.h |   6 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h |   6 +-
 .../llvm/Support/BalancedPartitioning.h   |   7 +-
 llvm/include/llvm/Support/ThreadPool.h| 191 --
 llvm/lib/Debuginfod/Debuginfod.cpp|   3 +-
 llvm/lib/Support/ThreadPool.cpp   |  41 ++--
 llvm/tools/llvm-cov/CoverageReport.h  |   4 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.h  |   2 -
 mlir/include/mlir/CAPI/Support.h  |   4 +-
 mlir/include/mlir/IR/MLIRContext.h|   6 +-
 mlir/include/mlir/IR/Threading.h  |   2 +-
 mlir/lib/CAPI/IR/IR.cpp   |   1 +
 mlir/lib/IR/MLIRContext.cpp   |   8 +-
 mlir/lib/Tools/mlir-opt/MlirOptMain.cpp   |   4 +-
 15 files changed, 174 insertions(+), 114 deletions(-)

diff --git a/bolt/include/bolt/Core/ParallelUtilities.h 
b/bolt/include/bolt/Core/ParallelUtilities.h
index 7d3af47757bce6..8a95a486113321 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -28,7 +28,6 @@ extern cl::opt TaskCount;
 } // namespace opts
 
 namespace llvm {
-class ThreadPool;
 
 namespace bolt {
 class BinaryContext;
@@ -51,7 +50,7 @@ enum SchedulingPolicy {
 };
 
 /// Return the managed thread pool and initialize it if not initiliazed.
-ThreadPool &getThreadPool();
+ThreadPoolInterface &getThreadPool();
 
 /// Perform the work on each BinaryFunction except those that are accepted
 /// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 6ba90eb6ed8fdf..66b1e28a9cc618 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -52,7 +52,7 @@
 
 namespace llvm {
 class raw_ostream;
-class ThreadPool;
+class ThreadPoolInterface;
 } // namespace llvm
 
 namespace lldb_private {
@@ -499,8 +499,8 @@ class Debugger : public 
std::enable_shared_from_this,
 return m_broadcaster_manager_sp;
   }
 
-  /// Shared thread poll. Use only with ThreadPoolTaskGroup.
-  static llvm::ThreadPool &GetThreadPool();
+  /// Shared thread pool. Use only with ThreadPoolTaskGroup.
+  static llvm::ThreadPoolInterface &GetThreadPool();
 
   /// Report warning events.
   ///
diff --git a/llvm/include/llvm/Debuginfod/Debuginfod.h 
b/llvm/include/llvm/Debuginfod/Debuginfod.h
index ef03948a706c06..99fe15ad859794 100644
--- a/llvm/include/llvm/Debuginfod/Debuginfod.h
+++ b/llvm/include/llvm/Debuginfod/Debuginfod.h
@@ -97,7 +97,7 @@ Expected getCachedOrDownloadArtifact(
 StringRef UniqueKey, StringRef UrlPath, StringRef CacheDirectoryPath,
 ArrayRef DebuginfodUrls, std::chrono::milliseconds Timeout);
 
-class ThreadPool;
+class ThreadPoolInterface;
 
 struct DebuginfodLogEntry {
   std::string Message;
@@ -135,7 +135,7 @@ class DebuginfodCollection {
   // error.
   Expected updateIfStale();
   DebuginfodLog &Log;
-  ThreadPool &Pool;
+  ThreadPoolInterface &Pool;
   Timer UpdateTimer;
   sys::Mutex UpdateMutex;
 
@@ -145,7 +145,7 @@ class DebuginfodCollection {
 
 public:
   DebuginfodCollection(ArrayRef Paths, DebuginfodLog &Log,
-   ThreadPool &Pool, double MinInterval);
+   ThreadPoolInterface &Pool, double MinInterval);
   Error update();
   Error updateForever(std::chrono::milliseconds Interval);
   Expected findDebugBinaryPath(object::BuildIDRef);
diff --git a/llvm/include/llvm/Support/BalancedPartitioning.h 
b/llvm/include/llvm/Support/BalancedPartitioning.h
index a8464ac0fe60e5..9738e742f7f1e9 100644
--- a/llvm/include/llvm/Support/BalancedPartitioning.h
+++ b/llvm/include/llvm/Support/BalancedPartitioning.h
@@ -50,7 +50,7 @@
 
 namespace llvm {
 
-class ThreadPool;
+class ThreadPoolInterface;
 /// A function with a set of utility nodes where it is beneficial to order two
 /// functions close together if they have similar utility nodes
 class BPFunctionNode {
@@ -115,7 +115,7 @@ class BalancedPartitioning {
   /// threads, so we need to track how many active threads that could spawn 
more
   /// threads.
   struct BPThreadPool {
-ThreadPool &TheThreadPool;
+ThreadPoolInterface &TheThreadPool;
 std::mutex mtx;
 std::condition_variable cv;
 /// The number of threads tha

[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libclc] [libcxx] [lld] [lldb] [llvm] [NFC] Remove trailing whitespace across all non-test related files (PR #82838)

2024-02-23 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

Fine with me if we want to land this as is, but per-top-level subproject may be 
a better granularity.

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


[Lldb-commits] [mlir] [lldb] [llvm] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)

2024-02-02 Thread Mehdi Amini via lldb-commits


@@ -0,0 +1,101 @@
+//===- LoopLikeInterfaceTest.cpp - Unit tests for Loop Like Interfaces. 
---===//
+//
+// 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
+//
+//===--===//
+
+#include "mlir/Interfaces/LoopLikeInterface.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/Dialect.h"
+#include "mlir/IR/DialectImplementation.h"
+#include "mlir/IR/OpDefinition.h"
+#include "mlir/IR/OpImplementation.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Parser/Parser.h"
+
+#include 
+
+using namespace mlir;
+
+struct NoZeroTripCheckLoopOp
+: public Op {
+  using Op::Op;
+
+  static ArrayRef getAttributeNames() { return {}; }
+
+  static StringRef getOperationName() {
+return "looptest.no_zero_trip_check_loop_op";
+  }
+
+  SmallVector getLoopRegions() { return {}; }
+};
+
+struct ImplZeroTripCheckLoopOp
+: public Op {
+  using Op::Op;
+
+  static ArrayRef getAttributeNames() { return {}; }
+
+  static StringRef getOperationName() {
+return "looptest.impl_zero_trip_check_loop_op";
+  }
+
+  SmallVector getLoopRegions() { return {}; }
+
+  FailureOr
+  replaceWithZeroTripCheck(RewriterBase &rewriter) {
+return cast(this->getOperation());
+  }
+};
+
+/// A dialect putting all the above together.
+struct LoopTestDialect : Dialect {
+  explicit LoopTestDialect(MLIRContext *ctx)
+  : Dialect(getDialectNamespace(), ctx, TypeID::get()) {
+addOperations();
+  }
+  static StringRef getDialectNamespace() { return "looptest"; }
+};
+
+TEST(LoopLikeOpInterface, NoReplaceWithZeroTripCheck) {
+  const char *ir = R"MLIR(
+  "looptest.no_zero_trip_check_loop_op"() : () -> ()
+  )MLIR";
+
+  DialectRegistry registry;
+  registry.insert();
+  MLIRContext ctx(registry);
+
+  OwningOpRef module = parseSourceString(ir, &ctx);
+  LoopLikeOpInterface testOp =
+  cast(module->getBody()->getOperations().front());
+
+  IRRewriter rewriter(&ctx);
+  FailureOr result =
+  testOp.replaceWithZeroTripCheck(rewriter);
+
+  EXPECT_TRUE(failed(result));
+}
+
+TEST(LoopLikeOpInterface, ImplReplaceWithZeroTripCheck) {
+  const char *ir = R"MLIR(
+  "looptest.impl_zero_trip_check_loop_op"() : () -> ()
+  )MLIR";
+
+  DialectRegistry registry;
+  registry.insert();
+  MLIRContext ctx(registry);
+
+  OwningOpRef module = parseSourceString(ir, &ctx);
+  LoopLikeOpInterface testOp =
+  cast(module->getBody()->getOperations().front());
+
+  IRRewriter rewriter(&ctx);
+  FailureOr result =
+  testOp.replaceWithZeroTripCheck(rewriter);
+
+  EXPECT_TRUE(succeeded(result));
+  EXPECT_EQ(*result, testOp);
+}

joker-eph wrote:

Please make it a pass: we're avoiding C++ unit-tests as much as possible.

I would implement the interface for scf.while and scf.for and have the pass 
just walk the IR, find all `LoopLikeOpInterface`, and call 
`replaceWithZeroTripCheck`.



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


[Lldb-commits] [flang] [libcxx] [libc] [clang] [lldb] [llvm] [mlir] [mlir] Skip invalid test on big endian platform (s390x) (PR #80246)

2024-02-02 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph closed 
https://github.com/llvm/llvm-project/pull/80246
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [mlir] [llvm] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)

2024-02-01 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph requested changes to this pull request.

Can you add some tests for this?

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


[Lldb-commits] [mlir] [libc] [lldb] [flang] [libcxxabi] [lld] [libcxx] [clang-tools-extra] [compiler-rt] [llvm] [clang] [mlir][complex] Prevent underflow in complex.abs (PR #76316)

2024-01-27 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

I had to revert because this broke a bot: 
https://lab.llvm.org/buildbot/#/builders/264/builds/6131

```
# RUN: at line 1
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/mlir-opt 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
-func-bufferize -tensor-bufferize -arith-bufferize --canonicalize
-convert-scf-to-cf --convert-complex-to-standard-finalize-memref-to-llvm 
-convert-math-to-llvm -convert-math-to-libm-convert-vector-to-llvm 
-convert-complex-to-llvm-convert-func-to-llvm -reconcile-unrealized-casts | 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/mlir-cpu-runner   -e 
entry -entry-point-result=void
-shared-libs=/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/lib/libmlir_c_runner_utils.so
 | /vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/FileCheck 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
# executed command: 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/mlir-opt 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
 -func-bufferize -tensor-bufferize -arith-bufferize --canonicalize 
-convert-scf-to-cf --convert-complex-to-standard -finalize-memref-to-llvm 
-convert-math-to-llvm -convert-math-to-libm -convert-vector-to-llvm 
-convert-complex-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts
# executed command: 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/mlir-cpu-runner -e entry 
-entry-point-result=void 
-shared-libs=/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/lib/libmlir_c_runner_utils.so
# executed command: 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.obj/bin/FileCheck 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
# .---command stderr
# | 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir:135:17:
 error: CHECK-NEXT: expected string not found in input
# |  // CHECK-NEXT: -1.098
# | ^
# | :3:6: note: scanning from here
# | 0.45509
# |  ^
# | :4:1: note: possible intended match here
# | 1.09868
# | ^
# | 
# | Input file: 
# | Check file: 
/vol/worker/mlir-nvidia/mlir-nvidia-gcc7/llvm.src/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<
# | 1: nan 
# | 2: nan 
# | 3: 0.45509 
# | next:135'0  X~~ error: no match found
# | 4: 1.09868 
# | next:135'0 
# | next:135'1 ?possible intended match
# | 5: 0 
# | next:135'0 ~~
# | 6: 0 
# | next:135'0 ~~
# | 7: 0.707107 
# | next:135'0 ~
# | 8: 0.707107 
# | next:135'0 ~
# | 9: 1.09868 
# | next:135'0 
# | .
# | .
# | .
# | >>
# `-
# error: command failed with exit status: 1
```

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


[Lldb-commits] [lldb] [polly] [libcxx] [openmp] [libcxxabi] [mlir] [compiler-rt] [clang] [llvm] [clang-tools-extra] [libc] [flang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-03 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph approved this pull request.


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


[Lldb-commits] [llvm] [libcxxabi] [lldb] [libcxx] [polly] [openmp] [compiler-rt] [flang] [libc] [mlir] [clang-tools-extra] [clang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-02 Thread Mehdi Amini via lldb-commits


@@ -897,7 +921,8 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
   } else {
 // It's safe to assume the mask buffer can be unpacked if the data
 // buffer was unpacked.
-auto castedMaskType = *unpackOneDim(maskBufferType);
+auto maskBufferType = dyn_cast(maskBuffer.getType());

joker-eph wrote:

OK, but we're not checking the result: if this can't fail here by construction 
it should be a cast instead.

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


[Lldb-commits] [compiler-rt] [lld] [openmp] [libcxx] [mlir] [clang] [lldb] [llvm] [flang] [libc] [clang-tools-extra] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [lld] [openmp] [libcxx] [mlir] [clang] [lldb] [llvm] [flang] [libc] [clang-tools-extra] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Mehdi Amini via lldb-commits


@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);

joker-eph wrote:

> The PR has been open for a while and blocking other work that depends on it. 
> Would be great if you can approve soon.

Well, we were waiting on the test that you just added today!

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


[Lldb-commits] [compiler-rt] [lld] [openmp] [libcxx] [mlir] [clang] [lldb] [llvm] [flang] [libc] [clang-tools-extra] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Mehdi Amini via lldb-commits


@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.cpp - Translate SPIRV to LLVM IR 
--===//
+//
+// 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 a translation between the MLIR SPIRV dialect and
+// LLVM IR.
+//
+//===--===//
+
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/IR/Operation.h"
+#include "mlir/Target/LLVMIR/ModuleTranslation.h"
+
+using namespace mlir;
+using namespace mlir::LLVM;
+
+void mlir::registerSPIRVDialectTranslation(DialectRegistry ®istry) {
+  registry.insert();

joker-eph wrote:

It does not make sense to me to have an API called 
"registerSPIRVDialectTranslation" that itself registers a dialect and no 
translation actually.

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


[Lldb-commits] [flang] [clang] [libcxx] [lld] [lldb] [compiler-rt] [mlir] [llvm] [mlir][async] Avoid crash when not using `func.func` (PR #72801)

2023-11-20 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

FYI the build is failing (maybe re-running would be enough though)

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


[Lldb-commits] [lldb] [compiler-rt] [llvm] [clang] [lld] [mlir] [flang] [libcxx] [mlir][async] Avoid crash when not using `func.func` (PR #72801)

2023-11-20 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph approved this pull request.


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


[Lldb-commits] [libc] [clang-tools-extra] [mlir] [compiler-rt] [lld] [libcxx] [clang] [flang] [lldb] [llvm] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-17 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libc] [clang-tools-extra] [mlir] [compiler-rt] [lld] [libcxx] [clang] [flang] [lldb] [llvm] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-17 Thread Mehdi Amini via lldb-commits


@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);

joker-eph wrote:

Which muir-translate test requires that? I don't find it by skimming the patch.

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


[Lldb-commits] [libc] [clang-tools-extra] [flang] [clang] [llvm] [compiler-rt] [libcxx] [lld] [mlir] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-16 Thread Mehdi Amini via lldb-commits


@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.cpp - Translate SPIRV to LLVM IR 
--===//
+//
+// 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 a translation between the MLIR SPIRV dialect and
+// LLVM IR.
+//
+//===--===//
+
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/IR/Operation.h"
+#include "mlir/Target/LLVMIR/ModuleTranslation.h"
+
+using namespace mlir;
+using namespace mlir::LLVM;
+
+void mlir::registerSPIRVDialectTranslation(DialectRegistry ®istry) {
+  registry.insert();

joker-eph wrote:

I'm confused here: there is no translation interface.

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


[Lldb-commits] [libc] [clang-tools-extra] [flang] [clang] [llvm] [compiler-rt] [libcxx] [lld] [mlir] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-16 Thread Mehdi Amini via lldb-commits


@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);

joker-eph wrote:

Trying to understand...
What is the unit test that requires this?

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


[Lldb-commits] [libcxxabi] [flang] [libcxx] [llvm] [clang] [mlir] [clang-tools-extra] [lldb] [lld] [compiler-rt] Refactor ModuleToObject to offer more flexibility to subclass (NFC) (PR #71165)

2023-11-03 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph closed 
https://github.com/llvm/llvm-project/pull/71165
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libcxxabi] [flang] [libcxx] [llvm] [clang] [mlir] [clang-tools-extra] [lldb] [lld] [compiler-rt] Refactor ModuleToObject to offer more flexibility to subclass (NFC) (PR #71165)

2023-11-03 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/71165
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [mlir] Verify TestBuiltinAttributeInterfaces eltype (PR #69878)

2023-10-22 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph approved this pull request.


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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits


@@ -71,7 +71,8 @@ void GPUToSPIRVPass::runOnOperation() {
   std::unique_ptr target =
   spirv::getMemorySpaceToStorageClassTarget(*context);
   spirv::MemorySpaceToStorageClassMap memorySpaceMap =
-  spirv::mapMemorySpaceToVulkanStorageClass;
+  this->useOpenCL ? spirv::mapMemorySpaceToOpenCLStorageClass :
+  spirv::mapMemorySpaceToVulkanStorageClass;

joker-eph wrote:

Can you point out which unit-test is covering this? Can you send this in a 
separate PR?

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph commented:

LGTM overall, this should likely get reviewed by @antiagainst / @kuhar ; and 
it's be great if you can split the independent changes and send them ahead of 
the e2e integration.

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

joker-eph wrote:

I see a unit-test for this: but can you send everything related to 
`isHostShared` in a separate PR?


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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits


@@ -0,0 +1,70 @@
+//===- SerializeToSPIRV.cpp - Convert GPU kernel to SPIRV blob 
-===//
+//
+// 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
+/// This pass iterates all the SPIR-V modules in the top module and serializes
+/// each SPIR-V module to SPIR-V binary and then attachs the binary blob as a
+/// string attribute to the corresponding gpu module.
+///
+//===--===//
+
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+
+#include "mlir/Dialect/GPU/IR/GPUDialect.h"
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Target/SPIRV/Serialization.h"
+
+namespace mlir {
+#define GEN_PASS_DEF_GPUSERIALIZETOSPIRVPASS
+#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+struct GpuSerializeToSPIRVPass : public 
mlir::impl::GpuSerializeToSPIRVPassBase {
+public:
+  void runOnOperation() override {
+auto mod = getOperation();
+llvm::SmallVector spvBinary;
+for (mlir::gpu::GPUModuleOp gpuMod : mod.getOps()) {
+  auto name = gpuMod.getName();
+  // check that the spv module has the same name with gpu module except the
+  // prefix "__spv__"
+  auto isSameMod = [&](spirv::ModuleOp spvMod) -> bool {
+auto spvModName = spvMod.getName();
+return spvModName->consume_front("__spv__") && spvModName == name;
+  };
+  auto spvMods = mod.getOps();
+  auto it = llvm::find_if(spvMods, isSameMod);
+  if (it == spvMods.end()) {
+gpuMod.emitError() << "Unable to find corresponding SPIR-V module";
+signalPassFailure();
+return;
+  }
+  auto spvMod = *it;
+
+  spvBinary.clear();
+  // serialize the spv module to spv binary
+  if (mlir::failed(spirv::serialize(spvMod, spvBinary))) {
+spvMod.emitError() << "Failed to serialize SPIR-V module";
+signalPassFailure();
+return;
+  }
+
+  // attach the spv binary to the gpu module
+  auto spvData =
+  llvm::StringRef(reinterpret_cast(spvBinary.data()),
+  spvBinary.size() * sizeof(uint32_t));
+  auto spvAttr = mlir::StringAttr::get(&getContext(), spvData);
+  gpuMod->setAttr(gpu::getDefaultGpuBinaryAnnotation(), spvAttr);
+  spvMod->erase();
+}
+  }
+};

joker-eph wrote:

@fabianmcg : how would that fit in the new serialization flow?

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits


@@ -0,0 +1,70 @@
+//===- SerializeToSPIRV.cpp - Convert GPU kernel to SPIRV blob 
-===//
+//
+// 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
+/// This pass iterates all the SPIR-V modules in the top module and serializes
+/// each SPIR-V module to SPIR-V binary and then attachs the binary blob as a
+/// string attribute to the corresponding gpu module.
+///
+//===--===//
+
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+
+#include "mlir/Dialect/GPU/IR/GPUDialect.h"
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Target/SPIRV/Serialization.h"
+
+namespace mlir {
+#define GEN_PASS_DEF_GPUSERIALIZETOSPIRVPASS
+#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+struct GpuSerializeToSPIRVPass : public 
mlir::impl::GpuSerializeToSPIRVPassBase {
+public:
+  void runOnOperation() override {
+auto mod = getOperation();
+llvm::SmallVector spvBinary;
+for (mlir::gpu::GPUModuleOp gpuMod : mod.getOps()) {
+  auto name = gpuMod.getName();
+  // check that the spv module has the same name with gpu module except the
+  // prefix "__spv__"
+  auto isSameMod = [&](spirv::ModuleOp spvMod) -> bool {
+auto spvModName = spvMod.getName();
+return spvModName->consume_front("__spv__") && spvModName == name;
+  };
+  auto spvMods = mod.getOps();
+  auto it = llvm::find_if(spvMods, isSameMod);

joker-eph wrote:

This is really costly, can you build a symbol table once at the beginning of 
the function and use it for the queries instead?

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph edited 
https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r306134 - Fix typo: using && instead of & when evaluating a mask

2017-06-26 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Fri Jun 23 13:20:13 2017
New Revision: 306134

URL: http://llvm.org/viewvc/llvm-project?rev=306134&view=rev
Log:
Fix typo: using && instead of & when evaluating a mask

Summary: Reported by coverity, I don't know how to provide a test.

Reviewers: zturner

Subscribers: lldb-commits, emaste

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

Modified:
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=306134&r1=306133&r2=306134&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Jun 23 
13:20:13 2017
@@ -1693,7 +1693,7 @@ size_t ObjectFileELF::GetSectionHeaderIn
 // ABI Mask doesn't cover N32 and N64 ABI.
 if (header.e_ident[EI_CLASS] == llvm::ELF::ELFCLASS64)
   arch_flags |= lldb_private::ArchSpec::eMIPSABI_N64;
-else if (header.e_flags && llvm::ELF::EF_MIPS_ABI2)
+else if (header.e_flags & llvm::ELF::EF_MIPS_ABI2)
   arch_flags |= lldb_private::ArchSpec::eMIPSABI_N32;
 break;
   }


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


[Lldb-commits] [PATCH] D24863: Keep dependencies separated between static and dynamic libraries. Fix for bug #28127.

2016-11-12 Thread Mehdi AMINI via lldb-commits
mehdi_amini added a comment.

Please also close https://llvm.org/bugs/show_bug.cgi?id=28127 if @labath fix is 
enough.


Repository:
  rL LLVM

https://reviews.llvm.org/D24863



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


[Lldb-commits] [lldb] r286565 - Revert unwanted changes in lldb when updating llvm::Error()

2016-11-10 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Thu Nov 10 23:07:57 2016
New Revision: 286565

URL: http://llvm.org/viewvc/llvm-project?rev=286565&view=rev
Log:
Revert unwanted changes in lldb when updating llvm::Error()

My script updated lldb::Errors, and I failed to fix it entirely
before pushing. This restore everything in lldb as it was before
r286561.

Modified:
lldb/trunk/source/Host/windows/LockFileWindows.cpp
lldb/trunk/source/Host/windows/PipeWindows.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp

lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp

lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp
lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp

Modified: lldb/trunk/source/Host/windows/LockFileWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/LockFileWindows.cpp?rev=286565&r1=286564&r2=286565&view=diff
==
--- lldb/trunk/source/Host/windows/LockFileWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/LockFileWindows.cpp Thu Nov 10 23:07:57 2016
@@ -31,7 +31,7 @@ Error fileLock(HANDLE file_handle, DWORD
   if (!::GetOverlappedResult(file_handle, &overlapped, &bytes, TRUE))
 return Error(::GetLastError(), eErrorTypeWin32);
 
-  return Error::success();
+  return Error();
 }
 
 } // namespace
@@ -74,5 +74,5 @@ Error LockFileWindows::DoUnlock() {
   if (!::GetOverlappedResult(m_file, &overlapped, &bytes, TRUE))
 return Error(::GetLastError(), eErrorTypeWin32);
 
-  return Error::success();
+  return Error();
 }

Modified: lldb/trunk/source/Host/windows/PipeWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/PipeWindows.cpp?rev=286565&r1=286564&r2=286565&view=diff
==
--- lldb/trunk/source/Host/windows/PipeWindows.cpp (original)
+++ lldb/trunk/source/Host/windows/PipeWindows.cpp Thu Nov 10 23:07:57 2016
@@ -161,7 +161,7 @@ Error PipeWindows::OpenNamedPipe(llvm::S
 ZeroMemory(&m_write_overlapped, sizeof(m_write_overlapped));
   }
 
-  return Error::success();
+  return Error();
 }
 
 int PipeWindows::GetReadFileDescriptor() const { return m_read_fd; }
@@ -217,7 +217,7 @@ void PipeWindows::Close() {
   CloseWriteFileDescriptor();
 }
 
-Error PipeWindows::Delete(llvm::StringRef name) { return Error::success(); }
+Error PipeWindows::Delete(llvm::StringRef name) { return Error(); }
 
 bool PipeWindows::CanRead() const { return (m_read != INVALID_HANDLE_VALUE); }
 
@@ -273,7 +273,7 @@ Error PipeWindows::ReadWithTimeout(void
 return Error(::GetLastError(), eErrorTypeWin32);
 
   bytes_read = sys_bytes_read;
-  return Error::success();
+  return Error();
 }
 
 Error PipeWindows::Write(const void *buf, size_t num_bytes,
@@ -291,5 +291,5 @@ Error PipeWindows::Write(const void *buf
 &sys_bytes_written, TRUE);
   if (!result)
 return Error(::GetLastError(), eErrorTypeWin32);
-  return Error::success();
+  return Error();
 }

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp?rev=286565&r1=286564&r2=286565&view=diff
==
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Thu Nov 10 
23:07:57 2016
@@ -150,7 +150,7 @@ Error ProcessFreeBSD::DoResume() {
   else
 m_monitor->Resume(GetID(), m_resume_signo);
 
-  return Error::success();
+  return Error();
 }
 
 bool ProcessFreeBSD::UpdateThreadList(ThreadList &old_thread_list,

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=286565&r1=286564&r2=286565&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Thu Nov 10 
23:07:57 2016
@@ -1364,13 +1364,13 @@ Error NativeProcessLinux::SetupSoftwareS
   // If setting the breakpoint fails because next_pc is out of
   // the address space, ignore it and let the debugee segfault.
   if (error.GetError() == EIO || error.GetE

[Lldb-commits] [lldb] r286562 - Prevent at compile time converting from Error::success() to Expected

2016-11-10 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Thu Nov 10 22:29:25 2016
New Revision: 286562

URL: http://llvm.org/viewvc/llvm-project?rev=286562&view=rev
Log:
Prevent at compile time converting from Error::success() to Expected

This would trigger an assertion at runtime otherwise.

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

Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Core/ModuleList.cpp
lldb/trunk/source/Host/common/NativeBreakpoint.cpp
lldb/trunk/source/Host/common/NativeBreakpointList.cpp
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Host/common/NativeWatchpointList.cpp
lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp
lldb/trunk/source/Host/posix/FileSystem.cpp
lldb/trunk/source/Host/posix/MainLoopPosix.cpp
lldb/trunk/source/Host/posix/PipePosix.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
lldb/trunk/source/Interpreter/OptionValueString.cpp

lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp

lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp
lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/trunk/source/Target/Platform.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/source/Utility/ModuleCache.cpp
lldb/trunk/tools/lldb-server/lldb-platform.cpp
lldb/trunk/unittests/Utility/ModuleCacheTest.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=286562&r1=286561&r2=286562&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Nov 10 22:29:25 2016
@@ -1082,9 +1082,7 @@ public:
   /// @return
   /// Returns an error object.
   //--
-  virtual Error WillAttachToProcessWithID(lldb::pid_t pid) {
-return Error::success();
-  }
+  virtual Error WillAttachToProcessWithID(lldb::pid_t pid) { return Error(); }
 
   //--
   /// Called before attaching to a process.
@@ -1097,7 +1095,7 @@ public:
   //--
   virtual Error WillAttachToProcessWithName(const char *process_name,
 bool wait_for_launch) {
-return Error::success();
+return Error();
   }
 
   //--
@@ -1206,7 +1204,7 @@ public:
   /// @return
   /// Returns an error object.
   //--
-  virtual Error WillLaunch(Module *module) { return Error::success(); }
+  virtual Error WillLaunch(Module *module) { return Error(); }
 
   //--
   /// Launch a new process.
@@ -1252,7 +1250,7 @@ public:
   /// @return
   /// Returns an error object.
   //--
-  virtual Error WillResume() { return Error::success(); }
+  virtual Error WillResume() { return Error(); }
 
   //--
   /// Resumes all of a process's threads as configured using the
@@ -1296,7 +1294,7 @@ public:
   /// @return
   /// Returns an error object.
   //--

[Lldb-commits] [lldb] r286561 - Make the Error class constructor protected

2016-11-10 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Thu Nov 10 22:28:40 2016
New Revision: 286561

URL: http://llvm.org/viewvc/llvm-project?rev=286561&view=rev
Log:
Make the Error class constructor protected

This is forcing to use Error::success(), which is in a wide majority
of cases a lot more readable.

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

Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Core/ModuleList.cpp
lldb/trunk/source/Host/common/NativeBreakpoint.cpp
lldb/trunk/source/Host/common/NativeBreakpointList.cpp
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Host/common/NativeWatchpointList.cpp
lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp
lldb/trunk/source/Host/posix/FileSystem.cpp
lldb/trunk/source/Host/posix/MainLoopPosix.cpp
lldb/trunk/source/Host/posix/PipePosix.cpp
lldb/trunk/source/Host/windows/LockFileWindows.cpp
lldb/trunk/source/Host/windows/PipeWindows.cpp
lldb/trunk/source/Interpreter/OptionGroupVariable.cpp
lldb/trunk/source/Interpreter/OptionValueString.cpp

lldb/trunk/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp

lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp

lldb/trunk/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp
lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/trunk/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp

lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp

lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.cpp
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp
lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/trunk/source/Target/Platform.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/source/Utility/ModuleCache.cpp
lldb/trunk/tools/lldb-server/lldb-platform.cpp
lldb/trunk/unittests/Utility/ModuleCacheTest.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=286561&r1=286560&r2=286561&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Nov 10 22:28:40 2016
@@ -1082,7 +1082,9 @@ public:
   /// @return
   /// Returns an error object.
   //--
-  virtual Error WillAttachToProcessWithID(lldb::pid_t pid) { return Error(); }
+  virtual Error WillAttachToProcessWithID(lldb::pid_t pid) {
+return Error::success();
+  }
 
   //--
   /// Called before attaching to a process.
@@ -1095,7 +1097,7 @@ public:
   //--
   virtual Error WillAttachToProcessWithName(const char *process_name,
 bool wait_for_launch) {
-return Error();
+return Error::success();
   }
 
   //--
@@ -1204,7 +1206,7 @@ public:
   /// @return
   /// R

[Lldb-commits] [PATCH] D26190: [RFC] Solve linking inconsistency, proposal two

2016-11-01 Thread Mehdi AMINI via lldb-commits
mehdi_amini added a comment.

Just to clarify: I don't have a dog in this, I'm just lurking here to learn 
something, and I'm curious about the tradeoff.

In https://reviews.llvm.org/D26190#585059, @labath wrote:

> In https://reviews.llvm.org/D26190#585016, @mehdi_amini wrote:
>
> > > Does that make sense?
> >
> > This makes sense (assuming static linking reduces some possibility though)
>
>
> I am not sure we are on the same page here. What is the scenario you have in 
> mind here? I am not forbidding anyone from building liblldb linking to 
> libllvm (in fact, I think it should work). I am assuming static linking just 
> because that is the use case most developers use.


Same case as I mentioned below: namespace pollution.

> 
> 
>> , but LLVM is not robust to mix and match build settings: building half of 
>> the source with -DNDEBUG and not the other is likely to cause weird runtime 
>> failures. That can be an issue because now you need libLLDB built in two 
>> modes and the client app to link the right one.
> 
> I don't see how this applies. This is true when you build liblldb, and it's 
> true that lldb's assertion settings need to match llvm's, but since liblldb's 
> api is stable wrt. N/_DEBUG, it's user should not need to care about that.

It applies at the moment you consider that the client code does not need to 
link to LLVM because LLDB provides a copy. It means that now, even if it is not 
relevant for the LLVM interface, the client code needs to be built with the 
same configuration as the libLLDB shared lib.

Not exposing LLVM but only the minimal non-LLVM API prevents the client code 
from using any LLVM symbol from libLLDB, and thus makes it possible to 
mix-n-match a release build of libLLDB with an assert built client code.

Make sense?

> 
> 
>> Also, exporting more than the minimum prevent an efficient LTO build of 
>> libLLDB.so
> 
> This proposal is about exporting the bare minimum (i.e. lldb namespace).

Yes: this is a good point of this proposal that I was just pointing  (sorry I 
wasn't clear).

>>> Everything should work fine as long as you don't actually *depend* on 
>>> having a separate copy of llvm (which is pretty pointless as it does not 
>>> have global state (apart from the crazy cl globals)).
>> 
>> Is it pointless? Users have dependencies they don't control. I have seen 
>> mentioned in the past issues with "symbol pollution" from external library 
>> that was affecting LLVM users (a quick search yields 
>> https://root.cern.ch/phpBB3/viewtopic.php?f=3&t=22462&sid=dfd0c149390349defea19eb9ce0073c5
>>  )
> 
> Again I think we are misunderstanding each other, the "pointless" was 
> referring to the "relying on global state of libllvm" part of the statement. 
> It seems the problem you quote was caused by a library exporting interfaces 
> it should have kept private, which is what we are doing here (but in your 
> first sentence you seem to indicate you prefer dynamic linking, in which case 
> you cannot hide the symbols (or can you?)).

I don't have any preference (or rather: I prefer static for 
performance/efficiency reason). I'm more concerned about what use-case exists 
out-there. Exporting LLVM APIs can cause problem to folks that want/need to 
build against various third-party.

> I think you'll have to repeat your point, as now I am totally confused about 
> what you are trying to say. :)

Sorry, I hope it is more clear now?


https://reviews.llvm.org/D26190



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


[Lldb-commits] [PATCH] D26190: [RFC] Solve linking inconsistency, proposal two

2016-11-01 Thread Mehdi AMINI via lldb-commits
mehdi_amini added a comment.

> Does that make sense?

This makes sense (assuming static linking reduces some possibility though), but 
LLVM is not robust to mix and match build settings: building half of the source 
with -DNDEBUG and not the other is likely to cause weird runtime failures. That 
can be an issue because now you need libLLDB built in two modes and the client 
app to link the right one.

Also, exporting more than the minimum prevent an efficient LTO build of 
libLLDB.so

> Everything should work fine as long as you don't actually *depend* on having 
> a separate copy of llvm (which is pretty pointless as it does not have global 
> state (apart from the crazy cl globals)).

Is it pointless? Users have dependencies they don't control. I have seen 
mentioned in the past issues with "symbol pollution" from external library that 
was affecting LLVM users (a quick search yields 
https://root.cern.ch/phpBB3/viewtopic.php?f=3&t=22462&sid=dfd0c149390349defea19eb9ce0073c5
 )


https://reviews.llvm.org/D26190



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


[Lldb-commits] [PATCH] D26190: [RFC] Solve linking inconsistency, proposal two

2016-11-01 Thread Mehdi AMINI via lldb-commits
mehdi_amini added a comment.

OK!

How is it different from the other proposal? In the other proposal, using a 
LLVM class in the API boundary would break the same way under the same 
conditions, or did I miss something?

Something that isn't clear to me with this proposal, is how a user supposed to 
include its own copy of LLVM? Let say I write a client code that link to 
libLLVM.so and libLLDB.so?


https://reviews.llvm.org/D26190



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


[Lldb-commits] [PATCH] D26190: [RFC] Solve linking inconsistency, proposal two

2016-11-01 Thread Mehdi AMINI via lldb-commits
mehdi_amini added a comment.

> and has potential to introduce latent bugs.

Can you elaborate on this?


https://reviews.llvm.org/D26190



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


[Lldb-commits] [lldb] r283298 - Re-commit "Use StringRef in Support/Darf APIs (NFC)"

2016-10-04 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Wed Oct  5 00:59:29 2016
New Revision: 283298

URL: http://llvm.org/viewvc/llvm-project?rev=283298&view=rev
Log:
Re-commit "Use StringRef in Support/Darf APIs (NFC)"

This reverts commit r283285 and re-commit r283275 with
a fix for format("%s", Str); where Str is a StringRef.

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp?rev=283298&r1=283297&r2=283298&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp Wed Oct  5 
00:59:29 2016
@@ -21,53 +21,53 @@ const char *DW_TAG_value_to_name(uint32_
   if (val == 0)
 return "NULL";
 
-  const char *llvmstr = llvm::dwarf::TagString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::TagString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_TAG constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_CHILDREN_value_to_name(uint8_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::ChildrenString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::ChildrenString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_CHILDREN constant: 0x%x",
  val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_AT_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::AttributeString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AttributeString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_AT constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_FORM_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::FormEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::FormEncodingString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_FORM constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_OP_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::OperationEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::OperationEncodingString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_OP constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 DRC_class DW_OP_value_to_class(uint32_t val) {
@@ -383,145 +383,145 @@ DRC_class DW_OP_value_to_class(uint32_t
 
 const char *DW_ATE_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::AttributeEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AttributeEncodingString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_ATE constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_ACCESS_value_to_name(uint32_t val) {
   static char invalid[100];
 
-  const char *llvmstr = llvm::dwarf::AccessibilityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AccessibilityString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_ACCESS constant: 0x%x", 
val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_VIS_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::VisibilityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::VisibilityString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_VIS constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_VIRTUALITY_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::VirtualityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::VirtualityString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_VIRTUALITY constant: 0x%x",
  val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_LANG_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::LanguageString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::LanguageString(val);
+  if (llvmstr.e

[Lldb-commits] [lldb] r283285 - Revert "Re-commit "Use StringRef in Support/Darf APIs (NFC)""

2016-10-04 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Tue Oct  4 20:04:02 2016
New Revision: 283285

URL: http://llvm.org/viewvc/llvm-project?rev=283285&view=rev
Log:
Revert "Re-commit "Use StringRef in Support/Darf APIs (NFC)""

One test seems randomly broken: DebugInfo/X86/gnu-public-names.ll

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp?rev=283285&r1=283284&r2=283285&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp Tue Oct  4 
20:04:02 2016
@@ -21,53 +21,53 @@ const char *DW_TAG_value_to_name(uint32_
   if (val == 0)
 return "NULL";
 
-  llvm::StringRef llvmstr = llvm::dwarf::TagString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::TagString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_TAG constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 const char *DW_CHILDREN_value_to_name(uint8_t val) {
   static char invalid[100];
-  llvm::StringRef llvmstr = llvm::dwarf::ChildrenString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::ChildrenString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_CHILDREN constant: 0x%x",
  val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 const char *DW_AT_value_to_name(uint32_t val) {
   static char invalid[100];
-  llvm::StringRef llvmstr = llvm::dwarf::AttributeString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::AttributeString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_AT constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 const char *DW_FORM_value_to_name(uint32_t val) {
   static char invalid[100];
-  llvm::StringRef llvmstr = llvm::dwarf::FormEncodingString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::FormEncodingString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_FORM constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 const char *DW_OP_value_to_name(uint32_t val) {
   static char invalid[100];
-  llvm::StringRef llvmstr = llvm::dwarf::OperationEncodingString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::OperationEncodingString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_OP constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 DRC_class DW_OP_value_to_class(uint32_t val) {
@@ -383,145 +383,145 @@ DRC_class DW_OP_value_to_class(uint32_t
 
 const char *DW_ATE_value_to_name(uint32_t val) {
   static char invalid[100];
-  llvm::StringRef llvmstr = llvm::dwarf::AttributeEncodingString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::AttributeEncodingString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_ATE constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 const char *DW_ACCESS_value_to_name(uint32_t val) {
   static char invalid[100];
 
-  llvm::StringRef llvmstr = llvm::dwarf::AccessibilityString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::AccessibilityString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_ACCESS constant: 0x%x", 
val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 const char *DW_VIS_value_to_name(uint32_t val) {
   static char invalid[100];
-  llvm::StringRef llvmstr = llvm::dwarf::VisibilityString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::VisibilityString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_VIS constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 const char *DW_VIRTUALITY_value_to_name(uint32_t val) {
   static char invalid[100];
-  llvm::StringRef llvmstr = llvm::dwarf::VirtualityString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::VirtualityString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_VIRTUALITY constant: 0x%x",
  val);
 return invalid;
   }
-  return llvmstr.data();
+  return llvmstr;
 }
 
 const char *DW_LANG_value_to_name(uint32_t val) {
   static char invalid[100];
-  llvm::StringRef llvmstr = llvm::dwarf::LanguageString(val);
-  if (llvmstr.empty()) {
+  const char *llvmstr = llvm::dwarf::LanguageString(val);
+  if (llvmstr == NULL) {
 snprintf(invalid, si

[Lldb-commits] [lldb] r283281 - Re-commit "Use StringRef in Support/Darf APIs (NFC)"

2016-10-04 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Tue Oct  4 19:37:18 2016
New Revision: 283281

URL: http://llvm.org/viewvc/llvm-project?rev=283281&view=rev
Log:
Re-commit "Use StringRef in Support/Darf APIs (NFC)"

This reverts commit r283278 and re-commit r283275 with
the update to fix the build on the LLDB side.

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp?rev=283281&r1=283280&r2=283281&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp Tue Oct  4 
19:37:18 2016
@@ -21,53 +21,53 @@ const char *DW_TAG_value_to_name(uint32_
   if (val == 0)
 return "NULL";
 
-  const char *llvmstr = llvm::dwarf::TagString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::TagString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_TAG constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_CHILDREN_value_to_name(uint8_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::ChildrenString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::ChildrenString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_CHILDREN constant: 0x%x",
  val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_AT_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::AttributeString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AttributeString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_AT constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_FORM_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::FormEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::FormEncodingString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_FORM constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_OP_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::OperationEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::OperationEncodingString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_OP constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 DRC_class DW_OP_value_to_class(uint32_t val) {
@@ -383,145 +383,145 @@ DRC_class DW_OP_value_to_class(uint32_t
 
 const char *DW_ATE_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::AttributeEncodingString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AttributeEncodingString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_ATE constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_ACCESS_value_to_name(uint32_t val) {
   static char invalid[100];
 
-  const char *llvmstr = llvm::dwarf::AccessibilityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::AccessibilityString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_ACCESS constant: 0x%x", 
val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_VIS_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::VisibilityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::VisibilityString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_VIS constant: 0x%x", val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_VIRTUALITY_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::VirtualityString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::VirtualityString(val);
+  if (llvmstr.empty()) {
 snprintf(invalid, sizeof(invalid), "Unknown DW_VIRTUALITY constant: 0x%x",
  val);
 return invalid;
   }
-  return llvmstr;
+  return llvmstr.data();
 }
 
 const char *DW_LANG_value_to_name(uint32_t val) {
   static char invalid[100];
-  const char *llvmstr = llvm::dwarf::LanguageString(val);
-  if (llvmstr == NULL) {
+  llvm::StringRef llvmstr = llvm::dwarf::LanguageString(val);
+  if (llvmstr.empty()) {

[Lldb-commits] [lldb] r283018 - Use StringRef instead of raw pointers in MCAsmInfo/MCInstrInfo APIs (NFC)

2016-09-30 Thread Mehdi Amini via lldb-commits
Author: mehdi_amini
Date: Sat Oct  1 01:46:33 2016
New Revision: 283018

URL: http://llvm.org/viewvc/llvm-project?rev=283018&view=rev
Log:
Use StringRef instead of raw pointers in MCAsmInfo/MCInstrInfo APIs (NFC)

Modified:
lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
lldb/trunk/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp

Modified: lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp?rev=283018&r1=283017&r2=283018&view=diff
==
--- lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp 
(original)
+++ lldb/trunk/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp Sat 
Oct  1 01:46:33 2016
@@ -1101,7 +1101,7 @@ bool EmulateInstructionMIPS::EvaluateIns
* mc_insn.getOpcode() returns decoded opcode. However to make use
* of llvm::Mips:: we would need "MipsGenInstrInfo.inc".
   */
-  const char *op_name = m_insn_info->getName(mc_insn.getOpcode());
+  const char *op_name = m_insn_info->getName(mc_insn.getOpcode()).data();
 
   if (op_name == NULL)
 return false;
@@ -1373,7 +1373,7 @@ bool EmulateInstructionMIPS::Emulate_SUB
   bool success = false;
   uint64_t result;
   uint8_t src, dst, rt;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   dst = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   src = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
@@ -1834,7 +1834,7 @@ bool EmulateInstructionMIPS::Emulate_BXX
   bool success = false;
   uint32_t rs, rt;
   int32_t offset, pc, target = 0, rs_val, rt_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   rt = m_reg_info->getEncodingValue(insn.getOperand(1).getReg());
@@ -1886,7 +1886,7 @@ bool EmulateInstructionMIPS::Emulate_BXX
   bool success = false;
   uint32_t rs, rt;
   int32_t offset, pc, target = 0, rs_val, rt_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
   uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
@@ -1969,7 +1969,7 @@ bool EmulateInstructionMIPS::Emulate_Bco
   uint32_t rs;
   int32_t offset, pc, target = 0;
   int32_t rs_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   offset = insn.getOperand(1).getImm();
@@ -2038,7 +2038,7 @@ bool EmulateInstructionMIPS::Emulate_Bco
   uint32_t rs;
   int32_t offset, pc, target = 0;
   int32_t rs_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   offset = insn.getOperand(1).getImm();
@@ -2088,7 +2088,7 @@ bool EmulateInstructionMIPS::Emulate_BXX
   uint32_t rs;
   int32_t offset, pc, target = 0;
   int32_t rs_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
   offset = insn.getOperand(1).getImm();
@@ -2144,7 +2144,7 @@ bool EmulateInstructionMIPS::Emulate_BXX
   uint32_t rs;
   int32_t offset, pc, target = 0;
   int32_t rs_val;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
   uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
 
   rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
@@ -2236,7 +2236,7 @@ bool EmulateInstructionMIPS::Emulate_Bra
   bool success = false;
   int32_t target = 0;
   uint32_t current_inst_size = m_insn_info->get(insn.getOpcode()).getSize();
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
   bool update_ra = false;
   uint32_t ra_offset = 0;
 
@@ -2336,7 +2336,7 @@ bool EmulateInstructionMIPS::Emulate_Bra
 bool EmulateInstructionMIPS::Emulate_JALRx16_MM(llvm::MCInst &insn) {
   bool success = false;
   uint32_t ra_offset = 0;
-  const char *op_name = m_insn_info->getName(insn.getOpcode());
+  const char *op_name = m_insn_info->getName(insn.getOpcode()).data();
 
   uint32_t rs = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
 
@@ -2375,7 +2375,7 @@ bool EmulateInstructionMIPS::Emulate_JAL
 bool EmulateInstructionMIPS::Emulate_JALx(llvm::

  1   2   >