[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread David Spickett via lldb-commits


@@ -38,7 +38,43 @@ read packet: +
 read packet: $OK#9a
 send packet: +
 
+//--
+// "QSupported"
+//
+// BRIEF
+//  Query the GDB remote server for features it supports
+//
+// PRIORITY TO IMPLEMENT
+//  Optional.
+//--
 
+QSupported is a standard GDB Remote Serial Protocol packet, but
+there are several additions to the response that lldb can parse.
+An example exchange:
+
+send packet: 
qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+
+
+read packet: 
qXfer:features:read+;PacketSize=2;qEcho+;native-signals+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;SupportedWatchpointTypes=aarch64-mask,aarch64-bas;
+
+In this example, three lldb extensions are shown:
+
+  PacketSize=2
+The base16 maximum packet size that the stub can handle.

DavidSpickett wrote:

I was mostly confused by the lack of a space between base and 16. "base 16" is 
recognisable, "base16" sounds like a nightclub.I was mostly confused by the 
lack of a space between base and 16. "base 16" is recognisable, "base16" sounds 
like a nightclub.

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


[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread David Spickett via lldb-commits


@@ -38,7 +38,43 @@ read packet: +
 read packet: $OK#9a
 send packet: +
 
+//--
+// "QSupported"
+//
+// BRIEF
+//  Query the GDB remote server for features it supports
+//
+// PRIORITY TO IMPLEMENT
+//  Optional.
+//--
 
+QSupported is a standard GDB Remote Serial Protocol packet, but
+there are several additions to the response that lldb can parse.
+An example exchange:
+
+send packet: 
qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+
+
+read packet: 
qXfer:features:read+;PacketSize=2;qEcho+;native-signals+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;SupportedWatchpointTypes=aarch64-mask,aarch64-bas;
+
+In this example, three lldb extensions are shown:

DavidSpickett wrote:

"In the example above"

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


[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread David Spickett via lldb-commits


@@ -38,7 +38,43 @@ read packet: +
 read packet: $OK#9a
 send packet: +
 
+//--
+// "QSupported"
+//
+// BRIEF
+//  Query the GDB remote server for features it supports
+//
+// PRIORITY TO IMPLEMENT
+//  Optional.
+//--
 
+QSupported is a standard GDB Remote Serial Protocol packet, but
+there are several additions to the response that lldb can parse.

DavidSpickett wrote:

"can parse. They are not all listed here.

An example exchange:"

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


[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread David Spickett via lldb-commits


@@ -403,6 +403,22 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() {
 x.split(compressions, ',');
 if (!compressions.empty())
   MaybeEnableCompression(compressions);
+  } else if (x.consume_front("SupportedWatchpointTypes=")) {
+llvm::SmallVector watchpoint_types;
+x.split(watchpoint_types, ',');
+m_watchpoint_types =
+WatchpointHardwareFeature::eWatchpointHardwareFeatureUnknown;
+for (auto wp_type : watchpoint_types) {
+  if (wp_type == "x86_64")
+m_watchpoint_types |=
+WatchpointHardwareFeature::eWatchpointHardwareX86;
+  if (wp_type == "aarch64-mask")
+m_watchpoint_types |=
+WatchpointHardwareFeature::eWatchpointHardwareArmMASK;
+  if (wp_type == "aarch64-bas")
+m_watchpoint_types |=
+WatchpointHardwareFeature::eWatchpointHardwareArmBAS;
+}

DavidSpickett wrote:

Sure. The other motivation for me was to not add more else if to 
`GetRemoteQSupported` which is probably a gazillion lines long. But a few more 
on top of that isn't changing anything so it's fine.

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


[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)

2024-02-05 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> What happens now is that there is a ProcessGDBRemote that registers for 
> gdb-remote and it is returned by Process::FindPlugin. > Then there is the new 
> ProcessWasm which might also register for the same gdb-remote maybe.
> But the problem is that at the moment when we start the connection we do not 
> know that we are connecting to a Wasm target.
>
> Here, with the following call stack, target_sp->m_arch is still not 
> initialized in Process::FindPlugin:

This feels like a bug or at least a design flaw in lldb then. ABI plugins for 
example clearly need to know the architecture and they work with remotes just 
fine, by reading the architecture from the object file (somehow).

But I'm not expecting you to address or even find that here, I would just 
prefer that this went ahead without the `wasm` top level command. If you still 
want to add that it can be a follow up where we can focus on that.

> When using read register I can only see pc and nothing else though. I'm not 
> sure assimilating Wasm variables to registers is > the good way to go anyway, 
> because the number of Wasm variables is not fixed in advance, and subject to 
> the context of > execution (with local variables). This is not the case at 
> all for classic CPU registers, and I'm not sure the generic code managing > 
> registers in lldb will support that.

We have some registers on Linux that could be considered part of the kernel 
interface not the hardware, so there is precedent for these "pseudo" registers. 
Examples are the memory tagging and scalable matrix control registers. However 
those features are enabled at kernel boot, so they don't come and go at 
runtime. Scalable vectors (SVE) can change *size* at runtime but they don't 
come and go either.

The one register that does that is the scalable matrix array register, which 
can be disabled by software. But, and this should tell you something, both I 
and my colleagues on GDB decided to just show it as all 0s when it's disabled. 
Instead of re-configuring the registers on every stop. It becomes hard to keep 
track when a register in the middle of the context disappears.

So I don't disagree with the concept of showing them as registers. They could 
be compared to the Linux kernel pseudo registers we have. However it will be 
more difficult than those registers, due to the dynamism. So if you're going to 
do it, please open a PR focused on that.

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


[Lldb-commits] [lld] [libc] [lldb] [flang] [clang] [libcxx] [llvm] [clang-tools-extra] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread David Stuttard via lldb-commits

https://github.com/dstutt updated 
https://github.com/llvm/llvm-project/pull/67104

>From 259138920126f09149b488fc54e8d2a7da969ca4 Mon Sep 17 00:00:00 2001
From: David Stuttard 
Date: Thu, 24 Aug 2023 16:45:50 +0100
Subject: [PATCH 1/4] [AMDGPU] Add pal metadata 3.0 support to callable pal
 funcs

---
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   |  28 +-
 .../AMDGPU/pal-metadata-3.0-callable.ll   | 290 ++
 2 files changed, 314 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index b2360ce30fd6e..22ecd3656d00a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1098,10 +1098,30 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const 
MachineFunction &MF) {
   StringRef FnName = MF.getFunction().getName();
   MD->setFunctionScratchSize(FnName, MFI.getStackSize());
 
-  // Set compute registers
-  MD->setRsrc1(CallingConv::AMDGPU_CS,
-   CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
-  MD->setRsrc2(CallingConv::AMDGPU_CS, 
CurrentProgramInfo.getComputePGMRSrc2());
+  if (MD->getPALMajorVersion() < 3) {
+// Set compute registers
+MD->setRsrc1(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
+MD->setRsrc2(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getComputePGMRSrc2());
+  } else {
+MD->setHwStage(CallingConv::AMDGPU_CS, ".ieee_mode",
+   (bool)CurrentProgramInfo.IEEEMode);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".wgp_mode",
+   (bool)CurrentProgramInfo.WgpMode);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".mem_ordered",
+   (bool)CurrentProgramInfo.MemOrdered);
+
+MD->setHwStage(CallingConv::AMDGPU_CS, ".trap_present",
+   (bool)CurrentProgramInfo.TrapHandlerEnable);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".excp_en",
+   CurrentProgramInfo.EXCPEnable);
+
+const unsigned LdsDwGranularity = 128;
+MD->setHwStage(CallingConv::AMDGPU_CS, ".lds_size",
+   (unsigned)(CurrentProgramInfo.LdsSize * LdsDwGranularity *
+  sizeof(uint32_t)));
+  }
 
   // Set optional info
   MD->setFunctionLdsSize(FnName, CurrentProgramInfo.LDSSize);
diff --git a/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll 
b/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
new file mode 100644
index 0..d4a5f61aced61
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
@@ -0,0 +1,290 @@
+; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1100 -verify-machineinstrs < %s | 
FileCheck %s
+
+; CHECK:   .amdgpu_pal_metadata
+; CHECK-NEXT: ---
+; CHECK-NEXT: amdpal.pipelines:
+; CHECK-NEXT:  - .api:Vulkan
+; CHECK-NEXT:.compute_registers:
+; CHECK-NEXT:  .tg_size_en: true
+; CHECK-NEXT:  .tgid_x_en:  false
+; CHECK-NEXT:  .tgid_y_en:  false
+; CHECK-NEXT:  .tgid_z_en:  false
+; CHECK-NEXT:  .tidig_comp_cnt: 0x1
+; CHECK-NEXT:.hardware_stages:
+; CHECK-NEXT:  .cs:
+; CHECK-NEXT:.checksum_value: 0x9444d7d0
+; CHECK-NEXT:.debug_mode: 0
+; CHECK-NEXT:.excp_en:0
+; CHECK-NEXT:.float_mode: 0xc0
+; CHECK-NEXT:.ieee_mode:  true
+; CHECK-NEXT:.image_op:   false
+; CHECK-NEXT:.lds_size:   0x200
+; CHECK-NEXT:.mem_ordered:true
+; CHECK-NEXT:.sgpr_limit: 0x6a
+; CHECK-NEXT:.threadgroup_dimensions:
+; CHECK-NEXT:  - 0x1
+; CHECK-NEXT:  - 0x400
+; CHECK-NEXT:  - 0x1
+; CHECK-NEXT:.trap_present:   false
+; CHECK-NEXT:.user_data_reg_map:
+; CHECK-NEXT:  - 0x1000
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT

[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)

2024-02-05 Thread Xu Jun via lldb-commits

xujuntwt95329 wrote:

> > On the other hand, as a managed language, I think most people won't need to 
> > read specific local/global of an instance, just like most of the JavaScript 
> > developer won't care about the value of a register in V8 during debugging, 
> > they just care about the value of their variables.
> 
> I agree that the average developer will not have much use of the possibility 
> of accessing Wasm locals and globals. I also understand that Wasm locals and 
> global are a very specific, Wasm-only concept and that adding this concept in 
> LLVM core is not pertinent. However for people working on the inner workings 
> of Wasm (like me), it may be very useful. I'm not sure it belongs to this PR 
> but implementing support for accessing Wasm locals/globals in the future 
> (using perhaps a command like `language wasm`) seems an interesting thing to 
> do to complete the debugging experience on Wasm with lldb.
> 
> What I'm wondering is, does these potential added commands have an impact on 
> this PR ? Or can we imagine commands that will send a specific, Wasm-only 
> request to the debugging server to get the values of the variables without 
> using the implementation of locals and globals of this PR ?

I agree that implementing support for accessing Wasm locals/globals would be a 
very interesting and exciting thing, and as a WebAssembly runtime developer, 
such features will be extremely useful to me (currently I need to debug the 
runtime itself to retrieve the internal data structures to find the value of 
locals/globals). But since there isn't an existing concepts in lldb to support 
these, we think it should be better to focus this PR on the source level 
debugging support to control the complexity, and leave the local/global support 
as further enhancement.

> What I'm wondering is, does these potential added commands have an impact on 
> this PR ? Or can we imagine commands that will send a specific, Wasm-only 
> request to the debugging server to get the values of the variables without 
> using the implementation of locals and globals of this PR ?

I think a wasm-specific command which directly send message to debug server for 
getting local/global values would be a simple approach to support the nice 
features, maybe we can consider such solution in the future to improve the 
debugging experience.

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


[Lldb-commits] [llvm] [clang-tools-extra] [flang] [lldb] [clang] [libcxx] [libc] [lld] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread Matt Arsenault via lldb-commits


@@ -1127,10 +1131,16 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const 
MachineFunction &MF) {
   MD->setFunctionScratchSize(FnName, MFI.getStackSize());
   const GCNSubtarget &ST = MF.getSubtarget();
 
-  // Set compute registers
-  MD->setRsrc1(CallingConv::AMDGPU_CS,
-   CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS, ST));
-  MD->setRsrc2(CallingConv::AMDGPU_CS, 
CurrentProgramInfo.getComputePGMRSrc2());
+  if (MD->getPALMajorVersion() < 3) {
+// Set compute registers
+MD->setRsrc1(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS, ST));
+MD->setRsrc2(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getComputePGMRSrc2());
+  } else {
+EmitPALMetadataCommon(MD, CurrentProgramInfo, CallingConv::AMDGPU_CS,
+  *getGlobalSTI());

arsenm wrote:

Never use getGlobalSTI. Use ST

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


[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)

2024-02-05 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> I don't know specifically why we skip those tests on our bot. Could be that 
> the Windows APIs are target specific like ptrace is, > and we just didn't 
> implement it for Windows on Arm yet, could be that the hardware we have 
> doesn't support it.
> 
> I'll found out what the status is there.

@jasonmolenda, https://github.com/llvm/llvm-project/issues/80665.

They could work but there is work to be done to get there. You don't need to 
consider it The tests should work on x86 Windows, but there's no bot for that 
anymore. Maybe someone pops up in future with a report if it's being tested 
elsewhere.

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


[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)

2024-02-05 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Unlikely even that given the range breakpoint stuff is all on AArch64 anyway.

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


[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)

2024-02-05 Thread Xu Jun via lldb-commits

xujuntwt95329 wrote:

> > I see, thanks for the clarification. In the patch, the WasmLocal and 
> > WasmGlobal calls are done in ReadRegister, so it seems like those are being 
> > presented as register values? `register read` should show them. BTW, we 
> > shouldn't make a top level `wasm` command, we really try hard not to occupy 
> > more of the "easy to type" parts of the lldb command set than we can help, 
> > so there is lots left free for users to customize. There's a `language 
> > cplusplus` command (and on the swift fork `language swift`, so it would 
> > make sense to have wasm commands be vended as `language wasm`. Then people 
> > who do a lot of WebAssembly debugging can make an alias to wasm if that 
> > helps. Jim
> 
> However, `language` plugins do not seem to work for the Wasm case here. When 
> we are debugging Wasm code, WebAssembly is the architecture and the source 
> language is the whatever was compiled to Wasm, commonly C/C++ or Rust.
> 
> If we implement a `WasmLanguage` plugin we should override virtual methods 
> like `bool IsTopLevelFunction(Function &function)`, `bool 
> IsSourceFile(StringRef &file_path) `GetFormatters()` which do not really 
> apply here.
> 
> But I agree that it is not nice to make a top level `wasm` command, so maybe 
> the best way is to leave everything as it is and to just specify the plugin 
> name at connection time: `process connect --plugin wasm 
> connect://localhost:`

Yes, the top level `wasm` command may be useful to WebAssembly users but may 
cause confusion to other users who doesn't use WebAssembly (Just like their 
isn't a top level `arm` command, `wasm` here should be conceptually equivalent 
with `arm`). Maybe we can remove this command from this PR, and users can add 
their own alias for convenience.

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


[Lldb-commits] [lldb] [lld] [clang] [libcxx] [flang] [clang-tools-extra] [llvm] [libc] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread David Stuttard via lldb-commits

https://github.com/dstutt updated 
https://github.com/llvm/llvm-project/pull/67104

>From 259138920126f09149b488fc54e8d2a7da969ca4 Mon Sep 17 00:00:00 2001
From: David Stuttard 
Date: Thu, 24 Aug 2023 16:45:50 +0100
Subject: [PATCH 1/5] [AMDGPU] Add pal metadata 3.0 support to callable pal
 funcs

---
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   |  28 +-
 .../AMDGPU/pal-metadata-3.0-callable.ll   | 290 ++
 2 files changed, 314 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index b2360ce30fd6e..22ecd3656d00a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1098,10 +1098,30 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const 
MachineFunction &MF) {
   StringRef FnName = MF.getFunction().getName();
   MD->setFunctionScratchSize(FnName, MFI.getStackSize());
 
-  // Set compute registers
-  MD->setRsrc1(CallingConv::AMDGPU_CS,
-   CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
-  MD->setRsrc2(CallingConv::AMDGPU_CS, 
CurrentProgramInfo.getComputePGMRSrc2());
+  if (MD->getPALMajorVersion() < 3) {
+// Set compute registers
+MD->setRsrc1(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
+MD->setRsrc2(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getComputePGMRSrc2());
+  } else {
+MD->setHwStage(CallingConv::AMDGPU_CS, ".ieee_mode",
+   (bool)CurrentProgramInfo.IEEEMode);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".wgp_mode",
+   (bool)CurrentProgramInfo.WgpMode);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".mem_ordered",
+   (bool)CurrentProgramInfo.MemOrdered);
+
+MD->setHwStage(CallingConv::AMDGPU_CS, ".trap_present",
+   (bool)CurrentProgramInfo.TrapHandlerEnable);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".excp_en",
+   CurrentProgramInfo.EXCPEnable);
+
+const unsigned LdsDwGranularity = 128;
+MD->setHwStage(CallingConv::AMDGPU_CS, ".lds_size",
+   (unsigned)(CurrentProgramInfo.LdsSize * LdsDwGranularity *
+  sizeof(uint32_t)));
+  }
 
   // Set optional info
   MD->setFunctionLdsSize(FnName, CurrentProgramInfo.LDSSize);
diff --git a/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll 
b/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
new file mode 100644
index 0..d4a5f61aced61
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
@@ -0,0 +1,290 @@
+; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1100 -verify-machineinstrs < %s | 
FileCheck %s
+
+; CHECK:   .amdgpu_pal_metadata
+; CHECK-NEXT: ---
+; CHECK-NEXT: amdpal.pipelines:
+; CHECK-NEXT:  - .api:Vulkan
+; CHECK-NEXT:.compute_registers:
+; CHECK-NEXT:  .tg_size_en: true
+; CHECK-NEXT:  .tgid_x_en:  false
+; CHECK-NEXT:  .tgid_y_en:  false
+; CHECK-NEXT:  .tgid_z_en:  false
+; CHECK-NEXT:  .tidig_comp_cnt: 0x1
+; CHECK-NEXT:.hardware_stages:
+; CHECK-NEXT:  .cs:
+; CHECK-NEXT:.checksum_value: 0x9444d7d0
+; CHECK-NEXT:.debug_mode: 0
+; CHECK-NEXT:.excp_en:0
+; CHECK-NEXT:.float_mode: 0xc0
+; CHECK-NEXT:.ieee_mode:  true
+; CHECK-NEXT:.image_op:   false
+; CHECK-NEXT:.lds_size:   0x200
+; CHECK-NEXT:.mem_ordered:true
+; CHECK-NEXT:.sgpr_limit: 0x6a
+; CHECK-NEXT:.threadgroup_dimensions:
+; CHECK-NEXT:  - 0x1
+; CHECK-NEXT:  - 0x400
+; CHECK-NEXT:  - 0x1
+; CHECK-NEXT:.trap_present:   false
+; CHECK-NEXT:.user_data_reg_map:
+; CHECK-NEXT:  - 0x1000
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT

[Lldb-commits] [lld] [lldb] [libcxx] [clang] [libc] [clang-tools-extra] [flang] [llvm] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread David Stuttard via lldb-commits


@@ -1127,10 +1131,16 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const 
MachineFunction &MF) {
   MD->setFunctionScratchSize(FnName, MFI.getStackSize());
   const GCNSubtarget &ST = MF.getSubtarget();
 
-  // Set compute registers
-  MD->setRsrc1(CallingConv::AMDGPU_CS,
-   CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS, ST));
-  MD->setRsrc2(CallingConv::AMDGPU_CS, 
CurrentProgramInfo.getComputePGMRSrc2());
+  if (MD->getPALMajorVersion() < 3) {
+// Set compute registers
+MD->setRsrc1(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS, ST));
+MD->setRsrc2(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getComputePGMRSrc2());
+  } else {
+EmitPALMetadataCommon(MD, CurrentProgramInfo, CallingConv::AMDGPU_CS,
+  *getGlobalSTI());

dstutt wrote:

Thanks - done.

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


[Lldb-commits] [libc] [libcxx] [clang-tools-extra] [flang] [lld] [lldb] [llvm] [clang] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread Matt Arsenault via lldb-commits


@@ -1025,6 +1025,26 @@ void AMDGPUAsmPrinter::EmitProgramInfoSI(const 
MachineFunction &MF,
   OutStreamer->emitInt32(MFI->getNumSpilledVGPRs());
 }
 
+// Helper function to add common PAL Metadata 3.0+
+static void EmitPALMetadataCommon(AMDGPUPALMetadata *MD,
+  const SIProgramInfo &CurrentProgramInfo,
+  CallingConv::ID CC,
+  const MCSubtargetInfo &ST) {
+  MD->setHwStage(CC, ".ieee_mode", (bool)CurrentProgramInfo.IEEEMode);

arsenm wrote:

should this be skipped for gfx12? 

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


[Lldb-commits] [lld] [lldb] [libcxx] [clang] [libc] [clang-tools-extra] [flang] [llvm] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread Piotr Sobczak via lldb-commits


@@ -1025,6 +1025,26 @@ void AMDGPUAsmPrinter::EmitProgramInfoSI(const 
MachineFunction &MF,
   OutStreamer->emitInt32(MFI->getNumSpilledVGPRs());
 }
 
+// Helper function to add common PAL Metadata 3.0+
+static void EmitPALMetadataCommon(AMDGPUPALMetadata *MD,
+  const SIProgramInfo &CurrentProgramInfo,
+  CallingConv::ID CC,
+  const MCSubtargetInfo &ST) {
+  MD->setHwStage(CC, ".ieee_mode", (bool)CurrentProgramInfo.IEEEMode);

piotrAMD wrote:

Maybe, but I wasn't sure. Seems we generally do not bother to do gfxip checks 
for others (e.g., "MemOrdered" is only supported on gfx10 and gfx11).

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


[Lldb-commits] [lld] [lldb] [libcxx] [clang] [libc] [clang-tools-extra] [flang] [llvm] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread David Stuttard via lldb-commits


@@ -1025,6 +1025,26 @@ void AMDGPUAsmPrinter::EmitProgramInfoSI(const 
MachineFunction &MF,
   OutStreamer->emitInt32(MFI->getNumSpilledVGPRs());
 }
 
+// Helper function to add common PAL Metadata 3.0+
+static void EmitPALMetadataCommon(AMDGPUPALMetadata *MD,
+  const SIProgramInfo &CurrentProgramInfo,
+  CallingConv::ID CC,
+  const MCSubtargetInfo &ST) {
+  MD->setHwStage(CC, ".ieee_mode", (bool)CurrentProgramInfo.IEEEMode);

dstutt wrote:

I can easily add that though - and that does mirror the recent change to 
getPGMRsrc1.

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


[Lldb-commits] [lld] [lldb] [libcxx] [clang] [libc] [clang-tools-extra] [flang] [llvm] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread Piotr Sobczak via lldb-commits


@@ -1025,6 +1025,26 @@ void AMDGPUAsmPrinter::EmitProgramInfoSI(const 
MachineFunction &MF,
   OutStreamer->emitInt32(MFI->getNumSpilledVGPRs());
 }
 
+// Helper function to add common PAL Metadata 3.0+
+static void EmitPALMetadataCommon(AMDGPUPALMetadata *MD,
+  const SIProgramInfo &CurrentProgramInfo,
+  CallingConv::ID CC,
+  const MCSubtargetInfo &ST) {
+  MD->setHwStage(CC, ".ieee_mode", (bool)CurrentProgramInfo.IEEEMode);

piotrAMD wrote:

Sounds good.

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


[Lldb-commits] [lld] [lldb] [libcxx] [clang] [libc] [clang-tools-extra] [flang] [llvm] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread David Stuttard via lldb-commits

https://github.com/dstutt updated 
https://github.com/llvm/llvm-project/pull/67104

>From 259138920126f09149b488fc54e8d2a7da969ca4 Mon Sep 17 00:00:00 2001
From: David Stuttard 
Date: Thu, 24 Aug 2023 16:45:50 +0100
Subject: [PATCH 1/6] [AMDGPU] Add pal metadata 3.0 support to callable pal
 funcs

---
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   |  28 +-
 .../AMDGPU/pal-metadata-3.0-callable.ll   | 290 ++
 2 files changed, 314 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index b2360ce30fd6e..22ecd3656d00a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1098,10 +1098,30 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const 
MachineFunction &MF) {
   StringRef FnName = MF.getFunction().getName();
   MD->setFunctionScratchSize(FnName, MFI.getStackSize());
 
-  // Set compute registers
-  MD->setRsrc1(CallingConv::AMDGPU_CS,
-   CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
-  MD->setRsrc2(CallingConv::AMDGPU_CS, 
CurrentProgramInfo.getComputePGMRSrc2());
+  if (MD->getPALMajorVersion() < 3) {
+// Set compute registers
+MD->setRsrc1(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
+MD->setRsrc2(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getComputePGMRSrc2());
+  } else {
+MD->setHwStage(CallingConv::AMDGPU_CS, ".ieee_mode",
+   (bool)CurrentProgramInfo.IEEEMode);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".wgp_mode",
+   (bool)CurrentProgramInfo.WgpMode);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".mem_ordered",
+   (bool)CurrentProgramInfo.MemOrdered);
+
+MD->setHwStage(CallingConv::AMDGPU_CS, ".trap_present",
+   (bool)CurrentProgramInfo.TrapHandlerEnable);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".excp_en",
+   CurrentProgramInfo.EXCPEnable);
+
+const unsigned LdsDwGranularity = 128;
+MD->setHwStage(CallingConv::AMDGPU_CS, ".lds_size",
+   (unsigned)(CurrentProgramInfo.LdsSize * LdsDwGranularity *
+  sizeof(uint32_t)));
+  }
 
   // Set optional info
   MD->setFunctionLdsSize(FnName, CurrentProgramInfo.LDSSize);
diff --git a/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll 
b/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
new file mode 100644
index 0..d4a5f61aced61
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
@@ -0,0 +1,290 @@
+; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1100 -verify-machineinstrs < %s | 
FileCheck %s
+
+; CHECK:   .amdgpu_pal_metadata
+; CHECK-NEXT: ---
+; CHECK-NEXT: amdpal.pipelines:
+; CHECK-NEXT:  - .api:Vulkan
+; CHECK-NEXT:.compute_registers:
+; CHECK-NEXT:  .tg_size_en: true
+; CHECK-NEXT:  .tgid_x_en:  false
+; CHECK-NEXT:  .tgid_y_en:  false
+; CHECK-NEXT:  .tgid_z_en:  false
+; CHECK-NEXT:  .tidig_comp_cnt: 0x1
+; CHECK-NEXT:.hardware_stages:
+; CHECK-NEXT:  .cs:
+; CHECK-NEXT:.checksum_value: 0x9444d7d0
+; CHECK-NEXT:.debug_mode: 0
+; CHECK-NEXT:.excp_en:0
+; CHECK-NEXT:.float_mode: 0xc0
+; CHECK-NEXT:.ieee_mode:  true
+; CHECK-NEXT:.image_op:   false
+; CHECK-NEXT:.lds_size:   0x200
+; CHECK-NEXT:.mem_ordered:true
+; CHECK-NEXT:.sgpr_limit: 0x6a
+; CHECK-NEXT:.threadgroup_dimensions:
+; CHECK-NEXT:  - 0x1
+; CHECK-NEXT:  - 0x400
+; CHECK-NEXT:  - 0x1
+; CHECK-NEXT:.trap_present:   false
+; CHECK-NEXT:.user_data_reg_map:
+; CHECK-NEXT:  - 0x1000
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT

[Lldb-commits] [flang] [llvm] [libc] [clang-tools-extra] [libcxx] [clang] [lldb] [lld] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 84ea236af9f36d409d2c45c66f8a8b6eb027935d 
2f727b08b894bca7c0c8aec2fdaffe536f8348d6 -- 
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp 
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index f5495aa756..059df7879d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1028,8 +1028,7 @@ void AMDGPUAsmPrinter::EmitProgramInfoSI(const 
MachineFunction &MF,
 // Helper function to add common PAL Metadata 3.0+
 static void EmitPALMetadataCommon(AMDGPUPALMetadata *MD,
   const SIProgramInfo &CurrentProgramInfo,
-  CallingConv::ID CC,
-  const GCNSubtarget &ST) {
+  CallingConv::ID CC, const GCNSubtarget &ST) {
   if (ST.hasIEEEMode())
 MD->setHwStage(CC, ".ieee_mode", (bool)CurrentProgramInfo.IEEEMode);
 

``




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


[Lldb-commits] [compiler-rt] [libcxx] [flang] [openmp] [llvm] [clang-tools-extra] [clang] [lldb] [lld] [libc] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)

2024-02-05 Thread Matt Arsenault via lldb-commits


@@ -862,14 +862,18 @@ static void instrumentOneFunc(
   auto Name = FuncInfo.FuncNameVar;
   auto CFGHash = ConstantInt::get(Type::getInt64Ty(M->getContext()),
   FuncInfo.FunctionHash);
+  // Make sure that pointer to global is passed in with zero addrspace
+  // This is relevant during GPU profiling
+  auto *NormalizedPtr = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+  Name, llvm::PointerType::getUnqual(M->getContext()));

arsenm wrote:

Avoid getUnqual, use an explicit 0 addrspace.

Also there should be no reason to emit pointer bitcast, simplify to just create 
addrspacecast 

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


[Lldb-commits] [clang-tools-extra] [clang] [lld] [flang] [libc] [libcxx] [llvm] [lldb] [AMDGPU] Add pal metadata 3.0 support to callable pal funcs (PR #67104)

2024-02-05 Thread David Stuttard via lldb-commits

https://github.com/dstutt updated 
https://github.com/llvm/llvm-project/pull/67104

>From 259138920126f09149b488fc54e8d2a7da969ca4 Mon Sep 17 00:00:00 2001
From: David Stuttard 
Date: Thu, 24 Aug 2023 16:45:50 +0100
Subject: [PATCH 1/7] [AMDGPU] Add pal metadata 3.0 support to callable pal
 funcs

---
 llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp   |  28 +-
 .../AMDGPU/pal-metadata-3.0-callable.ll   | 290 ++
 2 files changed, 314 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index b2360ce30fd6e..22ecd3656d00a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1098,10 +1098,30 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const 
MachineFunction &MF) {
   StringRef FnName = MF.getFunction().getName();
   MD->setFunctionScratchSize(FnName, MFI.getStackSize());
 
-  // Set compute registers
-  MD->setRsrc1(CallingConv::AMDGPU_CS,
-   CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
-  MD->setRsrc2(CallingConv::AMDGPU_CS, 
CurrentProgramInfo.getComputePGMRSrc2());
+  if (MD->getPALMajorVersion() < 3) {
+// Set compute registers
+MD->setRsrc1(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS));
+MD->setRsrc2(CallingConv::AMDGPU_CS,
+ CurrentProgramInfo.getComputePGMRSrc2());
+  } else {
+MD->setHwStage(CallingConv::AMDGPU_CS, ".ieee_mode",
+   (bool)CurrentProgramInfo.IEEEMode);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".wgp_mode",
+   (bool)CurrentProgramInfo.WgpMode);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".mem_ordered",
+   (bool)CurrentProgramInfo.MemOrdered);
+
+MD->setHwStage(CallingConv::AMDGPU_CS, ".trap_present",
+   (bool)CurrentProgramInfo.TrapHandlerEnable);
+MD->setHwStage(CallingConv::AMDGPU_CS, ".excp_en",
+   CurrentProgramInfo.EXCPEnable);
+
+const unsigned LdsDwGranularity = 128;
+MD->setHwStage(CallingConv::AMDGPU_CS, ".lds_size",
+   (unsigned)(CurrentProgramInfo.LdsSize * LdsDwGranularity *
+  sizeof(uint32_t)));
+  }
 
   // Set optional info
   MD->setFunctionLdsSize(FnName, CurrentProgramInfo.LDSSize);
diff --git a/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll 
b/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
new file mode 100644
index 0..d4a5f61aced61
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
@@ -0,0 +1,290 @@
+; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx1100 -verify-machineinstrs < %s | 
FileCheck %s
+
+; CHECK:   .amdgpu_pal_metadata
+; CHECK-NEXT: ---
+; CHECK-NEXT: amdpal.pipelines:
+; CHECK-NEXT:  - .api:Vulkan
+; CHECK-NEXT:.compute_registers:
+; CHECK-NEXT:  .tg_size_en: true
+; CHECK-NEXT:  .tgid_x_en:  false
+; CHECK-NEXT:  .tgid_y_en:  false
+; CHECK-NEXT:  .tgid_z_en:  false
+; CHECK-NEXT:  .tidig_comp_cnt: 0x1
+; CHECK-NEXT:.hardware_stages:
+; CHECK-NEXT:  .cs:
+; CHECK-NEXT:.checksum_value: 0x9444d7d0
+; CHECK-NEXT:.debug_mode: 0
+; CHECK-NEXT:.excp_en:0
+; CHECK-NEXT:.float_mode: 0xc0
+; CHECK-NEXT:.ieee_mode:  true
+; CHECK-NEXT:.image_op:   false
+; CHECK-NEXT:.lds_size:   0x200
+; CHECK-NEXT:.mem_ordered:true
+; CHECK-NEXT:.sgpr_limit: 0x6a
+; CHECK-NEXT:.threadgroup_dimensions:
+; CHECK-NEXT:  - 0x1
+; CHECK-NEXT:  - 0x400
+; CHECK-NEXT:  - 0x1
+; CHECK-NEXT:.trap_present:   false
+; CHECK-NEXT:.user_data_reg_map:
+; CHECK-NEXT:  - 0x1000
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT:  - 0x
+; CHECK-NEXT

[Lldb-commits] [libcxx] [libc] [compiler-rt] [lld] [clang] [lldb] [llvm] [flang] [clang-tools-extra] [libc++] P2602R2 Poison Pills are Too Toxic (PR #74534)

2024-02-05 Thread Jakub Mazurkiewicz via lldb-commits

https://github.com/JMazurkiewicz updated 
https://github.com/llvm/llvm-project/pull/74534

>From aaccb9e13618517803df1230741b02b4c5ee08c7 Mon Sep 17 00:00:00 2001
From: Jakub Mazurkiewicz 
Date: Tue, 5 Dec 2023 23:36:57 +0100
Subject: [PATCH 1/6] [libc++] P2602R2 Poison Pills are Too Toxic

---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/Status/Cxx23Papers.csv|  2 +-
 libcxx/include/__compare/partial_order.h  |  2 ++
 libcxx/include/__compare/strong_order.h   |  2 ++
 libcxx/include/__compare/weak_order.h |  2 ++
 libcxx/include/__iterator/iter_move.h |  2 +-
 libcxx/include/__ranges/access.h  |  6 ++--
 libcxx/include/__ranges/rbegin.h  |  3 +-
 libcxx/include/__ranges/rend.h|  3 +-
 libcxx/include/__ranges/size.h|  3 +-
 libcxx/include/version|  4 +--
 .../iterator.cust.move/iter_move.pass.cpp | 11 +++
 .../iterator.cust.swap/iter_swap.pass.cpp |  6 
 .../ordinary_unqualified_lookup_helpers.h | 33 +++
 .../cmp/cmp.alg/partial_order.pass.cpp|  9 +
 .../cmp/cmp.alg/strong_order.pass.cpp |  9 +
 .../cmp/cmp.alg/weak_order.pass.cpp   |  9 +
 .../algorithm.version.compile.pass.cpp| 14 
 .../functional.version.compile.pass.cpp   | 14 
 .../iterator.version.compile.pass.cpp | 14 
 .../memory.version.compile.pass.cpp   | 14 
 .../ranges.version.compile.pass.cpp   | 14 
 .../version.version.compile.pass.cpp  | 14 
 .../std/ranges/range.access/begin.pass.cpp| 18 +++---
 .../test/std/ranges/range.access/end.pass.cpp | 20 +++
 .../ordinary_unqualified_lookup_helpers.h | 25 ++
 .../std/ranges/range.access/rbegin.pass.cpp   | 18 +++---
 .../std/ranges/range.access/rend.pass.cpp | 20 +++
 .../std/ranges/range.access/size.pass.cpp |  9 -
 .../generate_feature_test_macro_components.py |  2 +-
 30 files changed, 223 insertions(+), 81 deletions(-)
 create mode 100644 
libcxx/test/std/language.support/cmp/cmp.alg/ordinary_unqualified_lookup_helpers.h
 create mode 100644 
libcxx/test/std/ranges/range.access/ordinary_unqualified_lookup_helpers.h

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index d09f65b7cadc0..f4788aa574788 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -266,7 +266,7 @@ Status
 --- -
 ``__cpp_lib_polymorphic_allocator`` ``201902L``
 --- -
-``__cpp_lib_ranges````202207L``
+``__cpp_lib_ranges````202211L``
 --- -
 ``__cpp_lib_remove_cvref``  ``201711L``
 --- -
diff --git a/libcxx/docs/Status/Cxx23Papers.csv 
b/libcxx/docs/Status/Cxx23Papers.csv
index e03cbff2a08bb..7dc6f36ba1e63 100644
--- a/libcxx/docs/Status/Cxx23Papers.csv
+++ b/libcxx/docs/Status/Cxx23Papers.csv
@@ -100,7 +100,7 @@
 "`P2396R1 `__","LWG", "Concurrency TS 2 fixes ", 
"November 2022","","","|concurrency TS|"
 "`P2505R5 `__","LWG", "Monadic Functions for 
``std::expected``", "November 2022","|Complete|","17.0",""
 "`P2539R4 `__","LWG", "Should the output of 
``std::print`` to a terminal be synchronized with the underlying stream?", 
"November 2022","|In Progress|","","|format|"
-"`P2602R2 `__","LWG", "Poison Pills are Too Toxic", 
"November 2022","","","|ranges|"
+"`P2602R2 `__","LWG", "Poison Pills are Too Toxic", 
"November 2022","|Complete|","18.0","|ranges|"
 "`P2708R1 `__","LWG", "No Further Fundamentals 
TSes", "November 2022","|Nothing to do|","",""
 "","","","","","",""
 "`P0290R4 `__","LWG", "``apply()`` for 
``synchronized_value``","February 2023","","","|concurrency TS|"
diff --git a/libcxx/include/__compare/partial_order.h 
b/libcxx/include/__compare/partial_order.h
index 36a11dfaa2881..b422bdd4ef841 100644
--- a/libcxx/include/__compare/partial_order.h
+++ b/libcxx/include/__compare/partial_order.h
@@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 // [cmp.alg]
 namespace __partial_order {
+void partial_order() = delete;
+
 struct __fn {
 // NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, 
but only here
 template
diff --git a/libcxx/include/__compare/strong_order.h 
b/libcxx/include/__compare/strong_order.h
index cbfcf7316de9e..ba59cb51b86d9 100644
--- a/libcxx/include/__co

[Lldb-commits] [lldb] ae92f6e - [lldb][Docs] Remove unnecessary colon in title

2024-02-05 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2024-02-05T15:25:16Z
New Revision: ae92f6e8aeb97e39b95a40fde8a176f6aff94063

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

LOG: [lldb][Docs] Remove unnecessary colon in title

Added: 


Modified: 
lldb/docs/use/python-reference.rst

Removed: 




diff  --git a/lldb/docs/use/python-reference.rst 
b/lldb/docs/use/python-reference.rst
index 79851490aa437..e5195a2471d9a 100644
--- a/lldb/docs/use/python-reference.rst
+++ b/lldb/docs/use/python-reference.rst
@@ -885,8 +885,8 @@ When the program is stopped at the beginning of the 'read' 
function in libc, we
   (lldb) frame variable
   (int) fd = 3
 
-Writing Target Stop-Hooks in Python:
-
+Writing Target Stop-Hooks in Python
+---
 
 Stop hooks fire whenever the process stops just before control is returned to 
the
 user.  Stop hooks can either be a set of lldb command-line commands, or can



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


[Lldb-commits] [llvm] [clang] [lldb] [clang-tools-extra] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #78977)

2024-02-05 Thread Paolo Severini via lldb-commits

https://github.com/paolosevMSFT updated 
https://github.com/llvm/llvm-project/pull/78977

>From 4bcf2b50123b18752108aad163a059577e360aa6 Mon Sep 17 00:00:00 2001
From: Paolo Severini 
Date: Mon, 22 Jan 2024 06:06:56 -0800
Subject: [PATCH 1/3] Add support for DW_OP_WASM_location to DWARFExpression

---
 lldb/source/Expression/DWARFExpression.cpp | 41 ++
 1 file changed, 41 insertions(+)

diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index fe4928d4f43a4..95033db5ed8f5 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -346,6 +346,16 @@ static offset_t GetOpcodeDataSize(const DataExtractor 
&data,
 return (offset - data_offset) + subexpr_len;
   }
 
+  case DW_OP_WASM_location: {
+uint8_t wasm_op = data.GetU8(&offset);
+if (wasm_op == 3) {
+  data.GetU32(&offset);
+} else {
+  data.GetULEB128(&offset);
+}
+return offset - data_offset;
+  }
+
   default:
 if (!dwarf_cu) {
   return LLDB_INVALID_OFFSET;
@@ -2595,6 +2605,37 @@ bool DWARFExpression::Evaluate(
   break;
 }
 
+case DW_OP_WASM_location: {
+  uint8_t wasm_op = opcodes.GetU8(&offset);
+  uint32_t index;
+
+  /* LLDB doesn't have an address space to represents WebAssembly locals,
+   * globals and operand stacks.
+   * We encode these elements into virtual registers:
+   *   | tag: 2 bits | index: 30 bits |
+   *   where tag is:
+   *0: Not a WebAssembly location
+   *1: Local
+   *2: Global
+   *3: Operand stack value
+   */
+  if (wasm_op == 3) {
+index = opcodes.GetU32(&offset);
+wasm_op = 2; // Global
+  } else {
+index = opcodes.GetULEB128(&offset);
+  }
+
+  reg_num = (((wasm_op + 1) & 0x03) << 30) | (index & 0x3fff);
+
+  if (ReadRegisterValueAsScalar(reg_ctx, reg_kind, reg_num, error_ptr, 
tmp))
+stack.push_back(tmp);
+  else
+return false;
+
+  break;
+}
+
 default:
   if (dwarf_cu) {
 if (dwarf_cu->GetSymbolFileDWARF().ParseVendorDWARFOpcode(

>From 639295de7bdd4a2e710b62337a511ded92eb702a Mon Sep 17 00:00:00 2001
From: Paolo Severini 
Date: Mon, 29 Jan 2024 06:25:58 -0800
Subject: [PATCH 2/3] Add unite tests

---
 .../include/lldb/Expression/DWARFExpression.h |   5 +
 lldb/source/Expression/DWARFExpression.cpp|  53 +-
 .../ObjectFile/wasm/ObjectFileWasm.cpp|   6 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  66 ++
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  27 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp   |   8 +-
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.h |   8 +-
 lldb/unittests/Expression/CMakeLists.txt  |   2 +
 .../Expression/DWARFExpressionTest.cpp| 562 ++
 9 files changed, 580 insertions(+), 157 deletions(-)

diff --git a/lldb/include/lldb/Expression/DWARFExpression.h 
b/lldb/include/lldb/Expression/DWARFExpression.h
index 1d85308d1caa7..73143399ff147 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -153,6 +153,11 @@ class DWARFExpression {
 
   bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op) const;
 
+  static bool ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
+lldb::RegisterKind reg_kind,
+uint32_t reg_num, Status *error_ptr,
+Value &value);
+
 private:
   /// A data extractor capable of reading opcode bytes
   DataExtractor m_data;
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 95033db5ed8f5..7298ccbf998d4 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -95,10 +95,12 @@ void DWARFExpression::SetRegisterKind(RegisterKind 
reg_kind) {
 }
 
 
-static bool ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
-  lldb::RegisterKind reg_kind,
-  uint32_t reg_num, Status *error_ptr,
-  Value &value) {
+// static
+bool DWARFExpression::ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
+lldb::RegisterKind reg_kind,
+uint32_t reg_num,
+Status *error_ptr,
+Value &value) {
   if (reg_ctx == nullptr) {
 if (error_ptr)
   error_ptr->SetErrorString("No register context in frame.\n");
@@ -346,16 +348,6 @@ static offset_t GetOpcodeDataSize(const DataExtractor 
&data,
 return (offset - data_offset) + subexpr_len;
   }
 
-  case DW_OP_WASM_location: {
-uint8_t wasm_op = data.GetU8(&offset);
-if (wasm_op == 3) {

[Lldb-commits] [libcxxabi] [lldb] [llvm] [flang] [libc] [compiler-rt] [clang] [libcxx] [clang-tools-extra] [lld] [docs] Fix malformed csv files (PR #80567)

2024-02-05 Thread via lldb-commits

github-actions[bot] wrote:

⚠️ We detected that you are using a GitHub private e-mail address to contribute 
to the repo.
  Please turn off [Keep my email addresses 
private](https://github.com/settings/emails) setting in your account.


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


[Lldb-commits] [lldb] [lldb] Remove unnecessary FormatCache::GetEntry (NFC) (PR #80603)

2024-02-05 Thread Adrian Prantl via lldb-commits


@@ -45,15 +45,12 @@ class FormatCache {
 void Set(lldb::TypeSummaryImplSP);
 void Set(lldb::SyntheticChildrenSP);
   };
-  typedef std::map CacheMap;
-  CacheMap m_map;
+  std::map m_entries;

adrian-prantl wrote:

Could this be a StringMap, or if we benefit from ConstString here, a 
DenseMap for faster lookups?

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


[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/80375

>From 59e1499ec0afebb533c4952f079278341b957241 Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Thu, 1 Feb 2024 18:07:51 -0800
Subject: [PATCH 1/4] Add commands frequency to statistics dump

---
 lldb/include/lldb/API/SBCommandInterpreter.h  |  9 ---
 lldb/include/lldb/API/SBStructuredData.h  |  1 +
 .../lldb/Interpreter/CommandInterpreter.h | 15 +--
 lldb/source/API/SBCommandInterpreter.cpp  | 15 ++-
 .../source/Commands/CommandObjectCommands.cpp | 10 ---
 .../source/Interpreter/CommandInterpreter.cpp |  9 ++-
 lldb/source/Interpreter/CommandObject.cpp |  1 +
 lldb/source/Target/Statistics.cpp |  4 +++
 .../commands/statistics/basic/TestStats.py| 24 +
 .../stats_api/TestStatisticsAPI.py| 26 +++
 10 files changed, 103 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index b7f5b3bf3396e4..b4629a4c2f5a84 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -246,13 +247,13 @@ class SBCommandInterpreter {
lldb::SBStringList &matches,
lldb::SBStringList &descriptions);
 
-  /// Returns whether an interrupt flag was raised either by the SBDebugger - 
+  /// Returns whether an interrupt flag was raised either by the SBDebugger -
   /// when the function is not running on the RunCommandInterpreter thread, or
   /// by SBCommandInterpreter::InterruptCommand if it is.  If your code is 
doing
-  /// interruptible work, check this API periodically, and interrupt if it 
+  /// interruptible work, check this API periodically, and interrupt if it
   /// returns true.
   bool WasInterrupted() const;
-  
+
   /// Interrupts the command currently executing in the RunCommandInterpreter
   /// thread.
   ///
@@ -315,6 +316,8 @@ class SBCommandInterpreter {
   /// and aliases.  If successful, result->GetOutput has the full expansion.
   void ResolveCommand(const char *command_line, SBCommandReturnObject &result);
 
+  SBStructuredData GetStatistics();
+
 protected:
   friend class lldb_private::CommandPluginInterfaceImplementation;
 
diff --git a/lldb/include/lldb/API/SBStructuredData.h 
b/lldb/include/lldb/API/SBStructuredData.h
index 35d321eaa7b891..fc6e1ec95c7b86 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -122,6 +122,7 @@ class SBStructuredData {
   friend class SBTrace;
   friend class lldb_private::python::SWIGBridge;
   friend class lldb_private::lua::SWIGBridge;
+  friend class SBCommandInterpreter;
 
   SBStructuredData(const lldb_private::StructuredDataImpl &impl);
 
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 747188a15312fa..c46cf0409bab60 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 class CommandInterpreter;
@@ -240,7 +241,7 @@ class CommandInterpreter : public Broadcaster,
 eCommandTypesAllThem = 0x  //< all commands
   };
 
-  // The CommandAlias and CommandInterpreter both have a hand in 
+  // The CommandAlias and CommandInterpreter both have a hand in
   // substituting for alias commands.  They work by writing special tokens
   // in the template form of the Alias command, and then detecting them when 
the
   // command is executed.  These are the special tokens:
@@ -575,7 +576,7 @@ class CommandInterpreter : public Broadcaster,
   void SetEchoCommentCommands(bool enable);
 
   bool GetRepeatPreviousCommand() const;
-  
+
   bool GetRequireCommandOverwrite() const;
 
   const CommandObject::CommandMap &GetUserCommands() const {
@@ -641,6 +642,12 @@ class CommandInterpreter : public Broadcaster,
   Status PreprocessCommand(std::string &command);
   Status PreprocessToken(std::string &token);
 
+  void IncreaseCommandUsage(const CommandObject &cmd_obj) {
+++m_command_usages[cmd_obj.GetCommandName().str()];
+  }
+
+  llvm::json::Value GetStatistics();
+
 protected:
   friend class Debugger;
 
@@ -754,6 +761,10 @@ class CommandInterpreter : public Broadcaster,
   // If the driver is accepts custom exit codes for the 'quit' command.
   bool m_allow_exit_code = false;
 
+  /// Command usage statistics.
+  typedef std::unordered_map CommandUsageMap;
+  CommandUsageMap m_command_usages;
+
   StreamString m_transcript_stream;
 };
 
diff --git a/lldb/source/API/SBCommandInterpreter.cpp 
b/lldb

[Lldb-commits] [lldb] [lldb] Remove unused private TypeCategoryMap methods (NFC) (PR #80602)

2024-02-05 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread Alex Langford via lldb-commits

bulbazord wrote:

> @bulbazord in the most recent commit I moved this internal-only enum from 
> lldb-enumerations.h to lldb-private-enumerations.h, but I need to use the 
> constexpr templatey thing that LLDB_MARK_AS_BITMASK_ENUM() defines for the 
> enum so I can use bit-wise | & operations without casting everywhere; that's 
> defined in lldb-enumerations.h so I included the public enums in the 
> lldb-private-enumerations.h. It seems like it's probably not a great choice, 
> but the other one is breaking out this and FLAGS_ENUM etc into a little 
> lldb-common-enumerations.h or something. What do you think?

Not the greatest thing in the world but it's not terrible either. We use the 
lldb public enumerations everywhere in private code, so as long as we're not 
going the other way this is ok to do. I will say, by moving the definitions 
from `lldb-enumerations.h` to `lldb-private-enumerations.h` you have removed 
these values from the python bindings. Technically that's an API break, but I'm 
not sure where anyone could have used these values otherwise. LGTM.

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


[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)

2024-02-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/80368

>From 3f3d7aeffe1d156efd4f54cdce6f6c6ca933da75 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 25 Jan 2024 11:05:02 +
Subject: [PATCH 1/2] [lldb] Add frame recognizer for __builtin_verbose_trap

This patch adds a frame recognizer for Clang's
`__builtin_verbose_trap`, which behaves like a
`__builtin_trap`, but emits a failure-reason string
into debug-info in order for debuggers to display
it to a user.

The frame recognizer triggers when we encounter
a frame with a function name that begins with
`__llvm_verbose_trap`, which is the magic prefix
Clang emits into debug-info for verbose traps.
Once such frame is encountered we display the
frame function name as the `Stop Reason` and display
that frame to the user.

Example output:
```
(lldb) run
warning: a.out was compiled with optimization - stepping may behave oddly; 
variables may not be available.
Process 35942 launched: 'a.out' (arm64)
Process 35942 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = 
__llvm_verbose_trap: Function is not implemented
frame #1: 0x00013fa4 a.out`main [inlined] 
Dummy::func(this=) at verbose_trap.cpp:3:5 [opt]
   1struct Dummy {
   2  void func() {
-> 3__builtin_verbose_trap("Function is not implemented");
   4  }
   5};
   6
   7int main() {
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = 
__llvm_verbose_trap: Function is not implemented
frame #0: 0x00013fa4 a.out`main [inlined] __llvm_verbose_trap: 
Function is not implemented at verbose_trap.cpp:0 [opt]
  * frame #1: 0x00013fa4 a.out`main [inlined] 
Dummy::func(this=) at verbose_trap.cpp:3:5 [opt]
frame #2: 0x00013fa4 a.out`main at verbose_trap.cpp:8:13 [opt]
frame #3: 0x000189d518b4 dyld`start + 1988
```
---
 .../lldb/Target/VerboseTrapFrameRecognizer.h  | 39 +
 lldb/source/Target/CMakeLists.txt |  1 +
 lldb/source/Target/Process.cpp|  2 +
 .../Target/VerboseTrapFrameRecognizer.cpp | 85 +++
 .../Shell/Recognizer/Inputs/verbose_trap.cpp  |  8 ++
 lldb/test/Shell/Recognizer/verbose_trap.test  |  9 ++
 6 files changed, 144 insertions(+)
 create mode 100644 lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
 create mode 100644 lldb/source/Target/VerboseTrapFrameRecognizer.cpp
 create mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap.cpp
 create mode 100644 lldb/test/Shell/Recognizer/verbose_trap.test

diff --git a/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h 
b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
new file mode 100644
index 00..7e045760a28be6
--- /dev/null
+++ b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
@@ -0,0 +1,39 @@
+#ifndef LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
+#define LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
+
+#include "lldb/Target/StackFrameRecognizer.h"
+
+namespace lldb_private {
+
+void RegisterVerboseTrapFrameRecognizer(Process &process);
+
+/// Holds the stack frame that caused the Verbose trap and the inlined stop
+/// reason message.
+class VerboseTrapRecognizedStackFrame : public RecognizedStackFrame {
+public:
+  VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp,
+  std::string stop_desc);
+
+  lldb::StackFrameSP GetMostRelevantFrame() override;
+
+private:
+  lldb::StackFrameSP m_most_relevant_frame;
+};
+
+/// When a thread stops, it checks the current frame contains a
+/// Verbose Trap diagnostic. If so, it returns a \a
+/// VerboseTrapRecognizedStackFrame holding the diagnostic a stop reason
+/// description with and the parent frame as the most relavant frame.
+class VerboseTrapFrameRecognizer : public StackFrameRecognizer {
+public:
+  std::string GetName() override {
+return "Verbose Trap StackFrame Recognizer";
+  }
+
+  lldb::RecognizedStackFrameSP
+  RecognizeFrame(lldb::StackFrameSP frame) override;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
diff --git a/lldb/source/Target/CMakeLists.txt 
b/lldb/source/Target/CMakeLists.txt
index cf4818eae3eb8b..8186ccbea27d42 100644
--- a/lldb/source/Target/CMakeLists.txt
+++ b/lldb/source/Target/CMakeLists.txt
@@ -78,6 +78,7 @@ add_lldb_library(lldbTarget
   UnixSignals.cpp
   UnwindAssembly.cpp
   UnwindLLDB.cpp
+  VerboseTrapFrameRecognizer.cpp
 
   LINK_LIBS
 lldbBreakpoint
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 23a8a66645c02d..04b00aaa1fac9e 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -63,6 +63,7 @@
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanStack.h"
 #include "lldb/Target/UnixSignals.h"
+#include "lldb/Target/VerboseTrapFrameRecognizer.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
@@ -497,6 

[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)

2024-02-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/80368

>From 3f3d7aeffe1d156efd4f54cdce6f6c6ca933da75 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 25 Jan 2024 11:05:02 +
Subject: [PATCH 1/3] [lldb] Add frame recognizer for __builtin_verbose_trap

This patch adds a frame recognizer for Clang's
`__builtin_verbose_trap`, which behaves like a
`__builtin_trap`, but emits a failure-reason string
into debug-info in order for debuggers to display
it to a user.

The frame recognizer triggers when we encounter
a frame with a function name that begins with
`__llvm_verbose_trap`, which is the magic prefix
Clang emits into debug-info for verbose traps.
Once such frame is encountered we display the
frame function name as the `Stop Reason` and display
that frame to the user.

Example output:
```
(lldb) run
warning: a.out was compiled with optimization - stepping may behave oddly; 
variables may not be available.
Process 35942 launched: 'a.out' (arm64)
Process 35942 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = 
__llvm_verbose_trap: Function is not implemented
frame #1: 0x00013fa4 a.out`main [inlined] 
Dummy::func(this=) at verbose_trap.cpp:3:5 [opt]
   1struct Dummy {
   2  void func() {
-> 3__builtin_verbose_trap("Function is not implemented");
   4  }
   5};
   6
   7int main() {
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = 
__llvm_verbose_trap: Function is not implemented
frame #0: 0x00013fa4 a.out`main [inlined] __llvm_verbose_trap: 
Function is not implemented at verbose_trap.cpp:0 [opt]
  * frame #1: 0x00013fa4 a.out`main [inlined] 
Dummy::func(this=) at verbose_trap.cpp:3:5 [opt]
frame #2: 0x00013fa4 a.out`main at verbose_trap.cpp:8:13 [opt]
frame #3: 0x000189d518b4 dyld`start + 1988
```
---
 .../lldb/Target/VerboseTrapFrameRecognizer.h  | 39 +
 lldb/source/Target/CMakeLists.txt |  1 +
 lldb/source/Target/Process.cpp|  2 +
 .../Target/VerboseTrapFrameRecognizer.cpp | 85 +++
 .../Shell/Recognizer/Inputs/verbose_trap.cpp  |  8 ++
 lldb/test/Shell/Recognizer/verbose_trap.test  |  9 ++
 6 files changed, 144 insertions(+)
 create mode 100644 lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
 create mode 100644 lldb/source/Target/VerboseTrapFrameRecognizer.cpp
 create mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap.cpp
 create mode 100644 lldb/test/Shell/Recognizer/verbose_trap.test

diff --git a/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h 
b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
new file mode 100644
index 0..7e045760a28be
--- /dev/null
+++ b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
@@ -0,0 +1,39 @@
+#ifndef LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
+#define LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
+
+#include "lldb/Target/StackFrameRecognizer.h"
+
+namespace lldb_private {
+
+void RegisterVerboseTrapFrameRecognizer(Process &process);
+
+/// Holds the stack frame that caused the Verbose trap and the inlined stop
+/// reason message.
+class VerboseTrapRecognizedStackFrame : public RecognizedStackFrame {
+public:
+  VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp,
+  std::string stop_desc);
+
+  lldb::StackFrameSP GetMostRelevantFrame() override;
+
+private:
+  lldb::StackFrameSP m_most_relevant_frame;
+};
+
+/// When a thread stops, it checks the current frame contains a
+/// Verbose Trap diagnostic. If so, it returns a \a
+/// VerboseTrapRecognizedStackFrame holding the diagnostic a stop reason
+/// description with and the parent frame as the most relavant frame.
+class VerboseTrapFrameRecognizer : public StackFrameRecognizer {
+public:
+  std::string GetName() override {
+return "Verbose Trap StackFrame Recognizer";
+  }
+
+  lldb::RecognizedStackFrameSP
+  RecognizeFrame(lldb::StackFrameSP frame) override;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
diff --git a/lldb/source/Target/CMakeLists.txt 
b/lldb/source/Target/CMakeLists.txt
index cf4818eae3eb8..8186ccbea27d4 100644
--- a/lldb/source/Target/CMakeLists.txt
+++ b/lldb/source/Target/CMakeLists.txt
@@ -78,6 +78,7 @@ add_lldb_library(lldbTarget
   UnixSignals.cpp
   UnwindAssembly.cpp
   UnwindLLDB.cpp
+  VerboseTrapFrameRecognizer.cpp
 
   LINK_LIBS
 lldbBreakpoint
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 23a8a66645c02..04b00aaa1fac9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -63,6 +63,7 @@
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanStack.h"
 #include "lldb/Target/UnixSignals.h"
+#include "lldb/Target/VerboseTrapFrameRecognizer.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
@@ -497,6 +498,7

[Lldb-commits] [lldb] ac585ab - [lldb] Remove unused private TypeCategoryMap methods (NFC) (#80602)

2024-02-05 Thread via lldb-commits

Author: Dave Lee
Date: 2024-02-05T10:49:46-08:00
New Revision: ac585ab71470d4f20c96a95b49e852ee1c967003

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

LOG: [lldb] Remove unused private TypeCategoryMap methods (NFC) (#80602)

Added: 


Modified: 
lldb/include/lldb/DataFormatters/TypeCategoryMap.h

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h 
b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
index efd01f321da92..b1981233378bf 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -94,12 +94,6 @@ class TypeCategoryMap {
 
   MapType m_map;
   ActiveCategoriesList m_active_categories;
-
-  MapType &map() { return m_map; }
-
-  ActiveCategoriesList &active_list() { return m_active_categories; }
-
-  std::recursive_mutex &mutex() { return m_map_mutex; }
 };
 } // namespace lldb_private
 



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


[Lldb-commits] [lldb] [lldb] Remove unused private TypeCategoryMap methods (NFC) (PR #80602)

2024-02-05 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] 0c02ea0 - [lldb] Cleanup regex in libcxx formatters (NFC) (#80618)

2024-02-05 Thread via lldb-commits

Author: Dave Lee
Date: 2024-02-05T10:52:30-08:00
New Revision: 0c02ea05c8414e72339e2521d1fdae54e91569bb

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

LOG: [lldb] Cleanup regex in libcxx formatters (NFC) (#80618)

I noticed a number of regex for libcxx formatters use an unnecessary regex 
grouping. 
This change removes those parentheses.

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index e0de80880376ac..1dcda53350afa6 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -788,7 +788,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
   "libc++ std::unordered containers synthetic children",
-  "^(std::__[[:alnum:]]+::)unordered_(multi)?(map|set)<.+> >$",
+  "^std::__[[:alnum:]]+::unordered_(multi)?(map|set)<.+> >$",
   stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
@@ -824,7 +824,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   "^std::__[[:alnum:]]+::ranges::ref_view<.+>$", stl_deref_flags, true);
 
   cpp_category_sp->AddTypeSynthetic(
-  "^(std::__[[:alnum:]]+::)deque<.+>$", eFormatterMatchRegex,
+  "^std::__[[:alnum:]]+::deque<.+>$", eFormatterMatchRegex,
   SyntheticChildrenSP(new ScriptedSyntheticChildren(
   stl_synth_flags,
   "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
@@ -832,8 +832,8 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
-  "shared_ptr synthetic children",
-  "^(std::__[[:alnum:]]+::)shared_ptr<.+>$", stl_synth_flags, true);
+  "shared_ptr synthetic children", "^std::__[[:alnum:]]+::shared_ptr<.+>$",
+  stl_synth_flags, true);
 
   static constexpr const char *const libcxx_std_unique_ptr_regex =
   "^std::__[[:alnum:]]+::unique_ptr<.+>$";
@@ -846,7 +846,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
-  "weak_ptr synthetic children", "^(std::__[[:alnum:]]+::)weak_ptr<.+>$",
+  "weak_ptr synthetic children", "^std::__[[:alnum:]]+::weak_ptr<.+>$",
   stl_synth_flags, true);
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxFunctionSummaryProvider,
@@ -910,7 +910,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxContainerSummaryProvider,
 "libc++ std::unordered containers summary provider",
-"^(std::__[[:alnum:]]+::)unordered_(multi)?(map|set)<.+> >$",
+"^std::__[[:alnum:]]+::unordered_(multi)?(map|set)<.+> >$",
 stl_summary_flags, true);
   AddCXXSummary(cpp_category_sp, LibcxxContainerSummaryProvider,
 "libc++ std::tuple summary provider",



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


[Lldb-commits] [lldb] [lldb] Cleanup regex in libcxx formatters (NFC) (PR #80618)

2024-02-05 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits


@@ -3055,8 +3055,8 @@ void CommandInterpreter::PrintCommandOutput(IOHandler 
&io_handler,
   }
 
   std::lock_guard guard(io_handler.GetOutputMutex());
-  if (had_output && INTERRUPT_REQUESTED(GetDebugger(), 
-"Interrupted dumping command output"))
+  if (had_output &&
+  INTERRUPT_REQUESTED(GetDebugger(), "Interrupted dumping command output"))

jeffreytan81 wrote:

No, it is actually required by the formatter reported by github: 
https://github.com/llvm/llvm-project/actions/runs/7789051206/job/21239805569?pr=80375

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


[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits


@@ -307,7 +311,8 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger 
&debugger,
   {"totalModuleCount", num_modules},
   {"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
   {"totalModuleCountWithVariableErrors", num_modules_with_variable_errors},
-  {"totalModuleCountWithIncompleteTypes", 
num_modules_with_incomplete_types},
+  {"totalModuleCountWithIncompleteTypes",
+   num_modules_with_incomplete_types},

jeffreytan81 wrote:

No, it is actually required by the formatter reported by github: 
https://github.com/llvm/llvm-project/actions/runs/7789051206/job/21239805569?pr=80375

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


[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits


@@ -1788,12 +1792,13 @@ class CommandObjectCommandsScriptDelete : public 
CommandObjectParsed {
   return;
 }
 const char *leaf_cmd = command[num_args - 1].c_str();
-llvm::Error llvm_error = container->RemoveUserSubcommand(leaf_cmd,
-/* multiword not okay */ false);
+llvm::Error llvm_error =
+container->RemoveUserSubcommand(leaf_cmd,
+/* multiword not okay */ false);
 if (llvm_error) {
-  result.AppendErrorWithFormat("could not delete command '%s': %s",
-   leaf_cmd, 
-   
llvm::toString(std::move(llvm_error)).c_str());
+  result.AppendErrorWithFormat(
+  "could not delete command '%s': %s", leaf_cmd,
+  llvm::toString(std::move(llvm_error)).c_str());

jeffreytan81 wrote:

No, it is actually required by the formatter reported by github: 
https://github.com/llvm/llvm-project/actions/runs/7789051206/job/21239805569?pr=80375

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


[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits


@@ -1644,8 +1647,9 @@ class CommandObjectCommandsScriptAdd : public 
CommandObjectParsed,
   llvm::Error llvm_error =
   m_container->LoadUserSubcommand(m_cmd_name, new_cmd_sp, m_overwrite);
   if (llvm_error)
-result.AppendErrorWithFormat("cannot add command: %s", 
- 
llvm::toString(std::move(llvm_error)).c_str());
+result.AppendErrorWithFormat(
+"cannot add command: %s",
+llvm::toString(std::move(llvm_error)).c_str());

jeffreytan81 wrote:

No, it is actually required by the formatter reported by github: 
https://github.com/llvm/llvm-project/actions/runs/7789051206/job/21239805569?pr=80375

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


[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits


@@ -355,6 +360,25 @@ def test_modules(self):
 self.assertNotEqual(exe_module, None)
 self.verify_keys(exe_module, 'module dict for "%s"' % (exe), 
module_keys)
 
+def test_commands(self):
+"""
+Test "statistics dump" and the command information.
+"""
+self.build()
+exe = self.getBuildArtifact("a.out")
+target = self.createTestTarget(file_path=exe)
+
+interp = self.dbg.GetCommandInterpreter()
+result = lldb.SBCommandReturnObject()
+interp.HandleCommand("target list", result)
+interp.HandleCommand("target list", result)
+
+debug_stats = self.get_stats()
+
+command_stats = self.get_command_stats(debug_stats)
+self.assertNotEqual(command_stats, None)
+self.assertEqual(command_stats["target list"], 2)

jeffreytan81 wrote:

I am pretty sure lldb test base class destroys debugger object during 
tearDown() between each test method which means the associated command 
interpreter will be destroyed as well.

I have run "ninja check-lldb" to see no failure from this test (these tests has 
been running internally for half year now).

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


[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits

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


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


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

2024-02-05 Thread Diego Caballero via lldb-commits


@@ -220,6 +220,31 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever
+run and return the new loop inside the check. The loop body is moved
+over to the new loop. Returns "failure" if the loop doesn't support
+this transformation.
+
+After the transformation, the ops inserted to the parent region of the
+loop are guaranteed to be run only if the loop body runs at least one
+iteration.
+
+Note: Ops in the loop body might be rearranged because of loop rotating
+to maintain the semantic. Terminators might be removed/added during 
this
+transformation. Also callers are not required to check the side-effect
+of loop condition, so the transformation needs to consider that to make
+sure the loop behavior is unchanged when moving the condtion out of the

dcaballe wrote:

typo: condition

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] [llvm] [lldb] [mlir] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)

2024-02-05 Thread Diego Caballero via lldb-commits


@@ -220,6 +220,31 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever

dcaballe wrote:

Would it make sense to start with `scf.if` and generalize later as needed?

I think it's worth clarifying that loop rotation will only be possible for 
`scf.while` ops for now, that is, turning regular a "while-do" into a 
"do-while". That kind of rotation won't be possible at this level of 
abstraction for `scf.for`, hence the comment about redundant first iteration 
check. I think the rotation responsibility belongs to the interface itself.

If we want to make it extra configurable, we could separate the zero-trip-check 
method from the rotation method...

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] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/80375

>From 59e1499ec0afebb533c4952f079278341b957241 Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Thu, 1 Feb 2024 18:07:51 -0800
Subject: [PATCH 1/5] Add commands frequency to statistics dump

---
 lldb/include/lldb/API/SBCommandInterpreter.h  |  9 ---
 lldb/include/lldb/API/SBStructuredData.h  |  1 +
 .../lldb/Interpreter/CommandInterpreter.h | 15 +--
 lldb/source/API/SBCommandInterpreter.cpp  | 15 ++-
 .../source/Commands/CommandObjectCommands.cpp | 10 ---
 .../source/Interpreter/CommandInterpreter.cpp |  9 ++-
 lldb/source/Interpreter/CommandObject.cpp |  1 +
 lldb/source/Target/Statistics.cpp |  4 +++
 .../commands/statistics/basic/TestStats.py| 24 +
 .../stats_api/TestStatisticsAPI.py| 26 +++
 10 files changed, 103 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index b7f5b3bf3396e..b4629a4c2f5a8 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -246,13 +247,13 @@ class SBCommandInterpreter {
lldb::SBStringList &matches,
lldb::SBStringList &descriptions);
 
-  /// Returns whether an interrupt flag was raised either by the SBDebugger - 
+  /// Returns whether an interrupt flag was raised either by the SBDebugger -
   /// when the function is not running on the RunCommandInterpreter thread, or
   /// by SBCommandInterpreter::InterruptCommand if it is.  If your code is 
doing
-  /// interruptible work, check this API periodically, and interrupt if it 
+  /// interruptible work, check this API periodically, and interrupt if it
   /// returns true.
   bool WasInterrupted() const;
-  
+
   /// Interrupts the command currently executing in the RunCommandInterpreter
   /// thread.
   ///
@@ -315,6 +316,8 @@ class SBCommandInterpreter {
   /// and aliases.  If successful, result->GetOutput has the full expansion.
   void ResolveCommand(const char *command_line, SBCommandReturnObject &result);
 
+  SBStructuredData GetStatistics();
+
 protected:
   friend class lldb_private::CommandPluginInterfaceImplementation;
 
diff --git a/lldb/include/lldb/API/SBStructuredData.h 
b/lldb/include/lldb/API/SBStructuredData.h
index 35d321eaa7b89..fc6e1ec95c7b8 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -122,6 +122,7 @@ class SBStructuredData {
   friend class SBTrace;
   friend class lldb_private::python::SWIGBridge;
   friend class lldb_private::lua::SWIGBridge;
+  friend class SBCommandInterpreter;
 
   SBStructuredData(const lldb_private::StructuredDataImpl &impl);
 
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 747188a15312f..c46cf0409bab6 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 class CommandInterpreter;
@@ -240,7 +241,7 @@ class CommandInterpreter : public Broadcaster,
 eCommandTypesAllThem = 0x  //< all commands
   };
 
-  // The CommandAlias and CommandInterpreter both have a hand in 
+  // The CommandAlias and CommandInterpreter both have a hand in
   // substituting for alias commands.  They work by writing special tokens
   // in the template form of the Alias command, and then detecting them when 
the
   // command is executed.  These are the special tokens:
@@ -575,7 +576,7 @@ class CommandInterpreter : public Broadcaster,
   void SetEchoCommentCommands(bool enable);
 
   bool GetRepeatPreviousCommand() const;
-  
+
   bool GetRequireCommandOverwrite() const;
 
   const CommandObject::CommandMap &GetUserCommands() const {
@@ -641,6 +642,12 @@ class CommandInterpreter : public Broadcaster,
   Status PreprocessCommand(std::string &command);
   Status PreprocessToken(std::string &token);
 
+  void IncreaseCommandUsage(const CommandObject &cmd_obj) {
+++m_command_usages[cmd_obj.GetCommandName().str()];
+  }
+
+  llvm::json::Value GetStatistics();
+
 protected:
   friend class Debugger;
 
@@ -754,6 +761,10 @@ class CommandInterpreter : public Broadcaster,
   // If the driver is accepts custom exit codes for the 'quit' command.
   bool m_allow_exit_code = false;
 
+  /// Command usage statistics.
+  typedef std::unordered_map CommandUsageMap;
+  CommandUsageMap m_command_usages;
+
   StreamString m_transcript_stream;
 };
 
diff --git a/lldb/source/API/SBCommandInterpreter.cpp 
b/lldb/sourc

[Lldb-commits] [lldb] [libcxx] [clang] [libc] [llvm] [libcxxabi] [flang] [lld] [compiler-rt] [clang-tools-extra] [TTI][RISCV]Improve costs for fixed vector whole reg extract/insert. (PR #80164)

2024-02-05 Thread Alexey Bataev via lldb-commits


@@ -326,6 +326,48 @@ InstructionCost 
RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
 switch (Kind) {
 default:
   break;
+case TTI::SK_ExtractSubvector:
+  if (isa(SubTp) &&
+  LT.second.getVectorElementType() != MVT::i1) {
+unsigned TpRegs = getRegUsageForType(Tp);
+unsigned NumElems =
+divideCeil(Tp->getElementCount().getFixedValue(), TpRegs);
+// Whole vector extract - just the vector itself + (possible) vsetvli.
+// TODO: consider adding the cost for vsetvli.
+if (Index == 0 || (ST->getRealMaxVLen() == ST->getRealMinVLen() &&
+   NumElems * LT.second.getScalarSizeInBits() ==

alexey-bataev wrote:

Fixed, thanks!

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


[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)

2024-02-05 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/80368

>From 3f3d7aeffe1d156efd4f54cdce6f6c6ca933da75 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Thu, 25 Jan 2024 11:05:02 +
Subject: [PATCH 1/4] [lldb] Add frame recognizer for __builtin_verbose_trap

This patch adds a frame recognizer for Clang's
`__builtin_verbose_trap`, which behaves like a
`__builtin_trap`, but emits a failure-reason string
into debug-info in order for debuggers to display
it to a user.

The frame recognizer triggers when we encounter
a frame with a function name that begins with
`__llvm_verbose_trap`, which is the magic prefix
Clang emits into debug-info for verbose traps.
Once such frame is encountered we display the
frame function name as the `Stop Reason` and display
that frame to the user.

Example output:
```
(lldb) run
warning: a.out was compiled with optimization - stepping may behave oddly; 
variables may not be available.
Process 35942 launched: 'a.out' (arm64)
Process 35942 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = 
__llvm_verbose_trap: Function is not implemented
frame #1: 0x00013fa4 a.out`main [inlined] 
Dummy::func(this=) at verbose_trap.cpp:3:5 [opt]
   1struct Dummy {
   2  void func() {
-> 3__builtin_verbose_trap("Function is not implemented");
   4  }
   5};
   6
   7int main() {
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = 
__llvm_verbose_trap: Function is not implemented
frame #0: 0x00013fa4 a.out`main [inlined] __llvm_verbose_trap: 
Function is not implemented at verbose_trap.cpp:0 [opt]
  * frame #1: 0x00013fa4 a.out`main [inlined] 
Dummy::func(this=) at verbose_trap.cpp:3:5 [opt]
frame #2: 0x00013fa4 a.out`main at verbose_trap.cpp:8:13 [opt]
frame #3: 0x000189d518b4 dyld`start + 1988
```
---
 .../lldb/Target/VerboseTrapFrameRecognizer.h  | 39 +
 lldb/source/Target/CMakeLists.txt |  1 +
 lldb/source/Target/Process.cpp|  2 +
 .../Target/VerboseTrapFrameRecognizer.cpp | 85 +++
 .../Shell/Recognizer/Inputs/verbose_trap.cpp  |  8 ++
 lldb/test/Shell/Recognizer/verbose_trap.test  |  9 ++
 6 files changed, 144 insertions(+)
 create mode 100644 lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
 create mode 100644 lldb/source/Target/VerboseTrapFrameRecognizer.cpp
 create mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap.cpp
 create mode 100644 lldb/test/Shell/Recognizer/verbose_trap.test

diff --git a/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h 
b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
new file mode 100644
index 0..7e045760a28be
--- /dev/null
+++ b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h
@@ -0,0 +1,39 @@
+#ifndef LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
+#define LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
+
+#include "lldb/Target/StackFrameRecognizer.h"
+
+namespace lldb_private {
+
+void RegisterVerboseTrapFrameRecognizer(Process &process);
+
+/// Holds the stack frame that caused the Verbose trap and the inlined stop
+/// reason message.
+class VerboseTrapRecognizedStackFrame : public RecognizedStackFrame {
+public:
+  VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp,
+  std::string stop_desc);
+
+  lldb::StackFrameSP GetMostRelevantFrame() override;
+
+private:
+  lldb::StackFrameSP m_most_relevant_frame;
+};
+
+/// When a thread stops, it checks the current frame contains a
+/// Verbose Trap diagnostic. If so, it returns a \a
+/// VerboseTrapRecognizedStackFrame holding the diagnostic a stop reason
+/// description with and the parent frame as the most relavant frame.
+class VerboseTrapFrameRecognizer : public StackFrameRecognizer {
+public:
+  std::string GetName() override {
+return "Verbose Trap StackFrame Recognizer";
+  }
+
+  lldb::RecognizedStackFrameSP
+  RecognizeFrame(lldb::StackFrameSP frame) override;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
diff --git a/lldb/source/Target/CMakeLists.txt 
b/lldb/source/Target/CMakeLists.txt
index cf4818eae3eb8..8186ccbea27d4 100644
--- a/lldb/source/Target/CMakeLists.txt
+++ b/lldb/source/Target/CMakeLists.txt
@@ -78,6 +78,7 @@ add_lldb_library(lldbTarget
   UnixSignals.cpp
   UnwindAssembly.cpp
   UnwindLLDB.cpp
+  VerboseTrapFrameRecognizer.cpp
 
   LINK_LIBS
 lldbBreakpoint
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 23a8a66645c02..04b00aaa1fac9 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -63,6 +63,7 @@
 #include "lldb/Target/ThreadPlanCallFunction.h"
 #include "lldb/Target/ThreadPlanStack.h"
 #include "lldb/Target/UnixSignals.h"
+#include "lldb/Target/VerboseTrapFrameRecognizer.h"
 #include "lldb/Utility/Event.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
@@ -497,6 +498,7

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

2024-02-05 Thread Matthias Springer via lldb-commits


@@ -220,6 +220,31 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever

matthias-springer wrote:

This makes sense, I did not think of side effects.

The lambda sounds like a good idea, but I'm not sure what exactly it should 
look like. (Should it return a `Block *` into which the loop is moved?) We can 
generalize later if needed.

I think it would also work for `scf.for`. The check condition is `lb < ub`.


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] [llvm] [mlir] [lldb] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)

2024-02-05 Thread Matthias Springer via lldb-commits


@@ -220,6 +220,31 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever
+run and return the new loop inside the check. The loop body is moved

matthias-springer wrote:

This sounds like an implementation detail. Can an implementation choose to move 
over the loop? I think this would be easier for `scf.for`. In that case I would 
just write that the returned loop could be the same loop (moved) or a new loop 
(and the the old loop is erased).


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] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits

https://github.com/jeffreytan81 updated 
https://github.com/llvm/llvm-project/pull/80375

>From 59e1499ec0afebb533c4952f079278341b957241 Mon Sep 17 00:00:00 2001
From: jeffreytan81 
Date: Thu, 1 Feb 2024 18:07:51 -0800
Subject: [PATCH 1/6] Add commands frequency to statistics dump

---
 lldb/include/lldb/API/SBCommandInterpreter.h  |  9 ---
 lldb/include/lldb/API/SBStructuredData.h  |  1 +
 .../lldb/Interpreter/CommandInterpreter.h | 15 +--
 lldb/source/API/SBCommandInterpreter.cpp  | 15 ++-
 .../source/Commands/CommandObjectCommands.cpp | 10 ---
 .../source/Interpreter/CommandInterpreter.cpp |  9 ++-
 lldb/source/Interpreter/CommandObject.cpp |  1 +
 lldb/source/Target/Statistics.cpp |  4 +++
 .../commands/statistics/basic/TestStats.py| 24 +
 .../stats_api/TestStatisticsAPI.py| 26 +++
 10 files changed, 103 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index b7f5b3bf3396e..b4629a4c2f5a8 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -246,13 +247,13 @@ class SBCommandInterpreter {
lldb::SBStringList &matches,
lldb::SBStringList &descriptions);
 
-  /// Returns whether an interrupt flag was raised either by the SBDebugger - 
+  /// Returns whether an interrupt flag was raised either by the SBDebugger -
   /// when the function is not running on the RunCommandInterpreter thread, or
   /// by SBCommandInterpreter::InterruptCommand if it is.  If your code is 
doing
-  /// interruptible work, check this API periodically, and interrupt if it 
+  /// interruptible work, check this API periodically, and interrupt if it
   /// returns true.
   bool WasInterrupted() const;
-  
+
   /// Interrupts the command currently executing in the RunCommandInterpreter
   /// thread.
   ///
@@ -315,6 +316,8 @@ class SBCommandInterpreter {
   /// and aliases.  If successful, result->GetOutput has the full expansion.
   void ResolveCommand(const char *command_line, SBCommandReturnObject &result);
 
+  SBStructuredData GetStatistics();
+
 protected:
   friend class lldb_private::CommandPluginInterfaceImplementation;
 
diff --git a/lldb/include/lldb/API/SBStructuredData.h 
b/lldb/include/lldb/API/SBStructuredData.h
index 35d321eaa7b89..fc6e1ec95c7b8 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -122,6 +122,7 @@ class SBStructuredData {
   friend class SBTrace;
   friend class lldb_private::python::SWIGBridge;
   friend class lldb_private::lua::SWIGBridge;
+  friend class SBCommandInterpreter;
 
   SBStructuredData(const lldb_private::StructuredDataImpl &impl);
 
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 747188a15312f..c46cf0409bab6 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 class CommandInterpreter;
@@ -240,7 +241,7 @@ class CommandInterpreter : public Broadcaster,
 eCommandTypesAllThem = 0x  //< all commands
   };
 
-  // The CommandAlias and CommandInterpreter both have a hand in 
+  // The CommandAlias and CommandInterpreter both have a hand in
   // substituting for alias commands.  They work by writing special tokens
   // in the template form of the Alias command, and then detecting them when 
the
   // command is executed.  These are the special tokens:
@@ -575,7 +576,7 @@ class CommandInterpreter : public Broadcaster,
   void SetEchoCommentCommands(bool enable);
 
   bool GetRepeatPreviousCommand() const;
-  
+
   bool GetRequireCommandOverwrite() const;
 
   const CommandObject::CommandMap &GetUserCommands() const {
@@ -641,6 +642,12 @@ class CommandInterpreter : public Broadcaster,
   Status PreprocessCommand(std::string &command);
   Status PreprocessToken(std::string &token);
 
+  void IncreaseCommandUsage(const CommandObject &cmd_obj) {
+++m_command_usages[cmd_obj.GetCommandName().str()];
+  }
+
+  llvm::json::Value GetStatistics();
+
 protected:
   friend class Debugger;
 
@@ -754,6 +761,10 @@ class CommandInterpreter : public Broadcaster,
   // If the driver is accepts custom exit codes for the 'quit' command.
   bool m_allow_exit_code = false;
 
+  /// Command usage statistics.
+  typedef std::unordered_map CommandUsageMap;
+  CommandUsageMap m_command_usages;
+
   StreamString m_transcript_stream;
 };
 
diff --git a/lldb/source/API/SBCommandInterpreter.cpp 
b/lldb/sourc

[Lldb-commits] [lldb] [clang] [clang-tools-extra] [libcxxabi] [libc] [flang] [llvm] [lld] [libcxx] [compiler-rt] [TTI][RISCV]Improve costs for fixed vector whole reg extract/insert. (PR #80164)

2024-02-05 Thread Alexey Bataev via lldb-commits

https://github.com/alexey-bataev updated 
https://github.com/llvm/llvm-project/pull/80164

>From cfd0dcfa1f5fabd12cf4d7bf8d5a10bd324ace0a Mon Sep 17 00:00:00 2001
From: Alexey Bataev 
Date: Wed, 31 Jan 2024 16:47:49 +
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 .../Target/RISCV/RISCVTargetTransformInfo.cpp |  42 +
 .../RISCV/shuffle-extract_subvector.ll| 174 +-
 .../RISCV/shuffle-insert_subvector.ll |  42 ++---
 .../CostModel/RISCV/shuffle-interleave.ll |   6 +-
 4 files changed, 153 insertions(+), 111 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp 
b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index fe1cdb2dfa423..465a05b6497a2 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -326,6 +326,48 @@ InstructionCost 
RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
 switch (Kind) {
 default:
   break;
+case TTI::SK_ExtractSubvector:
+  if (isa(SubTp)) {
+unsigned TpRegs = getRegUsageForType(Tp);
+unsigned NumElems =
+divideCeil(Tp->getElementCount().getFixedValue(), TpRegs);
+// Whole vector extract - just the vector itself + (possible) vsetvli.
+// TODO: consider adding the cost for vsetvli.
+if (Index % NumElems == 0) {
+  std::pair SubLT =
+  getTypeLegalizationCost(SubTp);
+  return Index == 0
+ ? TTI::TCC_Free
+ : SubLT.first * getRISCVInstructionCost(RISCV::VMV_V_V,
+ SubLT.second,
+ CostKind);
+}
+  }
+  break;
+case TTI::SK_InsertSubvector:
+  if (auto *FSubTy = dyn_cast(SubTp)) {
+unsigned TpRegs = getRegUsageForType(Tp);
+unsigned SubTpRegs = getRegUsageForType(SubTp);
+unsigned NextSubTpRegs = getRegUsageForType(FixedVectorType::get(
+Tp->getElementType(), FSubTy->getNumElements() + 1));
+unsigned NumElems =
+divideCeil(Tp->getElementCount().getFixedValue(), TpRegs);
+// Whole vector insert - just the vector itself + (possible) vsetvli.
+// TODO: consider adding the cost for vsetvli.
+if (Index % NumElems == 0 &&
+(any_of(Args, UndefValue::classof) ||
+ (SubTpRegs != 0 && SubTpRegs != NextSubTpRegs &&
+  TpRegs / SubTpRegs > 1))) {
+  std::pair SubLT =
+  getTypeLegalizationCost(SubTp);
+  return Index == 0
+ ? TTI::TCC_Free
+ : SubLT.first * getRISCVInstructionCost(RISCV::VMV_V_V,
+ SubLT.second,
+ CostKind);
+}
+  }
+  break;
 case TTI::SK_PermuteSingleSrc: {
   if (Mask.size() >= 2 && LT.second.isFixedLengthVector()) {
 MVT EltTp = LT.second.getVectorElementType();
diff --git a/llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll 
b/llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll
index 76cb1955a2b37..901d66e1124d8 100644
--- a/llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll
+++ b/llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll
@@ -9,15 +9,15 @@
 
 define void @test_vXf64(<4 x double> %src256, <8 x double> %src512) {
 ; CHECK-LABEL: 'test_vXf64'
-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: 
%V256_01 = shufflevector <4 x double> %src256, <4 x double> undef, <2 x i32> 

-; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: 
%V256_23 = shufflevector <4 x double> %src256, <4 x double> undef, <2 x i32> 

-; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: 
%V512_01 = shufflevector <8 x double> %src512, <8 x double> undef, <2 x i32> 

-; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: 
%V512_23 = shufflevector <8 x double> %src512, <8 x double> undef, <2 x i32> 

-; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: 
%V512_45 = shufflevector <8 x double> %src512, <8 x double> undef, <2 x i32> 

-; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: 
%V512_67 = shufflevector <8 x double> %src512, <8 x double> undef, <2 x i32> 

-; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: 
%V512_0123 = shufflevector <8 x double> %src512, <8 x double> undef, <4 x i32> 

-; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: 
%V512_2345 = shufflevector <8 x double> %src512, <8 x double> undef, <4 x i32> 

-; CHECK-NEXT:  Cost Model: Found an estimat

[Lldb-commits] [lldb] [clang] [clang-tools-extra] [libcxxabi] [libc] [flang] [llvm] [lld] [libcxx] [compiler-rt] [TTI][RISCV]Improve costs for fixed vector whole reg extract/insert. (PR #80164)

2024-02-05 Thread Alexey Bataev via lldb-commits


@@ -326,6 +326,48 @@ InstructionCost 
RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
 switch (Kind) {
 default:
   break;
+case TTI::SK_ExtractSubvector:
+  if (isa(SubTp) &&
+  LT.second.getVectorElementType() != MVT::i1) {
+unsigned TpRegs = getRegUsageForType(Tp);
+unsigned NumElems =
+divideCeil(Tp->getElementCount().getFixedValue(), TpRegs);
+// Whole vector extract - just the vector itself + (possible) vsetvli.
+// TODO: consider adding the cost for vsetvli.
+if (Index == 0 || (ST->getRealMaxVLen() == ST->getRealMinVLen() &&
+   NumElems * LT.second.getScalarSizeInBits() ==
+   ST->getRealMinVLen() &&
+   Index % NumElems == 0))

alexey-bataev wrote:

Added couple, hope it works

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


[Lldb-commits] [compiler-rt] [flang] [llvm] [openmp] [libc] [lldb] [mlir] [libcxx] [clang-tools-extra] [clang] [lld] [Driver] Report invalid target triple versions for all environment types. (PR #7865

2024-02-05 Thread Mike Hommey via lldb-commits

glandium wrote:

This broke the wasi-threads target:
`clang: error: version 'threads' in target triple 'wasm32-unknown-wasi-threads' 
is invalid`

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


[Lldb-commits] [lldb] 7670609 - Add commands frequency to statistics dump (#80375)

2024-02-05 Thread via lldb-commits

Author: jeffreytan81
Date: 2024-02-05T13:17:29-08:00
New Revision: 76706090c2f672ae933798292bfa889f9e3dac3d

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

LOG: Add commands frequency to statistics dump (#80375)

Adding command interpreter statistics into "statistics dump" command so
that we can track the command usage frequency for telemetry purpose.
This is useful to answer questions like what is the most frequently used
lldb commands across all our users.

-

Co-authored-by: jeffreytan81 

Added: 


Modified: 
lldb/include/lldb/API/SBCommandInterpreter.h
lldb/include/lldb/API/SBStructuredData.h
lldb/include/lldb/Interpreter/CommandInterpreter.h
lldb/source/API/SBCommandInterpreter.cpp
lldb/source/Commands/CommandObjectCommands.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/CommandObject.cpp
lldb/source/Target/Statistics.cpp
lldb/test/API/commands/statistics/basic/TestStats.py
lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py

Removed: 




diff  --git a/lldb/include/lldb/API/SBCommandInterpreter.h 
b/lldb/include/lldb/API/SBCommandInterpreter.h
index b7f5b3bf3396e..ba2e049204b8e 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -13,6 +13,7 @@
 
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBStructuredData.h"
 
 namespace lldb_private {
 class CommandPluginInterfaceImplementation;
@@ -315,6 +316,8 @@ class SBCommandInterpreter {
   /// and aliases.  If successful, result->GetOutput has the full expansion.
   void ResolveCommand(const char *command_line, SBCommandReturnObject &result);
 
+  SBStructuredData GetStatistics();
+
 protected:
   friend class lldb_private::CommandPluginInterfaceImplementation;
 

diff  --git a/lldb/include/lldb/API/SBStructuredData.h 
b/lldb/include/lldb/API/SBStructuredData.h
index 35d321eaa7b89..fc6e1ec95c7b8 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -122,6 +122,7 @@ class SBStructuredData {
   friend class SBTrace;
   friend class lldb_private::python::SWIGBridge;
   friend class lldb_private::lua::SWIGBridge;
+  friend class SBCommandInterpreter;
 
   SBStructuredData(const lldb_private::StructuredDataImpl &impl);
 

diff  --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 747188a15312f..d190bcdcab449 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace lldb_private {
 class CommandInterpreter;
@@ -641,6 +642,12 @@ class CommandInterpreter : public Broadcaster,
   Status PreprocessCommand(std::string &command);
   Status PreprocessToken(std::string &token);
 
+  void IncreaseCommandUsage(const CommandObject &cmd_obj) {
+++m_command_usages[cmd_obj.GetCommandName()];
+  }
+
+  llvm::json::Value GetStatistics();
+
 protected:
   friend class Debugger;
 
@@ -754,6 +761,10 @@ class CommandInterpreter : public Broadcaster,
   // If the driver is accepts custom exit codes for the 'quit' command.
   bool m_allow_exit_code = false;
 
+  /// Command usage statistics.
+  typedef llvm::StringMap CommandUsageMap;
+  CommandUsageMap m_command_usages;
+
   StreamString m_transcript_stream;
 };
 

diff  --git a/lldb/source/API/SBCommandInterpreter.cpp 
b/lldb/source/API/SBCommandInterpreter.cpp
index c3cbb00145ed3..7b87dc507e4be 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -557,6 +557,19 @@ bool SBCommandInterpreter::SetCommandOverrideCallback(
   return false;
 }
 
+SBStructuredData SBCommandInterpreter::GetStatistics() {
+  LLDB_INSTRUMENT_VA(this);
+
+  SBStructuredData data;
+  if (!IsValid())
+return data;
+
+  std::string json_str =
+  llvm::formatv("{0:2}", m_opaque_ptr->GetStatistics()).str();
+  data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
+  return data;
+}
+
 lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name,
   const char *help) {
   LLDB_INSTRUMENT_VA(this, name, help);

diff  --git a/lldb/source/Commands/CommandObjectCommands.cpp 
b/lldb/source/Commands/CommandObjectCommands.cpp
index 5b9af4a3e1b88..a51e5ab1af30c 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1123,6 +1123,8 @@ class CommandObjectPythonFunction : public 
CommandObjectRaw {
  CommandReturnObject &result) override {
 ScriptInterpreter *scripter = GetDebugger().GetScriptInt

[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)

2024-02-05 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/80376

>From 70a518030f2b23ca130a8d0ea667729d7985795c Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 1 Feb 2024 17:46:03 -0800
Subject: [PATCH 1/6] [lldb] Add QSupported key to report watchpoint types
 supported

debugserver on arm64 devices can manage both Byte Address Select
watchpoints (1-8 bytes) and MASK watchpoints (8 bytes-2 gigabytes).
This adds a SupportedWatchpointTypes key to the QSupported response
from debugserver with a list of these, so lldb can take full advantage
of them when creating larger regions with a single hardware watchpoint.

Also add documentation for this, and two other lldb extensions, to
the lldb-gdb-remote.txt documentation.

Re-enable TestLargeWatchpoint.py on Darwin systems when testing with
the in-tree built debugserver.  I can remove the "in-tree built
debugserver" in the future when this new key is handled by an Xcode
debugserver.
---
 lldb/docs/lldb-gdb-remote.txt | 37 +++
 .../tools/lldb-server/gdbremote_testcase.py   |  2 +
 .../GDBRemoteCommunicationClient.cpp  | 21 +++
 .../gdb-remote/GDBRemoteCommunicationClient.h |  4 ++
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 11 +-
 .../large-watchpoint/TestLargeWatchpoint.py   |  5 ---
 lldb/tools/debugserver/source/RNBRemote.cpp   | 30 ---
 7 files changed, 82 insertions(+), 28 deletions(-)

diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt
index 58269e4c2b688b..8db2fbc47b165d 100644
--- a/lldb/docs/lldb-gdb-remote.txt
+++ b/lldb/docs/lldb-gdb-remote.txt
@@ -38,7 +38,44 @@ read packet: +
 read packet: $OK#9a
 send packet: +
 
+//--
+// "QSupported"
+//
+// BRIEF
+//  Query the GDB remote server for features it supports
+//
+// PRIORITY TO IMPLEMENT
+//  Optional.
+//--
 
+QSupported is a standard GDB Remote Serial Protocol packet, but
+there are several additions to the response that lldb can parse.
+An example exchange:
+
+send packet: 
qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+
+
+read packet: 
qXfer:features:read+;PacketSize=2;qEcho+;native-signals+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;SupportedWatchpointTypes
 =aarch64-mask,aarch64-bas;
+
+In this example, three lldb extensions are reported:
+  PacketSize=2
+The base16 maximum packet size that the GDB Remote Serial stub
+can handle.
+  SupportedCompressions=
+A list of compression types that the GDB Remote Serial stub can use to
+compress packets when the QEnableCompression packet is used to request one
+of them.
+  SupportedWatchpointTypes=
+A list of watchpoint types that this GDB Remote Serial stub can manage.
+Currently defined names are:
+x86_64   64-bit x86-64 watchpoints
+ (1, 2, 4, 8 byte watchpoints aligned to those amounts)
+aarch64-bas  AArch64 Byte Address Select watchpoints
+ (any number of contiguous bytes within a doubleword)
+aarch64-mask AArch64 MASK watchpoints
+ (any power-of-2 region of memory from 8 to 2GB, aligned)
+
+lldb will default to sending power-of-2 watchpoints up to a pointer size
+(void*) in the target process if nothing is specified.
 
 //--
 // "A" - launch args packet
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 3341b6e54a3bc7..75522158b32210 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -921,6 +921,8 @@ def add_qSupported_packets(self, client_features=[]):
 "qSaveCore",
 "native-signals",
 "QNonStop",
+"SupportedWatchpointTypes",
+"SupportedCompressions",
 ]
 
 def parse_qSupported_response(self, context):
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 7bb44984185139..c625adc87cbd41 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -403,6 +403,22 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() {
 x.split(compressions, ',');
 if (!compressions.empty())
   MaybeEnableCompression(compressions);
+  } else if (x.consume_front("SupportedWatchpointTypes=")) {
+llvm::SmallVector watchpoint_types;
+x.split(watchpoint_types, ',');
+m_watchpoint_types =
+WatchpointHardwareFeature

[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/80376

>From 70a518030f2b23ca130a8d0ea667729d7985795c Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 1 Feb 2024 17:46:03 -0800
Subject: [PATCH 1/7] [lldb] Add QSupported key to report watchpoint types
 supported

debugserver on arm64 devices can manage both Byte Address Select
watchpoints (1-8 bytes) and MASK watchpoints (8 bytes-2 gigabytes).
This adds a SupportedWatchpointTypes key to the QSupported response
from debugserver with a list of these, so lldb can take full advantage
of them when creating larger regions with a single hardware watchpoint.

Also add documentation for this, and two other lldb extensions, to
the lldb-gdb-remote.txt documentation.

Re-enable TestLargeWatchpoint.py on Darwin systems when testing with
the in-tree built debugserver.  I can remove the "in-tree built
debugserver" in the future when this new key is handled by an Xcode
debugserver.
---
 lldb/docs/lldb-gdb-remote.txt | 37 +++
 .../tools/lldb-server/gdbremote_testcase.py   |  2 +
 .../GDBRemoteCommunicationClient.cpp  | 21 +++
 .../gdb-remote/GDBRemoteCommunicationClient.h |  4 ++
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 11 +-
 .../large-watchpoint/TestLargeWatchpoint.py   |  5 ---
 lldb/tools/debugserver/source/RNBRemote.cpp   | 30 ---
 7 files changed, 82 insertions(+), 28 deletions(-)

diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt
index 58269e4c2b688..8db2fbc47b165 100644
--- a/lldb/docs/lldb-gdb-remote.txt
+++ b/lldb/docs/lldb-gdb-remote.txt
@@ -38,7 +38,44 @@ read packet: +
 read packet: $OK#9a
 send packet: +
 
+//--
+// "QSupported"
+//
+// BRIEF
+//  Query the GDB remote server for features it supports
+//
+// PRIORITY TO IMPLEMENT
+//  Optional.
+//--
 
+QSupported is a standard GDB Remote Serial Protocol packet, but
+there are several additions to the response that lldb can parse.
+An example exchange:
+
+send packet: 
qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+
+
+read packet: 
qXfer:features:read+;PacketSize=2;qEcho+;native-signals+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;SupportedWatchpointTypes
 =aarch64-mask,aarch64-bas;
+
+In this example, three lldb extensions are reported:
+  PacketSize=2
+The base16 maximum packet size that the GDB Remote Serial stub
+can handle.
+  SupportedCompressions=
+A list of compression types that the GDB Remote Serial stub can use to
+compress packets when the QEnableCompression packet is used to request one
+of them.
+  SupportedWatchpointTypes=
+A list of watchpoint types that this GDB Remote Serial stub can manage.
+Currently defined names are:
+x86_64   64-bit x86-64 watchpoints
+ (1, 2, 4, 8 byte watchpoints aligned to those amounts)
+aarch64-bas  AArch64 Byte Address Select watchpoints
+ (any number of contiguous bytes within a doubleword)
+aarch64-mask AArch64 MASK watchpoints
+ (any power-of-2 region of memory from 8 to 2GB, aligned)
+
+lldb will default to sending power-of-2 watchpoints up to a pointer size
+(void*) in the target process if nothing is specified.
 
 //--
 // "A" - launch args packet
diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 3341b6e54a3bc..75522158b3221 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -921,6 +921,8 @@ def add_qSupported_packets(self, client_features=[]):
 "qSaveCore",
 "native-signals",
 "QNonStop",
+"SupportedWatchpointTypes",
+"SupportedCompressions",
 ]
 
 def parse_qSupported_response(self, context):
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 7bb4498418513..c625adc87cbd4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -403,6 +403,22 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() {
 x.split(compressions, ',');
 if (!compressions.empty())
   MaybeEnableCompression(compressions);
+  } else if (x.consume_front("SupportedWatchpointTypes=")) {
+llvm::SmallVector watchpoint_types;
+x.split(watchpoint_types, ',');
+m_watchpoint_types =
+WatchpointHardwareFeature::eWat

[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread Jason Molenda via lldb-commits


@@ -38,7 +38,43 @@ read packet: +
 read packet: $OK#9a
 send packet: +
 
+//--
+// "QSupported"
+//
+// BRIEF
+//  Query the GDB remote server for features it supports
+//
+// PRIORITY TO IMPLEMENT
+//  Optional.
+//--
 
+QSupported is a standard GDB Remote Serial Protocol packet, but
+there are several additions to the response that lldb can parse.
+An example exchange:
+
+send packet: 
qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+
+
+read packet: 
qXfer:features:read+;PacketSize=2;qEcho+;native-signals+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;SupportedWatchpointTypes=aarch64-mask,aarch64-bas;
+
+In this example, three lldb extensions are shown:
+
+  PacketSize=2
+The base16 maximum packet size that the stub can handle.

jasonmolenda wrote:

OK, I can see that.  I fixed this and a handful of other basenn uses in the 
file (probably all from me over the years).

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


[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

Thanks for the feedback Alex & David, I think this one might be good enough now.

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour created 
https://github.com/llvm/llvm-project/pull/80745

Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
Per my benchmark against AdFinder, full statistics dump takes 20 ~ 30 
seconds to complete while statisitics dump --summary completes immediately. 
This makes sense because the bottleneck is in JSON construction/serialization 
instead of module enumeration.
With this change, statistics dump --summary can now be included in lldb 
command line telemetry without slowing down lldb exiting.

>From db568e0a5194cdb48f65972c71c707a5a015a7c2 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/2] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
Per my benchmark against AdFinder, full statistics dump takes 20 ~ 30 seconds 
to complete while statisitics dump --summary completes immediately. This makes 
sense because the bottleneck is in JSON construction/serialization instead of 
module enumeration.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
Need this change so that we can capture some important telemetry for coredump 
debugging -- how many coredump sessions are using upcoming new NT_FILE dynamic 
loader instead of old Posix dynamic loader (A new dyldPluginName field is added 
into the output). I will upstream this change later.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 187 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 168 insertions(+), 77 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5..7fd888cf7014e 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84..98658ba0cac31 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target &target);
+  llvm::json::Value ToJSON(Target &target, bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ class DebuggerStats {
   ///   The single target to emit statistics for if non NULL, otherwise dump
   ///   statistics only for the specified target.
   ///
+  /// \param summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  static llvm::json::Value ReportStatistics(Debugger &debugger, Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target,
+bool summary_only = false);
 
 protected:
   // Collecting stats can be set to true to collect stats that are expensive
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a0385..4bf6c123dc1dd 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats &GetStatistics() { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8..615a

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Wanyi (kusmour)


Changes

Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
Per my benchmark against AdFinder, full statistics dump takes 20 ~ 30 
seconds to complete while statisitics dump --summary completes immediately. 
This makes sense because the bottleneck is in JSON construction/serialization 
instead of module enumeration.
With this change, statistics dump --summary can now be included in lldb 
command line telemetry without slowing down lldb exiting.

---

Patch is 23.00 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/80745.diff


13 Files Affected:

- (modified) lldb/include/lldb/API/SBTarget.h (+6-2) 
- (modified) lldb/include/lldb/Target/Statistics.h (+7-2) 
- (modified) lldb/include/lldb/Target/Target.h (+1-1) 
- (modified) lldb/source/API/SBTarget.cpp (+5-4) 
- (modified) lldb/source/Commands/CommandObjectStats.cpp (+7-1) 
- (modified) lldb/source/Commands/Options.td (+3) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (+3-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+4) 
- (modified) lldb/source/Target/Statistics.cpp (+121-66) 
- (modified) lldb/source/Target/Target.cpp (+3-1) 
- (modified) lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py (+15) 


``diff
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..7fd888cf7014e3 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target &target);
+  llvm::json::Value ToJSON(Target &target, bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ class DebuggerStats {
   ///   The single target to emit statistics for if non NULL, otherwise dump
   ///   statistics only for the specified target.
   ///
+  /// \param summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  static llvm::json::Value ReportStatistics(Debugger &debugger, Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target,
+bool summary_only = false);
 
 protected:
   // Collecting stats can be set to true to collect stats that are expensive
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats &GetStatistics() { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-   

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
76706090c2f672ae933798292bfa889f9e3dac3d...ebf4db52352c39f33e483affa2bcee88298b353a
 lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
``





View the diff from darker here.


``diff
--- TestStatisticsAPI.py2024-02-05 21:30:06.00 +
+++ TestStatisticsAPI.py2024-02-05 21:36:35.135968 +
@@ -77,18 +77,18 @@
 # Test statistics summary.
 stats_summary = target.GetStatistics(True)
 stream_summary = lldb.SBStream()
 res = stats_summary.GetAsJSON(stream_summary)
 debug_stats_summary = json.loads(stream_summary.GetData())
-self.assertNotIn('modules', debug_stats_summary)
-self.assertNotIn('memory', debug_stats_summary)
-self.assertNotIn('commands', debug_stats_summary)
+self.assertNotIn("modules", debug_stats_summary)
+self.assertNotIn("memory", debug_stats_summary)
+self.assertNotIn("commands", debug_stats_summary)
 
 # Summary values should be the same as in full statistics.
 for key, value in debug_stats_summary.items():
 self.assertIn(key, debug_stats)
-if key != 'targets':
+if key != "targets":
 self.assertEqual(debug_stats[key], value)
 
 def test_command_stats_api(self):
 """
 Test GetCommandInterpreter::GetStatistics() API.

``




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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 76706090c2f672ae933798292bfa889f9e3dac3d 
ebf4db52352c39f33e483affa2bcee88298b353a -- lldb/include/lldb/API/SBTarget.h 
lldb/include/lldb/Target/Statistics.h lldb/include/lldb/Target/Target.h 
lldb/source/API/SBTarget.cpp lldb/source/Commands/CommandObjectStats.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
lldb/source/Target/Statistics.cpp lldb/source/Target/Target.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/Statistics.cpp 
b/lldb/source/Target/Statistics.cpp
index 0738c2fc68..8189f87c3d 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -327,29 +327,28 @@ llvm::json::Value 
DebuggerStats::ReportStatistics(Debugger &debugger,
   json::Value cmd_stats = debugger.GetCommandInterpreter().GetStatistics();
 
   json::Object global_stats{
-  {"targets", std::move(json_targets)},
-  {"modules", std::move(json_modules)},
-  {"memory", std::move(json_memory)},
-  {"commands", std::move(cmd_stats)},
+{"targets", std::move(json_targets)}, {"modules", std::move(json_modules)},
+{"memory", std::move(json_memory)}, {"commands", std::move(cmd_stats)},
 ===
   json::Object global_stats{
 >>> a018d51da52f (Support statistics dump summary only mode)
-  {"totalSymbolTableParseTime", symtab_parse_time},
-  {"totalSymbolTableIndexTime", symtab_index_time},
-  {"totalSymbolTablesLoadedFromCache", symtabs_loaded},
-  {"totalSymbolTablesSavedToCache", symtabs_saved},
-  {"totalDebugInfoParseTime", debug_parse_time},
-  {"totalDebugInfoIndexTime", debug_index_time},
-  {"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
-  {"totalDebugInfoIndexSavedToCache", debug_index_saved},
-  {"totalDebugInfoByteSize", debug_info_size},
-  {"totalModuleCount", num_modules},
-  {"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
-  {"totalModuleCountWithVariableErrors", num_modules_with_variable_errors},
-  {"totalModuleCountWithIncompleteTypes",
-   num_modules_with_incomplete_types},
-  {"totalDebugInfoEnabled", num_debug_info_enabled_modules},
-  {"totalSymbolTableStripped", num_stripped_modules},
+{"totalSymbolTableParseTime", symtab_parse_time},
+{"totalSymbolTableIndexTime", symtab_index_time},
+{"totalSymbolTablesLoadedFromCache", symtabs_loaded},
+{"totalSymbolTablesSavedToCache", symtabs_saved},
+{"totalDebugInfoParseTime", debug_parse_time},
+{"totalDebugInfoIndexTime", debug_index_time},
+{"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
+{"totalDebugInfoIndexSavedToCache", debug_index_saved},
+{"totalDebugInfoByteSize", debug_info_size},
+{"totalModuleCount", num_modules},
+{"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
+{"totalModuleCountWithVariableErrors",
+ num_modules_with_variable_errors},
+{"totalModuleCountWithIncompleteTypes",
+ num_modules_with_incomplete_types},
+{"totalDebugInfoEnabled", num_debug_info_enabled_modules},
+{"totalSymbolTableStripped", num_stripped_modules},
   };
 
   if (target) {

``




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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 429a44aa6332440e879f7c5f91037741814d1a17 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/2] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 187 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 168 insertions(+), 77 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5..7fd888cf7014e 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84..98658ba0cac31 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target &target);
+  llvm::json::Value ToJSON(Target &target, bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ class DebuggerStats {
   ///   The single target to emit statistics for if non NULL, otherwise dump
   ///   statistics only for the specified target.
   ///
+  /// \param summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  static llvm::json::Value ReportStatistics(Debugger &debugger, Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target,
+bool summary_only = false);
 
 protected:
   // Collecting stats can be set to true to collect stats that are expensive
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a0385..4bf6c123dc1dd 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats &GetStatistics() { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8..615a00ceeaee1 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .str();
   data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
   return data;
 }
diff --git a/lldb/source/Commands/CommandObjectStats.cpp 
b/lldb/source/Commands/CommandObjectStats.cpp
index 262de0bda144a..781b90794dc37 100644
--- a/lldb/so

[Lldb-commits] [lldb] [lldb][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (PR #80167)

2024-02-05 Thread Greg Clayton via lldb-commits

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

Looks great with the updates. Much more clear. 

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


[Lldb-commits] [libcxxabi] [lldb] [clang] [flang] [compiler-rt] [lld] [libc] [clang-tools-extra] [libcxx] [llvm] [SLP]Improve findReusedOrderedScalars and graph rotation. (PR #77529)

2024-02-05 Thread Alexey Bataev via lldb-commits

https://github.com/alexey-bataev updated 
https://github.com/llvm/llvm-project/pull/77529

>From 7440ee8ba235fd871af0999f66d5d6130456400b Mon Sep 17 00:00:00 2001
From: Alexey Bataev 
Date: Tue, 9 Jan 2024 21:43:31 +
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5
---
 .../Transforms/Vectorize/SLPVectorizer.cpp| 476 ++
 .../AArch64/extractelements-to-shuffle.ll |  16 +-
 .../AArch64/reorder-fmuladd-crash.ll  |   7 +-
 .../SLPVectorizer/AArch64/tsc-s116.ll |  22 +-
 .../Transforms/SLPVectorizer/X86/pr35497.ll   |  16 +-
 .../SLPVectorizer/X86/reduction-transpose.ll  |  16 +-
 .../X86/reorder-clustered-node.ll |  11 +-
 .../X86/reorder-reused-masked-gather.ll   |   7 +-
 .../SLPVectorizer/X86/reorder-vf-to-resize.ll |   2 +-
 .../X86/scatter-vectorize-reorder.ll  |  17 +-
 .../X86/shrink_after_reorder2.ll  |  11 +-
 11 files changed, 445 insertions(+), 156 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp 
b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 8e22b54f002d1c..4765cef290b9df 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -858,7 +858,7 @@ static void addMask(SmallVectorImpl &Mask, 
ArrayRef SubMask,
 /// values 3 and 7 respectively:
 /// before:  6 9 5 4 9 2 1 0
 /// after:   6 3 5 4 7 2 1 0
-static void fixupOrderingIndices(SmallVectorImpl &Order) {
+static void fixupOrderingIndices(MutableArrayRef Order) {
   const unsigned Sz = Order.size();
   SmallBitVector UnusedIndices(Sz, /*t=*/true);
   SmallBitVector MaskedIndices(Sz);
@@ -2418,7 +2418,8 @@ class BoUpSLP {
   std::optional
   isGatherShuffledSingleRegisterEntry(
   const TreeEntry *TE, ArrayRef VL, MutableArrayRef Mask,
-  SmallVectorImpl &Entries, unsigned Part);
+  SmallVectorImpl &Entries, unsigned Part,
+  bool ForOrder);
 
   /// Checks if the gathered \p VL can be represented as multi-register
   /// shuffle(s) of previous tree entries.
@@ -2432,7 +2433,7 @@ class BoUpSLP {
   isGatherShuffledEntry(
   const TreeEntry *TE, ArrayRef VL, SmallVectorImpl &Mask,
   SmallVectorImpl> &Entries,
-  unsigned NumParts);
+  unsigned NumParts, bool ForOrder = false);
 
   /// \returns the scalarization cost for this list of values. Assuming that
   /// this subtree gets vectorized, we may need to extract the values from the
@@ -3756,65 +3757,169 @@ static void reorderOrder(SmallVectorImpl 
&Order, ArrayRef Mask) {
 std::optional
 BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE) {
   assert(TE.State == TreeEntry::NeedToGather && "Expected gather node only.");
-  unsigned NumScalars = TE.Scalars.size();
+  // Try to find subvector extract/insert patterns and reorder only such
+  // patterns.
+  SmallVector GatheredScalars(TE.Scalars.begin(), TE.Scalars.end());
+  Type *ScalarTy = GatheredScalars.front()->getType();
+  int NumScalars = GatheredScalars.size();
+  if (!isValidElementType(ScalarTy))
+return std::nullopt;
+  auto *VecTy = FixedVectorType::get(ScalarTy, NumScalars);
+  int NumParts = TTI->getNumberOfParts(VecTy);
+  if (NumParts == 0 || NumParts >= NumScalars)
+NumParts = 1;
+  SmallVector ExtractMask;
+  SmallVector Mask;
+  SmallVector> Entries;
+  SmallVector> ExtractShuffles 
=
+  tryToGatherExtractElements(GatheredScalars, ExtractMask, NumParts);
+  SmallVector> GatherShuffles =
+  isGatherShuffledEntry(&TE, GatheredScalars, Mask, Entries, NumParts,
+/*ForOrder=*/true);
+  // No shuffled operands - ignore.
+  if (GatherShuffles.empty() && ExtractShuffles.empty())
+return std::nullopt;
   OrdersType CurrentOrder(NumScalars, NumScalars);
-  SmallVector Positions;
-  SmallBitVector UsedPositions(NumScalars);
-  const TreeEntry *STE = nullptr;
-  // Try to find all gathered scalars that are gets vectorized in other
-  // vectorize node. Here we can have only one single tree vector node to
-  // correctly identify order of the gathered scalars.
-  for (unsigned I = 0; I < NumScalars; ++I) {
-Value *V = TE.Scalars[I];
-if (!isa(V))
-  continue;
-if (const auto *LocalSTE = getTreeEntry(V)) {
-  if (!STE)
-STE = LocalSTE;
-  else if (STE != LocalSTE)
-// Take the order only from the single vector node.
-return std::nullopt;
-  unsigned Lane =
-  std::distance(STE->Scalars.begin(), find(STE->Scalars, V));
-  if (Lane >= NumScalars)
-return std::nullopt;
-  if (CurrentOrder[Lane] != NumScalars) {
-if (Lane != I)
+  if (GatherShuffles.size() == 1 &&
+  *GatherShuffles.front() == TTI::SK_PermuteSingleSrc &&
+  Entries.front().front()->isSame(TE.Scalars)) {
+// Exclude nodes for strided geps from analysis, bett

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

2024-02-05 Thread Jerry Wu via lldb-commits

https://github.com/pzread updated 
https://github.com/llvm/llvm-project/pull/80331

>From 70f54b51bef87bde5e3f5ee067c0f2414d34e915 Mon Sep 17 00:00:00 2001
From: Jerry Wu 
Date: Thu, 1 Feb 2024 19:57:26 +
Subject: [PATCH 1/4] Add replaceWithZeroTripCheck to LoopLikeOpInterface

---
 .../mlir/Interfaces/LoopLikeInterface.td  | 22 +++
 1 file changed, 22 insertions(+)

diff --git a/mlir/include/mlir/Interfaces/LoopLikeInterface.td 
b/mlir/include/mlir/Interfaces/LoopLikeInterface.td
index e2ac85a3f7725d..77409cb3a8274b 100644
--- a/mlir/include/mlir/Interfaces/LoopLikeInterface.td
+++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td
@@ -220,6 +220,28 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever
+run and return the new loop inside the check. The loop body is moved
+over to the new loop. Returns "failure" if the loop doesn't support
+this transformation.
+
+After the transformation, the ops inserted to the parent region of the
+loop are guaranteed to be run only if the loop body runs at least one
+iteration.
+
+Note: Ops in the loop body might be rearranged because of loop rotating
+to maintain the semantic. Terminators might be removed/added during 
this
+transformation.
+  }],
+  /*retTy=*/"::mlir::FailureOr<::mlir::LoopLikeOpInterface>",
+  /*methodName=*/"replaceWithZeroTripCheck",
+  /*args=*/(ins "::mlir::RewriterBase &":$rewriter),
+  /*methodBody=*/"",
+  /*defaultImplementation=*/[{
+return ::mlir::failure();
+  }]
 >
   ];
 

>From d6703ebbeb5ddc358929672b44994a9d05683523 Mon Sep 17 00:00:00 2001
From: Jerry Wu 
Date: Fri, 2 Feb 2024 18:59:03 +
Subject: [PATCH 2/4] Add tests

---
 mlir/unittests/Interfaces/CMakeLists.txt  |   3 +
 .../Interfaces/LoopLikeInterfaceTest.cpp  | 101 ++
 2 files changed, 104 insertions(+)
 create mode 100644 mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp

diff --git a/mlir/unittests/Interfaces/CMakeLists.txt 
b/mlir/unittests/Interfaces/CMakeLists.txt
index d192b2922d6b9d..cab9503cf295b1 100644
--- a/mlir/unittests/Interfaces/CMakeLists.txt
+++ b/mlir/unittests/Interfaces/CMakeLists.txt
@@ -3,6 +3,7 @@ add_mlir_unittest(MLIRInterfacesTests
   DataLayoutInterfacesTest.cpp
   InferIntRangeInterfaceTest.cpp
   InferTypeOpInterfaceTest.cpp
+  LoopLikeInterfaceTest.cpp
 )
 
 target_link_libraries(MLIRInterfacesTests
@@ -12,7 +13,9 @@ target_link_libraries(MLIRInterfacesTests
   MLIRDataLayoutInterfaces
   MLIRDLTIDialect
   MLIRFuncDialect
+  MLIRIR
   MLIRInferIntRangeInterface
   MLIRInferTypeOpInterface
+  MLIRLoopLikeInterface
   MLIRParser
 )
diff --git a/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp 
b/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp
new file mode 100644
index 00..b0b7680fed68e7
--- /dev/null
+++ b/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp
@@ -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"() : () -> ()
+  )ML

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

2024-02-05 Thread Jerry Wu via lldb-commits


@@ -220,6 +220,31 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever
+run and return the new loop inside the check. The loop body is moved
+over to the new loop. Returns "failure" if the loop doesn't support
+this transformation.
+
+After the transformation, the ops inserted to the parent region of the
+loop are guaranteed to be run only if the loop body runs at least one
+iteration.
+
+Note: Ops in the loop body might be rearranged because of loop rotating
+to maintain the semantic. Terminators might be removed/added during 
this
+transformation. Also callers are not required to check the side-effect
+of loop condition, so the transformation needs to consider that to make
+sure the loop behavior is unchanged when moving the condtion out of the

pzread wrote:

Fixed.

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] [lldb] [mlir] [llvm] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)

2024-02-05 Thread Jerry Wu via lldb-commits


@@ -220,6 +220,31 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever

pzread wrote:

I think whether the loop rotation is needed (or possible) is the implementation 
details of each type of loop. `scf.while` needs it because the before block is 
in the loop and can contain ops with side-effects. `scf.for` is simpler as the 
`lb < ub` should have no side-effect and lightweight, which can be run twice 
(for `scf.if` and the for loop)

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] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 30d723ba9808c7a8109b11dd0f20b4d8808e9ad5 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/2] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 164 insertions(+), 88 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..7fd888cf7014e3 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target &target);
+  llvm::json::Value ToJSON(Target &target, bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ class DebuggerStats {
   ///   The single target to emit statistics for if non NULL, otherwise dump
   ///   statistics only for the specified target.
   ///
+  /// \param summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  static llvm::json::Value ReportStatistics(Debugger &debugger, Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target,
+bool summary_only = false);
 
 protected:
   // Collecting stats can be set to true to collect stats that are expensive
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats &GetStatistics() { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .str();
   data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
   return data;
 }
diff --git a/lldb/source/Commands/CommandObjectStats.cpp 
b/lldb/source/Commands/CommandObjectStats.cpp
index 262de0bda144a6..781b90794dc377 100644
---

[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread Jonas Devlieghere via lldb-commits

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

LGTM if @DavidSpickett and @bulbazord are happy.

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


[Lldb-commits] [llvm] [lldb] [lldb-dap][NFC] Add Breakpoint struct to share common logic. (PR #80753)

2024-02-05 Thread Zequan Wu via lldb-commits

https://github.com/ZequanWu created 
https://github.com/llvm/llvm-project/pull/80753

This adds a layer between `SounceBreakpoint`/`FunctionBreakpoint` and 
`BreakpointBase` to have better separation and encapsulation so we are not 
directly operating on `SBBreakpoint`. 

I basically moved the `SBBreakpoint` and the methods that requires it from 
`BreakpointBase` to `Breakpoint`. This allows adding support for data 
watchpoint easier by sharing the logic inside `BreakpointBase`.

>From c4b767909a9ffc2a3015dc9021e4c265da0d877d Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Mon, 5 Feb 2024 17:26:48 -0500
Subject: [PATCH] [lldb-dap][NFC] Add Breakpoint struct to share common logic.

---
 lldb/tools/lldb-dap/Breakpoint.cpp| 182 ++
 lldb/tools/lldb-dap/Breakpoint.h  |  34 
 lldb/tools/lldb-dap/BreakpointBase.cpp| 113 ---
 lldb/tools/lldb-dap/BreakpointBase.h  |  12 +-
 lldb/tools/lldb-dap/CMakeLists.txt|   1 +
 lldb/tools/lldb-dap/FunctionBreakpoint.cpp|  12 +-
 lldb/tools/lldb-dap/FunctionBreakpoint.h  |   4 +-
 lldb/tools/lldb-dap/JSONUtils.cpp |  46 +
 lldb/tools/lldb-dap/JSONUtils.h   |   5 +-
 lldb/tools/lldb-dap/SourceBreakpoint.cpp  |  12 +-
 lldb/tools/lldb-dap/SourceBreakpoint.h|   6 +-
 lldb/tools/lldb-dap/lldb-dap.cpp  |  17 +-
 .../gn/secondary/lldb/tools/lldb-dap/BUILD.gn |   1 +
 13 files changed, 248 insertions(+), 197 deletions(-)
 create mode 100644 lldb/tools/lldb-dap/Breakpoint.cpp
 create mode 100644 lldb/tools/lldb-dap/Breakpoint.h

diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp 
b/lldb/tools/lldb-dap/Breakpoint.cpp
new file mode 100644
index 00..4ccf353b06
--- /dev/null
+++ b/lldb/tools/lldb-dap/Breakpoint.cpp
@@ -0,0 +1,182 @@
+//===-- Breakpoint.cpp --*- C++ 
-*-===//
+//
+// 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 "Breakpoint.h"
+#include "DAP.h"
+#include "JSONUtils.h"
+#include "llvm/ADT/StringExtras.h"
+
+using namespace lldb_dap;
+
+void Breakpoint::SetCondition() { bp.SetCondition(condition.c_str()); }
+
+void Breakpoint::SetHitCondition() {
+  uint64_t hitCount = 0;
+  if (llvm::to_integer(hitCondition, hitCount))
+bp.SetIgnoreCount(hitCount - 1);
+}
+
+// logMessage will be divided into array of LogMessagePart as two kinds:
+// 1. raw print text message, and
+// 2. interpolated expression for evaluation which is inside matching curly
+//braces.
+//
+// The function tries to parse logMessage into a list of LogMessageParts
+// for easy later access in BreakpointHitCallback.
+void Breakpoint::SetLogMessage() {
+  logMessageParts.clear();
+
+  // Contains unmatched open curly braces indices.
+  std::vector unmatched_curly_braces;
+
+  // Contains all matched curly braces in logMessage.
+  // Loop invariant: matched_curly_braces_ranges are sorted by start index in
+  // ascending order without any overlap between them.
+  std::vector> matched_curly_braces_ranges;
+
+  lldb::SBError error;
+  // Part1 - parse matched_curly_braces_ranges.
+  // locating all curly braced expression ranges in logMessage.
+  // The algorithm takes care of nested and imbalanced curly braces.
+  for (size_t i = 0; i < logMessage.size(); ++i) {
+if (logMessage[i] == '{') {
+  unmatched_curly_braces.push_back(i);
+} else if (logMessage[i] == '}') {
+  if (unmatched_curly_braces.empty())
+// Nothing to match.
+continue;
+
+  int last_unmatched_index = unmatched_curly_braces.back();
+  unmatched_curly_braces.pop_back();
+
+  // Erase any matched ranges included in the new match.
+  while (!matched_curly_braces_ranges.empty()) {
+assert(matched_curly_braces_ranges.back().first !=
+   last_unmatched_index &&
+   "How can a curley brace be matched twice?");
+if (matched_curly_braces_ranges.back().first < last_unmatched_index)
+  break;
+
+// This is a nested range let's earse it.
+assert((size_t)matched_curly_braces_ranges.back().second < i);
+matched_curly_braces_ranges.pop_back();
+  }
+
+  // Assert invariant.
+  assert(matched_curly_braces_ranges.empty() ||
+ matched_curly_braces_ranges.back().first < last_unmatched_index);
+  matched_curly_braces_ranges.emplace_back(last_unmatched_index, i);
+}
+  }
+
+  // Part2 - parse raw text and expresions parts.
+  // All expression ranges have been parsed in matched_curly_braces_ranges.
+  // The code below uses matched_curly_braces_ranges to divide logMessage
+  // into raw text parts and expression parts.
+  int last_raw_text_start = 0;
+  for (const std::pa

[Lldb-commits] [llvm] [lldb] [lldb-dap][NFC] Add Breakpoint struct to share common logic. (PR #80753)

2024-02-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Zequan Wu (ZequanWu)


Changes

This adds a layer between `SounceBreakpoint`/`FunctionBreakpoint` and 
`BreakpointBase` to have better separation and encapsulation so we are not 
directly operating on `SBBreakpoint`. 

I basically moved the `SBBreakpoint` and the methods that requires it from 
`BreakpointBase` to `Breakpoint`. This allows adding support for data 
watchpoint easier by sharing the logic inside `BreakpointBase`.

---

Patch is 27.36 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/80753.diff


13 Files Affected:

- (added) lldb/tools/lldb-dap/Breakpoint.cpp (+182) 
- (added) lldb/tools/lldb-dap/Breakpoint.h (+34) 
- (modified) lldb/tools/lldb-dap/BreakpointBase.cpp (-113) 
- (modified) lldb/tools/lldb-dap/BreakpointBase.h (+6-6) 
- (modified) lldb/tools/lldb-dap/CMakeLists.txt (+1) 
- (modified) lldb/tools/lldb-dap/FunctionBreakpoint.cpp (+2-10) 
- (modified) lldb/tools/lldb-dap/FunctionBreakpoint.h (+2-2) 
- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+3-43) 
- (modified) lldb/tools/lldb-dap/JSONUtils.h (+3-2) 
- (modified) lldb/tools/lldb-dap/SourceBreakpoint.cpp (+2-10) 
- (modified) lldb/tools/lldb-dap/SourceBreakpoint.h (+3-3) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+9-8) 
- (modified) llvm/utils/gn/secondary/lldb/tools/lldb-dap/BUILD.gn (+1) 


``diff
diff --git a/lldb/tools/lldb-dap/Breakpoint.cpp 
b/lldb/tools/lldb-dap/Breakpoint.cpp
new file mode 100644
index 0..4ccf353b06ccc
--- /dev/null
+++ b/lldb/tools/lldb-dap/Breakpoint.cpp
@@ -0,0 +1,182 @@
+//===-- Breakpoint.cpp --*- C++ 
-*-===//
+//
+// 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 "Breakpoint.h"
+#include "DAP.h"
+#include "JSONUtils.h"
+#include "llvm/ADT/StringExtras.h"
+
+using namespace lldb_dap;
+
+void Breakpoint::SetCondition() { bp.SetCondition(condition.c_str()); }
+
+void Breakpoint::SetHitCondition() {
+  uint64_t hitCount = 0;
+  if (llvm::to_integer(hitCondition, hitCount))
+bp.SetIgnoreCount(hitCount - 1);
+}
+
+// logMessage will be divided into array of LogMessagePart as two kinds:
+// 1. raw print text message, and
+// 2. interpolated expression for evaluation which is inside matching curly
+//braces.
+//
+// The function tries to parse logMessage into a list of LogMessageParts
+// for easy later access in BreakpointHitCallback.
+void Breakpoint::SetLogMessage() {
+  logMessageParts.clear();
+
+  // Contains unmatched open curly braces indices.
+  std::vector unmatched_curly_braces;
+
+  // Contains all matched curly braces in logMessage.
+  // Loop invariant: matched_curly_braces_ranges are sorted by start index in
+  // ascending order without any overlap between them.
+  std::vector> matched_curly_braces_ranges;
+
+  lldb::SBError error;
+  // Part1 - parse matched_curly_braces_ranges.
+  // locating all curly braced expression ranges in logMessage.
+  // The algorithm takes care of nested and imbalanced curly braces.
+  for (size_t i = 0; i < logMessage.size(); ++i) {
+if (logMessage[i] == '{') {
+  unmatched_curly_braces.push_back(i);
+} else if (logMessage[i] == '}') {
+  if (unmatched_curly_braces.empty())
+// Nothing to match.
+continue;
+
+  int last_unmatched_index = unmatched_curly_braces.back();
+  unmatched_curly_braces.pop_back();
+
+  // Erase any matched ranges included in the new match.
+  while (!matched_curly_braces_ranges.empty()) {
+assert(matched_curly_braces_ranges.back().first !=
+   last_unmatched_index &&
+   "How can a curley brace be matched twice?");
+if (matched_curly_braces_ranges.back().first < last_unmatched_index)
+  break;
+
+// This is a nested range let's earse it.
+assert((size_t)matched_curly_braces_ranges.back().second < i);
+matched_curly_braces_ranges.pop_back();
+  }
+
+  // Assert invariant.
+  assert(matched_curly_braces_ranges.empty() ||
+ matched_curly_braces_ranges.back().first < last_unmatched_index);
+  matched_curly_braces_ranges.emplace_back(last_unmatched_index, i);
+}
+  }
+
+  // Part2 - parse raw text and expresions parts.
+  // All expression ranges have been parsed in matched_curly_braces_ranges.
+  // The code below uses matched_curly_braces_ranges to divide logMessage
+  // into raw text parts and expression parts.
+  int last_raw_text_start = 0;
+  for (const std::pair &curly_braces_range :
+   matched_curly_braces_ranges) {
+// Raw text before open curly brace.
+assert(curly_braces_range.first >= last_raw_text_start);
+size_t raw_text_len = curly_braces_r

[Lldb-commits] [lldb] [llvm] [lldb-dap][NFC] Add Breakpoint struct to share common logic. (PR #80753)

2024-02-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 41ea02261224446dadb1b1561d70137699255518 
c4b767909a9ffc2a3015dc9021e4c265da0d877d -- lldb/tools/lldb-dap/Breakpoint.cpp 
lldb/tools/lldb-dap/Breakpoint.h lldb/tools/lldb-dap/BreakpointBase.cpp 
lldb/tools/lldb-dap/BreakpointBase.h lldb/tools/lldb-dap/FunctionBreakpoint.cpp 
lldb/tools/lldb-dap/FunctionBreakpoint.h lldb/tools/lldb-dap/JSONUtils.cpp 
lldb/tools/lldb-dap/JSONUtils.h lldb/tools/lldb-dap/SourceBreakpoint.cpp 
lldb/tools/lldb-dap/SourceBreakpoint.h lldb/tools/lldb-dap/lldb-dap.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/tools/lldb-dap/Breakpoint.h b/lldb/tools/lldb-dap/Breakpoint.h
index a668e29f3d..5600bc1792 100644
--- a/lldb/tools/lldb-dap/Breakpoint.h
+++ b/lldb/tools/lldb-dap/Breakpoint.h
@@ -19,7 +19,7 @@ struct Breakpoint : public BreakpointBase {
 
   Breakpoint() = default;
   Breakpoint(const llvm::json::Object &obj) : BreakpointBase(obj){};
-  Breakpoint(lldb::SBBreakpoint bp): bp(bp) {}
+  Breakpoint(lldb::SBBreakpoint bp) : bp(bp) {}
 
   void SetCondition() override;
   void SetHitCondition() override;

``




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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 36c84ce56e9ea288d64833aa1f927a7f97fd904c Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/2] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 164 insertions(+), 88 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..7fd888cf7014e3 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target &target);
+  llvm::json::Value ToJSON(Target &target, bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ class DebuggerStats {
   ///   The single target to emit statistics for if non NULL, otherwise dump
   ///   statistics only for the specified target.
   ///
+  /// \param summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  static llvm::json::Value ReportStatistics(Debugger &debugger, Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target,
+bool summary_only = false);
 
 protected:
   // Collecting stats can be set to true to collect stats that are expensive
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats &GetStatistics() { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .str();
   data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
   return data;
 }
diff --git a/lldb/source/Commands/CommandObjectStats.cpp 
b/lldb/source/Commands/CommandObjectStats.cpp
index 262de0bda144a6..781b90794dc377 100644
---

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits

https://github.com/hawkinsw commented:

Thank you for doing this! I hope that these little nits are helpful!

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -1412,4 +1412,7 @@ let Command = "trace schema" in {
 let Command = "statistics dump" in {
   def statistics_dump_all: Option<"all-targets", "a">, Group<1>,
 Desc<"Include statistics for all targets.">;
+  def statistics_dump_summary: Option<"summary", "s">, Group<1>,
+Desc<"Dump only high level summary statistics."
+ "Exclude targets, modules, breakpoints etc.. details.">;

hawkinsw wrote:

```suggestion
 "Exclude targets, modules, breakpoints etc... details.">;
```

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -1412,4 +1412,7 @@ let Command = "trace schema" in {
 let Command = "statistics dump" in {
   def statistics_dump_all: Option<"all-targets", "a">, Group<1>,
 Desc<"Include statistics for all targets.">;
+  def statistics_dump_summary: Option<"summary", "s">, Group<1>,
+Desc<"Dump only high level summary statistics."

hawkinsw wrote:

```suggestion
Desc<"Dump only high-level summary statistics."
```

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -100,60 +101,91 @@ llvm::json::Value ConstStringStats::ToJSON() const {
   return obj;
 }
 
-json::Value TargetStats::ToJSON(Target &target) {
-  CollectStats(target);
+json::Value TargetStats::ToJSON(Target &target, bool summary_only) {
+  json::Object target_metrics_json;
+  ProcessSP process_sp = target.GetProcessSP();
+  if (!summary_only) {
+CollectStats(target);
 
-  json::Array json_module_uuid_array;
-  for (auto module_identifier : m_module_identifiers)
-json_module_uuid_array.emplace_back(module_identifier);
+json::Array json_module_uuid_array;
+for (auto module_identifier : m_module_identifiers)
+  json_module_uuid_array.emplace_back(module_identifier);
 
-  json::Object target_metrics_json{
-  {m_expr_eval.name, m_expr_eval.ToJSON()},
-  {m_frame_var.name, m_frame_var.ToJSON()},
-  {"moduleIdentifiers", std::move(json_module_uuid_array)}};
+target_metrics_json.try_emplace(m_expr_eval.name, m_expr_eval.ToJSON());
+target_metrics_json.try_emplace(m_frame_var.name, m_frame_var.ToJSON());
+target_metrics_json.try_emplace("moduleIdentifiers",
+std::move(json_module_uuid_array));
 
-  if (m_launch_or_attach_time && m_first_private_stop_time) {
-double elapsed_time =
-elapsed(*m_launch_or_attach_time, *m_first_private_stop_time);
-target_metrics_json.try_emplace("launchOrAttachTime", elapsed_time);
-  }
-  if (m_launch_or_attach_time && m_first_public_stop_time) {
-double elapsed_time =
-elapsed(*m_launch_or_attach_time, *m_first_public_stop_time);
-target_metrics_json.try_emplace("firstStopTime", elapsed_time);
+if (m_launch_or_attach_time && m_first_private_stop_time) {
+  double elapsed_time =
+  elapsed(*m_launch_or_attach_time, *m_first_private_stop_time);
+  target_metrics_json.try_emplace("launchOrAttachTime", elapsed_time);
+}
+if (m_launch_or_attach_time && m_first_public_stop_time) {
+  double elapsed_time =
+  elapsed(*m_launch_or_attach_time, *m_first_public_stop_time);
+  target_metrics_json.try_emplace("firstStopTime", elapsed_time);
+}
+target_metrics_json.try_emplace("targetCreateTime",
+m_create_time.get().count());
+
+json::Array breakpoints_array;
+double totalBreakpointResolveTime = 0.0;
+// Rport both the normal breakpoint list and the internal breakpoint list.

hawkinsw wrote:

```suggestion
// Report both the normal breakpoint list and the internal breakpoint list.
```

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -186,6 +186,10 @@ class SymbolFileDWARF : public SymbolFileCommon {
   GetMangledNamesForFunction(const std::string &scope_qualified_name,
  std::vector &mangled_names) override;
 
+  // Return total currently loaded debug info

hawkinsw wrote:

```suggestion
  // Return total currently loaded debug info.
```

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -74,7 +75,7 @@ json::Value ModuleStats::ToJSON() const {
 
   if (!symfile_modules.empty()) {
 json::Array symfile_ids;
-for (const auto symfile_id: symfile_modules)
+for (const auto symfile_id : symfile_modules)

hawkinsw wrote:

Is this just a whitespace change? 

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


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

2024-02-05 Thread Jerry Wu via lldb-commits

https://github.com/pzread updated 
https://github.com/llvm/llvm-project/pull/80331

>From 70f54b51bef87bde5e3f5ee067c0f2414d34e915 Mon Sep 17 00:00:00 2001
From: Jerry Wu 
Date: Thu, 1 Feb 2024 19:57:26 +
Subject: [PATCH 1/6] Add replaceWithZeroTripCheck to LoopLikeOpInterface

---
 .../mlir/Interfaces/LoopLikeInterface.td  | 22 +++
 1 file changed, 22 insertions(+)

diff --git a/mlir/include/mlir/Interfaces/LoopLikeInterface.td 
b/mlir/include/mlir/Interfaces/LoopLikeInterface.td
index e2ac85a3f7725..77409cb3a8274 100644
--- a/mlir/include/mlir/Interfaces/LoopLikeInterface.td
+++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td
@@ -220,6 +220,28 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever
+run and return the new loop inside the check. The loop body is moved
+over to the new loop. Returns "failure" if the loop doesn't support
+this transformation.
+
+After the transformation, the ops inserted to the parent region of the
+loop are guaranteed to be run only if the loop body runs at least one
+iteration.
+
+Note: Ops in the loop body might be rearranged because of loop rotating
+to maintain the semantic. Terminators might be removed/added during 
this
+transformation.
+  }],
+  /*retTy=*/"::mlir::FailureOr<::mlir::LoopLikeOpInterface>",
+  /*methodName=*/"replaceWithZeroTripCheck",
+  /*args=*/(ins "::mlir::RewriterBase &":$rewriter),
+  /*methodBody=*/"",
+  /*defaultImplementation=*/[{
+return ::mlir::failure();
+  }]
 >
   ];
 

>From d6703ebbeb5ddc358929672b44994a9d05683523 Mon Sep 17 00:00:00 2001
From: Jerry Wu 
Date: Fri, 2 Feb 2024 18:59:03 +
Subject: [PATCH 2/6] Add tests

---
 mlir/unittests/Interfaces/CMakeLists.txt  |   3 +
 .../Interfaces/LoopLikeInterfaceTest.cpp  | 101 ++
 2 files changed, 104 insertions(+)
 create mode 100644 mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp

diff --git a/mlir/unittests/Interfaces/CMakeLists.txt 
b/mlir/unittests/Interfaces/CMakeLists.txt
index d192b2922d6b9..cab9503cf295b 100644
--- a/mlir/unittests/Interfaces/CMakeLists.txt
+++ b/mlir/unittests/Interfaces/CMakeLists.txt
@@ -3,6 +3,7 @@ add_mlir_unittest(MLIRInterfacesTests
   DataLayoutInterfacesTest.cpp
   InferIntRangeInterfaceTest.cpp
   InferTypeOpInterfaceTest.cpp
+  LoopLikeInterfaceTest.cpp
 )
 
 target_link_libraries(MLIRInterfacesTests
@@ -12,7 +13,9 @@ target_link_libraries(MLIRInterfacesTests
   MLIRDataLayoutInterfaces
   MLIRDLTIDialect
   MLIRFuncDialect
+  MLIRIR
   MLIRInferIntRangeInterface
   MLIRInferTypeOpInterface
+  MLIRLoopLikeInterface
   MLIRParser
 )
diff --git a/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp 
b/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp
new file mode 100644
index 0..b0b7680fed68e
--- /dev/null
+++ b/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp
@@ -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";
+

[Lldb-commits] [openmp] [clang] [libc] [mlir] [libcxx] [compiler-rt] [lld] [lldb] [llvm] [clang-tools-extra] [flang] [Driver] Report invalid target triple versions for all environment types. (PR #7865

2024-02-05 Thread via lldb-commits

ZijunZhaoCCK wrote:

> This broke the wasi-threads target: `clang: error: version 'threads' in 
> target triple 'wasm32-unknown-wasi-threads' is invalid`

Because `threads` is not in EnvironmentType list: 
https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/TargetParser/Triple.h#L231
 or ObjectType list: 
https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/TargetParser/Triple.h#L284
 . 

The format should be `arch-vendor-os-env`. If `threads` is a new environment 
type, please add it in the list. If `wasi-threads` is a special case, please 
let me know!

And one more question, would you mind pointing me out the test case of 
`wasm32-unknown-wasi-threads` ? I don't see it. Thank you!

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


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

2024-02-05 Thread Jerry Wu 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);
+}

pzread wrote:

Done. PTAL. I prefer to keep this change focusing on the interface definition 
so I only add a `scf.while` test with no transformation. The actual 
transformation and tests will be added in the follow-up change #80349

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] [llvm] [mlir] [lldb] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)

2024-02-05 Thread Jerry Wu via lldb-commits

https://github.com/pzread updated 
https://github.com/llvm/llvm-project/pull/80331

>From 70f54b51bef87bde5e3f5ee067c0f2414d34e915 Mon Sep 17 00:00:00 2001
From: Jerry Wu 
Date: Thu, 1 Feb 2024 19:57:26 +
Subject: [PATCH 1/7] Add replaceWithZeroTripCheck to LoopLikeOpInterface

---
 .../mlir/Interfaces/LoopLikeInterface.td  | 22 +++
 1 file changed, 22 insertions(+)

diff --git a/mlir/include/mlir/Interfaces/LoopLikeInterface.td 
b/mlir/include/mlir/Interfaces/LoopLikeInterface.td
index e2ac85a3f7725d..77409cb3a8274b 100644
--- a/mlir/include/mlir/Interfaces/LoopLikeInterface.td
+++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td
@@ -220,6 +220,28 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever
+run and return the new loop inside the check. The loop body is moved
+over to the new loop. Returns "failure" if the loop doesn't support
+this transformation.
+
+After the transformation, the ops inserted to the parent region of the
+loop are guaranteed to be run only if the loop body runs at least one
+iteration.
+
+Note: Ops in the loop body might be rearranged because of loop rotating
+to maintain the semantic. Terminators might be removed/added during 
this
+transformation.
+  }],
+  /*retTy=*/"::mlir::FailureOr<::mlir::LoopLikeOpInterface>",
+  /*methodName=*/"replaceWithZeroTripCheck",
+  /*args=*/(ins "::mlir::RewriterBase &":$rewriter),
+  /*methodBody=*/"",
+  /*defaultImplementation=*/[{
+return ::mlir::failure();
+  }]
 >
   ];
 

>From d6703ebbeb5ddc358929672b44994a9d05683523 Mon Sep 17 00:00:00 2001
From: Jerry Wu 
Date: Fri, 2 Feb 2024 18:59:03 +
Subject: [PATCH 2/7] Add tests

---
 mlir/unittests/Interfaces/CMakeLists.txt  |   3 +
 .../Interfaces/LoopLikeInterfaceTest.cpp  | 101 ++
 2 files changed, 104 insertions(+)
 create mode 100644 mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp

diff --git a/mlir/unittests/Interfaces/CMakeLists.txt 
b/mlir/unittests/Interfaces/CMakeLists.txt
index d192b2922d6b9d..cab9503cf295b1 100644
--- a/mlir/unittests/Interfaces/CMakeLists.txt
+++ b/mlir/unittests/Interfaces/CMakeLists.txt
@@ -3,6 +3,7 @@ add_mlir_unittest(MLIRInterfacesTests
   DataLayoutInterfacesTest.cpp
   InferIntRangeInterfaceTest.cpp
   InferTypeOpInterfaceTest.cpp
+  LoopLikeInterfaceTest.cpp
 )
 
 target_link_libraries(MLIRInterfacesTests
@@ -12,7 +13,9 @@ target_link_libraries(MLIRInterfacesTests
   MLIRDataLayoutInterfaces
   MLIRDLTIDialect
   MLIRFuncDialect
+  MLIRIR
   MLIRInferIntRangeInterface
   MLIRInferTypeOpInterface
+  MLIRLoopLikeInterface
   MLIRParser
 )
diff --git a/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp 
b/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp
new file mode 100644
index 00..b0b7680fed68e7
--- /dev/null
+++ b/mlir/unittests/Interfaces/LoopLikeInterfaceTest.cpp
@@ -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"() : () -> ()
+  )ML

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

2024-02-05 Thread Jerry Wu via lldb-commits


@@ -220,6 +220,31 @@ def LoopLikeOpInterface : 
OpInterface<"LoopLikeOpInterface"> {
   /*defaultImplementation=*/[{
 return ::mlir::failure();
   }]
+>,
+InterfaceMethod<[{
+Add a zero-trip-check around the loop to check if the loop body is ever
+run and return the new loop inside the check. The loop body is moved

pzread wrote:

SG. Updated the comments

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] [clang-tools-extra] [openmp] [compiler-rt] [llvm] [libcxx] [lldb] [lld] [clang] [flang] [libc] [mlir] [Driver] Report invalid target triple versions for all environment types. (PR #7865

2024-02-05 Thread Mike Hommey via lldb-commits

glandium wrote:

We stumbled upon this downstream because we have jobs building wasi-sdk with 
clang-trunk, and wasi-sdk builds some things with that target. It apparently 
comes from https://github.com/WebAssembly/wasi-libc/pull/381

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


[Lldb-commits] [compiler-rt] [openmp] [clang] [lldb] [mlir] [llvm] [libcxx] [flang] [libc] [lld] [clang-tools-extra] [Driver] Report invalid target triple versions for all environment types. (PR #7865

2024-02-05 Thread Mike Hommey via lldb-commits

glandium wrote:

There's apparently also wasm32-wasi-preview2 and wasm32-wasi-pthread, which I 
suppose are equally broken by this change.

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits


@@ -74,7 +75,7 @@ json::Value ModuleStats::ToJSON() const {
 
   if (!symfile_modules.empty()) {
 json::Array symfile_ids;
-for (const auto symfile_id: symfile_modules)
+for (const auto symfile_id : symfile_modules)

kusmour wrote:

Yes I can revert that, probs a formatting on save that I didn't notice. 

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 36c84ce56e9ea288d64833aa1f927a7f97fd904c Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/3] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 164 insertions(+), 88 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..7fd888cf7014e3 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target &target);
+  llvm::json::Value ToJSON(Target &target, bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ class DebuggerStats {
   ///   The single target to emit statistics for if non NULL, otherwise dump
   ///   statistics only for the specified target.
   ///
+  /// \param summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  static llvm::json::Value ReportStatistics(Debugger &debugger, Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target,
+bool summary_only = false);
 
 protected:
   // Collecting stats can be set to true to collect stats that are expensive
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats &GetStatistics() { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .str();
   data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str));
   return data;
 }
diff --git a/lldb/source/Commands/CommandObjectStats.cpp 
b/lldb/source/Commands/CommandObjectStats.cpp
index 262de0bda144a6..781b90794dc377 100644
---

[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)

2024-02-05 Thread Alex Langford via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-02-05 Thread via lldb-commits

jimingham wrote:

Okay, I made one more trivial change, I switched the `varname` field to `dest` 
so it matched what argparse had, and I renamed the `usage` entry to `help` so 
it matches the argparse usage as well.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-02-05 Thread via lldb-commits

jimingham wrote:

At this point, I'd like to get this in so I can iterate on it in future PR's 
rather than churning this one.  If folks have a bit to look over this, that 
would be great.  Thanks!

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


[Lldb-commits] [lld] [flang] [llvm] [clang] [libc] [libcxx] [compiler-rt] [lldb] [clang-tools-extra] [openmp] [mlir] [Driver] Report invalid target triple versions for all environment types. (PR #7865

2024-02-05 Thread via lldb-commits

ZijunZhaoCCK wrote:

> There's apparently also wasm32-wasi-preview2 and wasm32-wasi-pthread, which I 
> suppose are equally broken by this change.

Yes, I think so. I think adding these environment types in wasi-libc repo could 
help fix those errors.

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits


@@ -2687,7 +2687,7 @@ uint64_t SymbolFileDWARF::GetDebugInfoSize() {
 if (cu == nullptr)
   continue;
 
-SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
+SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(false);

jeffreytan81 wrote:

Instead of hard-coding `false` here, I think it should the caller of 
`SymbolFileDWARF::GetDebugInfoSize` caller (statistics.cpp in this case) making 
this decision. 

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


[Lldb-commits] [compiler-rt] [mlir] [clang] [libc] [flang] [clang-tools-extra] [lld] [openmp] [lldb] [llvm] [libcxx] [Driver] Report invalid target triple versions for all environment types. (PR #7865

2024-02-05 Thread Mike Hommey via lldb-commits

glandium wrote:

> Yes, I think so. I think adding these environment types in wasi-libc repo 
> could help fix those errors.

WDYM?

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.


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


  1   2   >