[Lldb-commits] [compiler-rt] [flang] [clang] [libc] [llvm] [clang-tools-extra] [libcxx] [lldb] [PowerPC] Support mcmodel=large for AIX (PR #70652)

2023-11-02 Thread Fangrui Song via lldb-commits


@@ -5723,16 +5723,14 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
   if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
 StringRef CM = A->getValue();
 bool Ok = false;
-if (Triple.isOSAIX() && CM == "medium") {
+if (Triple.isOSAIX() && CM == "medium")
   CM = "large";
-  Ok = true;
-}
 if (Triple.isAArch64(64)) {
   Ok = CM == "tiny" || CM == "small" || CM == "large";
   if (CM == "large" && RelocationModel != llvm::Reloc::Static)
 D.Diag(diag::err_drv_argument_only_allowed_with)
 << A->getAsString(Args) << "-fno-pic";
-} else if (Triple.isPPC64()) {
+} else if (Triple.isPPC64() || Triple.isOSAIX()) {

MaskRay wrote:

Hi, may I ask what `-mcmodel=large` does on a 32-bit AIX?

`-mcmodel=large` is generally not supported for 32-bit systems and it seems 
that AIX does something special here.

GCC's rs6000 doc says:

> Generate PowerPC64 code for the large model: The TOC may be up to 4G in size. 
> Other data and code is only limited by the 64-bit address space.

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


[Lldb-commits] [lldb] [lldb][AArch64] Simplify handing of scalable registers using vg and svg (PR #70914)

2023-11-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

That's correct. Given how much churn this logic has had, I wanted to keep the 
changes clearly separated (for when I inevitably realise it's still not quite 
right :) ).

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread via lldb-commits

taalhaataahir0102 wrote:

Hi David!
Thanks for the detailed explanation. I got you point that instead of passing 
the whole object, we should only pass the information required by the next 
functions. Now I' passing a vector down the track that holds a pair of two 
things:
`std::vector> info;`

- The searched regex string
- Use-color settings

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


[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits


@@ -762,82 +756,22 @@ uint32_t 
GDBRemoteRegisterContext::ConvertRegisterKindToRegisterNumber(
   return m_reg_info_sp->ConvertRegisterKindToRegisterNumber(kind, num);
 }
 
-void GDBRemoteRegisterContext::AArch64Reconfigure() {
-  assert(m_reg_info_sp);
-
-  // Once we start to reconfigure registers, we cannot read any of them.
-  // So we must read VG and SVG up front.
-
-  const uint64_t fail_value = LLDB_INVALID_ADDRESS;
-  std::optional vg_reg_value;
-  const RegisterInfo *vg_reg_info = m_reg_info_sp->GetRegisterInfo("vg");
-  if (vg_reg_info) {
-// Make sure we get the latest value of vg from the remote.
-SetRegisterIsValid(vg_reg_info, false);
-uint32_t vg_reg_num = vg_reg_info->kinds[eRegisterKindLLDB];
-uint64_t reg_value = ReadRegisterAsUnsigned(vg_reg_num, fail_value);
-if (reg_value != fail_value && reg_value <= 32)
-  vg_reg_value = reg_value;
-  }
-
-  std::optional svg_reg_value;
-  const RegisterInfo *svg_reg_info = m_reg_info_sp->GetRegisterInfo("svg");
-  if (svg_reg_info) {
-// When vg is written it is automatically made invalid. Writing vg will 
also
-// change svg if we're in streaming mode but it will not be made invalid
-// so do this manually so the following read gets the latest svg value.
-SetRegisterIsValid(svg_reg_info, false);
-
-uint32_t svg_reg_num = svg_reg_info->kinds[eRegisterKindLLDB];
-uint64_t reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);
-if (reg_value != fail_value && reg_value <= 32)
-  svg_reg_value = reg_value;
-  }
-
-  if (vg_reg_value)
-m_reg_info_sp->UpdateARM64SVERegistersInfos(*vg_reg_value);
-  if (svg_reg_value)
-m_reg_info_sp->UpdateARM64SMERegistersInfos(*svg_reg_value);
-
-  // At this point if we have updated any registers, their offsets will all be
-  // invalid. If we did, we need to update them all.
-  if (vg_reg_value || svg_reg_value) {
-m_reg_info_sp->ConfigureOffsets();
-// From here we are able to read registers again.
-
-// Make a heap based buffer that is big enough to store all registers
-m_reg_data.SetData(std::make_shared(
-m_reg_info_sp->GetRegisterDataByteSize(), 0));
-m_reg_data.SetByteOrder(GetByteOrder());
-  }
-}
-
-void GDBRemoteDynamicRegisterInfo::UpdateARM64SVERegistersInfos(uint64_t vg) {
-  // SVE Z register size is vg x 8 bytes.
-  uint32_t z_reg_byte_size = vg * 8;
-
-  // SVE vector length has changed, accordingly set size of Z, P and FFR
-  // registers. Also invalidate register offsets it will be recalculated
-  // after SVE register size update.
-  for (auto ® : m_regs) {
-if (reg.value_regs == nullptr) {
-  if (reg.name[0] == 'z' && isdigit(reg.name[1]))
-reg.byte_size = z_reg_byte_size;
-  else if (reg.name[0] == 'p' && isdigit(reg.name[1]))
-reg.byte_size = vg;
-  else if (strcmp(reg.name, "ffr") == 0)
-reg.byte_size = vg;
-}
-reg.byte_offset = LLDB_INVALID_INDEX32;
-  }
+bool GDBRemoteRegisterContext::RegisterWriteCausesReconfigure(
+const char *name) {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();
+  const Architecture *architecture =
+  process->GetTarget().GetArchitecturePlugin();
+  return architecture && architecture->RegisterWriteCausesReconfigure(name);
 }
 
-void GDBRemoteDynamicRegisterInfo::UpdateARM64SMERegistersInfos(uint64_t svg) {
-  for (auto ® : m_regs) {
-if (strcmp(reg.name, "za") == 0) {
-  // ZA is a register with size (svg*8) * (svg*8). A square essentially.
-  reg.byte_size = (svg * 8) * (svg * 8);
-}
-reg.byte_offset = LLDB_INVALID_INDEX32;
-  }
+bool GDBRemoteRegisterContext::ReconfigureRegisterInfo() {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();

DavidSpickett wrote:

I copy and pasted from something that already assumed it was valid, so yeah, 
I'll get a ref instead.

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


[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits


@@ -93,6 +93,10 @@ class DynamicRegisterInfo {
 return llvm::iterator_range(m_regs);
   }
 
+  llvm::iterator_range registers_mutable() {

DavidSpickett wrote:

Wouldn't that have to overload on return type? I didn't think that was possible.

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


[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits


@@ -762,82 +756,22 @@ uint32_t 
GDBRemoteRegisterContext::ConvertRegisterKindToRegisterNumber(
   return m_reg_info_sp->ConvertRegisterKindToRegisterNumber(kind, num);
 }
 
-void GDBRemoteRegisterContext::AArch64Reconfigure() {
-  assert(m_reg_info_sp);
-
-  // Once we start to reconfigure registers, we cannot read any of them.
-  // So we must read VG and SVG up front.
-
-  const uint64_t fail_value = LLDB_INVALID_ADDRESS;
-  std::optional vg_reg_value;
-  const RegisterInfo *vg_reg_info = m_reg_info_sp->GetRegisterInfo("vg");
-  if (vg_reg_info) {
-// Make sure we get the latest value of vg from the remote.
-SetRegisterIsValid(vg_reg_info, false);
-uint32_t vg_reg_num = vg_reg_info->kinds[eRegisterKindLLDB];
-uint64_t reg_value = ReadRegisterAsUnsigned(vg_reg_num, fail_value);
-if (reg_value != fail_value && reg_value <= 32)
-  vg_reg_value = reg_value;
-  }
-
-  std::optional svg_reg_value;
-  const RegisterInfo *svg_reg_info = m_reg_info_sp->GetRegisterInfo("svg");
-  if (svg_reg_info) {
-// When vg is written it is automatically made invalid. Writing vg will 
also
-// change svg if we're in streaming mode but it will not be made invalid
-// so do this manually so the following read gets the latest svg value.
-SetRegisterIsValid(svg_reg_info, false);
-
-uint32_t svg_reg_num = svg_reg_info->kinds[eRegisterKindLLDB];
-uint64_t reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);
-if (reg_value != fail_value && reg_value <= 32)
-  svg_reg_value = reg_value;
-  }
-
-  if (vg_reg_value)
-m_reg_info_sp->UpdateARM64SVERegistersInfos(*vg_reg_value);
-  if (svg_reg_value)
-m_reg_info_sp->UpdateARM64SMERegistersInfos(*svg_reg_value);
-
-  // At this point if we have updated any registers, their offsets will all be
-  // invalid. If we did, we need to update them all.
-  if (vg_reg_value || svg_reg_value) {
-m_reg_info_sp->ConfigureOffsets();
-// From here we are able to read registers again.
-
-// Make a heap based buffer that is big enough to store all registers
-m_reg_data.SetData(std::make_shared(
-m_reg_info_sp->GetRegisterDataByteSize(), 0));
-m_reg_data.SetByteOrder(GetByteOrder());
-  }
-}
-
-void GDBRemoteDynamicRegisterInfo::UpdateARM64SVERegistersInfos(uint64_t vg) {
-  // SVE Z register size is vg x 8 bytes.
-  uint32_t z_reg_byte_size = vg * 8;
-
-  // SVE vector length has changed, accordingly set size of Z, P and FFR
-  // registers. Also invalidate register offsets it will be recalculated
-  // after SVE register size update.
-  for (auto ® : m_regs) {
-if (reg.value_regs == nullptr) {
-  if (reg.name[0] == 'z' && isdigit(reg.name[1]))
-reg.byte_size = z_reg_byte_size;
-  else if (reg.name[0] == 'p' && isdigit(reg.name[1]))
-reg.byte_size = vg;
-  else if (strcmp(reg.name, "ffr") == 0)
-reg.byte_size = vg;
-}
-reg.byte_offset = LLDB_INVALID_INDEX32;
-  }
+bool GDBRemoteRegisterContext::RegisterWriteCausesReconfigure(
+const char *name) {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();
+  const Architecture *architecture =
+  process->GetTarget().GetArchitecturePlugin();
+  return architecture && architecture->RegisterWriteCausesReconfigure(name);

DavidSpickett wrote:

Though I should change this process to a reference as well.

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


[Lldb-commits] [lldb] 805a36a - [lldb][AArch64] Simplify handing of scalable registers using vg and svg (#70914)

2023-11-02 Thread via lldb-commits

Author: David Spickett
Date: 2023-11-02T10:27:37Z
New Revision: 805a36aaf571a8d53781c0c413d1af125137bfa2

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

LOG: [lldb][AArch64] Simplify handing of scalable registers using vg and svg 
(#70914)

This removes explicit invalidation of vg and svg that was done in
`GDBRemoteRegisterContext::AArch64Reconfigure`. This was in fact
covering up a bug elsehwere.

Register information says that a write to vg also invalidates svg (it
does not unless you are in streaming mode, but we decided to keep it
simple and say it always does).

This invalidation was not being applied until *after* AArch64Reconfigure
was called. This meant that without those manual invalidates this
happened:
* vg is written
* svg is not invalidated
* Reconfigure uses the written vg value
* Reconfigure uses the *old* svg value

I have moved the AArch64Reconfigure call to after we've processed the
invalidations caused by the register write, so we no longer need the
manual invalidates in AArch64Reconfigure.

In addition I have changed the order in which expedited registers as
parsed. These registers come with a stop notification and include,
amongst others, vg and svg.

So now we:
* Parse them and update register values (including vg and svg)
* AArch64Reconfigure, which uses those values, and invalidates every
register, because offsets may have changed.
* Parse the expedited registers again, knowing that none of the values
will have changed due to the scaling.

This means we use the expedited registers during the reconfigure, but
the invalidate does not mean we throw all of them away.

The cost is we parse them twice client side, but this is cheap compared
to a network packet, and is limited to AArch64 targets only.

On a system with SVE and SME, these are the packets sent for a step:
```
(lldb) b-remote.async>  < 803> read packet:
$T05thread:p1f80.1f80;name:main.o;threads:1f80;thread-pcs:0040056c<...>a1:0800;d9:0400;reason:trace;#fc
intern-state <  21> send packet: $xf200,200#5e
intern-state < 516> read packet:
$e4f200<...>#71
intern-state <  15> send packet: $Z0,400568,4#4d
intern-state <   6> read packet: $OK#9a
dbg.evt-handler  <  16> send packet: $jThreadsInfo#c1
dbg.evt-handler  < 224> read packet:
$[{"name":"main.o","reason":"trace","registers":{"161":"0800",<...>}],"signal":5,"tid":8064}]]#73
```

You can see there are no extra register reads which means we're using
the expedited registers.

For a write to vg:
```
(lldb) register write vg 4
lldb <  37> send packet:
$Pa1=0400;thread:1f80;#4a
lldb <   6> read packet: $OK#9a
lldb <  20> send packet: $pa1;thread:1f80;#29
lldb <  20> read packet: $0400#04
lldb <  20> send packet: $pd9;thread:1f80;#34
lldb <  20> read packet: $0400#04
```

There is the initial P write, and lldb correctly assumes that SVG is
invalidated by this also so we read back the new vg and svg values
afterwards.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 72280927471f883..013b2bbc0e67f27 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -434,11 +434,6 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const 
RegisterInfo *reg_info,
 } else {
   // This is an actual register, write it
   success = SetPrimordialRegister(reg_info, gdb_comm);
-
-  if (success && do_reconfigure_arm64_sve) {
-AArch64Reconfigure();
-InvalidateAllRegisters();
-  }
 }
 
 // Check if writing this register will invalidate any other register
@@ -452,6 +447,11 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const 
RegisterInfo *reg_info,
false);
 }
 
+if (success && do_reconfigure_arm64_sve) {
+  AArch64Reconfigure();
+  InvalidateAllRegisters();
+}
+
 return success;
   }
 } else {
@@ -772,8 +772,6 @@ void GDBRemoteRegisterContext::AArch64Reconfigure() {
   std::optional vg_reg_value;
   const RegisterInfo *vg_reg_info = m_reg_info_sp->GetRegisterInfo("vg");
   if (vg_reg_info) {
-// Make sure we get the latest value of vg from the remote.
-SetRegisterIsValid(vg_reg_i

[Lldb-commits] [lldb] [lldb][AArch64] Simplify handing of scalable registers using vg and svg (PR #70914)

2023-11-02 Thread David Spickett via lldb-commits

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


[Lldb-commits] [flang] [mlir] [clang] [libcxx] [llvm] [lldb] [Flang][OpenMP] Port openmp threadprivate-use-association.f90 test to HLFIR flow (PR #71043)

2023-11-02 Thread chandan singh via lldb-commits

https://github.com/chandankds created 
https://github.com/llvm/llvm-project/pull/71043

None

>From 029b1687e5217e73655442b319a482865587277b Mon Sep 17 00:00:00 2001
From: chandan singh <36783761+chandan...@users.noreply.github.com>
Date: Thu, 2 Nov 2023 11:53:03 +0530
Subject: [PATCH 1/2] [Flang][OpenMP] Port OpenMP threadprivate tests to hlfir
 flow

---
 .../OpenMP/threadprivate-use-association.f90  | 74 +++
 1 file changed, 74 insertions(+)
 create mode 100644 flang/test/Lower/OpenMP/threadprivate-use-association.f90

diff --git a/flang/test/Lower/OpenMP/threadprivate-use-association.f90 
b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
new file mode 100644
index 000..71d454bb39ce1d1
--- /dev/null
+++ b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
@@ -0,0 +1,74 @@
+! This test checks lowering of OpenMP Threadprivate Directive.
+! Test for threadprivate variable in use association.
+
+!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+
+!CHECK-DAG: fir.global common @blk_(dense<0> : vector<24xi8>) : 
!fir.array<24xi8>
+!CHECK-DAG: fir.global @_QMtestEy : f32 {
+
+module test
+  integer :: x
+  real :: y, z(5)
+  common /blk/ x, z
+
+  !$omp threadprivate(y, /blk/)
+
+contains
+  subroutine sub()
+! CHECK-LABEL: @_QMtestPsub
+!CHECK-DAG:   [[ADDR0:%.*]] = fir.address_of(@blk_) : 
!fir.ref>
+!CHECK-DAG:   [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : 
!fir.ref> -> !fir.ref>
+!CHECK-DAG:   [[ADDR1:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref
+!CHECK-DAG:   [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref 
-> !fir.ref
+
+!$omp parallel
+!CHECK-DAG:[[ADDR2:%.*]] = omp.threadprivate [[ADDR0]] : 
!fir.ref> -> !fir.ref>
+!CHECK-DAG:[[ADDR3:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref -> 
!fir.ref
+!CHECK-DAG:[[ADDR4:%.*]] = fir.convert [[ADDR2]] : 
(!fir.ref>) -> !fir.ref>
+!CHECK-DAG:[[ADDR5:%.*]] = fir.coordinate_of [[ADDR4]], %{{.*}} : 
(!fir.ref>, index) -> !fir.ref
+!CHECK-DAG:[[ADDR6:%.*]] = fir.convert [[ADDR5:%.*]] : (!fir.ref) -> 
!fir.ref
+!CHECK-DAG:[[ADDR7:%.*]] = fir.convert [[ADDR2]] : 
(!fir.ref>) -> !fir.ref>
+!CHECK-DAG:[[ADDR8:%.*]] = fir.coordinate_of [[ADDR7]], %{{.*}} : 
(!fir.ref>, index) -> !fir.ref
+!CHECK-DAG:[[ADDR9:%.*]] = fir.convert [[ADDR8:%.*]] : (!fir.ref) -> 
!fir.ref>
+!CHECK-DAG:%{{.*}} = fir.load [[ADDR6]] : !fir.ref
+!CHECK-DAG:%{{.*}} = fir.load [[ADDR3]] : !fir.ref
+!CHECK-DAG:%{{.*}} = fir.embox [[ADDR9]](%{{.*}}) : 
(!fir.ref>, !fir.shape<1>) -> !fir.box>
+  print *, x, y, z
+!$omp end parallel
+  end
+end
+
+program main
+  use test
+  integer :: x1
+  real :: z1(5)
+  common /blk/ x1, z1
+
+  !$omp threadprivate(/blk/)
+
+  call sub()
+
+! CHECK-LABEL: @_QQmain()
+!CHECK-DAG:  [[ADDR0:%.*]] = fir.address_of(@blk_) : 
!fir.ref>
+!CHECK-DAG:  [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : 
!fir.ref> -> !fir.ref>
+!CHECK-DAG:  [[ADDR1:%.*]] = fir.address_of(@blk_) : 
!fir.ref>
+!CHECK-DAG:  [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : 
!fir.ref> -> !fir.ref>
+!CHECK-DAG:  [[ADDR2:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref
+!CHECK-DAG:  [[NEWADDR2:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref -> 
!fir.ref
+
+  !$omp parallel
+!CHECK-DAG:[[ADDR4:%.*]] = omp.threadprivate [[ADDR1]] : 
!fir.ref> -> !fir.ref>
+!CHECK-DAG:[[ADDR5:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref -> 
!fir.ref
+!CHECK-DAG:[[ADDR6:%.*]] = fir.convert [[ADDR4]] : 
(!fir.ref>) -> !fir.ref>
+!CHECK-DAG:[[ADDR7:%.*]] = fir.coordinate_of [[ADDR6]], %{{.*}} : 
(!fir.ref>, index) -> !fir.ref
+!CHECK-DAG:[[ADDR8:%.*]] = fir.convert [[ADDR7:%.*]] : (!fir.ref) -> 
!fir.ref
+!CHECK-DAG:[[ADDR9:%.*]] = fir.convert [[ADDR4]] : 
(!fir.ref>) -> !fir.ref>
+!CHECK-DAG:[[ADDR10:%.*]] = fir.coordinate_of [[ADDR9]], %{{.*}} : 
(!fir.ref>, index) -> !fir.ref
+!CHECK-DAG:[[ADDR11:%.*]] = fir.convert [[ADDR10:%.*]] : (!fir.ref) -> 
!fir.ref>
+!CHECK-DAG:%{{.*}} = fir.load [[ADDR8]] : !fir.ref
+!CHECK-DAG:%{{.*}} = fir.load [[ADDR5]] : !fir.ref
+!CHECK-DAG:%{{.*}} = fir.embox [[ADDR11]](%{{.*}}) : 
(!fir.ref>, !fir.shape<1>) -> !fir.box>
+print *, x1, y, z1
+  !$omp end parallel
+
+end

>From 85fd277116be1d59dd548b73f136a6f2c748dcba Mon Sep 17 00:00:00 2001
From: chandan singh <36783761+chandan...@users.noreply.github.com>
Date: Thu, 2 Nov 2023 11:57:40 +0530
Subject: [PATCH 2/2] [Flang][OpenMP] Port openmp
 threadprivate-use-association.f90 test to HLFIR flow

---
 .../OpenMP/threadprivate-use-association.f90  | 56 +++
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/flang/test/Lower/OpenMP/threadprivate-use-association.f90 
b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
index 71d454bb39ce1d1..d0d461547db2f68 100644
--- a/flang/test/Lower/OpenMP/threadprivate-use-association.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
@@ -1,7 +1,7 @@
 ! This test checks lowering of Op

[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/70950

>From 47a48746a8a8f8e37d12a2d38a30dbfa52d5c645 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 1 Nov 2023 13:41:54 +
Subject: [PATCH] [lldb][AArch64] Move register info reconfigure into
 architecture plugin

This removes AArch64 specific code from the GDB* classes.

To do this I've added 2 new methods to Architecture:
* RegisterWriteCausesReconfigure to check if what you are about to do
  will trash the register info.
* ReconfigureRegisterInfo to do the reconfiguring. This tells you if
  anything changed so that we only invalidate registers when needed.

So that ProcessGDBRemote can call ReconfigureRegisterInfo in SetThreadStopInfo,
I've added forwarding calls to GDBRemoteRegisterContext and the base class
RegisterContext.

(which removes a slightly sketchy static cast as well)

RegisterContext defaults to doing nothing for both the methods
so anything other than GDBRemoteRegisterContext will do nothing.
---
 lldb/include/lldb/Core/Architecture.h |  20 
 .../include/lldb/Target/DynamicRegisterInfo.h |   4 +
 lldb/include/lldb/Target/RegisterContext.h|   6 +
 .../AArch64/ArchitectureAArch64.cpp   |  91 ++
 .../AArch64/ArchitectureAArch64.h |  11 ++
 .../gdb-remote/GDBRemoteRegisterContext.cpp   | 113 --
 .../gdb-remote/GDBRemoteRegisterContext.h |   5 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  29 ++---
 8 files changed, 169 insertions(+), 110 deletions(-)

diff --git a/lldb/include/lldb/Core/Architecture.h 
b/lldb/include/lldb/Core/Architecture.h
index b68bf27ae0df888..b6fc1a20e1e6967 100644
--- a/lldb/include/lldb/Core/Architecture.h
+++ b/lldb/include/lldb/Core/Architecture.h
@@ -10,6 +10,7 @@
 #define LLDB_CORE_ARCHITECTURE_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Target/DynamicRegisterInfo.h"
 #include "lldb/Target/MemoryTagManager.h"
 
 namespace lldb_private {
@@ -109,6 +110,25 @@ class Architecture : public PluginInterface {
   virtual const MemoryTagManager *GetMemoryTagManager() const {
 return nullptr;
   }
+
+  // This returns true if a write to the named register should cause lldb to
+  // reconfigure its register information. For example on AArch64 writing to vg
+  // to change the vector length means lldb has to change the size of 
registers.
+  virtual bool
+  RegisterWriteCausesReconfigure(const llvm::StringRef name) const {
+return false;
+  }
+
+  // Call this after writing a register for which 
RegisterWriteCausesReconfigure
+  // returns true. This method will update the layout of registers according to
+  // the new state e.g. the new length of scalable vector registers.
+  // Returns true if anything changed, which means existing register values 
must
+  // be invalidated.
+  virtual bool ReconfigureRegisterInfo(DynamicRegisterInfo ®_info,
+   DataExtractor ®_data,
+   RegisterContext ®_context) const {
+return false;
+  }
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index fb22885e713d672..0e175a99eb7d58a 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -93,6 +93,10 @@ class DynamicRegisterInfo {
 return llvm::iterator_range(m_regs);
   }
 
+  llvm::iterator_range registers_mutable() {
+return llvm::iterator_range(m_regs);
+  }
+
   void ConfigureOffsets();
 
 protected:
diff --git a/lldb/include/lldb/Target/RegisterContext.h 
b/lldb/include/lldb/Target/RegisterContext.h
index 893569a98dbd8b3..309e231b2321e77 100644
--- a/lldb/include/lldb/Target/RegisterContext.h
+++ b/lldb/include/lldb/Target/RegisterContext.h
@@ -51,6 +51,12 @@ class RegisterContext : public 
std::enable_shared_from_this,
 return false;
   }
 
+  virtual bool RegisterWriteCausesReconfigure(const llvm::StringRef name) {
+return false;
+  }
+
+  virtual bool ReconfigureRegisterInfo() { return false; }
+
   // These two functions are used to implement "push" and "pop" of register
   // states.  They are used primarily for expression evaluation, where we need
   // to push a new state (storing the old one in data_sp) and then restoring
diff --git a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp 
b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
index 1b2b41ee8758758..2954eaa2083af08 100644
--- a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
+++ b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
@@ -8,7 +8,10 @@
 
 #include "Plugins/Architecture/AArch64/ArchitectureAArch64.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Target/RegisterContext.h"
 #include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
 
 using namespace l

[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread via lldb-commits

https://github.com/harishch4 updated 
https://github.com/llvm/llvm-project/pull/70950

>From 47a48746a8a8f8e37d12a2d38a30dbfa52d5c645 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Wed, 1 Nov 2023 13:41:54 +
Subject: [PATCH] [lldb][AArch64] Move register info reconfigure into
 architecture plugin

This removes AArch64 specific code from the GDB* classes.

To do this I've added 2 new methods to Architecture:
* RegisterWriteCausesReconfigure to check if what you are about to do
  will trash the register info.
* ReconfigureRegisterInfo to do the reconfiguring. This tells you if
  anything changed so that we only invalidate registers when needed.

So that ProcessGDBRemote can call ReconfigureRegisterInfo in SetThreadStopInfo,
I've added forwarding calls to GDBRemoteRegisterContext and the base class
RegisterContext.

(which removes a slightly sketchy static cast as well)

RegisterContext defaults to doing nothing for both the methods
so anything other than GDBRemoteRegisterContext will do nothing.
---
 lldb/include/lldb/Core/Architecture.h |  20 
 .../include/lldb/Target/DynamicRegisterInfo.h |   4 +
 lldb/include/lldb/Target/RegisterContext.h|   6 +
 .../AArch64/ArchitectureAArch64.cpp   |  91 ++
 .../AArch64/ArchitectureAArch64.h |  11 ++
 .../gdb-remote/GDBRemoteRegisterContext.cpp   | 113 --
 .../gdb-remote/GDBRemoteRegisterContext.h |   5 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |  29 ++---
 8 files changed, 169 insertions(+), 110 deletions(-)

diff --git a/lldb/include/lldb/Core/Architecture.h 
b/lldb/include/lldb/Core/Architecture.h
index b68bf27ae0df888..b6fc1a20e1e6967 100644
--- a/lldb/include/lldb/Core/Architecture.h
+++ b/lldb/include/lldb/Core/Architecture.h
@@ -10,6 +10,7 @@
 #define LLDB_CORE_ARCHITECTURE_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Target/DynamicRegisterInfo.h"
 #include "lldb/Target/MemoryTagManager.h"
 
 namespace lldb_private {
@@ -109,6 +110,25 @@ class Architecture : public PluginInterface {
   virtual const MemoryTagManager *GetMemoryTagManager() const {
 return nullptr;
   }
+
+  // This returns true if a write to the named register should cause lldb to
+  // reconfigure its register information. For example on AArch64 writing to vg
+  // to change the vector length means lldb has to change the size of 
registers.
+  virtual bool
+  RegisterWriteCausesReconfigure(const llvm::StringRef name) const {
+return false;
+  }
+
+  // Call this after writing a register for which 
RegisterWriteCausesReconfigure
+  // returns true. This method will update the layout of registers according to
+  // the new state e.g. the new length of scalable vector registers.
+  // Returns true if anything changed, which means existing register values 
must
+  // be invalidated.
+  virtual bool ReconfigureRegisterInfo(DynamicRegisterInfo ®_info,
+   DataExtractor ®_data,
+   RegisterContext ®_context) const {
+return false;
+  }
 };
 
 } // namespace lldb_private
diff --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index fb22885e713d672..0e175a99eb7d58a 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -93,6 +93,10 @@ class DynamicRegisterInfo {
 return llvm::iterator_range(m_regs);
   }
 
+  llvm::iterator_range registers_mutable() {
+return llvm::iterator_range(m_regs);
+  }
+
   void ConfigureOffsets();
 
 protected:
diff --git a/lldb/include/lldb/Target/RegisterContext.h 
b/lldb/include/lldb/Target/RegisterContext.h
index 893569a98dbd8b3..309e231b2321e77 100644
--- a/lldb/include/lldb/Target/RegisterContext.h
+++ b/lldb/include/lldb/Target/RegisterContext.h
@@ -51,6 +51,12 @@ class RegisterContext : public 
std::enable_shared_from_this,
 return false;
   }
 
+  virtual bool RegisterWriteCausesReconfigure(const llvm::StringRef name) {
+return false;
+  }
+
+  virtual bool ReconfigureRegisterInfo() { return false; }
+
   // These two functions are used to implement "push" and "pop" of register
   // states.  They are used primarily for expression evaluation, where we need
   // to push a new state (storing the old one in data_sp) and then restoring
diff --git a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp 
b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
index 1b2b41ee8758758..2954eaa2083af08 100644
--- a/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
+++ b/lldb/source/Plugins/Architecture/AArch64/ArchitectureAArch64.cpp
@@ -8,7 +8,10 @@
 
 #include "Plugins/Architecture/AArch64/ArchitectureAArch64.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Target/RegisterContext.h"
 #include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
 
 using namespace lldb_

[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits


@@ -109,6 +110,24 @@ class Architecture : public PluginInterface {
   virtual const MemoryTagManager *GetMemoryTagManager() const {
 return nullptr;
   }
+
+  // This returns true if a write to the named register should cause lldb to
+  // reconfigure its register information. For example on AArch64 writing to vg
+  // to change the vector length means lldb has to change the size of 
registers.
+  virtual bool RegisterWriteCausesReconfigure(const char *name) const {

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits


@@ -762,82 +756,22 @@ uint32_t 
GDBRemoteRegisterContext::ConvertRegisterKindToRegisterNumber(
   return m_reg_info_sp->ConvertRegisterKindToRegisterNumber(kind, num);
 }
 
-void GDBRemoteRegisterContext::AArch64Reconfigure() {
-  assert(m_reg_info_sp);
-
-  // Once we start to reconfigure registers, we cannot read any of them.
-  // So we must read VG and SVG up front.
-
-  const uint64_t fail_value = LLDB_INVALID_ADDRESS;
-  std::optional vg_reg_value;
-  const RegisterInfo *vg_reg_info = m_reg_info_sp->GetRegisterInfo("vg");
-  if (vg_reg_info) {
-// Make sure we get the latest value of vg from the remote.
-SetRegisterIsValid(vg_reg_info, false);
-uint32_t vg_reg_num = vg_reg_info->kinds[eRegisterKindLLDB];
-uint64_t reg_value = ReadRegisterAsUnsigned(vg_reg_num, fail_value);
-if (reg_value != fail_value && reg_value <= 32)
-  vg_reg_value = reg_value;
-  }
-
-  std::optional svg_reg_value;
-  const RegisterInfo *svg_reg_info = m_reg_info_sp->GetRegisterInfo("svg");
-  if (svg_reg_info) {
-// When vg is written it is automatically made invalid. Writing vg will 
also
-// change svg if we're in streaming mode but it will not be made invalid
-// so do this manually so the following read gets the latest svg value.
-SetRegisterIsValid(svg_reg_info, false);
-
-uint32_t svg_reg_num = svg_reg_info->kinds[eRegisterKindLLDB];
-uint64_t reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);
-if (reg_value != fail_value && reg_value <= 32)
-  svg_reg_value = reg_value;
-  }
-
-  if (vg_reg_value)
-m_reg_info_sp->UpdateARM64SVERegistersInfos(*vg_reg_value);
-  if (svg_reg_value)
-m_reg_info_sp->UpdateARM64SMERegistersInfos(*svg_reg_value);
-
-  // At this point if we have updated any registers, their offsets will all be
-  // invalid. If we did, we need to update them all.
-  if (vg_reg_value || svg_reg_value) {
-m_reg_info_sp->ConfigureOffsets();
-// From here we are able to read registers again.
-
-// Make a heap based buffer that is big enough to store all registers
-m_reg_data.SetData(std::make_shared(
-m_reg_info_sp->GetRegisterDataByteSize(), 0));
-m_reg_data.SetByteOrder(GetByteOrder());
-  }
-}
-
-void GDBRemoteDynamicRegisterInfo::UpdateARM64SVERegistersInfos(uint64_t vg) {
-  // SVE Z register size is vg x 8 bytes.
-  uint32_t z_reg_byte_size = vg * 8;
-
-  // SVE vector length has changed, accordingly set size of Z, P and FFR
-  // registers. Also invalidate register offsets it will be recalculated
-  // after SVE register size update.
-  for (auto ® : m_regs) {
-if (reg.value_regs == nullptr) {
-  if (reg.name[0] == 'z' && isdigit(reg.name[1]))
-reg.byte_size = z_reg_byte_size;
-  else if (reg.name[0] == 'p' && isdigit(reg.name[1]))
-reg.byte_size = vg;
-  else if (strcmp(reg.name, "ffr") == 0)
-reg.byte_size = vg;
-}
-reg.byte_offset = LLDB_INVALID_INDEX32;
-  }
+bool GDBRemoteRegisterContext::RegisterWriteCausesReconfigure(
+const char *name) {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();
+  const Architecture *architecture =
+  process->GetTarget().GetArchitecturePlugin();
+  return architecture && architecture->RegisterWriteCausesReconfigure(name);
 }
 
-void GDBRemoteDynamicRegisterInfo::UpdateARM64SMERegistersInfos(uint64_t svg) {
-  for (auto ® : m_regs) {
-if (strcmp(reg.name, "za") == 0) {
-  // ZA is a register with size (svg*8) * (svg*8). A square essentially.
-  reg.byte_size = (svg * 8) * (svg * 8);
-}
-reg.byte_offset = LLDB_INVALID_INDEX32;
-  }
+bool GDBRemoteRegisterContext::ReconfigureRegisterInfo() {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits


@@ -93,6 +93,10 @@ class DynamicRegisterInfo {
 return llvm::iterator_range(m_regs);
   }
 
+  llvm::iterator_range registers_mutable() {

DavidSpickett wrote:

Still not sure here, I guess you could pass a reference to an iterator to be 
set, then overload on the type of that?

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


[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits


@@ -762,82 +756,22 @@ uint32_t 
GDBRemoteRegisterContext::ConvertRegisterKindToRegisterNumber(
   return m_reg_info_sp->ConvertRegisterKindToRegisterNumber(kind, num);
 }
 
-void GDBRemoteRegisterContext::AArch64Reconfigure() {
-  assert(m_reg_info_sp);
-
-  // Once we start to reconfigure registers, we cannot read any of them.
-  // So we must read VG and SVG up front.
-
-  const uint64_t fail_value = LLDB_INVALID_ADDRESS;
-  std::optional vg_reg_value;
-  const RegisterInfo *vg_reg_info = m_reg_info_sp->GetRegisterInfo("vg");
-  if (vg_reg_info) {
-// Make sure we get the latest value of vg from the remote.
-SetRegisterIsValid(vg_reg_info, false);
-uint32_t vg_reg_num = vg_reg_info->kinds[eRegisterKindLLDB];
-uint64_t reg_value = ReadRegisterAsUnsigned(vg_reg_num, fail_value);
-if (reg_value != fail_value && reg_value <= 32)
-  vg_reg_value = reg_value;
-  }
-
-  std::optional svg_reg_value;
-  const RegisterInfo *svg_reg_info = m_reg_info_sp->GetRegisterInfo("svg");
-  if (svg_reg_info) {
-// When vg is written it is automatically made invalid. Writing vg will 
also
-// change svg if we're in streaming mode but it will not be made invalid
-// so do this manually so the following read gets the latest svg value.
-SetRegisterIsValid(svg_reg_info, false);
-
-uint32_t svg_reg_num = svg_reg_info->kinds[eRegisterKindLLDB];
-uint64_t reg_value = ReadRegisterAsUnsigned(svg_reg_num, fail_value);
-if (reg_value != fail_value && reg_value <= 32)
-  svg_reg_value = reg_value;
-  }
-
-  if (vg_reg_value)
-m_reg_info_sp->UpdateARM64SVERegistersInfos(*vg_reg_value);
-  if (svg_reg_value)
-m_reg_info_sp->UpdateARM64SMERegistersInfos(*svg_reg_value);
-
-  // At this point if we have updated any registers, their offsets will all be
-  // invalid. If we did, we need to update them all.
-  if (vg_reg_value || svg_reg_value) {
-m_reg_info_sp->ConfigureOffsets();
-// From here we are able to read registers again.
-
-// Make a heap based buffer that is big enough to store all registers
-m_reg_data.SetData(std::make_shared(
-m_reg_info_sp->GetRegisterDataByteSize(), 0));
-m_reg_data.SetByteOrder(GetByteOrder());
-  }
-}
-
-void GDBRemoteDynamicRegisterInfo::UpdateARM64SVERegistersInfos(uint64_t vg) {
-  // SVE Z register size is vg x 8 bytes.
-  uint32_t z_reg_byte_size = vg * 8;
-
-  // SVE vector length has changed, accordingly set size of Z, P and FFR
-  // registers. Also invalidate register offsets it will be recalculated
-  // after SVE register size update.
-  for (auto ® : m_regs) {
-if (reg.value_regs == nullptr) {
-  if (reg.name[0] == 'z' && isdigit(reg.name[1]))
-reg.byte_size = z_reg_byte_size;
-  else if (reg.name[0] == 'p' && isdigit(reg.name[1]))
-reg.byte_size = vg;
-  else if (strcmp(reg.name, "ffr") == 0)
-reg.byte_size = vg;
-}
-reg.byte_offset = LLDB_INVALID_INDEX32;
-  }
+bool GDBRemoteRegisterContext::RegisterWriteCausesReconfigure(
+const char *name) {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();
+  const Architecture *architecture =
+  process->GetTarget().GetArchitecturePlugin();
+  return architecture && architecture->RegisterWriteCausesReconfigure(name);

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits


@@ -373,14 +374,8 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const 
RegisterInfo *reg_info,
   if (dst == nullptr)
 return false;
 
-  // Code below is specific to AArch64 target in SVE or SME state
-  // If vector granule (vg) register is being written then thread's
-  // register context reconfiguration is triggered on success.
-  // We do not allow writes to SVG so it is not mentioned here.
-  const ArchSpec &arch = process->GetTarget().GetArchitecture();
-  bool do_reconfigure_arm64_sve = arch.IsValid() &&
-  arch.GetTriple().isAArch64() &&
-  (strcmp(reg_info->name, "vg") == 0);
+  bool should_reconfigure_registers =

DavidSpickett wrote:

It is a bit far from use isn't it. (const by default when :crab: )

Done.

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


[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

This got rebased to include https://github.com/llvm/llvm-project/pull/70914 so 
there is just 1 commit now.

Comments probably got shuffled so feel free to repeat anything I missed.

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


[Lldb-commits] [libc] [clang] [lld] [clang-tools-extra] [flang] [libcxx] [llvm] [lldb] [compiler-rt] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-11-02 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/70349

>From 7329f68092d5f8f5a5978e5a6cbad6ada87d4fe8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 26 Oct 2023 16:09:25 +0300
Subject: [PATCH 1/6] [clang][NFC] Annotate `Type` bit-fields with
 `clang::preferred_type`

---
 clang/include/clang/AST/DeclBase.h|  2 +-
 clang/include/clang/AST/DependenceFlags.h |  2 +-
 clang/include/clang/AST/Type.h| 46 ++-
 clang/include/clang/Basic/Linkage.h   |  2 +-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 978e4255e877ec2..0307691fdd480bf 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -49,7 +49,7 @@ class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionType;
 class IdentifierInfo;
-enum Linkage : unsigned char;
+enum Linkage : unsigned;
 class LinkageSpecDecl;
 class Module;
 class NamedDecl;
diff --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 3b3c1afb096addd..e91b6ff35b34966 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {
 /// Whether this type contains an unexpanded parameter pack
 /// (for C++11 variadic templates)
 UnexpandedPack = 1,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1e8e1303e65f6ba..f24b1dccc240785 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,22 +1611,28 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 template  friend class TypePropertyCache;
 
 /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
+[[clang::preferred_type(TypeClass)]]
 unsigned TC : 8;
 
 /// Store information on the type dependency.
+[[clang::preferred_type(TypeDependence)]]
 unsigned Dependence : llvm::BitWidth;
 
 /// True if the cache (i.e. the bitfields here starting with
 /// 'Cache') is valid.
+[[clang::preferred_type(bool)]]
 mutable unsigned CacheValid : 1;
 
 /// Linkage of this type.
+[[clang::preferred_type(Linkage)]]
 mutable unsigned CachedLinkage : 3;
 
 /// Whether this type involves and local or unnamed types.
+[[clang::preferred_type(bool)]]
 mutable unsigned CachedLocalOrUnnamed : 1;
 
 /// Whether this type comes from an AST file.
+[[clang::preferred_type(bool)]]
 mutable unsigned FromAST : 1;
 
 bool isCacheValid() const {
@@ -1652,10 +1658,12 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
 friend class ArrayType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// CVR qualifiers from declarations like
 /// 'int X[static restrict 4]'. For function parameters only.
+[[clang::preferred_type(Qualifiers)]]
 unsigned IndexTypeQuals : 3;
 
 /// Storage class qualifiers from declarations like
@@ -1671,12 +1679,14 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 unsigned : NumArrayTypeBits;
 
 /// Whether we have a stored size expression.
+[[clang::preferred_type(bool)]]
 unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
 friend class BuiltinType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
@@ -1691,15 +1701,18 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 friend class FunctionProtoType;
 friend class FunctionType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
+[[clang::preferred_type(CallingConv)]]
 unsigned ExtInfo : 13;
 
 /// The ref-qualifier associated with a \c FunctionProtoType.
 ///
 /// This is a value of type \c RefQualifierKind.
+[[clang::preferred_type(RefQualifierKind)]]
 unsigned RefQualifier : 2;
 
 /// Used only by FunctionProtoType, put here to pack with the
@@ -1708,8 +1721,10 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
+[[clang::preferred_type(Qualifiers)]]
 unsigned FastTypeQuals : Qualifiers::FastWidth;
 /// Whether this function has extended Qualifiers.
+[[clang::preferred_type(bool)]]
 unsigned HasExtQuals : 1;
 
 /// The number of parameters 

[Lldb-commits] [libc] [clang] [lld] [clang-tools-extra] [flang] [libcxx] [llvm] [lldb] [compiler-rt] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-11-02 Thread Vlad Serebrennikov via lldb-commits


@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {

Endilll wrote:

I reverted changes to underlying types. This should be good to go now.

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


[Lldb-commits] [lldb] [DRAFT][lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

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

>From a3d165aa30e8cd32877f30812b41fee380e24e60 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 1 Nov 2023 12:25:06 +
Subject: [PATCH] [lldb][DWARFASTParserClang] Fetch constant value from
 variable definition if available

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 63 ++-
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  3 +
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 10 +--
 .../TestConstStaticIntegralMember.py  | 21 +++
 .../cpp/const_static_integral_member/main.cpp | 21 +++
 5 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 182cc6764651747..8d1b08c492daa35 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -10,6 +10,7 @@
 
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
@@ -26,11 +27,13 @@
 #include "lldb/Core/Value.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
@@ -133,6 +136,52 @@ static lldb::ModuleSP GetContainingClangModule(const 
DWARFDIE &die) {
   return lldb::ModuleSP();
 }
 
+std::optional
+DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return {};
+
+  ConstString name{die.GetName()};
+  if (!name)
+return {};
+
+  auto *CU = die.GetCU();
+  if (!CU)
+return {};
+
+  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+  // Make sure we populate the GetDieToVariable cache.
+  VariableList variables;
+  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+
+  // The cache contains the variable definition whose DW_AT_specification
+  // points to our declaration DIE. Look up that definition using our
+  // declaration.
+  auto const &die_to_var = dwarf->GetDIEToVariable();
+  auto it = die_to_var.find(die.GetDIE());
+  if (it == die_to_var.end())
+return {};
+
+  auto var_sp = it->getSecond();
+  assert(var_sp != nullptr);
+
+  if (!var_sp->GetLocationIsConstantValueData())
+return {};
+
+  auto def = dwarf->GetDIE(var_sp->GetID());
+  auto def_attrs = def.GetAttributes();
+  DWARFFormValue form_value;
+  if (!def_attrs.ExtractFormValueAtIndex(
+  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+  form_value))
+return {};
+
+  return form_value;
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,
  Log *log) {
@@ -2906,9 +2955,21 @@ void DWARFASTParserClang::ParseSingleMember(
 
   bool unused;
   // TODO: Support float/double static members as well.
-  if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
+  if (!ct.IsIntegerOrEnumerationType(unused))
 return;
 
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of a inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!attrs.const_value_form) {
+auto maybe_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_form_value)
+  return;
+
+attrs.const_value_form = *maybe_form_value;
+  }
+
   llvm::Expected const_value_or_err =
   ExtractIntFromFormValue(ct, *attrs.const_value_form);
   if (!const_value_or_err) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index c381c58fba74263..399a6b9176620fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -373,6 +373,9 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
+
+  std::optional
+  FindConstantOnVariableDefinition(lldb_private::plugin::dwarf::DWARFDIE die);
 };
 
 //

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

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

>From a3d165aa30e8cd32877f30812b41fee380e24e60 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 1 Nov 2023 12:25:06 +
Subject: [PATCH 1/2] [lldb][DWARFASTParserClang] Fetch constant value from
 variable definition if available

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 63 ++-
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  3 +
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 10 +--
 .../TestConstStaticIntegralMember.py  | 21 +++
 .../cpp/const_static_integral_member/main.cpp | 21 +++
 5 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 182cc6764651747..8d1b08c492daa35 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -10,6 +10,7 @@
 
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
@@ -26,11 +27,13 @@
 #include "lldb/Core/Value.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
@@ -133,6 +136,52 @@ static lldb::ModuleSP GetContainingClangModule(const 
DWARFDIE &die) {
   return lldb::ModuleSP();
 }
 
+std::optional
+DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return {};
+
+  ConstString name{die.GetName()};
+  if (!name)
+return {};
+
+  auto *CU = die.GetCU();
+  if (!CU)
+return {};
+
+  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+  // Make sure we populate the GetDieToVariable cache.
+  VariableList variables;
+  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+
+  // The cache contains the variable definition whose DW_AT_specification
+  // points to our declaration DIE. Look up that definition using our
+  // declaration.
+  auto const &die_to_var = dwarf->GetDIEToVariable();
+  auto it = die_to_var.find(die.GetDIE());
+  if (it == die_to_var.end())
+return {};
+
+  auto var_sp = it->getSecond();
+  assert(var_sp != nullptr);
+
+  if (!var_sp->GetLocationIsConstantValueData())
+return {};
+
+  auto def = dwarf->GetDIE(var_sp->GetID());
+  auto def_attrs = def.GetAttributes();
+  DWARFFormValue form_value;
+  if (!def_attrs.ExtractFormValueAtIndex(
+  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+  form_value))
+return {};
+
+  return form_value;
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,
  Log *log) {
@@ -2906,9 +2955,21 @@ void DWARFASTParserClang::ParseSingleMember(
 
   bool unused;
   // TODO: Support float/double static members as well.
-  if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
+  if (!ct.IsIntegerOrEnumerationType(unused))
 return;
 
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of a inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!attrs.const_value_form) {
+auto maybe_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_form_value)
+  return;
+
+attrs.const_value_form = *maybe_form_value;
+  }
+
   llvm::Expected const_value_or_err =
   ExtractIntFromFormValue(ct, *attrs.const_value_form);
   if (!const_value_or_err) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index c381c58fba74263..399a6b9176620fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -373,6 +373,9 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
+
+  std::optional
+  FindConstantOnVariableDefinition(lldb_private::plugin::dwarf::DWARFDIE die);
 };
 

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

Michael137 wrote:

@clayborg what are your thoughts on this? This could be a way to continue 
supporting static inline members in the expression evaluator without having the 
constant on the declaration DIE.

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

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

>From a3d165aa30e8cd32877f30812b41fee380e24e60 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 1 Nov 2023 12:25:06 +
Subject: [PATCH 1/3] [lldb][DWARFASTParserClang] Fetch constant value from
 variable definition if available

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 63 ++-
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  3 +
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 10 +--
 .../TestConstStaticIntegralMember.py  | 21 +++
 .../cpp/const_static_integral_member/main.cpp | 21 +++
 5 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 182cc6764651747..8d1b08c492daa35 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -10,6 +10,7 @@
 
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
@@ -26,11 +27,13 @@
 #include "lldb/Core/Value.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
@@ -133,6 +136,52 @@ static lldb::ModuleSP GetContainingClangModule(const 
DWARFDIE &die) {
   return lldb::ModuleSP();
 }
 
+std::optional
+DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return {};
+
+  ConstString name{die.GetName()};
+  if (!name)
+return {};
+
+  auto *CU = die.GetCU();
+  if (!CU)
+return {};
+
+  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+  // Make sure we populate the GetDieToVariable cache.
+  VariableList variables;
+  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+
+  // The cache contains the variable definition whose DW_AT_specification
+  // points to our declaration DIE. Look up that definition using our
+  // declaration.
+  auto const &die_to_var = dwarf->GetDIEToVariable();
+  auto it = die_to_var.find(die.GetDIE());
+  if (it == die_to_var.end())
+return {};
+
+  auto var_sp = it->getSecond();
+  assert(var_sp != nullptr);
+
+  if (!var_sp->GetLocationIsConstantValueData())
+return {};
+
+  auto def = dwarf->GetDIE(var_sp->GetID());
+  auto def_attrs = def.GetAttributes();
+  DWARFFormValue form_value;
+  if (!def_attrs.ExtractFormValueAtIndex(
+  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+  form_value))
+return {};
+
+  return form_value;
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,
  Log *log) {
@@ -2906,9 +2955,21 @@ void DWARFASTParserClang::ParseSingleMember(
 
   bool unused;
   // TODO: Support float/double static members as well.
-  if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
+  if (!ct.IsIntegerOrEnumerationType(unused))
 return;
 
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of a inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!attrs.const_value_form) {
+auto maybe_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_form_value)
+  return;
+
+attrs.const_value_form = *maybe_form_value;
+  }
+
   llvm::Expected const_value_or_err =
   ExtractIntFromFormValue(ct, *attrs.const_value_form);
   if (!const_value_or_err) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index c381c58fba74263..399a6b9176620fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -373,6 +373,9 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
+
+  std::optional
+  FindConstantOnVariableDefinition(lldb_private::plugin::dwarf::DWARFDIE die);
 };
 

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

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

>From a3d165aa30e8cd32877f30812b41fee380e24e60 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 1 Nov 2023 12:25:06 +
Subject: [PATCH 1/4] [lldb][DWARFASTParserClang] Fetch constant value from
 variable definition if available

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 63 ++-
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  3 +
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 10 +--
 .../TestConstStaticIntegralMember.py  | 21 +++
 .../cpp/const_static_integral_member/main.cpp | 21 +++
 5 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 182cc6764651747..8d1b08c492daa35 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -10,6 +10,7 @@
 
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
@@ -26,11 +27,13 @@
 #include "lldb/Core/Value.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
@@ -133,6 +136,52 @@ static lldb::ModuleSP GetContainingClangModule(const 
DWARFDIE &die) {
   return lldb::ModuleSP();
 }
 
+std::optional
+DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return {};
+
+  ConstString name{die.GetName()};
+  if (!name)
+return {};
+
+  auto *CU = die.GetCU();
+  if (!CU)
+return {};
+
+  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+  // Make sure we populate the GetDieToVariable cache.
+  VariableList variables;
+  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+
+  // The cache contains the variable definition whose DW_AT_specification
+  // points to our declaration DIE. Look up that definition using our
+  // declaration.
+  auto const &die_to_var = dwarf->GetDIEToVariable();
+  auto it = die_to_var.find(die.GetDIE());
+  if (it == die_to_var.end())
+return {};
+
+  auto var_sp = it->getSecond();
+  assert(var_sp != nullptr);
+
+  if (!var_sp->GetLocationIsConstantValueData())
+return {};
+
+  auto def = dwarf->GetDIE(var_sp->GetID());
+  auto def_attrs = def.GetAttributes();
+  DWARFFormValue form_value;
+  if (!def_attrs.ExtractFormValueAtIndex(
+  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+  form_value))
+return {};
+
+  return form_value;
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,
  Log *log) {
@@ -2906,9 +2955,21 @@ void DWARFASTParserClang::ParseSingleMember(
 
   bool unused;
   // TODO: Support float/double static members as well.
-  if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
+  if (!ct.IsIntegerOrEnumerationType(unused))
 return;
 
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of a inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!attrs.const_value_form) {
+auto maybe_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_form_value)
+  return;
+
+attrs.const_value_form = *maybe_form_value;
+  }
+
   llvm::Expected const_value_or_err =
   ExtractIntFromFormValue(ct, *attrs.const_value_form);
   if (!const_value_or_err) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index c381c58fba74263..399a6b9176620fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -373,6 +373,9 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
+
+  std::optional
+  FindConstantOnVariableDefinition(lldb_private::plugin::dwarf::DWARFDIE die);
 };
 

[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

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

>From a3d165aa30e8cd32877f30812b41fee380e24e60 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 1 Nov 2023 12:25:06 +
Subject: [PATCH 1/5] [lldb][DWARFASTParserClang] Fetch constant value from
 variable definition if available

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 63 ++-
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  3 +
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 10 +--
 .../TestConstStaticIntegralMember.py  | 21 +++
 .../cpp/const_static_integral_member/main.cpp | 21 +++
 5 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 182cc6764651747..8d1b08c492daa35 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -10,6 +10,7 @@
 
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
@@ -26,11 +27,13 @@
 #include "lldb/Core/Value.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
@@ -133,6 +136,52 @@ static lldb::ModuleSP GetContainingClangModule(const 
DWARFDIE &die) {
   return lldb::ModuleSP();
 }
 
+std::optional
+DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return {};
+
+  ConstString name{die.GetName()};
+  if (!name)
+return {};
+
+  auto *CU = die.GetCU();
+  if (!CU)
+return {};
+
+  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+  // Make sure we populate the GetDieToVariable cache.
+  VariableList variables;
+  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+
+  // The cache contains the variable definition whose DW_AT_specification
+  // points to our declaration DIE. Look up that definition using our
+  // declaration.
+  auto const &die_to_var = dwarf->GetDIEToVariable();
+  auto it = die_to_var.find(die.GetDIE());
+  if (it == die_to_var.end())
+return {};
+
+  auto var_sp = it->getSecond();
+  assert(var_sp != nullptr);
+
+  if (!var_sp->GetLocationIsConstantValueData())
+return {};
+
+  auto def = dwarf->GetDIE(var_sp->GetID());
+  auto def_attrs = def.GetAttributes();
+  DWARFFormValue form_value;
+  if (!def_attrs.ExtractFormValueAtIndex(
+  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+  form_value))
+return {};
+
+  return form_value;
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,
  Log *log) {
@@ -2906,9 +2955,21 @@ void DWARFASTParserClang::ParseSingleMember(
 
   bool unused;
   // TODO: Support float/double static members as well.
-  if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
+  if (!ct.IsIntegerOrEnumerationType(unused))
 return;
 
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of a inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!attrs.const_value_form) {
+auto maybe_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_form_value)
+  return;
+
+attrs.const_value_form = *maybe_form_value;
+  }
+
   llvm::Expected const_value_or_err =
   ExtractIntFromFormValue(ct, *attrs.const_value_form);
   if (!const_value_or_err) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index c381c58fba74263..399a6b9176620fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -373,6 +373,9 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
+
+  std::optional
+  FindConstantOnVariableDefinition(lldb_private::plugin::dwarf::DWARFDIE die);
 };
 

[Lldb-commits] [llvm] [mlir] [libcxx] [clang] [lldb] [flang] [Flang][OpenMP] Port openmp threadprivate-use-association.f90 test to HLFIR flow (PR #71043)

2023-11-02 Thread Kiran Chandramohan via lldb-commits

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

LG. Thanks.

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 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 7d77bbef4ad9230f6f427649373fe46a668aa909 
5a37a703cd7c44bf9ecdfdfb77491ce9a18a4a72 -- 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index e1486ced5bee..7fdc414f3313 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -139,7 +139,7 @@ static lldb::ModuleSP GetContainingClangModule(const 
DWARFDIE &die) {
 
 std::optional
 DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
-  assert (die.Tag() == llvm::dwarf::DW_TAG_member);
+  assert(die.Tag() == llvm::dwarf::DW_TAG_member);
 
   auto *dwarf = die.GetDWARF();
   if (!dwarf)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 01b60bc8ac39..893a0315c852 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -375,12 +375,13 @@ private:
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
 
   /// Tries to find the definition DW_TAG_variable DIE of the the specified
-  /// DW_TAG_member 'die'. If such definition exists, returns the 
DW_AT_const_value
-  /// of that definition if available. Returns std::nullopt otherwise.
+  /// DW_TAG_member 'die'. If such definition exists, returns the
+  /// DW_AT_const_value of that definition if available. Returns std::nullopt
+  /// otherwise.
   ///
   /// In newer versions of clang, DW_AT_const_value's are not attached to the
-  /// declaration of a inline static data-member anymore, but rather on its 
definition.
-  /// This function is used to locate said constant.
+  /// declaration of a inline static data-member anymore, but rather on its
+  /// definition. This function is used to locate said constant.
   std::optional
   FindConstantOnVariableDefinition(lldb_private::plugin::dwarf::DWARFDIE die);
 };

``




https://github.com/llvm/llvm-project/pull/71004
___
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] [lld] [libc] [clang] [libcxx] [lldb] [compiler-rt] [flang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-11-02 Thread Aaron Ballman via lldb-commits

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

LGTM aside from a nit with the new macro (feel free to fix when landing).

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


[Lldb-commits] [lld] [compiler-rt] [flang] [libcxx] [llvm] [libc] [clang] [clang-tools-extra] [lldb] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-11-02 Thread Aaron Ballman via lldb-commits


@@ -569,4 +569,12 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
 #define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION
 #endif
 
+/// \macro LLVM_PREFERRED_TYPE
+/// Adjust type of bit-field in debug info.
+#if __has_attribute(preferred_type)

AaronBallman wrote:

```suggestion
#if LLVM_HAS_CPP_ATTRIBUTE(clang::preferred_type)
```
or leave the condition as-is and change the expansion to using 
`__attribute__(())` instead. Just making sure they both match up. (If we're 
using this from C interfaces, then we probably want to use the GNU-style 
spelling.)

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


[Lldb-commits] [libcxx] [flang] [compiler-rt] [clang] [lld] [lldb] [llvm] [libc] [clang-tools-extra] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-11-02 Thread Aaron Ballman via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Michael Buch via lldb-commits

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

>From a3d165aa30e8cd32877f30812b41fee380e24e60 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Wed, 1 Nov 2023 12:25:06 +
Subject: [PATCH 1/6] [lldb][DWARFASTParserClang] Fetch constant value from
 variable definition if available

---
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 63 ++-
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  3 +
 .../SymbolFile/DWARF/SymbolFileDWARF.h| 10 +--
 .../TestConstStaticIntegralMember.py  | 21 +++
 .../cpp/const_static_integral_member/main.cpp | 21 +++
 5 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 182cc6764651747..8d1b08c492daa35 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -10,6 +10,7 @@
 
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
+#include "DWARFCompileUnit.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
@@ -26,11 +27,13 @@
 #include "lldb/Core/Value.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/SymbolFile.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeMap.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/Language.h"
 #include "lldb/Utility/LLDBAssert.h"
 #include "lldb/Utility/Log.h"
@@ -133,6 +136,52 @@ static lldb::ModuleSP GetContainingClangModule(const 
DWARFDIE &die) {
   return lldb::ModuleSP();
 }
 
+std::optional
+DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) {
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return {};
+
+  ConstString name{die.GetName()};
+  if (!name)
+return {};
+
+  auto *CU = die.GetCU();
+  if (!CU)
+return {};
+
+  DWARFASTParser *dwarf_ast = dwarf->GetDWARFParser(*CU);
+  auto parent_decl_ctx = dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+
+  // Make sure we populate the GetDieToVariable cache.
+  VariableList variables;
+  dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
+
+  // The cache contains the variable definition whose DW_AT_specification
+  // points to our declaration DIE. Look up that definition using our
+  // declaration.
+  auto const &die_to_var = dwarf->GetDIEToVariable();
+  auto it = die_to_var.find(die.GetDIE());
+  if (it == die_to_var.end())
+return {};
+
+  auto var_sp = it->getSecond();
+  assert(var_sp != nullptr);
+
+  if (!var_sp->GetLocationIsConstantValueData())
+return {};
+
+  auto def = dwarf->GetDIE(var_sp->GetID());
+  auto def_attrs = def.GetAttributes();
+  DWARFFormValue form_value;
+  if (!def_attrs.ExtractFormValueAtIndex(
+  def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
+  form_value))
+return {};
+
+  return form_value;
+}
+
 TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
  const DWARFDIE &die,
  Log *log) {
@@ -2906,9 +2955,21 @@ void DWARFASTParserClang::ParseSingleMember(
 
   bool unused;
   // TODO: Support float/double static members as well.
-  if (!attrs.const_value_form || !ct.IsIntegerOrEnumerationType(unused))
+  if (!ct.IsIntegerOrEnumerationType(unused))
 return;
 
+  // Newer versions of Clang don't emit the DW_AT_const_value
+  // on the declaration of a inline static data member. Instead
+  // it's attached to the definition DIE. If that's the case,
+  // try and fetch it.
+  if (!attrs.const_value_form) {
+auto maybe_form_value = FindConstantOnVariableDefinition(die);
+if (!maybe_form_value)
+  return;
+
+attrs.const_value_form = *maybe_form_value;
+  }
+
   llvm::Expected const_value_or_err =
   ExtractIntFromFormValue(ct, *attrs.const_value_form);
   if (!const_value_or_err) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index c381c58fba74263..399a6b9176620fd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -373,6 +373,9 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
+
+  std::optional
+  FindConstantOnVariableDefinition(lldb_private::plugin::dwarf::DWARFDIE die);
 };
 

[Lldb-commits] [llvm] [clang-tools-extra] [lldb] [libc] [clang] [libcxx] [lld] [flang] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-02 Thread Erich Keane via lldb-commits


@@ -0,0 +1,14 @@
+// RUN: %clang -S -### -fopenacc %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DRIVER
+// CHECK-DRIVER: "-cc1" {{.*}} "-fopenacc"

erichkeane wrote:

At the moment, there should be no problem with them co-existing.  Kernels can 
be separately generated with each, and I believe other implementations permit 
both to be enabled at the same time.  That said, if we come across a reason to 
disable them both at the same time, we will.

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


[Lldb-commits] [llvm] [libcxx] [libc] [flang] [clang] [lldb] [clang-tools-extra] [lld] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-02 Thread Erich Keane via lldb-commits


@@ -1342,6 +1342,15 @@ def err_opencl_logical_exclusive_or : Error<
 def err_openclcxx_virtual_function : Error<
   "virtual functions are not supported in C++ for OpenCL">;
 
+// OpenACC Support.
+def warn_pragma_acc_ignored : Warning<
+  "unexpected '#pragma acc ...' in program">, InGroup, 
DefaultIgnore;
+def err_acc_unexpected_directive : Error<
+  "unexpected OpenACC directive %select{|'#pragma acc %1'}0">;
+def warn_pragma_acc_unimplemented
+: Warning<"OpenACC Directives not yet implemented, pragma ignored">,

erichkeane wrote:

Nope!  Thanks!

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


[Lldb-commits] [llvm] [compiler-rt] [libcxx] [libc] [flang] [clang] [lldb] [clang-tools-extra] [lld] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-11-02 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/70349

>From 7329f68092d5f8f5a5978e5a6cbad6ada87d4fe8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Thu, 26 Oct 2023 16:09:25 +0300
Subject: [PATCH 1/7] [clang][NFC] Annotate `Type` bit-fields with
 `clang::preferred_type`

---
 clang/include/clang/AST/DeclBase.h|  2 +-
 clang/include/clang/AST/DependenceFlags.h |  2 +-
 clang/include/clang/AST/Type.h| 46 ++-
 clang/include/clang/Basic/Linkage.h   |  2 +-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 978e4255e877ec2..0307691fdd480bf 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -49,7 +49,7 @@ class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionType;
 class IdentifierInfo;
-enum Linkage : unsigned char;
+enum Linkage : unsigned;
 class LinkageSpecDecl;
 class Module;
 class NamedDecl;
diff --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 3b3c1afb096addd..e91b6ff35b34966 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {
 /// Whether this type contains an unexpanded parameter pack
 /// (for C++11 variadic templates)
 UnexpandedPack = 1,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1e8e1303e65f6ba..f24b1dccc240785 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,22 +1611,28 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 template  friend class TypePropertyCache;
 
 /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
+[[clang::preferred_type(TypeClass)]]
 unsigned TC : 8;
 
 /// Store information on the type dependency.
+[[clang::preferred_type(TypeDependence)]]
 unsigned Dependence : llvm::BitWidth;
 
 /// True if the cache (i.e. the bitfields here starting with
 /// 'Cache') is valid.
+[[clang::preferred_type(bool)]]
 mutable unsigned CacheValid : 1;
 
 /// Linkage of this type.
+[[clang::preferred_type(Linkage)]]
 mutable unsigned CachedLinkage : 3;
 
 /// Whether this type involves and local or unnamed types.
+[[clang::preferred_type(bool)]]
 mutable unsigned CachedLocalOrUnnamed : 1;
 
 /// Whether this type comes from an AST file.
+[[clang::preferred_type(bool)]]
 mutable unsigned FromAST : 1;
 
 bool isCacheValid() const {
@@ -1652,10 +1658,12 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
 friend class ArrayType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// CVR qualifiers from declarations like
 /// 'int X[static restrict 4]'. For function parameters only.
+[[clang::preferred_type(Qualifiers)]]
 unsigned IndexTypeQuals : 3;
 
 /// Storage class qualifiers from declarations like
@@ -1671,12 +1679,14 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 unsigned : NumArrayTypeBits;
 
 /// Whether we have a stored size expression.
+[[clang::preferred_type(bool)]]
 unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
 friend class BuiltinType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
@@ -1691,15 +1701,18 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 friend class FunctionProtoType;
 friend class FunctionType;
 
+[[clang::preferred_type(TypeBitfields)]]
 unsigned : NumTypeBits;
 
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
+[[clang::preferred_type(CallingConv)]]
 unsigned ExtInfo : 13;
 
 /// The ref-qualifier associated with a \c FunctionProtoType.
 ///
 /// This is a value of type \c RefQualifierKind.
+[[clang::preferred_type(RefQualifierKind)]]
 unsigned RefQualifier : 2;
 
 /// Used only by FunctionProtoType, put here to pack with the
@@ -1708,8 +1721,10 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 ///
 /// C++ 8.3.5p4: The return type, the parameter type list and the
 /// cv-qualifier-seq, [...], are part of the function type.
+[[clang::preferred_type(Qualifiers)]]
 unsigned FastTypeQuals : Qualifiers::FastWidth;
 /// Whether this function has extended Qualifiers.
+[[clang::preferred_type(bool)]]
 unsigned HasExtQuals : 1;
 
 /// The number of parameters 

[Lldb-commits] [lld] [clang] [clang-tools-extra] [flang] [libcxx] [llvm] [libc] [lldb] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-02 Thread Erich Keane via lldb-commits


@@ -605,6 +605,17 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo &TI,
   Builder.defineMacro("HIP_API_PER_THREAD_DEFAULT_STREAM");
 }
   }
+
+  if (LangOpts.OpenACC) {
+// FIXME: When we have full support for OpenACC, we should set this to the
+// version we support. Until then, set as '1' by default, but provide a
+// temporary mechanism for users to override this so real-world examples 
can
+// be tested against.
+if (!LangOpts.OpenACCMacroOverride.empty())
+  Builder.defineMacro("_OPENACC", LangOpts.OpenACCMacroOverride);
+else
+  Builder.defineMacro("_OPENACC", "1");

erichkeane wrote:

Done! Added to the preprocessor test.

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


[Lldb-commits] [llvm] [lld] [libc] [libcxx] [flang] [clang-tools-extra] [clang] [lldb] [OpenACC] Initial commits to support OpenACC (PR #70234)

2023-11-02 Thread Erich Keane via lldb-commits

https://github.com/erichkeane updated 
https://github.com/llvm/llvm-project/pull/70234

>From b3d64b3f744ccb37e334e3aae8d6874cd8391c56 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Mon, 23 Oct 2023 11:09:11 -0700
Subject: [PATCH 1/6] [OpenACC] Initial commit for OpenACC Support

This is the initial commit to support OpenACC in Clang, which adds a
clang-command line argument '-fopenacc', and starts to define _OPENACC,
albeit to '1' instead of the standardized value (since we don't
properly implement OpenACC yet).
---
 clang/docs/ReleaseNotes.rst   | 12 
 clang/include/clang/Basic/LangOptions.def |  2 ++
 clang/include/clang/Driver/Options.td | 10 --
 clang/lib/Driver/ToolChains/Clang.cpp | 11 +++
 clang/lib/Frontend/CompilerInvocation.cpp |  7 +++
 clang/lib/Frontend/InitPreprocessor.cpp   |  6 ++
 clang/test/Driver/openacc.c   |  2 ++
 clang/test/Preprocessor/openacc.c |  4 
 8 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Driver/openacc.c
 create mode 100644 clang/test/Preprocessor/openacc.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f94e4e10b805911..8f40872b539322a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -211,6 +211,11 @@ New Compiler Flags
   the preprocessed text to the output. This can greatly reduce the size of the
   preprocessed output, which can be helpful when trying to reduce a test case.
 
+* ``-Wbitfield-conversion`` was added to detect assignments of integral
+  types to a bitfield that may change the value.
+
+* ``-fopenacc`` was added as a part of the effort to support OpenACC in clang.
+
 Deprecated Compiler Flags
 -
 
@@ -665,6 +670,13 @@ Miscellaneous Clang Crashes Fixed
 - Fixed a crash when an ObjC ivar has an invalid type. See
   (`#68001 `_)
 
+OpenACC Specific Changes
+
+- OpenACC Implementation effort is beginning with semantic analysis and parsing
+  of OpenACC pragmas. The ``-fopenacc`` flag was added to enable these new,
+  albeit incomplete changes. The ``_OPENACC`` macro is currently defined to
+  ``1``, as support is too incomplete to update to a standards-required value.
+
 Target Specific Changes
 ---
 
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index c0ea4ecb9806a5b..872d693cc3ebbff 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -283,6 +283,8 @@ LANGOPT(OffloadUniformBlock, 1, 0, "Assume that kernels are 
launched with unifor
 LANGOPT(HIPStdPar, 1, 0, "Enable Standard Parallel Algorithm Acceleration for 
HIP (experimental)")
 LANGOPT(HIPStdParInterposeAlloc, 1, 0, "Replace allocations / deallocations 
with HIP RT calls when Standard Parallel Algorithm Acceleration for HIP is 
enabled (Experimental)")
 
+LANGOPT(OpenACC   , 1, 0, "OpenACC Enabled")
+
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c6b1903a32a0621..ab28c3e394afe93 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3340,6 +3340,14 @@ def fno_openmp_target_debug : Flag<["-"], 
"fno-openmp-target-debug">;
 } // let Visibility = [ClangOption, CC1Option, FC1Option]
 } // let Flags = [NoArgumentUnused]
 
+//===--===//
+// FlangOption + FC1 + ClangOption + CC1Option
+//===--===//
+let Visibility = [FC1Option, FlangOption, CC1Option, ClangOption] in {
+def fopenacc : Flag<["-"], "fopenacc">, Group,
+  HelpText<"Enable OpenACC">;
+} // let Visibility = [FC1Option, FlangOption, CC1Option, ClangOption]
+
 
//===--===//
 // Optimisation remark options
 
//===--===//
@@ -6256,8 +6264,6 @@ file}]>;
 def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group, Alias;
 def fconvert_EQ : Joined<["-"], "fconvert=">, Group,
   HelpText<"Set endian conversion of data for unformatted files">;
-def fopenacc : Flag<["-"], "fopenacc">, Group,
-  HelpText<"Enable OpenACC">;
 def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group,
   HelpText<"Set the default double precision kind to an 8 byte wide type">;
 def fdefault_integer_8 : Flag<["-"],"fdefault-integer-8">, Group,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 601bbfb927746fc..cf65773de0d010d 100644
--- a/clang/l

[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Kevin Frei via lldb-commits


@@ -4892,6 +4894,21 @@ void TargetProperties::SetDebugUtilityExpression(bool 
debug) {
   SetPropertyAtIndex(idx, debug);
 }
 
+Args TargetProperties::GetDebugInfoDURLs() const {
+  Args urls;
+  m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyDebugInfoDURLs, urls);
+  return urls;
+}
+
+void TargetProperties::DebugInfoDURLsChangedCallback() {
+  Args urls = GetDebugInfoDURLs();
+  llvm::SmallVector dbginfod_urls;
+  std::transform(urls.begin(), urls.end(), dbginfod_urls.end(),
+ [](const auto &obj) { return obj.ref(); });
+  llvm::setDefaultDebuginfodUrls(dbginfod_urls);

kevinfrei wrote:

I believe this should be more of a global resource, so moving the setting to 
Debugger makes sense.

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Kevin Frei via lldb-commits


@@ -4892,6 +4894,21 @@ void TargetProperties::SetDebugUtilityExpression(bool 
debug) {
   SetPropertyAtIndex(idx, debug);
 }
 
+Args TargetProperties::GetDebugInfoDURLs() const {
+  Args urls;
+  m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyDebugInfoDURLs, urls);
+  return urls;
+}
+
+void TargetProperties::DebugInfoDURLsChangedCallback() {
+  Args urls = GetDebugInfoDURLs();
+  llvm::SmallVector dbginfod_urls;
+  std::transform(urls.begin(), urls.end(), dbginfod_urls.end(),
+ [](const auto &obj) { return obj.ref(); });
+  llvm::setDefaultDebuginfodUrls(dbginfod_urls);

kevinfrei wrote:

All cards on the table: I don't understand enough about that particular part of 
the architecture to know "where" is the right place for this setting to live. I 
added it to Target because that was where @clayborg originally suggested. In 
practice, you're not generally going to want to have completely different 
settings for different targets, as there shouldn't be different sources of 
truth for symbols.

And now that I read what I just typeed, I can very much imagine a scenario 
where there's one symbol server that only supports line info, and a different 
one that supports full type info :/ So, maybe per-target is a good idea?

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


[Lldb-commits] [flang] [clang] [libcxx] [mlir] [lldb] [llvm] [Flang][OpenMP] Port openmp threadprivate-use-association.f90 test to HLFIR flow (PR #71043)

2023-11-02 Thread chandan singh via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

Apparently I didn't submit the last set of review comments sorry about that.

The one about vector is the key one this time.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -0,0 +1,31 @@
+UNSUPPORTED: system-windows
+
+# RUN: %clang_host -g %S/Inputs/main.c -o %t

DavidSpickett wrote:

If you can, a test where the regular expression matches at the very end of the 
name would be a good addition.

This would check the tail end of your PrintRed loop, where you print any 
remaining text.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Oh and good work on the updates! (because that feedback is probably hard to see 
with all these comments :) )

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -1,6 +1,7 @@
 # RUN: yaml2obj %S/Inputs/symbols.yaml -o %t
 
 # RUN: %lldb %t -b -o "target modules lookup -A -r -s some" | FileCheck %s 
-DMODULE=%basename_t.tmp --implicit-check-not ignoreThisFunction
+

DavidSpickett wrote:

Undo the unrelated changes in this file.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -1506,13 +1514,50 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
 return true;
   }
 
   return false;
 }
 
+//===
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name, 
CommandInterpreter *interpreter= nullptr) {

DavidSpickett wrote:

Consider changing `name` to `re_pattern`, something that tells us that it is in 
fact a regex.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -247,7 +247,17 @@ class Address {
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
 uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+bool all_ranges = false,
+std::vector>* info = nullptr) const;

DavidSpickett wrote:

Another way to put this is:
* When `name` is nullptr, we won't print any colours.
* When `use_colour` is false, we won't print any colours.

So why not use `name == nullptr` to also mean that colour is disabled?

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -1506,13 +1514,50 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
 return true;
   }
 
   return false;
 }
 
+//===
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name, 
CommandInterpreter *interpreter= nullptr) {
+if (!name) {
+strm.PutCString(text);
+return;
+}
+
+bool use_color = interpreter->GetDebugger().GetUseColor();

DavidSpickett wrote:

1. If we only need this one part of the CommandInterpreter, we should only be 
passing that one thing down.
Try to find the earliest place you can to do the GetUseColor call, then 
pass the result down to here.

2. You can combine that approach with one observation, that if `name` is 
nullptr, this will never use colour regardless of the setting. Therefore 
instead of having another parameter you could just set name to nullptr if 
colours are disabled.

As in:
* No regex search - name is nullptr, colour setting is unused
* Regex search - name is not nullptr, colour setting must be read

So if early in the callstack you know that GetUseColor returns false, you could 
just pass name=nullptr. No extra parameters needed. So it becomes something 
like:
```
interpreter->GetDebugger().GetUseColor() ? name : nullptr;
```

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -0,0 +1,31 @@
+UNSUPPORTED: system-windows
+
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s ma' 
| FileCheck %s --check-prefix CHECK1
+
+# CHECK1: 3 symbols match the regular expression 'ma' in {{.*}}
+# CHECK1: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK1: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
main.c|foo' | FileCheck %s --check-prefix CHECK2
+
+# CHECK2: 2 symbols match the regular expression 'main.c|foo' in {{.*}}
+# CHECK2: Name: {{.+}}31mmain.c{{.+}}0m
+# CHECK2: Summary: {{.+}}`{{.+}}31mfoo{{.+}}0m at main.c:1
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
m[abc]' | FileCheck %s --check-prefix CHECK3
+
+# CHECK3: 5 symbols match the regular expression 'm[abc]' in {{.*}}
+# CHECK3: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK3: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+# CHECK3: Summary: {{.+}}`___lldb_unnamed_sy{{.+}}31mmb{{.+}}0mol36

DavidSpickett wrote:

Also these `__lldb_unnamed` tend to come from inlined functions or libc 
functions we don't have debug info for. Don't add checks for them as they'll 
vary by platform.

So I would say here to maybe drop the __lldb lines and not check for the `5 
symbols match` line either. It's not part of what you're testing here.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -0,0 +1,31 @@
+UNSUPPORTED: system-windows
+
+# RUN: %clang_host -g %S/Inputs/main.c -o %t

DavidSpickett wrote:

Also just for sanity checking, add one where you don't match anything at all. 
It shouldn't do any matching or even attempt to, so the test would just ensure 
that it doesn't try and end up crashing.

The classic "nothing in, nothing out" test case. So it will match 0 symbols but 
that's what we expect.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -247,7 +247,17 @@ class Address {
   bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
 DumpStyle fallback_style = DumpStyleInvalid,
 uint32_t addr_byte_size = UINT32_MAX,
-bool all_ranges = false) const;
+bool all_ranges = false,
+std::vector>* info = nullptr) const;

DavidSpickett wrote:

Gonna choose this one as the example. You're on the right lines again but 
implementation is a bit odd. Let's take it bit by bit.

You're using a pointer not a reference, which makes some sense as you can't 
default construct a reference. So just FYI in future, try to use `const &` if 
you are never going to pass a `nullptr` *and* can default construct the type 
(or better, use `optional`).

Next bit, `pair` is a decent choice but I don't see the need for a vector here. 
A single pair would do, so `std::pair* ` would suffice.

If you were to do that, you could default construct the parameter and pass via 
copy. No reference or pointer needed (and pointer/bool are small types cheap to 
pass by copy).

So you may choose to apply those idea maybe not after I tell you the next bit, 
which makes them academic.

If you were to write out a table of values of `name` (aka the pattern) and 
whether we're using colour, what would it look like? This:

| const char* name | use_colour | Do we use name? |
|-|-||
| non-null| false   | No |
| nullptr   | false   | No |
| non-null| true| Yes |
| nullptr   | true| No  |

(This is a https://en.wikipedia.org/wiki/Truth_table if you haven't seen one 
before)

Now look where we use the name. What's the equation for that state?
```
if (name is non-null) and (use_colour is true)
```
Which means that any function currently taking this pair/vector could just take 
`name`. Except that we change the value of name depending on the value of 
`use_colour`.

If `name` is non-null but colour is disabled, make `name` nullptr. The result 
is the same, but functions only need `name` to know what to do.

Example: https://godbolt.org/z/1W3EWTPqa

By doing this you can combine name and use_colour earlier in the callstack, and 
only pass name to the subsequent functions.

If we later added a way to highlight names that did not use colour, then yes, 
you would need a separate bool. But that is not what you're doing here.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -0,0 +1,31 @@
+UNSUPPORTED: system-windows
+
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s ma' 
| FileCheck %s --check-prefix CHECK1
+
+# CHECK1: 3 symbols match the regular expression 'ma' in {{.*}}
+# CHECK1: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK1: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
main.c|foo' | FileCheck %s --check-prefix CHECK2
+
+# CHECK2: 2 symbols match the regular expression 'main.c|foo' in {{.*}}
+# CHECK2: Name: {{.+}}31mmain.c{{.+}}0m
+# CHECK2: Summary: {{.+}}`{{.+}}31mfoo{{.+}}0m at main.c:1
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
m[abc]' | FileCheck %s --check-prefix CHECK3
+
+# CHECK3: 5 symbols match the regular expression 'm[abc]' in {{.*}}
+# CHECK3: Name: {{.+}}31mma{{.+}}0min.c
+# CHECK3: Summary: {{.+}}`{{.+}}31mma{{.+}}0min at main.c:2
+# CHECK3: Summary: {{.+}}`___lldb_unnamed_sy{{.+}}31mmb{{.+}}0mol36
+# CHECK3: Summary: {{.+}}`___lldb_unnamed_sy{{.+}}31mmb{{.+}}0mol37
+
+
+# RUN: %lldb %t -b -o 'settings set use-color true' -o 'image lookup -r -s 
[0-9]' | FileCheck %s --check-prefix CHECK4
+
+# CHECK4: 6 symbols match the regular expression '[0-9]' in {{.*}}
+# CHECK4: Name: Scrt{{.+}}31m1{{.+}}0m.o
+# CHECK4: Summary: {{.+}}`completed.{{.+}}31m0{{.+}}0m
+# CHECK4: Name: 
__libc_start_main@GLIBC_{{.+}}31m2{{.+}}0m_{{.+}}31m3{{.+}}0m{{.+}}31m4{{.+}}0m
+# CHECK4: Name: 
__cxa_finalize@GLIBC_{{.+}}31m2{{.+}}0m_{{.+}}31m2{{.+}}0m_{{.+}}31m5{{.+}}0m

DavidSpickett wrote:

This one will be a bit tricky running on all the OS we support. I suggest you 
keep your tests to symbols we know are defined in the user's program.

As if I go to FreeBSD for example, there will be no glibc in the process' 
address space, it'll be the FreeBSD libc with different names.

So stick to names from main.c.

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


[Lldb-commits] [lldb] [lldb][AArch64] Read SME2's ZT0 register from Linux core files (PR #70934)

2023-11-02 Thread David Spickett via lldb-commits


@@ -339,6 +337,18 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const 
RegisterInfo *reg_info,
   value.SetFromMemoryData(*reg_info, src + sizeof(sve::user_za_header),
   reg_info->byte_size, lldb::eByteOrderLittle,
   error);
+} else if (m_register_info_up->IsSMERegZT(reg)) {
+  value.SetFromMemoryData(*reg_info, m_zt_data.GetDataStart(),
+  reg_info->byte_size, lldb::eByteOrderLittle,
+  error);
+} else {
+  offset = reg_info->byte_offset - m_register_info_up->GetSMEOffset();
+  assert(offset < sizeof(m_sme_pseudo_regs));

DavidSpickett wrote:

The asserts are mostly for people like us because they generally happen if you 
are adding new registers and didn't update something.

But you are right Jason about non-asserts builds.

Since this is existing code I'm going to be cheeky and land this patch, and 
come back with another PR that makes these
assert in debug builds and return false for release builds.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -1506,13 +1514,50 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
 return true;
   }
 
   return false;
 }
 
+//===
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name, 
CommandInterpreter *interpreter= nullptr) {
+if (!name) {
+strm.PutCString(text);
+return;
+}
+
+bool use_color = interpreter->GetDebugger().GetUseColor();
+
+std::string str_text(text);
+std::regex reg_name(name);
+std::sregex_iterator next(str_text.begin(), str_text.end(), reg_name);
+std::sregex_iterator end;
+
+std::string red_start = 
lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}", use_color);
+std::string reset_color = 
lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.normal}", use_color);

DavidSpickett wrote:

Though on second thought, doing it your way saves making a new string later 
when you do `strm.Write(text + match.position(), match.length());`.

So leave it as is for now.

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


[Lldb-commits] [lldb] 0d0ca51 - [lldb][AArch64] Read SME2's ZT0 register from Linux core files (#70934)

2023-11-02 Thread via lldb-commits

Author: David Spickett
Date: 2023-11-02T15:56:46Z
New Revision: 0d0ca51ffe1002cec3b1b7a332e290176b650390

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

LOG: [lldb][AArch64] Read SME2's ZT0 register from Linux core files (#70934)

The ZT0 register is always 64 bytes in size so it is a lot easier to
handle than ZA which is scalable. In addition, reading an inactive ZT0
via ptrace returns all 0s, unlike ZA which returns no register data.

This means that a corefile from a process where ZA and ZT0 were inactive
still contains an NT_ARM_ZT note and we can simply say that if it's
there, then we should be able to read from it.

Along the way I removed a redundant check on the size of the ZA note. If
that note's size is < the ZA header size, we do not have SME, and
therefore could not have SME2 either.

I have added ZT0 to the existing SME core files tests. This means that
you need an SME2 system to generate them (Arm's FVP at this point). I
think this is a fair tradeoff given that this is all running in
simulation anyway and seperate ZT0 tests would be 99% identical copies
of the ZA only tests.

Added: 
lldb/test/API/linux/aarch64/sme_core_file/generate.sh

Modified: 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
lldb/test/API/linux/aarch64/sme_core_file/TestAArch64LinuxSMECoreFile.py
lldb/test/API/linux/aarch64/sme_core_file/core_0_16_32_1
lldb/test/API/linux/aarch64/sme_core_file/core_0_32_16_0
lldb/test/API/linux/aarch64/sme_core_file/core_1_16_32_0
lldb/test/API/linux/aarch64/sme_core_file/core_1_32_16_1
lldb/test/API/linux/aarch64/sme_core_file/main.c

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index db37b7cbb99d7e8..85073b56f64bf79 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -54,6 +54,13 @@ RegisterContextCorePOSIX_arm64::Create(Thread &thread, const 
ArchSpec &arch,
   if (mte_data.GetByteSize() >= sizeof(uint64_t))
 opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskMTE);
 
+  DataExtractor zt_data = getRegset(notes, arch.GetTriple(), AARCH64_ZT_Desc);
+  // Although ZT0 can be in a disabled state like ZA can, the kernel reports
+  // its content as 0s in that state. Therefore even a disabled ZT0 will have
+  // a note containing those 0s. ZT0 is a 512 bit / 64 byte register.
+  if (zt_data.GetByteSize() >= 64)
+opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskZT);
+
   auto register_info_up =
   std::make_unique(arch, opt_regsets);
   return std::unique_ptr(
@@ -98,6 +105,9 @@ 
RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
   if (m_register_info_up->IsMTEPresent())
 m_mte_data = getRegset(notes, target_triple, AARCH64_MTE_Desc);
 
+  if (m_register_info_up->IsZTPresent())
+m_zt_data = getRegset(notes, target_triple, AARCH64_ZT_Desc);
+
   ConfigureRegisterContext();
 }
 
@@ -298,19 +308,7 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const 
RegisterInfo *reg_info,
 if (m_za_data.GetByteSize() < sizeof(sve::user_za_header))
   return false;
 
-if (!IsSMEZA(reg)) {
-  offset = reg_info->byte_offset - m_register_info_up->GetSMEOffset();
-  assert(offset < sizeof(m_sme_pseudo_regs));
-  // Host endian since these values are derived instead of being read from 
a
-  // core file note.
-  value.SetFromMemoryData(
-  *reg_info, reinterpret_cast(&m_sme_pseudo_regs) + offset,
-  reg_info->byte_size, lldb_private::endian::InlHostByteOrder(), 
error);
-} else {
-  // If the process did not have the SME extension.
-  if (m_za_data.GetByteSize() < sizeof(sve::user_za_header))
-return false;
-
+if (m_register_info_up->IsSMERegZA(reg)) {
   // Don't use the size of the note to tell whether ZA is enabled. There 
may
   // be non-register padding data after the header. Use the embedded
   // header's size field instead.
@@ -339,6 +337,18 @@ bool RegisterContextCorePOSIX_arm64::ReadRegister(const 
RegisterInfo *reg_info,
   value.SetFromMemoryData(*reg_info, src + sizeof(sve::user_za_header),
   reg_info->byte_size, lldb::eByteOrderLittle,
   error);
+} else if (m_register_info_up->IsSMERegZT(reg)) {
+  value.SetFromMemoryData(*reg_info, m_zt_data.GetDataStart(),
+  reg_info->byte_size, lldb::eByteOrderLittle,
+  error);
+} else {
+  offset = reg_info->byte_of

[Lldb-commits] [lldb] [lldb][AArch64] Read SME2's ZT0 register from Linux core files (PR #70934)

2023-11-02 Thread David Spickett via lldb-commits

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


[Lldb-commits] [clang-tools-extra] [llvm] [clang] [lldb] [flang] [IndVars] Add check of loop invariant for trunc instructions (PR #71072)

2023-11-02 Thread Markos Horro via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -1506,13 +1514,50 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
 return true;
   }
 
   return false;
 }
 
+//===
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name, 
CommandInterpreter *interpreter= nullptr) {
+if (!name) {
+strm.PutCString(text);
+return;
+}
+
+bool use_color = interpreter->GetDebugger().GetUseColor();
+
+std::string str_text(text);

DavidSpickett wrote:

You can avoid some string copies by:
1. Passing the StringRef to this function, instead of converting it to 
std::string and then getting a char* from that.
2. Then using StringRef's `.begin` and `.end` in the `next` iterator. If it 
doesn't like the type you can build the begin/end from `.bytes_begin` and 
`.bytes_end` instead. Those give you char* instead.

Basically StringRef is a "view" onto a string, so as long as we know where it 
ends we can iterate over that instead of a new copy of it.

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


[Lldb-commits] [lldb] [lldb][AArch64] Read SME2's ZT0 register from Linux core files (PR #70934)

2023-11-02 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Adrian Prantl via lldb-commits


@@ -373,6 +373,17 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
lldb_private::CompilerType &class_clang_type,
const lldb::AccessType default_accesibility,
lldb_private::ClangASTImporter::LayoutInfo 
&layout_info);
+
+  /// Tries to find the definition DW_TAG_variable DIE of the the specified
+  /// DW_TAG_member 'die'. If such definition exists, returns the
+  /// DW_AT_const_value of that definition if available. Returns std::nullopt
+  /// otherwise.
+  ///
+  /// In newer versions of clang, DW_AT_const_value's are not attached to the

adrian-prantl wrote:

DW_AT_const_value attributes

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


[Lldb-commits] [clang-tools-extra] [llvm] [clang] [lldb] [flang] [IndVars] Add check of loop invariant for trunc instructions (PR #71072)

2023-11-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-transforms

Author: Markos Horro (markoshorro)


Changes

The same idea as in 34d380e1f63a7e2cdb9ab1e6498f727fcd710a14, but for 
truncation instructions.
Improvement for #59633.

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


2 Files Affected:

- (modified) llvm/lib/Transforms/Utils/SimplifyIndVar.cpp (+3-2) 
- (added) llvm/test/Transforms/IndVarSimplify/casted-trunc.ll (+28) 


``diff
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp 
b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index ae3644183a735bc..692242fff082583 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -909,8 +909,9 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, 
IVVisitor *V) {
 if (replaceIVUserWithLoopInvariant(UseInst))
   continue;
 
-// Go further for the bitcast ''prtoint ptr to i64'
-if (isa(UseInst))
+// Go further for the bitcast 'prtoint ptr to i64' or if the cast is done
+// by truncation
+if ((isa(UseInst)) || (isa(UseInst)))
   for (Use &U : UseInst->uses()) {
 Instruction *User = cast(U.getUser());
 if (replaceIVUserWithLoopInvariant(User))
diff --git a/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll 
b/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll
new file mode 100644
index 000..ef9db0b5774dada
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=indvars -S | FileCheck %s
+
+declare void @foo(i16 noundef)
+
+; Function Attrs: mustprogress noreturn uwtable
+define void @bar(i64 noundef %ptr) {
+; CHECK-LABEL: @bar(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = trunc i64 [[PTR:%.*]] to i4
+; CHECK-NEXT:[[TMP1:%.*]] = zext i4 [[TMP0]] to i16
+; CHECK-NEXT:br label [[WHILE_BODY:%.*]]
+; CHECK:   while.body:
+; CHECK-NEXT:tail call void @foo(i16 noundef signext [[TMP1]])
+; CHECK-NEXT:br label [[WHILE_BODY]]
+;
+entry:
+  br label %while.body
+
+while.body:   ; preds = %entry, %while.body
+  %0 = phi i64 [ %ptr, %entry ], [ %add.ptr, %while.body ]
+  %1 = trunc i64 %0 to i16
+  %and = and i16 %1, 15   ; loop invariant
+  tail call void @foo(i16 noundef signext %and)
+  %add.ptr = add nsw i64 %0,  16
+  br label %while.body
+}
+

``




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


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Kevin Frei via lldb-commits

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


[Lldb-commits] [llvm] [clang] [clang-tools-extra] [lldb] [flang] [IndVars] Add check of loop invariant for trunc instructions (PR #71072)

2023-11-02 Thread Markos Horro via lldb-commits

https://github.com/markoshorro created 
https://github.com/llvm/llvm-project/pull/71072

The same idea as in 34d380e1f63a7e2cdb9ab1e6498f727fcd710a14, but for 
truncation instructions.
Improvement for #59633.

>From 0c5299adb30888aa0dfd7c3106547a69606d5ab1 Mon Sep 17 00:00:00 2001
From: Marcos Horro 
Date: Thu, 2 Nov 2023 15:35:07 +
Subject: [PATCH] [IndVars] Truncation also considered as bitcast optimization

---
 llvm/lib/Transforms/Utils/SimplifyIndVar.cpp  |  5 ++--
 .../Transforms/IndVarSimplify/casted-trunc.ll | 28 +++
 2 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/Transforms/IndVarSimplify/casted-trunc.ll

diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp 
b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index a23ac41acaa58aa..740f726cb06b148 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -908,8 +908,9 @@ void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, 
IVVisitor *V) {
 if (replaceIVUserWithLoopInvariant(UseInst))
   continue;
 
-// Go further for the bitcast ''prtoint ptr to i64'
-if (isa(UseInst))
+// Go further for the bitcast 'prtoint ptr to i64' or if the cast is done
+// by truncation
+if ((isa(UseInst)) || (isa(UseInst)))
   for (Use &U : UseInst->uses()) {
 Instruction *User = cast(U.getUser());
 if (replaceIVUserWithLoopInvariant(User))
diff --git a/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll 
b/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll
new file mode 100644
index 000..ef9db0b5774dada
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/casted-trunc.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=indvars -S | FileCheck %s
+
+declare void @foo(i16 noundef)
+
+; Function Attrs: mustprogress noreturn uwtable
+define void @bar(i64 noundef %ptr) {
+; CHECK-LABEL: @bar(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = trunc i64 [[PTR:%.*]] to i4
+; CHECK-NEXT:[[TMP1:%.*]] = zext i4 [[TMP0]] to i16
+; CHECK-NEXT:br label [[WHILE_BODY:%.*]]
+; CHECK:   while.body:
+; CHECK-NEXT:tail call void @foo(i16 noundef signext [[TMP1]])
+; CHECK-NEXT:br label [[WHILE_BODY]]
+;
+entry:
+  br label %while.body
+
+while.body:   ; preds = %entry, %while.body
+  %0 = phi i64 [ %ptr, %entry ], [ %add.ptr, %while.body ]
+  %1 = trunc i64 %0 to i16
+  %and = and i16 %1, 15   ; loop invariant
+  tail call void @foo(i16 noundef signext %and)
+  %add.ptr = add nsw i64 %0,  16
+  br label %while.body
+}
+

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


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

> First off, thank you for working on this. `debuginfod` has been on my radar 
> since support was added to LLVM and I was curious at which point someone was 
> going to add support for it to LLDB. I wasn't super familiar with what 
> exactly it provides, and in case others here aren't either, I found the 
> following documentation very helpful: 
> https://llvm.org/doxygen/Debuginfod_8h.html. TL;DR: it gives you a way to get 
> sources, (symbol rich) executables and debug info files.
> 
> The functionality `debuginfod` offers seems very similar to `dsymForUUID` 
> (see https://lldb.llvm.org/use/symbols.html). We have series of functions 
> such as `LocateExecutableObjectFile` and `LocateExecutableSymbolFile` in 
> `LocateSymbolFile.h` that abstract over this. It seems appropriate that we 
> use the same abstractions for `debuginfod` which avoids the special casing 
> this patch introduces and a lot of things will "just work".
> 
> The one caveat is that the current implementation is really tied to a 
> platform. All the `dsymForUUID` stuff is implemented in 
> `LocateSymbolFileMacOSX.cpp`. I think we might need to move this to a Plugin 
> model where we can have multiple implementations. The plugin name 
> `SymbolVendor` is already taken so I would call this the `SymbolServer` 
> plugin. Converting the current model to a plugin should be done in separate 
> patch and myself or other Apple folks can make sure this doesn't break the 
> dsymForUUID paths (we have some tests but not enough given how critical this 
> is for us). With that done, it should be trivial to add a plugin 
> implementation that calls into `debuginfod`

Yes, that specific kind of refactoring seemed like a good idea, but given that 
this is my first real foray into the LLDB space, I didn't want to bite off that 
much work to start with. Once I've got the full DEBUGINFOD capabilities 
plumbed, refactoring it out into a SymbolServer plug-in makes lots of sense.

You can also read about the full DebugInfoD protocol (it's not very 
complicated) [from the RedHat blog introducing it in 
2019](https://developers.redhat.com/blog/2019/10/14/introducing-debuginfod-the-elfutils-debuginfo-server#).

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Kevin Frei via lldb-commits


@@ -396,8 +398,22 @@ Symbols::LocateExecutableSymbolFile(const ModuleSpec 
&module_spec,
   }
 }
   }
-
-  return LocateExecutableSymbolFileDsym(module_spec);
+  FileSpec dsym_bundle = LocateExecutableSymbolFileDsym(module_spec);
+  if (dsym_bundle)
+return dsym_bundle;
+
+  // If we didn't find anything by looking locally, let's try Debuginfod.
+  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
+llvm::object::BuildID build_id(module_uuid.GetBytes());
+llvm::Expected result =
+llvm::getCachedOrDownloadDebuginfo(build_id);
+if (result)
+  return FileSpec(*result);
+// An error is just fine, here...
+consumeError(result.takeError());

kevinfrei wrote:

That was my reason for just consuming it in the first place. I think adding a 
"debuginfod_failure_log" setting makes sense here. And I just signed myself up 
for more work :/ 

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


[Lldb-commits] [lldb] [lldb][docs] Update reference to test directory location (PR #71081)

2023-11-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Chelsea Cassanova (chelcassanova)


Changes

The instructions for running single tests in the LLDB test suite used an older 
directory structure from before the LLVM project became a monorepo. This commit 
updates the references to these directories.

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


1 Files Affected:

- (modified) lldb/docs/resources/test.rst (+3-3) 


``diff
diff --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst
index 3c9e24dde8fd454..52757864539ead5 100644
--- a/lldb/docs/resources/test.rst
+++ b/lldb/docs/resources/test.rst
@@ -483,7 +483,7 @@ run as part of a test suite.
 
 ::
 
-   $ ./bin/llvm-lit -sv tools/lldb/test --filter 
+   $ ./bin/llvm-lit -sv /lldb/test --filter 
 
 
 Because lit automatically scans a directory for tests, it's also possible to
@@ -491,7 +491,7 @@ pass a subdirectory to run a specific subset of the tests.
 
 ::
 
-   $ ./bin/llvm-lit -sv 
tools/lldb/test/Shell/Commands/CommandScriptImmediateOutput
+   $ ./bin/llvm-lit -sv 
/lldb/test/Shell/Commands/CommandScriptImmediateOutput
 
 
 For the SB API tests it is possible to forward arguments to ``dotest.py`` by
@@ -499,7 +499,7 @@ passing ``--param`` to lit and setting a value for 
``dotest-args``.
 
 ::
 
-   $ ./bin/llvm-lit -sv tools/lldb/test --param dotest-args='-C gcc'
+   $ ./bin/llvm-lit -sv /lldb/test --param dotest-args='-C 
gcc'
 
 
 Below is an overview of running individual test in the unit and API test suites

``




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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Fetch constant value from variable defintion if available (PR #71004)

2023-11-02 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Kevin Frei via lldb-commits

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


[Lldb-commits] [lldb] [lldb][docs] Update reference to test directory location (PR #71081)

2023-11-02 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova created 
https://github.com/llvm/llvm-project/pull/71081

The instructions for running single tests in the LLDB test suite used an older 
directory structure from before the LLVM project became a monorepo. This commit 
updates the references to these directories.

>From a61362cb67e62e6cba8cdf9235fe3e276db26573 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 2 Nov 2023 09:21:35 -0700
Subject: [PATCH] [lldb][docs] Update reference to test directory location

The instructions for running single tests in the LLDB test suite used
an older directory structure from before the LLVM project became a
monorepo. This commit updates the references to these directories.
---
 lldb/docs/resources/test.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst
index 3c9e24dde8fd454..52757864539ead5 100644
--- a/lldb/docs/resources/test.rst
+++ b/lldb/docs/resources/test.rst
@@ -483,7 +483,7 @@ run as part of a test suite.
 
 ::
 
-   $ ./bin/llvm-lit -sv tools/lldb/test --filter 
+   $ ./bin/llvm-lit -sv /lldb/test --filter 
 
 
 Because lit automatically scans a directory for tests, it's also possible to
@@ -491,7 +491,7 @@ pass a subdirectory to run a specific subset of the tests.
 
 ::
 
-   $ ./bin/llvm-lit -sv 
tools/lldb/test/Shell/Commands/CommandScriptImmediateOutput
+   $ ./bin/llvm-lit -sv 
/lldb/test/Shell/Commands/CommandScriptImmediateOutput
 
 
 For the SB API tests it is possible to forward arguments to ``dotest.py`` by
@@ -499,7 +499,7 @@ passing ``--param`` to lit and setting a value for 
``dotest-args``.
 
 ::
 
-   $ ./bin/llvm-lit -sv tools/lldb/test --param dotest-args='-C gcc'
+   $ ./bin/llvm-lit -sv /lldb/test --param dotest-args='-C 
gcc'
 
 
 Below is an overview of running individual test in the unit and API test suites

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -1506,13 +1514,50 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
 return true;
   }
 
   return false;
 }
 
+//===
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name, 
CommandInterpreter *interpreter= nullptr) {
+if (!name) {
+strm.PutCString(text);
+return;
+}
+
+bool use_color = interpreter->GetDebugger().GetUseColor();
+
+std::string str_text(text);
+std::regex reg_name(name);
+std::sregex_iterator next(str_text.begin(), str_text.end(), reg_name);
+std::sregex_iterator end;
+
+std::string red_start = 
lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}", use_color);
+std::string reset_color = 
lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.normal}", use_color);

DavidSpickett wrote:

Generally you'd use this by making a format string like:
```
${ansi.fg.red}%s${ansi.normal}
```
Then the function will remove the ansi bits as needed and you can use it as a 
format string to printf. `strm.Printf(fmt, ...)`.

What you have isn't wrong, but changing it will save a call or two.

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


[Lldb-commits] [flang] [compiler-rt] [libc] [llvm] [lldb] [lld] [libcxx] [clang-tools-extra] [clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

2023-11-02 Thread Vlad Serebrennikov via lldb-commits

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-11-02 Thread David Spickett via lldb-commits


@@ -1506,13 +1514,50 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
 return true;
   }
 
   return false;
 }
 
+//===
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name, 
CommandInterpreter *interpreter= nullptr) {
+if (!name) {
+strm.PutCString(text);
+return;
+}
+
+bool use_color = interpreter->GetDebugger().GetUseColor();
+
+std::string str_text(text);
+std::regex reg_name(name);
+std::sregex_iterator next(str_text.begin(), str_text.end(), reg_name);
+std::sregex_iterator end;
+
+std::string red_start = 
lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.fg.red}", use_color);
+std::string reset_color = 
lldb_private::ansi::FormatAnsiTerminalCodes("${ansi.normal}", use_color);
+
+size_t last_pos = 0;
+while (next != end) {
+std::smatch match = *next;
+size_t prefix_len = match.position() - last_pos;
+
+strm.Write(text, prefix_len);
+strm.PutCString(red_start.c_str());
+strm.Write(text + match.position(), match.length());
+strm.PutCString(reset_color.c_str());
+
+last_pos = match.position() + match.length();
+++next;

DavidSpickett wrote:

I generally prefer a for loop for this sort of thing, so that one doesn't 
forget this last bit.
```
for ( ; next != end; ++next) {
...
}
```

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


[Lldb-commits] [lldb] d483abd - [lldb][docs] Update reference to test directory location (#71081)

2023-11-02 Thread via lldb-commits

Author: Chelsea Cassanova
Date: 2023-11-02T10:35:42-07:00
New Revision: d483abd0fdd032c4169f8fcaedd2bc63986f7a40

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

LOG: [lldb][docs] Update reference to test directory location (#71081)

The instructions for running single tests in the LLDB test suite used an
older directory structure from before the LLVM project became a
monorepo. This commit updates the references to these directories.

Added: 


Modified: 
lldb/docs/resources/test.rst

Removed: 




diff  --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst
index 3c9e24dde8fd454..52757864539ead5 100644
--- a/lldb/docs/resources/test.rst
+++ b/lldb/docs/resources/test.rst
@@ -483,7 +483,7 @@ run as part of a test suite.
 
 ::
 
-   $ ./bin/llvm-lit -sv tools/lldb/test --filter 
+   $ ./bin/llvm-lit -sv /lldb/test --filter 
 
 
 Because lit automatically scans a directory for tests, it's also possible to
@@ -491,7 +491,7 @@ pass a subdirectory to run a specific subset of the tests.
 
 ::
 
-   $ ./bin/llvm-lit -sv 
tools/lldb/test/Shell/Commands/CommandScriptImmediateOutput
+   $ ./bin/llvm-lit -sv 
/lldb/test/Shell/Commands/CommandScriptImmediateOutput
 
 
 For the SB API tests it is possible to forward arguments to ``dotest.py`` by
@@ -499,7 +499,7 @@ passing ``--param`` to lit and setting a value for 
``dotest-args``.
 
 ::
 
-   $ ./bin/llvm-lit -sv tools/lldb/test --param dotest-args='-C gcc'
+   $ ./bin/llvm-lit -sv /lldb/test --param dotest-args='-C 
gcc'
 
 
 Below is an overview of running individual test in the unit and API test suites



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


[Lldb-commits] [lldb] [lldb][docs] Update reference to test directory location (PR #71081)

2023-11-02 Thread David Spickett via lldb-commits

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

LGTM, thanks!

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


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Yes, that specific kind of refactoring seemed like a good idea, but given 
> that this is my first real foray into the LLDB space, I didn't want to bite 
> off that much work to start with. 

I'd be happy to help with that and I'm sure @clayborg wouldn't mind providing 
guidance in this space. 

> Once I've got the full DEBUGINFOD capabilities plumbed, refactoring it out 
> into a SymbolServer plug-in makes lots of sense.

That's fine if the new code can be more self contained. This patch is adding 
things like a `HTTPClient` to the debugger or a dependency on `Debuginfod.h` in 
Target. I don't think either of those things belong there. At the very least 
should be abstracted behind `LocateSymbol`. All its functions are static which 
makes that hard, which is why I suggested symbol server plugin. Maybe as an 
intermediate step we can start by turning that class into something that can be 
instantiated? 

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


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Kevin Frei via lldb-commits


@@ -48,6 +48,7 @@ add_lldb_library(lldbSymbol NO_PLUGIN_DEPENDENCIES
 lldbHost
 lldbTarget
 lldbUtility
+LLVMDebuginfod

kevinfrei wrote:

`LINK_COMPONENTS` gets added to targets all over the place. The library is only 
used in this particular target, and any target that uses it, so this seemed 
like the minimal change necessary to make it work. I'm happy to put it in 
`LINK_COMPONENTS` if that's the right way to do it. Can anyone want to chime in 
who understands the build system more deeply than me? (I'm new to the 
community, so I have no idea who should make the call)

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


[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)

2023-11-02 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/70996

>From 6454d4fb652f61a20850c75f0e69759dffe28511 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Wed, 18 Oct 2023 14:37:34 -0700
Subject: [PATCH 1/2] DEBUGINFOD based DWP acquisition for LLDB

Summary:
I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic 
downloading of
DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set 
to a
space delimited set of web servers, LLDB will try to use them as a last resort 
when
searching for DWP files. If you do *not* have that environment variable set, 
nothing
should be changed. There's also a setting, per Greg Clayton's request, that will
override the env variable, or can be used instead of the env var. This setting 
is the
reason for the additional API added to the llvm's Debuginfod library.

Test Plan:
Suggestions are welcome here. I should probably have some positive and negative 
tests,
but I wanted to get the diff up for people who have a clue what they're doing 
to rip it
to pieces before spending too much time validating my implementation.
---
 lldb/include/lldb/Target/Target.h |  3 +++
 lldb/source/Core/CoreProperties.td|  2 +-
 lldb/source/Core/Debugger.cpp |  5 
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  1 +
 lldb/source/Symbol/CMakeLists.txt |  1 +
 lldb/source/Symbol/LocateSymbolFile.cpp   | 20 --
 lldb/source/Target/Target.cpp | 19 +-
 lldb/source/Target/TargetProperties.td|  4 +++
 llvm/include/llvm/Debuginfod/Debuginfod.h |  4 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++-
 10 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 82045988018b606..cd5c88767c900d1 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -258,6 +258,8 @@ class TargetProperties : public Properties {
 
   bool GetDebugUtilityExpression() const;
 
+  Args GetDebugInfoDURLs() const;
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();
@@ -270,6 +272,7 @@ class TargetProperties : public Properties {
   void DisableASLRValueChangedCallback();
   void InheritTCCValueChangedCallback();
   void DisableSTDIOValueChangedCallback();
+  void DebugInfoDURLsChangedCallback();
 
   // Settings checker for target.jit-save-objects-dir:
   void CheckJITObjectsDir();
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index 92884258347e9be..865030b0133bbb2 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -4,7 +4,7 @@ let Definition = "modulelist" in {
   def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">,
 Global,
 DefaultTrue,
-Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched.">;
+Desc<"Control the use of external tools and repositories to locate symbol 
files. Directories listed in target.debug-file-search-paths and directory of 
the executable are always checked first for separate debug info files. Then 
depending on this setting: On macOS, Spotlight would be also used to locate a 
matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory 
/usr/libdata/debug would be also searched. On platforms other than NetBSD 
directory /usr/lib/debug would be also searched. If all other methods fail, and 
the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol 
is used to acquire symbols from a compatible Debuginfod service.">;
   def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">,
 Global,
 DefaultFalse,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 21f71e449ca5ed0..9a3e82f3e6a2adf 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -61,6 +61,8 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
+#include "llvm/Debuginfod/Debuginfod.h"
+#include "llvm/Debuginfod/HTTPClient.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Process.h"
@@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() 
const {
 void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) {
   assert(g_debugger_list_ptr == nullptr &&
  "Debugger::Initialize called

[Lldb-commits] [lldb] [lldb][AArch64] Move register info reconfigure into architecture plugin (PR #70950)

2023-11-02 Thread Jonas Devlieghere via lldb-commits

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

Thanks!

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


[Lldb-commits] [lldb] [lldb][split-dwarf] Add --errors-only argument separate-debug-info list (PR #71000)

2023-11-02 Thread Tom Yang via lldb-commits


@@ -445,7 +445,11 @@ class SymbolFile : public PluginInterface {
   /// contains the keys "type", "symfile", and "separate-debug-info-files".
   /// "type" can be used to assume the structure of each object in
   /// "separate-debug-info-files".
-  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d) {
+  /// \param errors_only
+  /// If true, then only return separate debug info files that encountered
+  /// errors during loading.
+  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d,
+bool errors_only) {

zhyty wrote:

Ah yes it only filters! That explains the confusion. I'll update the doc so 
that's clearer.

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


[Lldb-commits] [lldb] [lldb][split-dwarf] Add --errors-only argument separate-debug-info list (PR #71000)

2023-11-02 Thread Alex Langford via lldb-commits


@@ -445,7 +445,11 @@ class SymbolFile : public PluginInterface {
   /// contains the keys "type", "symfile", and "separate-debug-info-files".
   /// "type" can be used to assume the structure of each object in
   /// "separate-debug-info-files".
-  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d) {
+  /// \param errors_only
+  /// If true, then only return separate debug info files that encountered
+  /// errors during loading.
+  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d,
+bool errors_only) {

bulbazord wrote:

I see. Does `GetSeparateDebugInfo` return all the successful entries and all 
the errors if `errors_only` is off? I guess what I'm asking is, is the flag 
there to filter or change the behavior entirely?

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


[Lldb-commits] [lldb] [lldb][docs] Update reference to test directory location (PR #71081)

2023-11-02 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

LGTM! Thanks!

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


[Lldb-commits] [lldb] [lldb][docs] Update reference to test directory location (PR #71081)

2023-11-02 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb][docs] Update reference to test directory location (PR #71081)

2023-11-02 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [lldb][split-dwarf] Add --errors-only argument separate-debug-info list (PR #71000)

2023-11-02 Thread Tom Yang via lldb-commits

https://github.com/zhyty updated https://github.com/llvm/llvm-project/pull/71000

>From c6900333c54d1c3f5dd3e6a88f0627b65ff0efca Mon Sep 17 00:00:00 2001
From: Tom Yang 
Date: Wed, 1 Nov 2023 00:53:19 -0700
Subject: [PATCH 1/3] [lldb] Add --errors-only argument separate-debug-info
 list

---
 lldb/include/lldb/Symbol/SymbolFile.h |  6 +-
 lldb/source/Commands/CommandObjectTarget.cpp  | 20 +--
 lldb/source/Commands/Options.td   |  4 +++-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  6 --
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  3 ++-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |  5 +++--
 .../DWARF/SymbolFileDWARFDebugMap.h   |  3 ++-
 .../dwo/TestDumpDwo.py| 20 ---
 .../oso/TestDumpOso.py| 18 -
 9 files changed, 59 insertions(+), 26 deletions(-)

diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index b40d0f03b6e0130..9fc90ad49361be8 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -445,7 +445,11 @@ class SymbolFile : public PluginInterface {
   /// contains the keys "type", "symfile", and "separate-debug-info-files".
   /// "type" can be used to assume the structure of each object in
   /// "separate-debug-info-files".
-  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d) {
+  /// \param errors_only
+  /// If true, then only return separate debug info files that encountered
+  /// errors during loading.
+  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d,
+bool errors_only) {
 return false;
   };
 
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index c84a6550d6c75cc..ca8484cc79d4054 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1452,11 +1452,11 @@ static bool DumpModuleSymbolFile(Stream &strm, Module 
*module) {
 }
 
 static bool GetSeparateDebugInfoList(StructuredData::Array &list,
- Module *module) {
+ Module *module, bool errors_only) {
   if (module) {
 if (SymbolFile *symbol_file = module->GetSymbolFile(/*can_create=*/true)) {
   StructuredData::Dictionary d;
-  if (symbol_file->GetSeparateDebugInfo(d)) {
+  if (symbol_file->GetSeparateDebugInfo(d, errors_only)) {
 list.AddItem(
 std::make_shared(std::move(d)));
 return true;
@@ -2561,7 +2561,10 @@ class 
CommandObjectTargetModulesDumpSeparateDebugInfoFiles
 m_json.SetCurrentValue(true);
 m_json.SetOptionWasSet();
 break;
-
+  case 'e':
+m_errors_only.SetCurrentValue(true);
+m_errors_only.SetOptionWasSet();
+break;
   default:
 llvm_unreachable("Unimplemented option");
   }
@@ -2570,6 +2573,7 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_json.Clear();
+  m_errors_only.Clear();
 }
 
 llvm::ArrayRef GetDefinitions() override {
@@ -2577,6 +2581,7 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
 }
 
 OptionValueBoolean m_json = false;
+OptionValueBoolean m_errors_only = false;
   };
 
 protected:
@@ -2607,7 +2612,8 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
   break;
 
 if (GetSeparateDebugInfoList(separate_debug_info_lists_by_module,
- module_sp.get()))
+ module_sp.get(),
+ bool(m_options.m_errors_only)))
   num_dumped++;
   }
 } else {
@@ -2628,7 +2634,7 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
   break;
 Module *module = module_list.GetModulePointerAtIndex(i);
 if (GetSeparateDebugInfoList(separate_debug_info_lists_by_module,
- module))
+ module, 
bool(m_options.m_errors_only)))
   num_dumped++;
   }
 } else
@@ -2639,11 +2645,13 @@ class 
CommandObjectTargetModulesDumpSeparateDebugInfoFiles
 
 if (num_dumped > 0) {
   Stream &strm = result.GetOutputStream();
+  // Display the debug info files in some format.
   if (m_options.m_json) {
+// JSON format
 separate_debug_info_lists_by_module.Dump(strm,
  /*pretty_print=*/true);
   } else {
-// List the debug info files in human readable form.
+// Human-readable table format
 separate_debug_info_lists_by_module.ForEach(
 [&result, &strm](StructuredData::Object *obj) {
   if (!obj) {
diff --g

[Lldb-commits] [libunwind] [compiler-rt] [lldb] [flang] [clang] [lld] [clang-tools-extra] [libcxx] [libc] [llvm] Test pr (PR #71086)

2023-11-02 Thread Zahira Ammarguellat via lldb-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/71086

None

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0d..3ce317d318f9bb6 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333a..ca883689b05c28a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUSh

[Lldb-commits] [lldb] [lldb][split-dwarf] Add --errors-only argument separate-debug-info list (PR #71000)

2023-11-02 Thread Alex Langford via lldb-commits


@@ -445,7 +445,11 @@ class SymbolFile : public PluginInterface {
   /// contains the keys "type", "symfile", and "separate-debug-info-files".
   /// "type" can be used to assume the structure of each object in
   /// "separate-debug-info-files".
-  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d) {
+  /// \param errors_only
+  /// If true, then only return separate debug info files that encountered
+  /// errors during loading.
+  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d,
+bool errors_only) {

bulbazord wrote:

Okay, so it doesn't do something completely different! That's what I wanted to 
avoid. No issue on my end then, thanks for clarifying.

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


[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread River Riddle via lldb-commits

https://github.com/River707 created 
https://github.com/llvm/llvm-project/pull/71087

These are already exported in non-windows builds, they aren't in the msvc path 
because we explicitly limit the symbols exported to prevent hitting the symbol 
export limit.

These symbols are useful for downstream projects that want to utilize code 
within the dwarf plugin. The Mojo language uses these to implement dwarf 
handling within its debugger plugin.

>From 105284ac2924a83655fafb6c8c7896bd247aee24 Mon Sep 17 00:00:00 2001
From: River Riddle 
Date: Thu, 2 Nov 2023 11:12:18 -0700
Subject: [PATCH] [lldb][windows] Export dwarf plugin symbols in
 LLDB_EXPORT_ALL_SYMBOLS

These are already exported in non-windows builds, they aren't
in the msvc path because we explicitly limit the symbols exported
to prevent hitting the symbol export limit.

These symbols are useful for downstream projects that want to
utilize code within the dwarf plugin. The Mojo language uses these
to implement dwarf handling within its debugger plugin.
---
 lldb/source/API/CMakeLists.txt | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 895c6221a8073cf..76e6caceb392303 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -196,13 +196,15 @@ elseif (LLDB_EXPORT_ALL_SYMBOLS)
   MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 
   # Pull out the various lldb libraries linked into liblldb, these will be used
-  # when looking for symbols to extract. We ignore plugin libraries here,
-  # because these symbols aren't publicly exposed.
+  # when looking for symbols to extract. We ignore most plugin libraries here,
+  # because we may expose more symbols than the DLL limit and these symbols
+  # aren't useful to expose.
   get_target_property(all_liblldb_libs liblldb LINK_LIBRARIES)
   set(lldb_libs "")
   foreach(lib ${all_liblldb_libs})
 if(TARGET ${lib} AND ${lib} MATCHES "^lldb" AND
-   NOT ${lib} MATCHES "^lldbPlugin")
+   (${lib} MATCHES "^lldbPluginSymbolFileDWARF" OR
+NOT ${lib} MATCHES "^lldbPlugin"))
   get_target_property(lib_type ${lib} TYPE)
   if("${lib_type}" STREQUAL "STATIC_LIBRARY")
 list(APPEND lldb_libs ${lib})

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


[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: River Riddle (River707)


Changes

These are already exported in non-windows builds, they aren't in the msvc path 
because we explicitly limit the symbols exported to prevent hitting the symbol 
export limit.

These symbols are useful for downstream projects that want to utilize code 
within the dwarf plugin. The Mojo language uses these to implement dwarf 
handling within its debugger plugin.

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


1 Files Affected:

- (modified) lldb/source/API/CMakeLists.txt (+5-3) 


``diff
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 895c6221a8073cf..76e6caceb392303 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -196,13 +196,15 @@ elseif (LLDB_EXPORT_ALL_SYMBOLS)
   MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 
   # Pull out the various lldb libraries linked into liblldb, these will be used
-  # when looking for symbols to extract. We ignore plugin libraries here,
-  # because these symbols aren't publicly exposed.
+  # when looking for symbols to extract. We ignore most plugin libraries here,
+  # because we may expose more symbols than the DLL limit and these symbols
+  # aren't useful to expose.
   get_target_property(all_liblldb_libs liblldb LINK_LIBRARIES)
   set(lldb_libs "")
   foreach(lib ${all_liblldb_libs})
 if(TARGET ${lib} AND ${lib} MATCHES "^lldb" AND
-   NOT ${lib} MATCHES "^lldbPlugin")
+   (${lib} MATCHES "^lldbPluginSymbolFileDWARF" OR
+NOT ${lib} MATCHES "^lldbPlugin"))
   get_target_property(lib_type ${lib} TYPE)
   if("${lib_type}" STREQUAL "STATIC_LIBRARY")
 list(APPEND lldb_libs ${lib})

``




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


[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread Alex Langford via lldb-commits


@@ -196,13 +196,15 @@ elseif (LLDB_EXPORT_ALL_SYMBOLS)
   MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 
   # Pull out the various lldb libraries linked into liblldb, these will be used
-  # when looking for symbols to extract. We ignore plugin libraries here,
-  # because these symbols aren't publicly exposed.
+  # when looking for symbols to extract. We ignore most plugin libraries here,
+  # because we may expose more symbols than the DLL limit and these symbols
+  # aren't useful to expose.
   get_target_property(all_liblldb_libs liblldb LINK_LIBRARIES)
   set(lldb_libs "")
   foreach(lib ${all_liblldb_libs})
 if(TARGET ${lib} AND ${lib} MATCHES "^lldb" AND
-   NOT ${lib} MATCHES "^lldbPlugin")
+   (${lib} MATCHES "^lldbPluginSymbolFileDWARF" OR
+NOT ${lib} MATCHES "^lldbPlugin"))

bulbazord wrote:

I'd prefer if we didn't hardcode this here. We should introduce another CMake 
variable that collects the list of plugins we want to export from or have a 
file specify it. 

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


[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread River Riddle via lldb-commits


@@ -196,13 +196,15 @@ elseif (LLDB_EXPORT_ALL_SYMBOLS)
   MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 
   # Pull out the various lldb libraries linked into liblldb, these will be used
-  # when looking for symbols to extract. We ignore plugin libraries here,
-  # because these symbols aren't publicly exposed.
+  # when looking for symbols to extract. We ignore most plugin libraries here,
+  # because we may expose more symbols than the DLL limit and these symbols
+  # aren't useful to expose.
   get_target_property(all_liblldb_libs liblldb LINK_LIBRARIES)
   set(lldb_libs "")
   foreach(lib ${all_liblldb_libs})
 if(TARGET ${lib} AND ${lib} MATCHES "^lldb" AND
-   NOT ${lib} MATCHES "^lldbPlugin")
+   (${lib} MATCHES "^lldbPluginSymbolFileDWARF" OR
+NOT ${lib} MATCHES "^lldbPlugin"))

River707 wrote:

SGTM, will update!

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


[Lldb-commits] [lldb] [lldb][split-dwarf] Add --errors-only argument separate-debug-info list (PR #71000)

2023-11-02 Thread Tom Yang via lldb-commits

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


[Lldb-commits] [lldb] 9e0a5be - [lldb][split-dwarf] Add --errors-only argument separate-debug-info list (#71000)

2023-11-02 Thread via lldb-commits

Author: Tom Yang
Date: 2023-11-02T11:36:24-07:00
New Revision: 9e0a5be0de320e29226225b6e466474c031d9ca6

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

LOG: [lldb][split-dwarf] Add --errors-only argument separate-debug-info list 
(#71000)

Often, we only care about the split-dwarf files that have failed to
load. This can be useful when diagnosing binaries with many separate
debug info files where only some have errors.

```
(lldb) help image dump separate-debug-info
List the separate debug info symbol files for one or more target modules.

Syntax: target modules dump separate-debug-info  [ 
[ [...]]]

Command Options Usage:
  target modules dump separate-debug-info [-ej] [ [ [...]]]

   -e ( --errors-only )
Filter to show only debug info files with errors.

   -j ( --json )
Output the details in JSON format.

 This command takes options and free-form arguments.  If your arguments
 resemble option specifiers (i.e., they start with a - or --), you must use
 ' -- ' between the end of the command options and the beginning of the
 arguments.

'image' is an abbreviation for 'target modules'
```

I updated the following tests
```
# on Linux
bin/lldb-dotest -p TestDumpDwo

# on Mac
bin/lldb-dotest -p TestDumpOso
```

This change applies to both the table and JSON outputs.

-

Co-authored-by: Tom Yang 

Added: 


Modified: 
lldb/include/lldb/Symbol/SymbolFile.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Commands/Options.td
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/test/API/commands/target/dump-separate-debug-info/dwo/TestDumpDwo.py
lldb/test/API/commands/target/dump-separate-debug-info/oso/TestDumpOso.py

Removed: 




diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index b40d0f03b6e0130..a546b05bfd31811 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -445,7 +445,12 @@ class SymbolFile : public PluginInterface {
   /// contains the keys "type", "symfile", and "separate-debug-info-files".
   /// "type" can be used to assume the structure of each object in
   /// "separate-debug-info-files".
-  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d) {
+  /// \param errors_only
+  /// If true, then only return separate debug info files that encountered
+  /// errors during loading. If false, then return all expected separate
+  /// debug info files, regardless of whether they were successfully 
loaded.
+  virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d,
+bool errors_only) {
 return false;
   };
 

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index c84a6550d6c75cc..ca8484cc79d4054 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1452,11 +1452,11 @@ static bool DumpModuleSymbolFile(Stream &strm, Module 
*module) {
 }
 
 static bool GetSeparateDebugInfoList(StructuredData::Array &list,
- Module *module) {
+ Module *module, bool errors_only) {
   if (module) {
 if (SymbolFile *symbol_file = module->GetSymbolFile(/*can_create=*/true)) {
   StructuredData::Dictionary d;
-  if (symbol_file->GetSeparateDebugInfo(d)) {
+  if (symbol_file->GetSeparateDebugInfo(d, errors_only)) {
 list.AddItem(
 std::make_shared(std::move(d)));
 return true;
@@ -2561,7 +2561,10 @@ class 
CommandObjectTargetModulesDumpSeparateDebugInfoFiles
 m_json.SetCurrentValue(true);
 m_json.SetOptionWasSet();
 break;
-
+  case 'e':
+m_errors_only.SetCurrentValue(true);
+m_errors_only.SetOptionWasSet();
+break;
   default:
 llvm_unreachable("Unimplemented option");
   }
@@ -2570,6 +2573,7 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_json.Clear();
+  m_errors_only.Clear();
 }
 
 llvm::ArrayRef GetDefinitions() override {
@@ -2577,6 +2581,7 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
 }
 
 OptionValueBoolean m_json = false;
+OptionValueBoolean m_errors_only = false;
   };
 
 protected:
@@ -2607,7 +2612,8 @@ class CommandObjectTargetModulesDumpSeparateDebugInfoFiles
   break;
 
 if (Ge

[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread Walter Erquinigo via lldb-commits


@@ -196,13 +196,15 @@ elseif (LLDB_EXPORT_ALL_SYMBOLS)
   MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 
   # Pull out the various lldb libraries linked into liblldb, these will be used
-  # when looking for symbols to extract. We ignore plugin libraries here,
-  # because these symbols aren't publicly exposed.
+  # when looking for symbols to extract. We ignore most plugin libraries here,
+  # because we may expose more symbols than the DLL limit and these symbols
+  # aren't useful to expose.
   get_target_property(all_liblldb_libs liblldb LINK_LIBRARIES)
   set(lldb_libs "")
   foreach(lib ${all_liblldb_libs})
 if(TARGET ${lib} AND ${lib} MATCHES "^lldb" AND
-   NOT ${lib} MATCHES "^lldbPlugin")
+   (${lib} MATCHES "^lldbPluginSymbolFileDWARF" OR
+NOT ${lib} MATCHES "^lldbPlugin"))

walter-erquinigo wrote:

It might be useful to have this cake variable be a cmake regex just to keep it 
simple and flexible 

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


[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb][windows] Export dwarf plugin symbols in LLDB_EXPORT_ALL_SYMBOLS (PR #71087)

2023-11-02 Thread River Riddle via lldb-commits

https://github.com/River707 updated 
https://github.com/llvm/llvm-project/pull/71087

>From 7201d6d99c22450681b9f788e5fe1833d50ab7c4 Mon Sep 17 00:00:00 2001
From: River Riddle 
Date: Thu, 2 Nov 2023 11:12:18 -0700
Subject: [PATCH] [lldb][windows] All exporting plugin symbols in
 LLDB_EXPORT_ALL_SYMBOLS

Plugins aren't exported by default in the msvc path because we explicitly
limit the symbols exported to prevent hitting the symbol export limit.
Some plugins, however, can still be useful for downstream projects to
build on, e.g. the Mojo language uses parts of the dwarf plugin to implement
dwarf handling within its debugger plugin.

This PR adds a cmake variable in the MSVC path,
LLDB_EXPORT_ALL_SYMBOLS_PLUGINS, that allows for providing the set
of plugins to export symbols from.
---
 lldb/cmake/modules/LLDBConfig.cmake | 5 +
 lldb/source/API/CMakeLists.txt  | 8 +---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index ce5e666a6f5e1ac..7efcc87b9799dd9 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -128,6 +128,11 @@ set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
 set(LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE "" CACHE PATH
   "When `LLDB_EXPORT_ALL_SYMBOLS` is enabled, this specifies the exports file 
to use when building liblldb.")
 
+if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(LLDB_EXPORT_ALL_SYMBOLS_PLUGINS "" CACHE STRING
+"When `LLDB_EXPORT_ALL_SYMBOLS` is enabled, this specifies the plugins 
whose symbols should be exported.")
+endif()
+
 if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 895c6221a8073cf..582af90eda8a4e0 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -196,13 +196,15 @@ elseif (LLDB_EXPORT_ALL_SYMBOLS)
   MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and 
lldb_private namespaces")
 
   # Pull out the various lldb libraries linked into liblldb, these will be used
-  # when looking for symbols to extract. We ignore plugin libraries here,
-  # because these symbols aren't publicly exposed.
+  # when looking for symbols to extract. We ignore most plugin libraries here,
+  # because we may expose more symbols than the DLL limit and these symbols
+  # aren't useful to expose.
   get_target_property(all_liblldb_libs liblldb LINK_LIBRARIES)
   set(lldb_libs "")
   foreach(lib ${all_liblldb_libs})
 if(TARGET ${lib} AND ${lib} MATCHES "^lldb" AND
-   NOT ${lib} MATCHES "^lldbPlugin")
+   (${lib} IN_LIST LLDB_EXPORT_ALL_SYMBOLS_PLUGINS OR
+NOT ${lib} MATCHES "^lldbPlugin"))
   get_target_property(lib_type ${lib} TYPE)
   if("${lib_type}" STREQUAL "STATIC_LIBRARY")
 list(APPEND lldb_libs ${lib})

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


  1   2   >