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

2024-02-01 Thread Jacques Pienaar via lldb-commits

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


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] Add config for PDL (PR #69927)

2023-10-23 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/69927

>From eea36708d838411d70eb99265c3a2f3aabb91460 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Sun, 22 Oct 2023 09:33:40 -0700
Subject: [PATCH] [mlir] Add config for PDL

Make it so that PDL can be optionally disabled. PDL is different than
other dialects as its included in rewrite framework. This results in
these being included even where it isn't used and not removed during
compilation. Add option to disable for workloads where it isn't needed
or used. This ends up being rather invasive due to how PDL is included.
Ideally we'd have less ifdefs, not particularly happy with those, but
given how integrated it is, couldn't see simple alternative.

PDL is enabled by default (and not optional bazel).

This only works with tests disabled. With tests enabled this still
compiles but tests fail as there is no lit config to disable tests that
depend on PDL yet.
---
 mlir/CMakeLists.txt   | 12 ++--
 mlir/cmake/modules/AddMLIR.cmake  |  3 +
 mlir/examples/CMakeLists.txt  |  4 +-
 mlir/examples/minimal-opt/README.md   |  7 ++-
 mlir/include/mlir/Config/mlir-config.h.cmake  |  3 +
 mlir/include/mlir/Conversion/Passes.td|  2 +
 mlir/include/mlir/Dialect/CMakeLists.txt  |  6 +-
 .../mlir/Dialect/Transform/CMakeLists.txt |  4 +-
 mlir/include/mlir/IR/PatternMatch.h   | 17 +
 mlir/include/mlir/InitAllDialects.h   |  9 ++-
 mlir/include/mlir/InitAllExtensions.h | 11 +++-
 .../mlir/Rewrite/FrozenRewritePatternSet.h|  6 ++
 mlir/include/mlir/Rewrite/PatternApplicator.h |  5 ++
 .../mlir/Transforms/DialectConversion.h   |  2 +
 mlir/lib/CAPI/Dialect/CMakeLists.txt  | 18 +++---
 mlir/lib/Conversion/CMakeLists.txt|  4 +-
 mlir/lib/Dialect/Bufferization/CMakeLists.txt |  4 +-
 .../Bufferization/TransformOps/CMakeLists.txt |  1 -
 mlir/lib/Dialect/CMakeLists.txt   |  6 +-
 mlir/lib/Dialect/Transform/CMakeLists.txt |  4 +-
 mlir/lib/IR/PatternMatch.cpp  |  2 +
 mlir/lib/Rewrite/CMakeLists.txt   | 24 +--
 mlir/lib/Rewrite/FrozenRewritePatternSet.cpp  | 13 +++-
 mlir/lib/Rewrite/PatternApplicator.cpp| 26 +++-
 mlir/lib/Tools/CMakeLists.txt |  6 +-
 .../Transforms/Utils/DialectConversion.cpp|  2 +
 mlir/python/CMakeLists.txt| 62 ++-
 mlir/test/CAPI/CMakeLists.txt | 16 ++---
 mlir/test/CMakeLists.txt  | 20 --
 mlir/test/lib/Dialect/CMakeLists.txt  |  5 +-
 mlir/test/lib/Rewrite/CMakeLists.txt  |  3 +-
 mlir/test/lib/Tools/CMakeLists.txt|  4 +-
 mlir/test/lib/Transforms/CMakeLists.txt   | 28 ++---
 mlir/tools/CMakeLists.txt |  4 +-
 mlir/tools/mlir-lsp-server/CMakeLists.txt | 10 ++-
 .../tools/mlir-lsp-server/mlir-lsp-server.cpp |  4 ++
 mlir/tools/mlir-opt/CMakeLists.txt| 10 ++-
 mlir/tools/mlir-opt/mlir-opt.cpp  | 16 +++--
 mlir/unittests/Conversion/CMakeLists.txt  |  4 +-
 mlir/unittests/Dialect/CMakeLists.txt |  4 +-
 .../llvm-project-overlay/mlir/BUILD.bazel |  1 +
 41 files changed, 283 insertions(+), 109 deletions(-)

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index ac120aad0d1eda7..d0db9e341765b3d 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -132,6 +132,8 @@ set(MLIR_ENABLE_NVPTXCOMPILER 0 CACHE BOOL
 "Statically link the nvptxlibrary instead of calling ptxas as a subprocess 
\
 for compiling PTX to cubin")
 
+set(MLIR_ENABLE_PDL 1 CACHE BOOL "Enable PDL")
+
 option(MLIR_INCLUDE_TESTS
"Generate build targets for the MLIR unit tests."
${LLVM_INCLUDE_TESTS})
@@ -179,12 +181,14 @@ include_directories( ${MLIR_INCLUDE_DIR})
 # from another directory like tools
 add_subdirectory(tools/mlir-tblgen)
 add_subdirectory(tools/mlir-linalg-ods-gen)
-add_subdirectory(tools/mlir-pdll)
-
 set(MLIR_TABLEGEN_EXE "${MLIR_TABLEGEN_EXE}" CACHE INTERNAL "")
 set(MLIR_TABLEGEN_TARGET "${MLIR_TABLEGEN_TARGET}" CACHE INTERNAL "")
-set(MLIR_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}" CACHE INTERNAL "")
-set(MLIR_PDLL_TABLEGEN_TARGET "${MLIR_PDLL_TABLEGEN_TARGET}" CACHE INTERNAL "")
+
+if(MLIR_ENABLE_PDL)
+  add_subdirectory(tools/mlir-pdll)
+  set(MLIR_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}" CACHE INTERNAL "")
+  set(MLIR_PDLL_TABLEGEN_TARGET "${MLIR_PDLL_TABLEGEN_TARGET}" CACHE INTERNAL 
"")
+endif()
 
 add_subdirectory(include/mlir)
 add_subdirectory(lib)
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index 544abe43688820e..f20a2bc75d5433b 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -6,6 +6,9 @@ include(LLVMDistributionSupport)
 file(REMOVE ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml)
 
 function(mlir_tablegen ofn)
+  if (MLIR_ENABLE_PDL)

[Lldb-commits] [lldb] [mlir] Add config for PDL (PR #69927)

2023-10-27 Thread Jacques Pienaar via lldb-commits

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


[Lldb-commits] [lldb] [mlir] Add config for PDL (PR #69927)

2023-10-27 Thread Jacques Pienaar via lldb-commits

jpienaar wrote:

> Can you expand on the motivation? Why is it a problem that PDL is always 
> included? Your description isn’t very explicit on the impact.

Done. Its not PDL specific, I think it is a problem if any dialect is always 
included even if not used :) The others just have a simple method to elide.

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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-11 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/139252

>From c5ffbd84f8b68bae2112e8cec68803cefe571a72 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 05:23:00 -0700
Subject: [PATCH 1/2] [lldb][plugin] Clear in same thread as set

Here we were initializing & locking a mutex in a thread, while releasing it in 
the parent which may/often turned out to be a different thread 
(shared_mutex::unlock_shared is undefined behavior if called from a thread that 
doesn't hold the lock).

I'm not quite sure what the expectation is here as the variable is never used, 
so instead I've just reset in same thread as which it was set to ensure its 
freed in thread holding lock.
---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 523820874752a..0f0226ea9650c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,6 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
+ckear_cu_duex[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 5f5b8dc0deae4f63ddb83e0dfab96ab3a9e0cc80 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 08:15:26 -0700
Subject: [PATCH 2/2] Fix typo

---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0f0226ea9650c..6139d005b4f2e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,7 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
-ckear_cu_duex[idx].reset();
+ckear_cu_dies[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/139252



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Jacques Pienaar via lldb-commits

jpienaar wrote:

I agree a condition variable would work here. I realized this later too (wanted 
all destroyed at end), one could do that as follows too

// In ManualDWARFIndex
...
   std::vector clear_cu_dies;
clear_cu_dies.reserve(units_to_index.size());
for (auto &unit : units_to_index) clear_cu_dies.push_back(*unit);
for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit*) {
  clear_cu_dies[idx].Extract();
});
...

// in DWARFUnit.cpp

void DWARFUnit::ScopedExtractDIEs::Extract() {
  {
llvm::sys::ScopedReader lock(m_cu->m_die_array_mutex);
if (!m_cu->m_die_array.empty())
  return; // Already parsed
  }
  llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
  if (!m_cu->m_die_array.empty())
return; // Already parsed

  // Otherwise m_die_array would be already populated.
  lldbassert(!m_cu->m_cancel_scopes);

  m_cu->ExtractDIEsRWLocked();
  m_clear_dies = true;
}

DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped() {
  ScopedExtractDIEs scoped(*this);
  scoped.Extract();
  return scoped;
}
---

But if plain counter preferred, will switch to that.

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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-12 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/139252

>From c5ffbd84f8b68bae2112e8cec68803cefe571a72 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 05:23:00 -0700
Subject: [PATCH 1/3] [lldb][plugin] Clear in same thread as set

Here we were initializing & locking a mutex in a thread, while releasing it in 
the parent which may/often turned out to be a different thread 
(shared_mutex::unlock_shared is undefined behavior if called from a thread that 
doesn't hold the lock).

I'm not quite sure what the expectation is here as the variable is never used, 
so instead I've just reset in same thread as which it was set to ensure its 
freed in thread holding lock.
---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 523820874752a..0f0226ea9650c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,6 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
+ckear_cu_duex[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 5f5b8dc0deae4f63ddb83e0dfab96ab3a9e0cc80 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 08:15:26 -0700
Subject: [PATCH 2/3] Fix typo

---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0f0226ea9650c..6139d005b4f2e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,7 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
-ckear_cu_duex[idx].reset();
+ckear_cu_dies[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 6d8c69c480ce214772cb84a27da645b428916ecb Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Mon, 12 May 2025 13:19:45 +
Subject: [PATCH 3/3] Use plain reader counter

---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp   | 12 +---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h |  4 +++-
 .../Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp|  1 -
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 7d0afc04ac3b6..3a8409b1c3b66 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -189,17 +189,23 @@ DWARFUnit::ScopedExtractDIEs 
DWARFUnit::ExtractDIEsScoped() {
 }
 
 DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit &cu) : m_cu(&cu) {
-  m_cu->m_die_array_scoped_mutex.lock_shared();
+  llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
+  ++m_cu->m_die_array_scoped_count;
 }
 
 DWARFUnit::ScopedExtractDIEs::~ScopedExtractDIEs() {
   if (!m_cu)
 return;
-  m_cu->m_die_array_scoped_mutex.unlock_shared();
+  {
+llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
+--m_cu->m_die_array_scoped_count;
+if (m_cu->m_die_array_scoped_count == 0)
+  return;
+  }
   if (!m_clear_dies || m_cu->m_cancel_scopes)
 return;
   // Be sure no other ScopedExtractDIEs is running anymore.
-  llvm::sys::ScopedWriter lock_scoped(m_cu->m_die_array_scoped_mutex);
+  llvm::sys::ScopedLock lock_scoped(m_cu->m_die_array_scoped_mutex);
   llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
   if (m_cu->m_cancel_scopes)
 return;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 75a003e0a663c..c05bba36ed74b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -17,6 +17,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
+#include "llvm/Support/Mutex.h"
 #include "llvm/Support/RWMutex.h"
 #include 
 #include 
@@ -328,7 +329,8 @@ class DWARFUnit : public DWARFExpression::Delegate, public 
UserID {
   DWARFDebugInfoEntry::collection m_die_array;
   mutable llvm::sys::RWMutex m_die_array_mutex;
   // It is used for tracking of ScopedExtractDIEs instances.
-  mutable llvm::sys::RWMutex m_die_array_scoped_mutex;
+  mutable llvm::sys::Mutex m_die_array_scoped_mutex;
+  mutable int m_die_array_scoped_count = 0;
   // ScopedExtractDIEs ins

[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-09 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/139252

>From c5ffbd84f8b68bae2112e8cec68803cefe571a72 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 05:23:00 -0700
Subject: [PATCH 1/2] [lldb][plugin] Clear in same thread as set

Here we were initializing & locking a mutex in a thread, while releasing it in 
the parent which may/often turned out to be a different thread 
(shared_mutex::unlock_shared is undefined behavior if called from a thread that 
doesn't hold the lock).

I'm not quite sure what the expectation is here as the variable is never used, 
so instead I've just reset in same thread as which it was set to ensure its 
freed in thread holding lock.
---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 523820874752a..0f0226ea9650c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,6 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
+ckear_cu_duex[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 5f5b8dc0deae4f63ddb83e0dfab96ab3a9e0cc80 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 08:15:26 -0700
Subject: [PATCH 2/2] Fix typo

---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0f0226ea9650c..6139d005b4f2e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,7 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
-ckear_cu_duex[idx].reset();
+ckear_cu_dies[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-09 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar created 
https://github.com/llvm/llvm-project/pull/139252

Here we were initializing & locking a shared_mutex in a thread, while releasing 
it in the parent which may/often turned out to be a different thread 
(shared_mutex::unlock_shared is undefined behavior if called from a thread that 
doesn't hold the lock).

I'm not quite sure what the expectation is here as the variable is never used, 
so instead I've just reset in same thread as which it was set to ensure its 
freed in thread holding lock.

>From c5ffbd84f8b68bae2112e8cec68803cefe571a72 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 05:23:00 -0700
Subject: [PATCH] [lldb][plugin] Clear in same thread as set

Here we were initializing & locking a mutex in a thread, while releasing it in 
the parent which may/often turned out to be a different thread 
(shared_mutex::unlock_shared is undefined behavior if called from a thread that 
doesn't hold the lock).

I'm not quite sure what the expectation is here as the variable is never used, 
so instead I've just reset in same thread as which it was set to ensure its 
freed in thread holding lock.
---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 523820874752a..0f0226ea9650c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,6 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
+ckear_cu_duex[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

___
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] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)

2025-05-06 Thread Jacques Pienaar via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][plugin] Use counter directly for number of readers (PR #139252)

2025-05-13 Thread Jacques Pienaar via lldb-commits

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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-13 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/139252

>From c5ffbd84f8b68bae2112e8cec68803cefe571a72 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 05:23:00 -0700
Subject: [PATCH 1/5] [lldb][plugin] Clear in same thread as set

Here we were initializing & locking a mutex in a thread, while releasing it in 
the parent which may/often turned out to be a different thread 
(shared_mutex::unlock_shared is undefined behavior if called from a thread that 
doesn't hold the lock).

I'm not quite sure what the expectation is here as the variable is never used, 
so instead I've just reset in same thread as which it was set to ensure its 
freed in thread holding lock.
---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 523820874752a..0f0226ea9650c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,6 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
+ckear_cu_duex[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 5f5b8dc0deae4f63ddb83e0dfab96ab3a9e0cc80 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Fri, 9 May 2025 08:15:26 -0700
Subject: [PATCH 2/5] Fix typo

---
 lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 0f0226ea9650c..6139d005b4f2e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -121,7 +121,7 @@ void ManualDWARFIndex::Index() {
   units_to_index.size());
   for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) {
 clear_cu_dies[idx] = unit->ExtractDIEsScoped();
-ckear_cu_duex[idx].reset();
+ckear_cu_dies[idx].reset();
   });
 
   // Now index all DWARF unit in parallel.

>From 6d8c69c480ce214772cb84a27da645b428916ecb Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Mon, 12 May 2025 13:19:45 +
Subject: [PATCH 3/5] Use plain reader counter

---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp   | 12 +---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h |  4 +++-
 .../Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp|  1 -
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 7d0afc04ac3b6..3a8409b1c3b66 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -189,17 +189,23 @@ DWARFUnit::ScopedExtractDIEs 
DWARFUnit::ExtractDIEsScoped() {
 }
 
 DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit &cu) : m_cu(&cu) {
-  m_cu->m_die_array_scoped_mutex.lock_shared();
+  llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
+  ++m_cu->m_die_array_scoped_count;
 }
 
 DWARFUnit::ScopedExtractDIEs::~ScopedExtractDIEs() {
   if (!m_cu)
 return;
-  m_cu->m_die_array_scoped_mutex.unlock_shared();
+  {
+llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
+--m_cu->m_die_array_scoped_count;
+if (m_cu->m_die_array_scoped_count == 0)
+  return;
+  }
   if (!m_clear_dies || m_cu->m_cancel_scopes)
 return;
   // Be sure no other ScopedExtractDIEs is running anymore.
-  llvm::sys::ScopedWriter lock_scoped(m_cu->m_die_array_scoped_mutex);
+  llvm::sys::ScopedLock lock_scoped(m_cu->m_die_array_scoped_mutex);
   llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
   if (m_cu->m_cancel_scopes)
 return;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 75a003e0a663c..c05bba36ed74b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -17,6 +17,7 @@
 #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
 #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h"
+#include "llvm/Support/Mutex.h"
 #include "llvm/Support/RWMutex.h"
 #include 
 #include 
@@ -328,7 +329,8 @@ class DWARFUnit : public DWARFExpression::Delegate, public 
UserID {
   DWARFDebugInfoEntry::collection m_die_array;
   mutable llvm::sys::RWMutex m_die_array_mutex;
   // It is used for tracking of ScopedExtractDIEs instances.
-  mutable llvm::sys::RWMutex m_die_array_scoped_mutex;
+  mutable llvm::sys::Mutex m_die_array_scoped_mutex;
+  mutable int m_die_array_scoped_count = 0;
   // ScopedExtractDIEs ins

[Lldb-commits] [lldb] [lldb][plugin] Use counter directly for number of readers (PR #139252)

2025-05-13 Thread Jacques Pienaar via lldb-commits

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


[Lldb-commits] [lldb] [lldb][plugin] Clear in same thread as set (PR #139252)

2025-05-13 Thread Jacques Pienaar via lldb-commits

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