[Lldb-commits] [mlir] [openmp] [libc] [libcxx] [libclc] [lld] [lldb] [clang-tools-extra] [compiler-rt] [clang] [llvm] Make llvm-strip not eat the .gnu_debuglink section (PR #78919)

2024-01-22 Thread Felix Kellenbenz via lldb-commits

https://github.com/felixkellenbenz updated 
https://github.com/llvm/llvm-project/pull/78919

>From bf376afe7bd69fd25a006890b2910f2fd32c191b Mon Sep 17 00:00:00 2001
From: Felix Kellenbenz 
Date: Mon, 22 Jan 2024 00:49:21 +0100
Subject: [PATCH] Make llvm-strip not eat the .gnu_debuglink section

---
 llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp 
b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index daf03810fd7bff..b6d77d17bae36c 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -450,6 +450,8 @@ static Error replaceAndRemoveSections(const CommonConfig 
&Config,
 return false;
   if (StringRef(Sec.Name).starts_with(".gnu.warning"))
 return false;
+  if (StringRef(Sec.Name).starts_with(".gnu_debuglink"))
+return false;
   // We keep the .ARM.attribute section to maintain compatibility
   // with Debian derived distributions. This is a bug in their
   // patchset as documented here:

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


[Lldb-commits] [lldb] [libcxx] [libc] [compiler-rt] [flang] [llvm] [clang] [clang-tools-extra] [lld] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Matt Arsenault via lldb-commits

https://github.com/arsenm commented:

Why is so there so much special casing in the assembler/disassembler?

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


[Lldb-commits] [mlir] [openmp] [libc] [libcxx] [libclc] [lld] [lldb] [clang-tools-extra] [compiler-rt] [clang] [llvm] Make llvm-strip not eat the .gnu_debuglink section (PR #78919)

2024-01-22 Thread James Henderson via lldb-commits

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

Hi, thanks for the contribution.

Please could you add a new lit test case to show that this behaviour works as 
intended.

I note that this code as-is only impacts `--strip-all` behaviour. This means 
that if you use `--strip-debug`, the section will get removed. Is this 
intentional? What do GNU strip or objcopy do in these cases?

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


[Lldb-commits] [compiler-rt] [lldb] [lld] [llvm] [flang] [clang-tools-extra] [libcxx] [clang] [libc] [clang] Fix assertion failure with deleted overloaded unary operators (PR #78316)

2024-01-22 Thread Mariya Podchishchaeva via lldb-commits

Fznamznon wrote:

Driver failure seems unrelated.

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


[Lldb-commits] [compiler-rt] [lldb] [lld] [llvm] [flang] [clang-tools-extra] [libcxx] [clang] [libc] [clang] Fix assertion failure with deleted overloaded unary operators (PR #78316)

2024-01-22 Thread Mariya Podchishchaeva via lldb-commits

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


[Lldb-commits] [lldb] 7b925c3 - [lldb] refactor highlighting function for image lookup command (#76112)

2024-01-22 Thread via lldb-commits

Author: José Lira Junior
Date: 2024-01-22T09:08:42Z
New Revision: 7b925c3edb6297df6bcf87dfcfdfd645f03b5388

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

LOG: [lldb] refactor highlighting function for image lookup command (#76112)

Follow-up to #69422.

This PR puts all the highlighting settings into a single struct for
easier handling

Co-authored-by: Talha Tahir 

Added: 


Modified: 
lldb/include/lldb/Core/Address.h
lldb/include/lldb/Symbol/Symbol.h
lldb/include/lldb/Symbol/SymbolContext.h
lldb/include/lldb/Utility/Stream.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Core/Address.cpp
lldb/source/Symbol/Symbol.cpp
lldb/source/Symbol/SymbolContext.cpp
lldb/source/Utility/Stream.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Address.h 
b/lldb/include/lldb/Core/Address.h
index 725b5d9f91d3d5..9b5874f8b1fbe2 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -9,6 +9,7 @@
 #ifndef LLDB_CORE_ADDRESS_H
 #define LLDB_CORE_ADDRESS_H
 
+#include "lldb/Utility/Stream.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"
@@ -252,10 +253,11 @@ class Address {
   /// in such cases.
   ///
   /// \see Address::DumpStyle
-  bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
-DumpStyle fallback_style = DumpStyleInvalid,
-uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
-llvm::StringRef pattern = "") const;
+  bool
+  Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
+   DumpStyle fallback_style = DumpStyleInvalid,
+   uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false,
+   std::optional settings = std::nullopt) const;
 
   AddressClass GetAddressClass() const;
 

diff  --git a/lldb/include/lldb/Symbol/Symbol.h 
b/lldb/include/lldb/Symbol/Symbol.h
index e6c0b495bcf28c..e05c845a69f3ec 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -13,6 +13,7 @@
 #include "lldb/Core/Mangled.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Utility/Stream.h"
 #include "lldb/Utility/UserID.h"
 #include "lldb/lldb-private.h"
 #include "llvm/Support/JSON.h"
@@ -174,8 +175,9 @@ class Symbol : public SymbolContextScope {
 
   void SetFlags(uint32_t flags) { m_flags = flags; }
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
-  llvm::StringRef pattern = "") const;
+  void GetDescription(
+  Stream *s, lldb::DescriptionLevel level, Target *target,
+  std::optional settings = std::nullopt) const;
 
   bool IsSynthetic() const { return m_is_synthetic; }
 

diff  --git a/lldb/include/lldb/Symbol/SymbolContext.h 
b/lldb/include/lldb/Symbol/SymbolContext.h
index 26f3bac09a9626..bd33a71b46cac0 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -17,6 +17,7 @@
 #include "lldb/Core/Mangled.h"
 #include "lldb/Symbol/LineEntry.h"
 #include "lldb/Utility/Iterable.h"
+#include "lldb/Utility/Stream.h"
 #include "lldb/lldb-private.h"
 
 namespace lldb_private {
@@ -153,11 +154,11 @@ class SymbolContext {
   ///
   /// \return
   /// \b true if some text was dumped, \b false otherwise.
-  bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
-   const Address &so_addr, bool show_fullpaths,
-   bool show_module, bool show_inlined_frames,
-   bool show_function_arguments, bool show_function_name,
-   llvm::StringRef pattern = "") const;
+  bool DumpStopContext(
+  Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr,
+  bool show_fullpaths, bool show_module, bool show_inlined_frames,
+  bool show_function_arguments, bool show_function_name,
+  std::optional settings = std::nullopt) const;
 
   /// Get the address range contained within a symbol context.
   ///
@@ -223,8 +224,9 @@ class SymbolContext {
   /// The symbol that was found, or \b nullptr if none was found.
   const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
 
-  void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target,
-  llvm::StringRef pattern = "") const;
+  void GetDescription(
+  Stream *s, lldb::DescriptionLevel level, Target *target,
+  std::optional settings = std::nullopt) const;
 
   uint32_t GetResolvedMask() const;
 

diff  --git a/lldb/include/lldb/Utility/Stream.h 
b/lldb/include/lldb/Utility/Stream.h
index 20c55ac4597ae6..37bcdc99241715 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include

[Lldb-commits] [lldb] [lldb] refactor highlighting function for image lookup command (PR #76112)

2024-01-22 Thread David Spickett via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb-dap] Add a CMake variable for defining a welcome message (PR #78811)

2024-01-22 Thread David Spickett via lldb-commits


@@ -664,7 +674,7 @@ void request_attach(const llvm::json::Object &request) {
 
   // Run any initialize LLDB commands the user specified in the launch.json
   if (llvm::Error err = g_dap.RunInitCommands()) {
-response["success"] = false;
+ response["success"] = false;

DavidSpickett wrote:

Fixed by @DamonFool (thanks!).

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


[Lldb-commits] [compiler-rt] [mlir] [lldb] [lld] [llvm] [openmp] [clang-tools-extra] [libcxx] [libclc] [clang] [libc] Make llvm-strip not eat the .gnu_debuglink section (PR #78919)

2024-01-22 Thread Felix Kellenbenz via lldb-commits

felixkellenbenz wrote:

Hey thanks for the review, 

I will add a test case in a moment.

That's true, my change only impacts `--strip-all`. I tested `llvm-strip` with 
the `--strip-debug` flag and this didn't  remove the `.gnu_debuglink` section. 
This is also seen when using `GNU strip`.

Here are the commands I used when testing the `--strip-debug` flag:
```
gcc -g -xc /dev/null -ffreestanding -shared -o a.out
llvm-objcopy --only-keep-debug a.out a.out.dbg
llvm-objcopy --add-gnu-debuglink=a.out.dbg a.out
llvm-strip --strip-debug -o a.out.stripped a.out
readelf -wk a.out
```

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


[Lldb-commits] [openmp] [compiler-rt] [libclc] [llvm] [clang-tools-extra] [libcxx] [clang] [libc] [mlir] [lld] [lldb] Make llvm-strip not eat the .gnu_debuglink section (PR #78919)

2024-01-22 Thread Felix Kellenbenz via lldb-commits

https://github.com/felixkellenbenz updated 
https://github.com/llvm/llvm-project/pull/78919

>From bf376afe7bd69fd25a006890b2910f2fd32c191b Mon Sep 17 00:00:00 2001
From: Felix Kellenbenz 
Date: Mon, 22 Jan 2024 00:49:21 +0100
Subject: [PATCH 1/2] Make llvm-strip not eat the .gnu_debuglink section

---
 llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp 
b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index daf03810fd7bff..b6d77d17bae36c 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -450,6 +450,8 @@ static Error replaceAndRemoveSections(const CommonConfig 
&Config,
 return false;
   if (StringRef(Sec.Name).starts_with(".gnu.warning"))
 return false;
+  if (StringRef(Sec.Name).starts_with(".gnu_debuglink"))
+return false;
   // We keep the .ARM.attribute section to maintain compatibility
   // with Debian derived distributions. This is a bug in their
   // patchset as documented here:

>From b014ffa827fbf8c301a190e2fbf7aa943c78e6f1 Mon Sep 17 00:00:00 2001
From: Felix Kellenbenz 
Date: Mon, 22 Jan 2024 10:37:22 +0100
Subject: [PATCH 2/2] Add test that checks if llvm-strip removes the
 .gnu_debuglink section

---
 llvm/test/tools/llvm-objcopy/ELF/strip-all.test | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-all.test 
b/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
index 20f3c9addf556b..efc3d42f22953f 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/strip-all.test
@@ -68,6 +68,8 @@ Sections:
 Flags:   [ ]
   - Name:.gnu.warning.foo
 Type:SHT_PROGBITS
+  - Name:.gnu_debuglink
+Type:SHT_PROGBITS
 ProgramHeaders:
   # Use an arbitrary segment type to show that the segment type is unimportant.
   - Type: 0x61234567

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


[Lldb-commits] [libc] [flang] [compiler-rt] [llvm] [clang-tools-extra] [lldb] [clang] [libcxx] [lld] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mariusz Sikora via lldb-commits

mariusz-sikora-at-amd wrote:

> Why is so there so much special casing in the assembler/disassembler?

I'm not an original author of these change, but from what I understand it is a 
workaround to handle VOP3 instructions which have a single source but require 
the use of two bits from OPSEL.
`V_CVT_F32_FP8` has one source but is using two bits from OPSEL to specify 
which part from 32 bit register to convert ([7:0], [15:8], [23: 16] or 31 : 
24]). And since OPSELs are correlated with sources/destination (one bit from 
OPSEL with one soruce/destination) these is required without any deeper changes 
to TableGen.

I'm open to change TableGen, but I would prefer to create new ticket and do it 
with new PR. These change may take longer than one day and we would like to 
have these PR merged before LLVM branching.

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


[libc] [flang] [compiler-rt] [llvm] [clang-tools-extra] [lldb] [clang] [libcxx] [lld] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mirko Brkušanin via lldb-commits

mbrkusanin wrote:

> > Why is so there so much special casing in the assembler/disassembler?
> 
> I'm not an original author of these change, but from what I understand it is 
> a workaround to handle VOP3 instructions which have a single source but 
> require the use of two bits from OPSEL. `V_CVT_F32_FP8` has one source but is 
> using two bits from OPSEL to specify which part from 32 bit register to 
> convert ([7:0], [15:8], [23: 16] or 31 : 24]). And since OPSELs are 
> correlated with sources/destination (one bit from OPSEL with one 
> soruce/destination) these is required without any deeper changes to TableGen.
> 
> I'm open to change TableGen, but I would prefer to create new ticket and do 
> it with new PR. These change may take longer than one day and we would like 
> to have these PR merged before LLVM branching.

Correct some of these instructions use opsel[1] which in LLVM in stored in 
src1_modifiers so a dummy src1 is used. And as far as I know we can not have 
src1_modfiers without src1 operand.

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


[libc] [clang] [libcxx] [llvm] [lld] [clang-tools-extra] [flang] [compiler-rt] [lldb] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mirko Brkušanin via lldb-commits

mbrkusanin wrote:

> > > Why is so there so much special casing in the assembler/disassembler?
> > 
> > 
> > I'm not an original author of these change, but from what I understand it 
> > is a workaround to handle VOP3 instructions which have a single source but 
> > require the use of two bits from OPSEL. `V_CVT_F32_FP8` has one source but 
> > is using two bits from OPSEL to specify which part from 32 bit register to 
> > convert ([7:0], [15:8], [23: 16] or 31 : 24]). And since OPSELs are 
> > correlated with sources/destination (one bit from OPSEL with one 
> > soruce/destination) these is required without any deeper changes to 
> > TableGen.
> > I'm open to change TableGen, but I would prefer to create new ticket and do 
> > it with new PR. These change may take longer than one day and we would like 
> > to have these PR merged before LLVM branching.
> 
> Correct, some of these instructions use opsel[1] which in LLVM in stored in 
> src1_modifiers so a dummy src1 is used. And as far as I know we can not have 
> src1_modfiers without src1 operand.

Similarly V_CVT_SR_BF8_F32 for example uses opsel[2] and opsel[3] so we need 
src2_modifiers and src2.

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


[Lldb-commits] [lldb] [flang] [clang] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)

2024-01-22 Thread Tom Eccles via lldb-commits

https://github.com/tblah commented:

Flang changes LGTM once CI passes.

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


[Lldb-commits] [clang-tools-extra] [libcxx] [clang] [lldb] [lld] [llvm] [flang] [libc] [compiler-rt] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Ivan Kosarev via lldb-commits

kosarev wrote:

> Correct, some of these instructions use opsel[1] which in LLVM in stored in 
> src1_modifiers so a dummy src1 is used.

Why can't we just use `SRCMODS.OP_SEL_1` with src0?

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


[Lldb-commits] [libcxx] [lld] [libc] [lldb] [clang] [flang] [compiler-rt] [clang-tools-extra] [llvm] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Ivan Kosarev via lldb-commits


@@ -626,11 +629,82 @@ class Cvt_PK_F32_F8_Pat;
 
-foreach Index = [0, -1] in {
-  def : Cvt_PK_F32_F8_Pat;
-  def : Cvt_PK_F32_F8_Pat;
+let SubtargetPredicate = isGFX9Only in {
+  foreach Index = [0, -1] in {
+def : Cvt_PK_F32_F8_Pat;
+def : Cvt_PK_F32_F8_Pat;
+  }
+}
+
+
+// Similar to VOPProfile_Base_CVT_F32_F8, but for VOP3 instructions.
+def VOPProfile_Base_CVT_PK_F32_F8_OpSel : VOPProfileI2F  {
+  let InsVOP3OpSel = (ins Src0Mod:$src0_modifiers, Src0RC64:$src0,
+  clampmod:$clamp, omod:$omod, op_sel0:$op_sel);
+
+  let HasOpSel = 1;
+  let HasExtVOP3DPP = 0;
+}
+
+def VOPProfile_Base_CVT_F32_F8_OpSel : VOPProfile<[f32, i32, i32, untyped]> {
+  let InsVOP3OpSel = (ins Src0Mod:$src0_modifiers, Src0RC64:$src0,
+  Src1Mod:$src1_modifiers, Src1RC64:$src1,
+  clampmod:$clamp, omod:$omod, op_sel0:$op_sel);
+  let AsmVOP3OpSel = !subst(", $src1_modifiers", "", getAsmVOP3OpSel<2, 0, 0, 
1, 1, 0>.ret);
+
+  let HasOpSel = 1;
+  let HasExtDPP = 1;
+  let HasExtVOP3DPP = 1;
+
+  let Src1VOP3DPP = Src1RC64;
+  let AsmVOP3DPP8 = getAsmVOP3DPP8.ret;
+  let AsmVOP3DPP16 = getAsmVOP3DPP16.ret;
+}
+
+let SubtargetPredicate = isGFX12Plus, mayRaiseFPException = 0,
+SchedRW = [WriteFloatCvt] in {
+  defm V_CVT_F32_FP8_OP_SEL: VOP1Inst<"v_cvt_f32_fp8_op_sel", 
VOPProfile_Base_CVT_F32_F8_OpSel>;
+  defm V_CVT_F32_BF8_OP_SEL: VOP1Inst<"v_cvt_f32_bf8_op_sel", 
VOPProfile_Base_CVT_F32_F8_OpSel>;
+  defm V_CVT_PK_F32_FP8_OP_SEL : VOP1Inst<"v_cvt_pk_f32_fp8_op_sel", 
VOPProfile_Base_CVT_PK_F32_F8_OpSel>;
+  defm V_CVT_PK_F32_BF8_OP_SEL : VOP1Inst<"v_cvt_pk_f32_bf8_op_sel", 
VOPProfile_Base_CVT_PK_F32_F8_OpSel>;
+}
+
+class Cvt_F32_F8_Pat_OpSel index,
+VOP1_Pseudo inst_e32, VOP3_Pseudo inst_e64> : GCNPat<
+(f32 (node i32:$src, index)),
+!if (index,
+ (inst_e64 !if(index{0}, SRCMODS.OP_SEL_0, SRCMODS.OP_SEL_1), $src,
+   !if(index{1}, SRCMODS.OP_SEL_0, SRCMODS.OP_SEL_1), (i32 0),

kosarev wrote:

Why do we expect `SRCMODS.OP_SEL_1` for dropped index bits? Is there any test 
coverage for these cases?

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


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

2024-01-22 Thread Paolo Severini via lldb-commits

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

>From 30d932bb0988e1c78c3e023be2270259df5e6664 Mon Sep 17 00:00:00 2001
From: Paolo Severini 
Date: Fri, 12 Jan 2024 09:10:59 -0800
Subject: [PATCH 1/2] Add support for source-level debugging of WebAssembly
 code

---
 lldb/include/lldb/Target/Process.h|  40 +++
 lldb/source/Core/Value.cpp|   2 +-
 lldb/source/Expression/DWARFExpression.cpp|  41 +++
 .../source/Interpreter/CommandInterpreter.cpp |  18 ++
 lldb/source/Plugins/Process/CMakeLists.txt|   1 +
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |   7 +-
 .../Process/gdb-remote/ProcessGDBRemote.h |   2 +
 .../Plugins/Process/wasm/CMakeLists.txt   |  12 +
 .../Plugins/Process/wasm/ProcessWasm.cpp  | 291 ++
 .../source/Plugins/Process/wasm/ProcessWasm.h | 129 
 .../Plugins/Process/wasm/ThreadWasm.cpp   |  55 
 lldb/source/Plugins/Process/wasm/ThreadWasm.h |  44 +++
 .../Plugins/Process/wasm/UnwindWasm.cpp   |  76 +
 lldb/source/Plugins/Process/wasm/UnwindWasm.h |  55 
 .../Process/wasm/wasmRegisterContext.cpp  | 108 +++
 .../Process/wasm/wasmRegisterContext.h|  75 +
 16 files changed, 954 insertions(+), 2 deletions(-)
 create mode 100644 lldb/source/Plugins/Process/wasm/CMakeLists.txt
 create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
 create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.h
 create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.cpp
 create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.h
 create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.cpp
 create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.h
 create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp
 create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.h

diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 24c599e044c78f..587ae085b479b7 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -1548,6 +1548,46 @@ class Process : public 
std::enable_shared_from_this,
   virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
 Status &error);
 
+  /// Read of memory from a process.
+  ///
+  /// This function will read memory from the current process's address space
+  /// and remove any traps that may have been inserted into the memory.
+  ///
+  /// This overloads accepts an ExecutionContext as additional argument. By
+  /// default, it calls the previous overload without the ExecutionContext
+  /// argument, but it can be overridden by Process subclasses.
+  ///
+  /// \param[in] vm_addr
+  /// A virtual load address that indicates where to start reading
+  /// memory from.
+  ///
+  /// \param[out] buf
+  /// A byte buffer that is at least \a size bytes long that
+  /// will receive the memory bytes.
+  ///
+  /// \param[in] size
+  /// The number of bytes to read.
+  ///
+  /// \param[in] exe_ctx
+  ///The current execution context, if available.
+  ///
+  /// \param[out] error
+  /// An error that indicates the success or failure of this
+  /// operation. If error indicates success (error.Success()),
+  /// then the value returned can be trusted, otherwise zero
+  /// will be returned.
+  ///
+  /// \return
+  /// The number of bytes that were actually read into \a buf. If
+  /// the returned number is greater than zero, yet less than \a
+  /// size, then this function will get called again with \a
+  /// vm_addr, \a buf, and \a size updated appropriately. Zero is
+  /// returned in the case of an error.
+  virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+ExecutionContext *exe_ctx, Status &error) {
+return ReadMemory(vm_addr, buf, size, error);
+  }
+
   /// Read of memory from a process.
   ///
   /// This function has the same semantics of ReadMemory except that it
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 995cc934c82044..47a5fdee773886 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -552,7 +552,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, 
DataExtractor &data,
 
 if (process) {
   const size_t bytes_read =
-  process->ReadMemory(address, dst, byte_size, error);
+  process->ReadMemory(address, dst, byte_size, exe_ctx, error);
   if (bytes_read != byte_size)
 error.SetErrorStringWithFormat(
 "read memory from 0x%" PRIx64 " failed (%u of %u bytes read)",
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index fe4928d4f43a43..ca24611724dc7c 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.c

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

2024-01-22 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
f02b7770bb04b88455804b371dba1f44a86b90da...cbd046618749f229fce7221e012bf51f4789301b
 lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
``





View the diff from darker here.


``diff
--- TestWasm.py 2024-01-22 13:17:23.00 +
+++ TestWasm.py 2024-01-22 13:20:43.094496 +
@@ -21,10 +21,11 @@
 result += format(x, "02x")
 mask <<= 8
 shift += 8
 return result
 
+
 def make_code_address(module_id, offset):
 return 0x4000 | (module_id << 32) | offset
 
 class MyResponder(MockGDBServerResponder):
 current_pc = LOAD_ADDRESS + 0x0A
@@ -43,15 +44,15 @@
 
 def respond(self, packet):
 if packet[0:13] == "qRegisterInfo":
 return self.qRegisterInfo(packet[13:])
 if packet.startswith("qWasmCallStack"):
-return self.qWasmCallStack();
+return self.qWasmCallStack()
 if packet.startswith("qWasmLocal"):
-return self.qWasmLocal(packet);
+return self.qWasmLocal(packet)
 if packet.startswith("qWasmMem"):
-return self.qWasmMem(packet);
+return self.qWasmMem(packet)
 return MockGDBServerResponder.respond(self, packet)
 
 def qSupported(self, client_supported):
 return "qXfer:libraries:read+;PacketSize=1000;vContSupported-"
 
@@ -77,11 +78,11 @@
 
 def haltReason(self):
 return "T05thread-pcs:30083;thread:1;library:;"
 
 def readRegister(self, register):
-assert(register == 0)
+assert register == 0
 return format_register_value(self.current_pc)
 
 def qXferRead(self, obj, annex, offset, length):
 if obj == "libraries":
 xml = (
@@ -115,54 +116,60 @@
 def qfThreadInfo(self):
 return "m1"
 
 def cont(self):
 # Continue execution. Simulates running the Wasm engine until a 
breakpoint is hit.
-return "T05thread-pcs:" + format(int(self._bp_address, 16) & 
0x3fff, 'x') + ";thread:1"
+return (
+"T05thread-pcs:"
++ format(int(self._bp_address, 16) & 0x3FFF, "x")
++ ";thread:1"
+)
 
 def qWasmCallStack(self):
 if len(self._wasm_call_stacks) == 0:
 return ""
-result = 
self._wasm_call_stacks[self._call_stack_request_count].format();
+result = 
self._wasm_call_stacks[self._call_stack_request_count].format()
 self._call_stack_request_count = self._call_stack_request_count + 1
 return result
 
 def qWasmLocal(self, packet):
 # Format: qWasmLocal:frame_index;index
 data = packet.split(":")
 data = data[1].split(";")
 frame_index = data[0]
 local_index = data[1]
-if frame_index == '0' and local_index == '4':
+if frame_index == "0" and local_index == "4":
 return "b0ff"
-if frame_index == '1' and local_index == '5':
+if frame_index == "1" and local_index == "5":
 return "c0ff"
-return "E03";
+return "E03"
 
 def qWasmMem(self, packet):
 # Format: qWasmMem:module_id;addr;len
 data = packet.split(":")
 data = data[1].split(";")
 module_id = data[0]
 addr = int(data[1], 16)
 length = int(data[2])
-if module_id != '4':
+if module_id != "4":
 return "E03"
-if addr >= 0xffb8 and addr < 0x1:
-chunk = self._memory_view[addr:addr+length]
+if addr >= 0xFFB8 and addr < 0x1:
+chunk = self._memory_view[addr : addr + length]
 return chunk.hex()
-return "E03";
+return "E03"
+
 
 class WasmStackFrame:
 pass
 
 def __init__(self, module_id, address):
 self._module_id = module_id
 self._address = address
 
 def format(self):
 return format_register_value(make_code_address(self._module_id, 
self._address))
+
 
 class WasmCallStack:
 pass
 
 def __init__(self, wasm_stack_frames):
@@ -171,10 +178,11 @@
 def format(self):
 result = ""
 for frame in self._wasm_stack_frames:
 result += frame.format()
 return result
+
 
 class WasmMemorySpan:
 pass
 
 def __init__(self, offset, bytes):
@@ -195,11 +203,11 @@
 self.assertTrue(error.Success(), error.description)
 self.assertTrue(process, PROCESS_IS_VALID)
 return process
 
 def store_bytes(self, offset, bytes_obj):
-chunk = self.memory_view[offset:offset+len(bytes_obj)]
+chunk = self.memory_view[offset : offset + len(bytes_obj)]
 for i in range(len(bytes_obj)):
 chunk[i] = bytes_obj[i]
 
 @skipIfAsan
 @skipIfXmlSupportMissing
@@ -324,11

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

2024-01-22 Thread Paolo Severini via lldb-commits


@@ -0,0 +1,291 @@
+//===-- ProcessWasm.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ProcessWasm.h"
+#include "ThreadWasm.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Utility/DataBufferHeap.h"
+
+#include "lldb/Target/UnixSignals.h"
+#include "llvm/ADT/ArrayRef.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_gdb_remote;
+using namespace lldb_private::wasm;
+
+LLDB_PLUGIN_DEFINE(ProcessWasm)
+
+// ProcessGDBRemote constructor
+ProcessWasm::ProcessWasm(lldb::TargetSP target_sp, ListenerSP listener_sp)
+: ProcessGDBRemote(target_sp, listener_sp) {
+  /* always use linux signals for wasm process */
+  m_unix_signals_sp =
+  UnixSignals::Create(ArchSpec{"wasm32-unknown-unknown-wasm"});

paolosevMSFT wrote:

This change was made originally by @xujuntwt95329, who can provide more context.

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


[clang] [clang-tools-extra] [compiler-rt] [llvm] [flang] [libc] [lld] [lldb] [libcxx] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mirko Brkušanin via lldb-commits


@@ -626,11 +629,82 @@ class Cvt_PK_F32_F8_Pat;
 
-foreach Index = [0, -1] in {
-  def : Cvt_PK_F32_F8_Pat;
-  def : Cvt_PK_F32_F8_Pat;
+let SubtargetPredicate = isGFX9Only in {
+  foreach Index = [0, -1] in {
+def : Cvt_PK_F32_F8_Pat;
+def : Cvt_PK_F32_F8_Pat;
+  }
+}
+
+
+// Similar to VOPProfile_Base_CVT_F32_F8, but for VOP3 instructions.
+def VOPProfile_Base_CVT_PK_F32_F8_OpSel : VOPProfileI2F  {
+  let InsVOP3OpSel = (ins Src0Mod:$src0_modifiers, Src0RC64:$src0,
+  clampmod:$clamp, omod:$omod, op_sel0:$op_sel);
+
+  let HasOpSel = 1;
+  let HasExtVOP3DPP = 0;
+}
+
+def VOPProfile_Base_CVT_F32_F8_OpSel : VOPProfile<[f32, i32, i32, untyped]> {
+  let InsVOP3OpSel = (ins Src0Mod:$src0_modifiers, Src0RC64:$src0,
+  Src1Mod:$src1_modifiers, Src1RC64:$src1,
+  clampmod:$clamp, omod:$omod, op_sel0:$op_sel);
+  let AsmVOP3OpSel = !subst(", $src1_modifiers", "", getAsmVOP3OpSel<2, 0, 0, 
1, 1, 0>.ret);
+
+  let HasOpSel = 1;
+  let HasExtDPP = 1;
+  let HasExtVOP3DPP = 1;
+
+  let Src1VOP3DPP = Src1RC64;
+  let AsmVOP3DPP8 = getAsmVOP3DPP8.ret;
+  let AsmVOP3DPP16 = getAsmVOP3DPP16.ret;
+}
+
+let SubtargetPredicate = isGFX12Plus, mayRaiseFPException = 0,
+SchedRW = [WriteFloatCvt] in {
+  defm V_CVT_F32_FP8_OP_SEL: VOP1Inst<"v_cvt_f32_fp8_op_sel", 
VOPProfile_Base_CVT_F32_F8_OpSel>;
+  defm V_CVT_F32_BF8_OP_SEL: VOP1Inst<"v_cvt_f32_bf8_op_sel", 
VOPProfile_Base_CVT_F32_F8_OpSel>;
+  defm V_CVT_PK_F32_FP8_OP_SEL : VOP1Inst<"v_cvt_pk_f32_fp8_op_sel", 
VOPProfile_Base_CVT_PK_F32_F8_OpSel>;
+  defm V_CVT_PK_F32_BF8_OP_SEL : VOP1Inst<"v_cvt_pk_f32_bf8_op_sel", 
VOPProfile_Base_CVT_PK_F32_F8_OpSel>;
+}
+
+class Cvt_F32_F8_Pat_OpSel index,
+VOP1_Pseudo inst_e32, VOP3_Pseudo inst_e64> : GCNPat<
+(f32 (node i32:$src, index)),
+!if (index,
+ (inst_e64 !if(index{0}, SRCMODS.OP_SEL_0, SRCMODS.OP_SEL_1), $src,
+   !if(index{1}, SRCMODS.OP_SEL_0, SRCMODS.OP_SEL_1), (i32 0),

mbrkusanin wrote:

Looks like SRCMODS.OP_SEL_1 does nothing here. These should be 0.

Tests are in llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.fp8.ll:

test_cvt_f32_fp8_byte0
test_cvt_f32_fp8_byte1
test_cvt_f32_fp8_byte2
test_cvt_f32_fp8_byte3



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


[compiler-rt] [clang-tools-extra] [lld] [lldb] [clang] [flang] [libc] [libcxx] [llvm] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mirko Brkušanin via lldb-commits

mbrkusanin wrote:

> > Correct, some of these instructions use opsel[1] which in LLVM in stored in 
> > src1_modifiers so a dummy src1 is used.
> 
> Why can't we just use `SRCMODS.OP_SEL_1` with src0?

That could work. We would have to make custom encoding classes then since 
OP_SEL_1 would have different meaning for these instructions.

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


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

2024-01-22 Thread Paolo Severini via lldb-commits

paolosevMSFT wrote:

> > > A WebAssembly debugging session can be started using the new command:
> > > wasm [:]
> > 
> > 
> > What about wasm requires a new command, given that you are connecting to a 
> > GDB server as existing targets do.
> 
> +1! I don't think this needs a new command, it could just use `gdb-remote 
> [:]` command.

It is true that a new command is not really necessary. This command also works:
` process connect --plugin wasm connect://localhost:8765`

But currently a simple `gdb-remote [:]` does not enable the 
"wasm' plugin. Is there a way to detect that we are debugging WebAssembly at 
connect time?

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


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

2024-01-22 Thread Paolo Severini via lldb-commits

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

>From 30d932bb0988e1c78c3e023be2270259df5e6664 Mon Sep 17 00:00:00 2001
From: Paolo Severini 
Date: Fri, 12 Jan 2024 09:10:59 -0800
Subject: [PATCH 1/3] Add support for source-level debugging of WebAssembly
 code

---
 lldb/include/lldb/Target/Process.h|  40 +++
 lldb/source/Core/Value.cpp|   2 +-
 lldb/source/Expression/DWARFExpression.cpp|  41 +++
 .../source/Interpreter/CommandInterpreter.cpp |  18 ++
 lldb/source/Plugins/Process/CMakeLists.txt|   1 +
 .../Process/gdb-remote/ProcessGDBRemote.cpp   |   7 +-
 .../Process/gdb-remote/ProcessGDBRemote.h |   2 +
 .../Plugins/Process/wasm/CMakeLists.txt   |  12 +
 .../Plugins/Process/wasm/ProcessWasm.cpp  | 291 ++
 .../source/Plugins/Process/wasm/ProcessWasm.h | 129 
 .../Plugins/Process/wasm/ThreadWasm.cpp   |  55 
 lldb/source/Plugins/Process/wasm/ThreadWasm.h |  44 +++
 .../Plugins/Process/wasm/UnwindWasm.cpp   |  76 +
 lldb/source/Plugins/Process/wasm/UnwindWasm.h |  55 
 .../Process/wasm/wasmRegisterContext.cpp  | 108 +++
 .../Process/wasm/wasmRegisterContext.h|  75 +
 16 files changed, 954 insertions(+), 2 deletions(-)
 create mode 100644 lldb/source/Plugins/Process/wasm/CMakeLists.txt
 create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.cpp
 create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.h
 create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.cpp
 create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.h
 create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.cpp
 create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.h
 create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp
 create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.h

diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 24c599e044c78f..587ae085b479b7 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -1548,6 +1548,46 @@ class Process : public 
std::enable_shared_from_this,
   virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
 Status &error);
 
+  /// Read of memory from a process.
+  ///
+  /// This function will read memory from the current process's address space
+  /// and remove any traps that may have been inserted into the memory.
+  ///
+  /// This overloads accepts an ExecutionContext as additional argument. By
+  /// default, it calls the previous overload without the ExecutionContext
+  /// argument, but it can be overridden by Process subclasses.
+  ///
+  /// \param[in] vm_addr
+  /// A virtual load address that indicates where to start reading
+  /// memory from.
+  ///
+  /// \param[out] buf
+  /// A byte buffer that is at least \a size bytes long that
+  /// will receive the memory bytes.
+  ///
+  /// \param[in] size
+  /// The number of bytes to read.
+  ///
+  /// \param[in] exe_ctx
+  ///The current execution context, if available.
+  ///
+  /// \param[out] error
+  /// An error that indicates the success or failure of this
+  /// operation. If error indicates success (error.Success()),
+  /// then the value returned can be trusted, otherwise zero
+  /// will be returned.
+  ///
+  /// \return
+  /// The number of bytes that were actually read into \a buf. If
+  /// the returned number is greater than zero, yet less than \a
+  /// size, then this function will get called again with \a
+  /// vm_addr, \a buf, and \a size updated appropriately. Zero is
+  /// returned in the case of an error.
+  virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+ExecutionContext *exe_ctx, Status &error) {
+return ReadMemory(vm_addr, buf, size, error);
+  }
+
   /// Read of memory from a process.
   ///
   /// This function has the same semantics of ReadMemory except that it
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 995cc934c82044..47a5fdee773886 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -552,7 +552,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, 
DataExtractor &data,
 
 if (process) {
   const size_t bytes_read =
-  process->ReadMemory(address, dst, byte_size, error);
+  process->ReadMemory(address, dst, byte_size, exe_ctx, error);
   if (bytes_read != byte_size)
 error.SetErrorStringWithFormat(
 "read memory from 0x%" PRIx64 " failed (%u of %u bytes read)",
diff --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index fe4928d4f43a43..ca24611724dc7c 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.c

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

2024-01-22 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 f02b7770bb04b88455804b371dba1f44a86b90da 
db0bc4829b02aedf7a988824b38b56a1564a8125 -- 
lldb/source/Plugins/Process/wasm/ProcessWasm.cpp 
lldb/source/Plugins/Process/wasm/ProcessWasm.h 
lldb/source/Plugins/Process/wasm/ThreadWasm.cpp 
lldb/source/Plugins/Process/wasm/ThreadWasm.h 
lldb/source/Plugins/Process/wasm/UnwindWasm.cpp 
lldb/source/Plugins/Process/wasm/UnwindWasm.h 
lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp 
lldb/source/Plugins/Process/wasm/wasmRegisterContext.h 
lldb/test/API/functionalities/gdb_remote_client/calc.cpp 
lldb/include/lldb/Target/Process.h lldb/source/Core/Value.cpp 
lldb/source/Expression/DWARFExpression.cpp 
lldb/source/Expression/Materializer.cpp 
lldb/source/Interpreter/CommandInterpreter.cpp 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/functionalities/gdb_remote_client/calc.cpp 
b/lldb/test/API/functionalities/gdb_remote_client/calc.cpp
index 7e4c53c42c..450a318ec8 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/calc.cpp
+++ b/lldb/test/API/functionalities/gdb_remote_client/calc.cpp
@@ -4,15 +4,11 @@ struct Number {
 };
 
 struct Calc {
-  void add(const Number& number) {
-result_ += number.value_;
-  }
+  void add(const Number &number) { result_ += number.value_; }
 
-  Number result() const {
-return Number(result_);
-  }
+  Number result() const { return Number(result_); }
 
- private:
+private:
   double result_ = 0;
 };
 

``




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


[Lldb-commits] [lld] [lldb] [compiler-rt] [libc] [llvm] [libcxx] [libclc] [flang] [clang-tools-extra] [clang] [libc++] Ensure that `std::expected` has no tail padding (PR #69673)

2024-01-22 Thread Louis Dionne via lldb-commits
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,
Jan =?utf-8?q?Kokemüller?= ,Louis Dionne
 
Message-ID:
In-Reply-To: 


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


[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #78977)

2024-01-22 Thread Paolo Severini via lldb-commits

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

Add support for `DW_OP_WASM_location` in `DWARFExpression`.

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

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

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

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


[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #78977)

2024-01-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Paolo Severini (paolosevMSFT)


Changes

Add support for `DW_OP_WASM_location` in `DWARFExpression`.

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


1 Files Affected:

- (modified) lldb/source/Expression/DWARFExpression.cpp (+41) 


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

``




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


[Lldb-commits] [clang] [lldb] [flang] [lld] [libc] [libcxx] [compiler-rt] [llvm] [clang-tools-extra] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mariusz Sikora via lldb-commits


@@ -626,11 +629,82 @@ class Cvt_PK_F32_F8_Pat;
 
-foreach Index = [0, -1] in {
-  def : Cvt_PK_F32_F8_Pat;
-  def : Cvt_PK_F32_F8_Pat;
+let SubtargetPredicate = isGFX9Only in {
+  foreach Index = [0, -1] in {
+def : Cvt_PK_F32_F8_Pat;
+def : Cvt_PK_F32_F8_Pat;
+  }
+}
+
+
+// Similar to VOPProfile_Base_CVT_F32_F8, but for VOP3 instructions.
+def VOPProfile_Base_CVT_PK_F32_F8_OpSel : VOPProfileI2F  {
+  let InsVOP3OpSel = (ins Src0Mod:$src0_modifiers, Src0RC64:$src0,
+  clampmod:$clamp, omod:$omod, op_sel0:$op_sel);
+
+  let HasOpSel = 1;
+  let HasExtVOP3DPP = 0;
+}
+
+def VOPProfile_Base_CVT_F32_F8_OpSel : VOPProfile<[f32, i32, i32, untyped]> {
+  let InsVOP3OpSel = (ins Src0Mod:$src0_modifiers, Src0RC64:$src0,
+  Src1Mod:$src1_modifiers, Src1RC64:$src1,
+  clampmod:$clamp, omod:$omod, op_sel0:$op_sel);
+  let AsmVOP3OpSel = !subst(", $src1_modifiers", "", getAsmVOP3OpSel<2, 0, 0, 
1, 1, 0>.ret);
+
+  let HasOpSel = 1;
+  let HasExtDPP = 1;
+  let HasExtVOP3DPP = 1;
+
+  let Src1VOP3DPP = Src1RC64;
+  let AsmVOP3DPP8 = getAsmVOP3DPP8.ret;
+  let AsmVOP3DPP16 = getAsmVOP3DPP16.ret;
+}
+
+let SubtargetPredicate = isGFX12Plus, mayRaiseFPException = 0,
+SchedRW = [WriteFloatCvt] in {
+  defm V_CVT_F32_FP8_OP_SEL: VOP1Inst<"v_cvt_f32_fp8_op_sel", 
VOPProfile_Base_CVT_F32_F8_OpSel>;
+  defm V_CVT_F32_BF8_OP_SEL: VOP1Inst<"v_cvt_f32_bf8_op_sel", 
VOPProfile_Base_CVT_F32_F8_OpSel>;
+  defm V_CVT_PK_F32_FP8_OP_SEL : VOP1Inst<"v_cvt_pk_f32_fp8_op_sel", 
VOPProfile_Base_CVT_PK_F32_F8_OpSel>;
+  defm V_CVT_PK_F32_BF8_OP_SEL : VOP1Inst<"v_cvt_pk_f32_bf8_op_sel", 
VOPProfile_Base_CVT_PK_F32_F8_OpSel>;
+}
+
+class Cvt_F32_F8_Pat_OpSel index,
+VOP1_Pseudo inst_e32, VOP3_Pseudo inst_e64> : GCNPat<
+(f32 (node i32:$src, index)),
+!if (index,
+ (inst_e64 !if(index{0}, SRCMODS.OP_SEL_0, SRCMODS.OP_SEL_1), $src,
+   !if(index{1}, SRCMODS.OP_SEL_0, SRCMODS.OP_SEL_1), (i32 0),

mariusz-sikora-at-amd wrote:

I removed SRCMODS.OP_SEL_1 from the pattern

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


[Lldb-commits] [clang] [lldb] [flang] [lld] [libc] [libcxx] [compiler-rt] [llvm] [clang-tools-extra] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mariusz Sikora via lldb-commits

https://github.com/mariusz-sikora-at-amd edited 
https://github.com/llvm/llvm-project/pull/78414
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [llvm] [compiler-rt] [libc] [libcxx] [flang] [clang] [lld] [lldb] [clang-tools-extra] [lld-macho] Find objects in library search path (PR #78628)

2024-01-22 Thread Vy Nguyen via lldb-commits


@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: mkdir -p %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s 
-o %t/hello.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
+# RUN: %lld -L %t %t/main.o %t/hello.o -o %t/a.out

oontvoo wrote:

would you mind putting it in another PR? we can get it merged there. Thanks!

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


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

2024-01-22 Thread Quentin Michaud via lldb-commits

mh4ck-Thales wrote:

Seems like support for reading Wasm local and global variables is available in 
your code, but I don't understand how can one effectively read these variables 
from the lldb command line. Maybe adding commands to access these can be useful 
?

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


[Lldb-commits] [libcxxabi] [llvm] [clang-tools-extra] [lldb] [flang] [clang] [libunwind] [libcxx] [lld] [libc] [compiler-rt] Fix a bug in Smith's algorithm used in complex div. (PR #78330)

2024-01-22 Thread Aaron Ballman via lldb-commits

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

LGTM!

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


[Lldb-commits] [libcxxabi] [llvm] [clang-tools-extra] [lldb] [flang] [clang] [libunwind] [libcxx] [lld] [libc] [compiler-rt] Fix a bug in Smith's algorithm used in complex div. (PR #78330)

2024-01-22 Thread Zahira Ammarguellat via lldb-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/78330

>From 8f8917528e30d2ba67f669cfd1a893bc85c21121 Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Tue, 16 Jan 2024 11:24:03 -0800
Subject: [PATCH 1/6] Fixed a bug in Smith's algorithm and made sure last
 option in command line rules.

---
 clang/lib/CodeGen/CGExprComplex.cpp   |  8 ++--
 clang/lib/Driver/ToolChains/Clang.cpp | 19 ++-
 clang/test/CodeGen/cx-complex-range.c | 16 
 clang/test/Driver/range.c |  7 +++
 4 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index e532794b71bdb4..6fbd8f19eeb50a 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -936,7 +936,7 @@ ComplexPairTy 
ComplexExprEmitter::EmitRangeReductionDiv(llvm::Value *LHSr,
   llvm::Value *RC = Builder.CreateFMul(CdD, RHSr);  // rc
   llvm::Value *DpRC = Builder.CreateFAdd(RHSi, RC); // tmp=d+rc
 
-  llvm::Value *T7 = Builder.CreateFMul(LHSr, RC);// ar
+  llvm::Value *T7 = Builder.CreateFMul(LHSr, CdD);   // ar
   llvm::Value *T8 = Builder.CreateFAdd(T7, LHSi);// ar+b
   llvm::Value *DSTFr = Builder.CreateFDiv(T8, DpRC); // (ar+b)/tmp
 
@@ -978,7 +978,11 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const 
BinOpInfo &Op) {
   return EmitRangeReductionDiv(LHSr, LHSi, RHSr, RHSi);
 else if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Limited)
   return EmitAlgebraicDiv(LHSr, LHSi, RHSr, RHSi);
-else if (!CGF.getLangOpts().FastMath) {
+else if (!CGF.getLangOpts().FastMath ||
+ // '-ffast-math' is used in the command line but followed by an
+ // '-fno-cx-limited-range'.
+ (CGF.getLangOpts().FastMath &&
+  Op.FPFeatures.getComplexRange() == LangOptions::CX_Full)) {
   LHSi = OrigLHSi;
   // If we have a complex operand on the RHS and FastMath is not allowed, 
we
   // delegate to a libcall to handle all of the complexities and minimize
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9edae3fec91a87..0c05d1db396071 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2753,6 +2753,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   StringRef Float16ExcessPrecision = "";
   StringRef BFloat16ExcessPrecision = "";
   LangOptions::ComplexRangeKind Range = LangOptions::ComplexRangeKind::CX_Full;
+  std::string ComplexRangeStr = "";
 
   if (const Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
 CmdArgs.push_back("-mlimit-float-precision");
@@ -2768,24 +2769,24 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 case options::OPT_fcx_limited_range: {
   EmitComplexRangeDiag(D, Range, 
LangOptions::ComplexRangeKind::CX_Limited);
   Range = LangOptions::ComplexRangeKind::CX_Limited;
-  std::string ComplexRangeStr = RenderComplexRangeOption("limited");
-  if (!ComplexRangeStr.empty())
-CmdArgs.push_back(Args.MakeArgString(ComplexRangeStr));
+  ComplexRangeStr = RenderComplexRangeOption("limited");
   break;
 }
 case options::OPT_fno_cx_limited_range:
+  EmitComplexRangeDiag(D, Range, LangOptions::ComplexRangeKind::CX_Full);
   Range = LangOptions::ComplexRangeKind::CX_Full;
+  ComplexRangeStr = RenderComplexRangeOption("full");
   break;
 case options::OPT_fcx_fortran_rules: {
   EmitComplexRangeDiag(D, Range, 
LangOptions::ComplexRangeKind::CX_Fortran);
   Range = LangOptions::ComplexRangeKind::CX_Fortran;
-  std::string ComplexRangeStr = RenderComplexRangeOption("fortran");
-  if (!ComplexRangeStr.empty())
-CmdArgs.push_back(Args.MakeArgString(ComplexRangeStr));
+  ComplexRangeStr = RenderComplexRangeOption("fortran");
   break;
 }
 case options::OPT_fno_cx_fortran_rules:
+  EmitComplexRangeDiag(D, Range, LangOptions::ComplexRangeKind::CX_Full);
   Range = LangOptions::ComplexRangeKind::CX_Full;
+  ComplexRangeStr = RenderComplexRangeOption("full");
   break;
 case options::OPT_ffp_model_EQ: {
   // If -ffp-model= is seen, reset to fno-fast-math
@@ -3056,9 +3057,7 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
   SeenUnsafeMathModeOption = true;
   // ffast-math enables fortran rules for complex multiplication and
   // division.
-  std::string ComplexRangeStr = RenderComplexRangeOption("limited");
-  if (!ComplexRangeStr.empty())
-CmdArgs.push_back(Args.MakeArgString(ComplexRangeStr));
+  ComplexRangeStr = RenderComplexRangeOption("limited");
   break;
 }
 case options::OPT_fno_fast_math:
@@ -3215,6 +3214,8 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
optio

[Lldb-commits] [flang] [lld] [clang-tools-extra] [compiler-rt] [llvm] [libcxx] [lldb] [libc] [clang] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mariusz Sikora via lldb-commits

mariusz-sikora-at-amd wrote:

> > Correct, some of these instructions use opsel[1] which in LLVM in stored in 
> > src1_modifiers so a dummy src1 is used.
> 
> Why can't we just use `SRCMODS.OP_SEL_1` with src0?

When referring to `SRCMODS.OP_SEL_1` you are referring to `src1_modifier` 
(second bit in `OPSEL`) or you are referring to `OPSEL_HI` ?

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


[Lldb-commits] [libcxx] [compiler-rt] [llvm] [lld] [libcxxabi] [libc] [flang] [lldb] [clang-tools-extra] [libclc] [clang] [VPlan] Add new VPUniformPerUFRecipe, use for step truncation. (PR #78113)

2024-01-22 Thread Florian Hahn via lldb-commits

https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/78113

>From 36b085f21b76d7bf7c9965a86a09d1cef4fe9329 Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Sun, 14 Jan 2024 14:13:08 +
Subject: [PATCH 1/4] [VPlan] Add new VPUniformPerUFRecipe, use for step
 truncation.

Add a new recipe to model uniform-per-UF instructions, without relying
on an underlying instruction. Initially, it supports uniform cast-ops
and is therefore storing the result type.

Not relying on an underlying instruction (like the current
VPReplicateRecipe) allows to create instances without a corresponding
instruction.

In the future, to plan is to extend this recipe to handle all opcodes
needed to replace the uniform part of VPReplicateRecipe.
---
 llvm/lib/Transforms/Vectorize/VPlan.h | 30 
 .../Transforms/Vectorize/VPlanAnalysis.cpp|  6 ++-
 .../lib/Transforms/Vectorize/VPlanRecipes.cpp | 49 ---
 .../Transforms/Vectorize/VPlanTransforms.cpp  |  9 
 llvm/lib/Transforms/Vectorize/VPlanValue.h|  1 +
 .../LoopVectorize/cast-induction.ll   |  4 +-
 .../interleave-and-scalarize-only.ll  |  3 +-
 .../pr46525-expander-insertpoint.ll   |  2 +-
 8 files changed, 93 insertions(+), 11 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h 
b/llvm/lib/Transforms/Vectorize/VPlan.h
index 4b4f4911eb6415..d598522448 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1945,6 +1945,36 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags, 
public VPValue {
   }
 };
 
+/// VPUniformPerUFRecipe represents an instruction with Opcode that is uniform
+/// per UF, i.e. it generates a single scalar instance per UF.
+/// TODO: at the moment, only Cast opcodes are supported, extend to support
+///   missing opcodes to replace uniform part of VPReplicateRecipe.
+class VPUniformPerUFRecipe : public VPRecipeBase, public VPValue {
+  unsigned Opcode;
+
+  /// Result type for the cast.
+  Type *ResultTy;
+
+  Value *generate(VPTransformState &State, unsigned Part);
+
+public:
+  VPUniformPerUFRecipe(Instruction::CastOps Opcode, VPValue *Op, Type 
*ResultTy)
+  : VPRecipeBase(VPDef::VPUniformPerUFSC, {Op}), VPValue(this),
+Opcode(Opcode), ResultTy(ResultTy) {}
+
+  ~VPUniformPerUFRecipe() override = default;
+
+  VP_CLASSOF_IMPL(VPDef::VPWidenIntOrFpInductionSC)
+
+  void execute(VPTransformState &State) override;
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+  /// Print the recipe.
+  void print(raw_ostream &O, const Twine &Indent,
+ VPSlotTracker &SlotTracker) const override;
+#endif
+};
+
 /// A recipe for generating conditional branches on the bits of a mask.
 class VPBranchOnMaskRecipe : public VPRecipeBase {
 public:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp 
b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
index 97a8a1803bbf5a..d71b0703994450 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
@@ -230,7 +230,11 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
 return V->getUnderlyingValue()->getType();
   })
   .Case(
-  [](const VPWidenCastRecipe *R) { return R->getResultType(); });
+  [](const VPWidenCastRecipe *R) { return R->getResultType(); })
+  .Case([](const VPExpandSCEVRecipe *R) {
+return R->getSCEV()->getType();
+  });
+
   assert(ResultTy && "could not infer type for the given VPValue");
   CachedTypes[V] = ResultTy;
   return ResultTy;
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp 
b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 1f844bce23102e..423504e8f7e05e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -164,6 +164,8 @@ bool VPRecipeBase::mayHaveSideEffects() const {
 auto *R = cast(this);
 return R->getUnderlyingInstr()->mayHaveSideEffects();
   }
+  case VPUniformPerUFSC:
+return false;
   default:
 return true;
   }
@@ -1117,13 +1119,7 @@ void VPScalarIVStepsRecipe::execute(VPTransformState 
&State) {
 
   // Ensure step has the same type as that of scalar IV.
   Type *BaseIVTy = BaseIV->getType()->getScalarType();
-  if (BaseIVTy != Step->getType()) {
-// TODO: Also use VPDerivedIVRecipe when only the step needs truncating, to
-// avoid separate truncate here.
-assert(Step->getType()->isIntegerTy() &&
-   "Truncation requires an integer step");
-Step = State.Builder.CreateTrunc(Step, BaseIVTy);
-  }
+  assert(BaseIVTy == Step->getType());
 
   // We build scalar steps for both integer and floating-point induction
   // variables. Here, we determine the kind of arithmetic we will perform.
@@ -1469,6 +1465,45 @@ void VPReplicateRecipe::print(raw_ostream &O, const 
Twine &Indent,
 }
 #endif
 
+Value *VPUniformPerUFRecipe ::generate(VPTransformState 

[Lldb-commits] [llvm] [libc] [clang] [lldb] [libcxx] [mlir] [openmp] [compiler-rt] [lld] [clang-tools-extra] [flang] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-22 Thread Petr Hosek via lldb-commits

petrhosek wrote:

This is still broken so I'm going to revert the change.

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


[libc] [llvm] [clang] [lldb] [libcxx] [compiler-rt] [lld] [clang-tools-extra] [flang] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Mirko Brkušanin via lldb-commits


@@ -305,6 +305,11 @@ class VOP3OpSel_gfx10 op, VOPProfile p> : 
VOP3e_gfx10 {
 
 class VOP3OpSel_gfx11_gfx12 op, VOPProfile p> : VOP3OpSel_gfx10;
 
+class VOP3FP8OpSel_gfx11_gfx12 op, VOPProfile p> : VOP3e_gfx10 
{
+  let Inst{11} = !if(p.HasSrc0, src0_modifiers{2}, 0);
+  let Inst{12} = !if(p.HasSrc0, src0_modifiers{3}, 0);

mbrkusanin wrote:

@kosarev Is this what you had in mind? This uses OP_SEL_1 from src0_modifiers 
as opsel[1] so we can avoid using src1/src1_modifiers.

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


[Lldb-commits] [compiler-rt] [lldb] [libc] [libcxx] [flang] [libcxxabi] [clang] [libclc] [lld] [mlir] [clang-tools-extra] [llvm] [ELF] Add internal InputFile (PR #78944)

2024-01-22 Thread Fangrui Song via lldb-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/78944

>From a72bbb3ae04c7be90af36d2cd025329d4ef2ab16 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Sun, 21 Jan 2024 22:18:48 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 lld/ELF/Arch/ARM.cpp  |  6 ++--
 lld/ELF/Arch/Mips.cpp |  7 ++---
 lld/ELF/Arch/PPC64.cpp|  2 +-
 lld/ELF/Config.h  |  1 +
 lld/ELF/Driver.cpp|  6 +++-
 lld/ELF/InputFiles.cpp|  4 +++
 lld/ELF/InputFiles.h  |  7 +++--
 lld/ELF/InputSection.cpp  |  4 ++-
 lld/ELF/InputSection.h|  3 +-
 lld/ELF/LTO.cpp   |  6 ++--
 lld/ELF/LinkerScript.cpp  |  8 ++---
 lld/ELF/Relocations.cpp   |  2 +-
 lld/ELF/ScriptLexer.h |  4 +--
 lld/ELF/ScriptParser.cpp  |  3 +-
 lld/ELF/SyntheticSections.cpp |  4 +--
 lld/ELF/Target.cpp|  2 +-
 lld/ELF/Writer.cpp| 31 ++-
 lld/test/ELF/cref.s   | 11 ++-
 .../ELF/linkerscript/symbol-ordering-file2.s  |  5 +--
 lld/test/ELF/x86-64-gotpc-no-relax-err.s  |  3 ++
 20 files changed, 74 insertions(+), 45 deletions(-)

diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp
index d34e74a11c6d8d8..687f9499009d5eb 100644
--- a/lld/ELF/Arch/ARM.cpp
+++ b/lld/ELF/Arch/ARM.cpp
@@ -1381,9 +1381,9 @@ template  void 
elf::writeARMCmseImportLib() {
   // Copy the secure gateway entry symbols to the import library symbol table.
   for (auto &p : symtab.cmseSymMap) {
 Defined *d = cast(p.second.sym);
-impSymTab->addSymbol(makeDefined(nullptr, d->getName(), 
d->computeBinding(),
- /*stOther=*/0, STT_FUNC, d->getVA(),
- d->getSize(), nullptr));
+impSymTab->addSymbol(makeDefined(
+ctx.internalFile, d->getName(), d->computeBinding(),
+/*stOther=*/0, STT_FUNC, d->getVA(), d->getSize(), nullptr));
   }
 
   size_t idx = 0;
diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp
index d6c70aeba95dd44..b02ad10649d901d 100644
--- a/lld/ELF/Arch/Mips.cpp
+++ b/lld/ELF/Arch/Mips.cpp
@@ -771,12 +771,11 @@ template  bool elf::isMipsPIC(const Defined 
*sym) {
   if (!sym->section)
 return false;
 
-  ObjFile *file =
-  cast(sym->section)->template getFile();
-  if (!file)
+  InputFile *file = cast(sym->section)->file;
+  if (!file || file->isInternal())
 return false;
 
-  return file->getObj().getHeader().e_flags & EF_MIPS_PIC;
+  return cast>(file)->getObj().getHeader().e_flags & EF_MIPS_PIC;
 }
 
 template  TargetInfo *elf::getMipsTargetInfo() {
diff --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp
index 097a57514770aaf..de52f6a79a40b99 100644
--- a/lld/ELF/Arch/PPC64.cpp
+++ b/lld/ELF/Arch/PPC64.cpp
@@ -253,7 +253,7 @@ static bool addOptional(StringRef name, uint64_t value,
   Symbol *sym = symtab.find(name);
   if (!sym || sym->isDefined())
 return false;
-  sym->resolve(Defined{/*file=*/nullptr, StringRef(), STB_GLOBAL, STV_HIDDEN,
+  sym->resolve(Defined{ctx.internalFile, StringRef(), STB_GLOBAL, STV_HIDDEN,
STT_FUNC, value,
/*size=*/0, /*section=*/nullptr});
   defined.push_back(cast(sym));
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index 56229334f9a44ae..ab15701d9b57898 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -473,6 +473,7 @@ struct Ctx {
  std::pair>
   backwardReferences;
   llvm::SmallSet auxiliaryFiles;
+  InputFile *internalFile;
   // True if SHT_LLVM_SYMPART is used.
   std::atomic hasSympart{false};
   // True if there are TLS IE relocations. Set DF_STATIC_TLS if -shared.
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index b988f4311e61b83..62e1c29504ba26c 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -105,6 +105,7 @@ void Ctx::reset() {
   whyExtractRecords.clear();
   backwardReferences.clear();
   auxiliaryFiles.clear();
+  internalFile = nullptr;
   hasSympart.store(false, std::memory_order_relaxed);
   hasTlsIe.store(false, std::memory_order_relaxed);
   needsTlsLd.store(false, std::memory_order_relaxed);
@@ -2337,7 +2338,8 @@ static void readSymbolPartitionSection(InputSectionBase 
*s) {
 
 static Symbol *addUnusedUndefined(StringRef name,
   uint8_t binding = STB_GLOBAL) {
-  return symtab.addSymbol(Undefined{nullptr, name, binding, STV_DEFAULT, 0});
+  return symtab.addSymbol(
+  Undefined{ctx.internalFile, name, binding, STV_DEFAULT, 0});
 }
 
 static 

[Lldb-commits] [lldb] [lldb-dap] Add a CMake variable for defining a welcome message (PR #78811)

2024-01-22 Thread Walter Erquinigo via lldb-commits


@@ -655,6 +663,8 @@ void request_attach(const llvm::json::Object &request) {
   g_dap.SetFrameFormat(GetString(arguments, "customFrameFormat"));
   g_dap.SetThreadFormat(GetString(arguments, "customThreadFormat"));
 
+  PrintWelcomeMessage();

walter-erquinigo wrote:

Yes, it's defined in both places

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


[Lldb-commits] [lldb] [lldb-dap] Add a CMake variable for defining a welcome message (PR #78811)

2024-01-22 Thread Walter Erquinigo via lldb-commits


@@ -664,7 +674,7 @@ void request_attach(const llvm::json::Object &request) {
 
   // Run any initialize LLDB commands the user specified in the launch.json
   if (llvm::Error err = g_dap.RunInitCommands()) {
-response["success"] = false;
+ response["success"] = false;

walter-erquinigo wrote:

Thanks, man!

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


[Lldb-commits] [compiler-rt] [lldb] [libc] [libcxx] [flang] [libcxxabi] [clang] [libclc] [lld] [mlir] [clang-tools-extra] [llvm] [ELF] Add internal InputFile (PR #78944)

2024-01-22 Thread Fangrui Song via lldb-commits

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


[Lldb-commits] [clang] [libcxx] [libc] [lld] [llvm] [flang] [clang-tools-extra] [lldb] [compiler-rt] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Ivan Kosarev via lldb-commits
Mirko =?utf-8?q?Brkušanin?= 
Message-ID:
In-Reply-To: 



@@ -305,6 +305,11 @@ class VOP3OpSel_gfx10 op, VOPProfile p> : 
VOP3e_gfx10 {
 
 class VOP3OpSel_gfx11_gfx12 op, VOPProfile p> : VOP3OpSel_gfx10;
 
+class VOP3FP8OpSel_gfx11_gfx12 op, VOPProfile p> : VOP3e_gfx10 
{
+  let Inst{11} = !if(p.HasSrc0, src0_modifiers{2}, 0);
+  let Inst{12} = !if(p.HasSrc0, src0_modifiers{3}, 0);

kosarev wrote:

Yes, thanks Mirko. Can we also avoid adding the other dummy operands in 
`cvtVOP3DPP()` and `cvtDPP()`?

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


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

2024-01-22 Thread via lldb-commits

jimingham wrote:

Not sure what you mean by this.  "frame var" and "target var" are the lldb 
command line commands for viewing local and global variables respectively.  Why 
are these not appropriate for Wasm?

Jim


> On Jan 22, 2024, at 6:37 AM, Quentin Michaud ***@***.***> wrote:
> 
> 
> Seems like support for reading Wasm local and global variables is available 
> in your code, but I don't understand how can one effectively read these 
> variables from the lldb command line. Maybe adding commands to access these 
> can be useful ?
> 
> —
> Reply to this email directly, view it on GitHub 
> , or 
> unsubscribe 
> .
> You are receiving this because you are on a team that was mentioned.
> 



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


[Lldb-commits] [clang] [flang] [clang-tools-extra] [libcxx] [llvm] [lldb] [lld] [libc] [compiler-rt] [lld-macho] Find objects in library search path (PR #78628)

2024-01-22 Thread via lldb-commits


@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: mkdir -p %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s 
-o %t/hello.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
+# RUN: %lld -L %t %t/main.o %t/hello.o -o %t/a.out

OldWorldOrdr wrote:

> would you mind putting it in another PR? we can get it merged there. Thanks!

done https://github.com/llvm/llvm-project/pull/79018

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


[Lldb-commits] [lldb] [lldb][libc++] Adds system_clock data formatters. (PR #78609)

2024-01-22 Thread Michael Buch via lldb-commits


@@ -1073,18 +1073,79 @@ bool 
lldb_private::formatters::LibcxxWStringViewSummaryProvider(
   bool success;
   ValueObjectSP dataobj;
   size_t size;
-  std::tie( success, dataobj, size ) = LibcxxExtractStringViewData(valobj);
+  std::tie(success, dataobj, size) = LibcxxExtractStringViewData(valobj);
 
   if (!success) {
 stream << "Summary Unavailable";
 return true;
   }
 
-
   return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
 dataobj, size);
 }
 
+bool lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_");
+  if (!ptr_sp)
+return false;
+  ptr_sp = ptr_sp->GetChildMemberWithName("__rep_");
+  if (!ptr_sp)
+return false;
+
+  // The date time in the chrono library is valid in the range
+  // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a
+  // larger range, the function strftime is not able to format the entire range
+  // of time_t. The exact point has not been investigated; it's limited to
+  // chrono's range.
+  const std::time_t chrono_timestamp_min =
+  -1'096'193'779'200; // -32767-01-01T00:00:00Z
+  const std::time_t chrono_timestamp_max =
+  971'890'963'199; // 32767-12-31T23:59:59Z
+
+  const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
+  if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
+stream.Printf("timestamp=%ld s", seconds);
+  else {
+std::array str;
+std::strftime(str.data(), str.size(), "%FT%H:%M:%SZ", gmtime(&seconds));
+stream.Printf("date/time=%s timestamp=%ld s", str.data(), seconds);
+  }
+
+  return true;
+}
+
+bool lldb_private::formatters::LibcxxChronoSysDaysSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_");
+  if (!ptr_sp)
+return false;
+  ptr_sp = ptr_sp->GetChildMemberWithName("__rep_");
+  if (!ptr_sp)
+return false;
+
+  // The date time in the chrono library is valid in the range
+  // [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the
+  // function strftime is not able to format the entire range of time_t. The
+  // exact point has not been investigated; it's limited to chrono's range.
+  const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z
+  const int chrono_timestamp_max = 11'248'737;  // 32767-12-31Z
+
+  const int days = ptr_sp->GetValueAsSigned(0);
+  if (days < chrono_timestamp_min || days > chrono_timestamp_max)
+stream.Printf("timestamp=%d days", days);
+
+  else {
+const std::time_t seconds = std::time_t(86400) * days;
+
+std::array str;
+std::strftime(str.data(), str.size(), "%FZ", gmtime(&seconds));

Michael137 wrote:

is it worth checking the return of `strftime` here?

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


[Lldb-commits] [lldb] [lldb][libc++] Adds system_clock data formatters. (PR #78609)

2024-01-22 Thread Michael Buch via lldb-commits


@@ -32,6 +32,106 @@ def test_with_run_command(self):
 self.expect("frame variable m", substrs=["m = 4321 months"])
 self.expect("frame variable y", substrs=["y = 321 years"])
 
+self.expect(
+"frame variable ss_tp",
+substrs=["ss_tp = date/time=1970-01-01T00:00:00Z timestamp=0 s"],
+)
+self.expect(
+"frame variable ss_tp_d",
+substrs=["ss_tp_d = date/time=1970-01-01T00:00:00Z timestamp=0 s"],
+)
+self.expect(
+"frame variable ss_tp_d_r",
+substrs=["ss_tp_d_r = date/time=1970-01-01T00:00:00Z timestamp=0 
s"],
+)
+self.expect(
+"frame variable ss_tp_d_r2",
+substrs=["ss_tp_d_r2 = date/time=1970-01-01T00:00:00Z timestamp=0 
s"],
+)
+
+self.expect(
+"frame variable ss_0",
+substrs=["ss_0 = date/time=1970-01-01T00:00:00Z timestamp=0 s"],
+)
+
+self.expect(
+"frame variable ss_neg_date_time",
+substrs=[
+"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z 
timestamp=-1096193779200 s"
+],
+)
+self.expect(
+"frame variable ss_neg_seconds",
+substrs=["ss_neg_seconds = timestamp=-1096193779201 s"],
+)
+
+self.expect(
+"frame variable ss_pos_date_time",
+substrs=[
+"ss_pos_date_time = date/time=32767-12-31T23:59:59Z 
timestamp=971890963199 s"
+],
+)
+self.expect(
+"frame variable ss_pos_seconds",
+substrs=["ss_pos_seconds = timestamp=971890963200 s"],
+)
+
+self.expect(
+"frame variable ss_min",
+substrs=["ss_min = timestamp=-9223372036854775808 s"],
+)
+self.expect(
+"frame variable ss_max",
+substrs=["ss_max = timestamp=9223372036854775807 s"],
+)
+
+self.expect(
+"frame variable sd_tp",
+substrs=["sd_tp = date=1970-01-01Z timestamp=0 days"],
+)
+self.expect(
+"frame variable sd_tp_d_r",
+substrs=["sd_tp_d_r = date=1970-01-01Z timestamp=0 days"],
+)
+self.expect(
+"frame variable sd_tp_d_r2",
+substrs=["sd_tp_d_r2 = date=1970-01-01Z timestamp=0 days"],
+)
+
+self.expect(
+"frame variable sd_0", substrs=["sd_0 = date=1970-01-01Z 
timestamp=0 days"]
+)
+self.expect(
+"frame variable sd_neg_date",
+substrs=["sd_neg_date = date=-32767-01-01Z timestamp=-12687428 
days"],
+)
+self.expect(
+"frame variable sd_neg_days",
+substrs=["sd_neg_days = timestamp=-12687429 days"],
+)
+
+self.expect(
+"frame variable sd_pos_date",
+substrs=["sd_pos_date = date=32767-12-31Z timestamp=11248737 
days"],
+)
+self.expect(
+"frame variable sd_pos_days",
+substrs=["sd_pos_days = timestamp=11248738 days"],
+)
+
+self.expect(
+"frame variable sd_min",
+substrs=["sd_min = timestamp=-2147483648 days"],
+)
+self.expect(
+"frame variable sd_max",
+substrs=["sd_max = timestamp=2147483647 days"],
+)
+
+# self.expect("frame variable sd_min", substrs=["sd_min = 
date=1970-01-01Z timestamp=0 days"])

Michael137 wrote:

Why are these commented?

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


[Lldb-commits] [lldb] [lldb][libc++] Adds system_clock data formatters. (PR #78609)

2024-01-22 Thread Michael Buch via lldb-commits

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

LGTM (with minor questions)

https://github.com/llvm/llvm-project/pull/78609
___
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)

2024-01-22 Thread Kevin Frei via lldb-commits

kevinfrei wrote:

Sure. That's probably the solution. I just can't get a reliable repro, so I can 
only validate that it doesn't break the mainstream monorepo build. I'm happy to 
shepherd any diff you've indicated can tell me it's fixed on your configuration.

I truly appreciate the different worlds, here. You toss out "install a 
particular build of gentoo, which you've probably never done" while complaining 
about having to clone a repo I have on 5 different machines 🤣 

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] 0cea54a - [lldb][NFCI] Remove EventData* param from BroadcastEvent (#78773)

2024-01-22 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-22T10:46:20-08:00
New Revision: 0cea54a382f3187acbe3e81bd0fd7cf2cb1077b8

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

LOG: [lldb][NFCI] Remove EventData* param from BroadcastEvent (#78773)

BroadcastEvent currently takes its EventData* param and shoves it into
an Event object, which takes ownership of the pointer and places it into
a shared_ptr to manage the lifetime.

Instead of relying on `new` and passing raw pointers around, I think it
would make more sense to create the shared_ptr up front.

Added: 


Modified: 
lldb/include/lldb/Breakpoint/Watchpoint.h
lldb/include/lldb/Utility/Broadcaster.h
lldb/source/Breakpoint/BreakpointList.cpp
lldb/source/Breakpoint/BreakpointLocation.cpp
lldb/source/Breakpoint/Watchpoint.cpp
lldb/source/Breakpoint/WatchpointList.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Process.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/Thread.cpp
lldb/source/Target/ThreadList.cpp
lldb/source/Utility/Broadcaster.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/Watchpoint.h 
b/lldb/include/lldb/Breakpoint/Watchpoint.h
index 851162af24c74e..22fdfd686c3f11 100644
--- a/lldb/include/lldb/Breakpoint/Watchpoint.h
+++ b/lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -235,8 +235,6 @@ class Watchpoint : public 
std::enable_shared_from_this,
 
   void SendWatchpointChangedEvent(lldb::WatchpointEventType eventKind);
 
-  void SendWatchpointChangedEvent(WatchpointEventData *data);
-
   Watchpoint(const Watchpoint &) = delete;
   const Watchpoint &operator=(const Watchpoint &) = delete;
 };

diff  --git a/lldb/include/lldb/Utility/Broadcaster.h 
b/lldb/include/lldb/Utility/Broadcaster.h
index 8444c38f6ecc65..c8127f0a921d88 100644
--- a/lldb/include/lldb/Utility/Broadcaster.h
+++ b/lldb/include/lldb/Utility/Broadcaster.h
@@ -177,8 +177,8 @@ class Broadcaster {
 m_broadcaster_sp->BroadcastEvent(event_type, event_data_sp);
   }
 
-  void BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr) {
-m_broadcaster_sp->BroadcastEvent(event_type, event_data);
+  void BroadcastEvent(uint32_t event_type) {
+m_broadcaster_sp->BroadcastEvent(event_type);
   }
 
   void BroadcastEventIfUnique(uint32_t event_type,
@@ -346,7 +346,7 @@ class Broadcaster {
 
 void BroadcastEventIfUnique(lldb::EventSP &event_sp);
 
-void BroadcastEvent(uint32_t event_type, EventData *event_data = nullptr);
+void BroadcastEvent(uint32_t event_type);
 
 void BroadcastEvent(uint32_t event_type,
 const lldb::EventDataSP &event_data_sp);

diff  --git a/lldb/source/Breakpoint/BreakpointList.cpp 
b/lldb/source/Breakpoint/BreakpointList.cpp
index f7c2cdb938e62a..2c47b3b1263c65 100644
--- a/lldb/source/Breakpoint/BreakpointList.cpp
+++ b/lldb/source/Breakpoint/BreakpointList.cpp
@@ -17,9 +17,12 @@ using namespace lldb_private;
 
 static void NotifyChange(const BreakpointSP &bp, BreakpointEventType event) {
   Target &target = bp->GetTarget();
-  if (target.EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged))
+  if (target.EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) {
+auto event_data_sp =
+std::make_shared(event, bp);
 target.BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
-  new Breakpoint::BreakpointEventData(event, bp));
+  event_data_sp);
+  }
 }
 
 BreakpointList::BreakpointList(bool is_internal)

diff  --git a/lldb/source/Breakpoint/BreakpointLocation.cpp 
b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 99f94d04bb3184..98de059c2e2967 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -649,11 +649,11 @@ void 
BreakpointLocation::SendBreakpointLocationChangedEvent(
   if (!m_being_created && !m_owner.IsInternal() &&
   m_owner.GetTarget().EventTypeHasListeners(
   Target::eBroadcastBitBreakpointChanged)) {
-Breakpoint::BreakpointEventData *data = new 
Breakpoint::BreakpointEventData(
+auto data_sp = std::make_shared(
 eventKind, m_owner.shared_from_this());
-data->GetBreakpointLocationCollection().Add(shared_from_this());
+data_sp->GetBreakpointLocationCollection().Add(shared_from_this());
 m_owner.GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
-   data);
+   data_sp);
   }
 }
 

diff  --git a/lldb/source/Breakpoint/Watchpoint.cpp 
b/lldb/source/Breakpoint/Watchpoint.cpp
index 4602ce4213b9cd..1a8ef87c1e67a3 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -462,26 +462

[Lldb-commits] [lldb] [lldb][NFCI] Remove EventData* param from BroadcastEvent (PR #78773)

2024-01-22 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [libcxxabi] [clang] [lld] [lldb] [flang] [libunwind] [compiler-rt] [libc] [libcxx] [llvm] [clang-tools-extra] Fix a bug in Smith's algorithm used in complex div. (PR #78330)

2024-01-22 Thread Andy Kaylor via lldb-commits

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

lgtm

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


[Lldb-commits] [clang] [libcxxabi] [lldb] [libcxx] [libc] [llvm] [clang-tools-extra] [libc++] Fix the behavior of throwing `operator new` under -fno-exceptions (PR #69498)

2024-01-22 Thread Louis Dionne via lldb-commits

https://github.com/ldionne updated 
https://github.com/llvm/llvm-project/pull/69498

>From 6f89b118ed56ad7a3af1996e19ccd30cc893c51e Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Wed, 14 Jun 2023 17:49:22 -0700
Subject: [PATCH 1/8] [libc++] Fix the behavior of throwing `operator new`
 under -fno-exceptions

In D144319, Clang tried to land a change that would cause some functions
that are not supposed to return nullptr to optimize better. As reported
in https://reviews.llvm.org/D144319#4203982, libc++ started seeing failures
in its CI shortly after this change was landed.

As explained in D146379, the reason for these failures is that libc++'s
throwing `operator new` can in fact return nullptr when compiled with
exceptions disabled. However, this contradicts the Standard, which
clearly says that the throwing version of `operator new(size_t)`
should never return nullptr. This is actually a long standing issue.
I've previously seen a case where LTO would optimize incorrectly based
on the assumption that `operator new` doesn't return nullptr, an
assumption that was violated in that case because libc++.dylib was
compiled with -fno-exceptions.

Unfortunately, fixing this is kind of tricky. The Standard has a few
requirements for the allocation functions, some of which are impossible
to satisfy under -fno-exceptions:
1. `operator new(size_t)` must never return nullptr
2. `operator new(size_t, nothrow_t)` must call the throwing version
 and return nullptr on failure to allocate
3. We can't throw exceptions when compiled with -fno-exceptions

In the case where exceptions are enabled, things work nicely. `new(size_t)`
throws and `new(size_t, nothrow_t)` uses a try-catch to return nullptr.
However, when compiling the library with -fno-exceptions, we can't throw
an exception from `new(size_t)`, and we can't catch anything from
`new(size_t, nothrow_t)`. The only thing we can do from `new(size_t)`
is actually abort the program, which does not make it possible for
`new(size_t, nothrow_t)` to catch something and return nullptr.

This patch makes the following changes:
1. When compiled with -fno-exceptions, the throwing version of
   `operator new` will now abort on failure instead of returning
   nullptr on failure. This resolves the issue that the compiler
   could mis-compile based on the assumption that nullptr is never
   returned. This constitutes an API and ABI breaking change for
   folks compiling the library with -fno-exceptions (which is not
   the general public, who merely uses libc++ headers but use a
   shared library that has already been compiled). This should mostly
   impact vendors and other folks who compile libc++.dylib themselves.

2. When the library is compiled with -fexceptions, the nothrow version
   of `operator new` has no change. When the library is compiled with
   -fno-exceptions, the nothrow version of `operator new` will now check
   whether the throwing version of `operator new` has been overridden.
   If it has not been overridden, then it will use an implementation
   equivalent to that of the throwing `operator new`, except it will
   return nullptr on failure to allocate (instead of terminating).
   However, if the throwing `operator new` has been overridden, it is
   now an error NOT to also override the nothrow `operator new`. Indeed,
   there is no way for us to implement a valid nothrow `operator new`
   without knowing the exact implementation of the throwing version.

rdar://103958777

Differential Revision: https://reviews.llvm.org/D150610
---
 libcxx/docs/ReleaseNotes/18.rst   |  23 +++
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__overridable_function | 119 +
 libcxx/src/new.cpp|  99 ---
 ...new_not_overridden_fno_exceptions.pass.cpp |  59 ++
 .../new_dont_return_nullptr.pass.cpp  |  37 
 libcxx/test/support/check_assertion.h |   6 +
 libcxx/utils/generate_iwyu_mapping.py |   2 +
 libcxxabi/src/stdlib_new_delete.cpp   | 168 +++---
 9 files changed, 426 insertions(+), 88 deletions(-)
 create mode 100644 libcxx/include/__overridable_function
 create mode 100644 
libcxx/test/libcxx/language.support/support.dynamic/assert.nothrow_new_not_overridden_fno_exceptions.pass.cpp
 create mode 100644 
libcxx/test/libcxx/language.support/support.dynamic/new_dont_return_nullptr.pass.cpp

diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 9e509db6359c4aa..405f1e172893bc1 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -142,6 +142,29 @@ LLVM 20
 ABI Affecting Changes
 -
 
+- When the shared/static library is built with ``-fno-exceptions``, the 
behavior of ``operator new`` was changed
+  to make it standards-conforming. In LLVM 17 and before, the throwing 
versions of ``operator new`` would return
+  ``nullptr`` upon failure to allocate, when the sh

[Lldb-commits] [lldb] 6d5f8d3 - Added settings for DEBUGINFOD cache location and timeout (#78605)

2024-01-22 Thread via lldb-commits

Author: Kevin Frei
Date: 2024-01-22T11:09:48-08:00
New Revision: 6d5f8d3e6e473a6890f232dba8b14b7b46140558

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

LOG: Added settings for DEBUGINFOD cache location and timeout (#78605)

I've been working on more/better configuration for improving DEBUGINFOD
support. This is the first (and easiest) slice of the work.

I've added `timeout` and `cache-path` settings that can override the
DEBUGINFOD library defaults (and environment variables.) I also renamed
the `plugin.symbol-locator.debuginfod.server_urls` setting to
`server-urls` to be more consistent with the rest of LLDB's settings
(the underscore switch is switched to a hyphen)

I've got a few tests that validate the cache-path setting (as a
side-effect), but they've exposed a few bugs that I'll be putting up a
separate PR for (which will include the tests).

-

Co-authored-by: Kevin Frei 

Added: 


Modified: 
lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp

lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfodProperties.td
llvm/include/llvm/Debuginfod/Debuginfod.h
llvm/lib/Debuginfod/Debuginfod.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp 
b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 111be6be365240e..2cd72449028 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -9,7 +9,10 @@
 #include "SymbolLocatorDebuginfod.h"
 
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueString.h"
 #include "lldb/Utility/Args.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
 
 #include "llvm/Debuginfod/Debuginfod.h"
 #include "llvm/Debuginfod/HTTPClient.h"
@@ -54,6 +57,32 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {
+OptionValueString *s =
+m_collection_sp->GetPropertyAtIndexAsOptionValueString(
+ePropertySymbolCachePath);
+// If we don't have a valid cache location, use the default one.
+if (!s || !s->GetCurrentValueAsRef().size()) {
+  llvm::Expected maybeCachePath =
+  llvm::getDefaultDebuginfodCacheDirectory();
+  if (!maybeCachePath)
+return maybeCachePath;
+  return *maybeCachePath;
+}
+return s->GetCurrentValue();
+  }
+
+  std::chrono::milliseconds GetTimeout() const {
+std::optional seconds =
+m_collection_sp->GetPropertyAtIndexAs(ePropertyTimeout);
+if (seconds && *seconds != 0) {
+  return std::chrono::duration_cast(
+  std::chrono::seconds(*seconds));
+} else {
+  return llvm::getDefaultDebuginfodTimeout();
+}
+  }
+
 private:
   void ServerURLsChangedCallback() {
 m_server_urls = GetDebugInfoDURLs();
@@ -112,31 +141,51 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec &module_spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
+static std::optional
+GetFileForModule(const ModuleSpec &module_spec,
+ std::function UrlBuilder) 
{
   const UUID &module_uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false.
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab LLDB's Debuginfod overrides from the
+  // plugin.symbol-locator.debuginfod.* settings.
+  PluginProperties &plugin_props = GetGlobalPluginProperties();
+  llvm::Expected cache_path_or_err = plugin_props.GetCachePath();
+  // A cache location is *required*.
+  if (!cache_path_or_err)
+return {};
+  std::string cache_path = *cache_path_or_err;
+  llvm::SmallVector debuginfod_urls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file.
+  llvm::object::BuildID build_id(mo

[Lldb-commits] [llvm] [lldb] Added settings for DEBUGINFOD cache location and timeout (PR #78605)

2024-01-22 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lld] [flang] [mlir] [libcxx] [libc] [openmp] [compiler-rt] [clang] [lldb] [llvm] [clang-tools-extra] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

2024-01-22 Thread Hristo Hristov via lldb-commits

H-G-Hristov wrote:

> This is still broken so I'm going to revert the change.

Thanks! Sorry for the inconvenience. I didn't see your message earlier.

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


[Lldb-commits] [lldb] [lldb][libc++] Adds system_clock data formatters. (PR #78609)

2024-01-22 Thread Mark de Wever via lldb-commits


@@ -1073,18 +1073,79 @@ bool 
lldb_private::formatters::LibcxxWStringViewSummaryProvider(
   bool success;
   ValueObjectSP dataobj;
   size_t size;
-  std::tie( success, dataobj, size ) = LibcxxExtractStringViewData(valobj);
+  std::tie(success, dataobj, size) = LibcxxExtractStringViewData(valobj);
 
   if (!success) {
 stream << "Summary Unavailable";
 return true;
   }
 
-
   return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
 dataobj, size);
 }
 
+bool lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_");
+  if (!ptr_sp)
+return false;
+  ptr_sp = ptr_sp->GetChildMemberWithName("__rep_");
+  if (!ptr_sp)
+return false;
+
+  // The date time in the chrono library is valid in the range
+  // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a
+  // larger range, the function strftime is not able to format the entire range
+  // of time_t. The exact point has not been investigated; it's limited to
+  // chrono's range.
+  const std::time_t chrono_timestamp_min =
+  -1'096'193'779'200; // -32767-01-01T00:00:00Z
+  const std::time_t chrono_timestamp_max =
+  971'890'963'199; // 32767-12-31T23:59:59Z
+
+  const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
+  if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
+stream.Printf("timestamp=%ld s", seconds);
+  else {
+std::array str;
+std::strftime(str.data(), str.size(), "%FT%H:%M:%SZ", gmtime(&seconds));
+stream.Printf("date/time=%s timestamp=%ld s", str.data(), seconds);
+  }
+
+  return true;
+}
+
+bool lldb_private::formatters::LibcxxChronoSysDaysSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_");
+  if (!ptr_sp)
+return false;
+  ptr_sp = ptr_sp->GetChildMemberWithName("__rep_");
+  if (!ptr_sp)
+return false;
+
+  // The date time in the chrono library is valid in the range
+  // [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the
+  // function strftime is not able to format the entire range of time_t. The
+  // exact point has not been investigated; it's limited to chrono's range.
+  const int chrono_timestamp_min = -12'687'428; // -32767-01-01Z
+  const int chrono_timestamp_max = 11'248'737;  // 32767-12-31Z
+
+  const int days = ptr_sp->GetValueAsSigned(0);
+  if (days < chrono_timestamp_min || days > chrono_timestamp_max)
+stream.Printf("timestamp=%d days", days);
+
+  else {
+const std::time_t seconds = std::time_t(86400) * days;
+
+std::array str;
+std::strftime(str.data(), str.size(), "%FZ", gmtime(&seconds));

mordante wrote:

I'll them, but they should never trigger. 

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


[Lldb-commits] [lldb] [lldb][libc++] Adds system_clock data formatters. (PR #78609)

2024-01-22 Thread Mark de Wever via lldb-commits


@@ -32,6 +32,106 @@ def test_with_run_command(self):
 self.expect("frame variable m", substrs=["m = 4321 months"])
 self.expect("frame variable y", substrs=["y = 321 years"])
 
+self.expect(
+"frame variable ss_tp",
+substrs=["ss_tp = date/time=1970-01-01T00:00:00Z timestamp=0 s"],
+)
+self.expect(
+"frame variable ss_tp_d",
+substrs=["ss_tp_d = date/time=1970-01-01T00:00:00Z timestamp=0 s"],
+)
+self.expect(
+"frame variable ss_tp_d_r",
+substrs=["ss_tp_d_r = date/time=1970-01-01T00:00:00Z timestamp=0 
s"],
+)
+self.expect(
+"frame variable ss_tp_d_r2",
+substrs=["ss_tp_d_r2 = date/time=1970-01-01T00:00:00Z timestamp=0 
s"],
+)
+
+self.expect(
+"frame variable ss_0",
+substrs=["ss_0 = date/time=1970-01-01T00:00:00Z timestamp=0 s"],
+)
+
+self.expect(
+"frame variable ss_neg_date_time",
+substrs=[
+"ss_neg_date_time = date/time=-32767-01-01T00:00:00Z 
timestamp=-1096193779200 s"
+],
+)
+self.expect(
+"frame variable ss_neg_seconds",
+substrs=["ss_neg_seconds = timestamp=-1096193779201 s"],
+)
+
+self.expect(
+"frame variable ss_pos_date_time",
+substrs=[
+"ss_pos_date_time = date/time=32767-12-31T23:59:59Z 
timestamp=971890963199 s"
+],
+)
+self.expect(
+"frame variable ss_pos_seconds",
+substrs=["ss_pos_seconds = timestamp=971890963200 s"],
+)
+
+self.expect(
+"frame variable ss_min",
+substrs=["ss_min = timestamp=-9223372036854775808 s"],
+)
+self.expect(
+"frame variable ss_max",
+substrs=["ss_max = timestamp=9223372036854775807 s"],
+)
+
+self.expect(
+"frame variable sd_tp",
+substrs=["sd_tp = date=1970-01-01Z timestamp=0 days"],
+)
+self.expect(
+"frame variable sd_tp_d_r",
+substrs=["sd_tp_d_r = date=1970-01-01Z timestamp=0 days"],
+)
+self.expect(
+"frame variable sd_tp_d_r2",
+substrs=["sd_tp_d_r2 = date=1970-01-01Z timestamp=0 days"],
+)
+
+self.expect(
+"frame variable sd_0", substrs=["sd_0 = date=1970-01-01Z 
timestamp=0 days"]
+)
+self.expect(
+"frame variable sd_neg_date",
+substrs=["sd_neg_date = date=-32767-01-01Z timestamp=-12687428 
days"],
+)
+self.expect(
+"frame variable sd_neg_days",
+substrs=["sd_neg_days = timestamp=-12687429 days"],
+)
+
+self.expect(
+"frame variable sd_pos_date",
+substrs=["sd_pos_date = date=32767-12-31Z timestamp=11248737 
days"],
+)
+self.expect(
+"frame variable sd_pos_days",
+substrs=["sd_pos_days = timestamp=11248738 days"],
+)
+
+self.expect(
+"frame variable sd_min",
+substrs=["sd_min = timestamp=-2147483648 days"],
+)
+self.expect(
+"frame variable sd_max",
+substrs=["sd_max = timestamp=2147483647 days"],
+)
+
+# self.expect("frame variable sd_min", substrs=["sd_min = 
date=1970-01-01Z timestamp=0 days"])

mordante wrote:

nice catch, leftover copy-pasted

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


[Lldb-commits] [lldb] [lldb][libc++] Adds system_clock data formatters. (PR #78609)

2024-01-22 Thread Mark de Wever via lldb-commits

https://github.com/mordante updated 
https://github.com/llvm/llvm-project/pull/78609

>From 31a7604f872116521558dcb9f1b4c2c4f5f9d439 Mon Sep 17 00:00:00 2001
From: Mark de Wever 
Date: Thu, 18 Jan 2024 19:21:09 +0100
Subject: [PATCH 1/2] [lldb][libc++] Adds system_clock data formatters.

---
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  |  25 +
 .../Plugins/Language/CPlusPlus/LibCxx.cpp |  65 +++-
 .../Plugins/Language/CPlusPlus/LibCxx.h   |   8 ++
 .../chrono/TestDataFormatterLibcxxChrono.py   | 100 ++
 .../data-formatter-stl/libcxx/chrono/main.cpp |  52 +
 5 files changed, 248 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 21c73e6361904e5..f0fe6c9e06d9d47 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1032,6 +1032,31 @@ static void 
LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   TypeSummaryImplSP(new StringSummaryFormat(
   eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} s")));
 
+  // Chrono time point types
+
+  AddCXXSummary(cpp_category_sp,
+
lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider,
+"libc++ std::chrono::sys_seconds summary provider",
+"^std::__[[:alnum:]]+::chrono::time_point<"
+"std::__[[:alnum:]]+::chrono::system_clock, "
+"std::__[[:alnum:]]+::chrono::duration "
+"> >$",
+eTypeOptionHideChildren | eTypeOptionHideValue |
+eTypeOptionCascade,
+true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::LibcxxChronoSysDaysSummaryProvider,
+"libc++ std::chrono::sys_seconds summary provider",
+"^std::__[[:alnum:]]+::chrono::time_point<"
+"std::__[[:alnum:]]+::chrono::system_clock, "
+"std::__[[:alnum:]]+::chrono::duration "
+"> >$",
+eTypeOptionHideChildren | eTypeOptionHideValue |
+eTypeOptionCascade,
+true);
+
   // Chrono calendar types
 
   cpp_category_sp->AddTypeSummary(
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index d232a38adc029ad..042e22626969987 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -1073,18 +1073,79 @@ bool 
lldb_private::formatters::LibcxxWStringViewSummaryProvider(
   bool success;
   ValueObjectSP dataobj;
   size_t size;
-  std::tie( success, dataobj, size ) = LibcxxExtractStringViewData(valobj);
+  std::tie(success, dataobj, size) = LibcxxExtractStringViewData(valobj);
 
   if (!success) {
 stream << "Summary Unavailable";
 return true;
   }
 
-
   return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
 dataobj, size);
 }
 
+bool lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_");
+  if (!ptr_sp)
+return false;
+  ptr_sp = ptr_sp->GetChildMemberWithName("__rep_");
+  if (!ptr_sp)
+return false;
+
+  // The date time in the chrono library is valid in the range
+  // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a
+  // larger range, the function strftime is not able to format the entire range
+  // of time_t. The exact point has not been investigated; it's limited to
+  // chrono's range.
+  const std::time_t chrono_timestamp_min =
+  -1'096'193'779'200; // -32767-01-01T00:00:00Z
+  const std::time_t chrono_timestamp_max =
+  971'890'963'199; // 32767-12-31T23:59:59Z
+
+  const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
+  if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
+stream.Printf("timestamp=%ld s", seconds);
+  else {
+std::array str;
+std::strftime(str.data(), str.size(), "%FT%H:%M:%SZ", gmtime(&seconds));
+stream.Printf("date/time=%s timestamp=%ld s", str.data(), seconds);
+  }
+
+  return true;
+}
+
+bool lldb_private::formatters::LibcxxChronoSysDaysSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_");
+  if (!ptr_sp)
+return false;
+  ptr_sp = ptr_sp->GetChildMemberWithName("__rep_");
+  if (!ptr_sp)
+return false;
+
+  // The date time in the chrono library is valid in the range
+  // [-32767-01-01Z, 32767-12-31Z]. A 32-bit time_t has a larger range, the
+  // function strftime is not able to format the entire range of time_t. The
+  // exact point has not been investigate

[Lldb-commits] [lldb] bfd12f3 - [lldb][libc++] Adds system_clock data formatters. (#78609)

2024-01-22 Thread via lldb-commits

Author: Mark de Wever
Date: 2024-01-22T20:25:14+01:00
New Revision: bfd12f39b16e7ba2c342e120b925499f8504f5b3

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

LOG: [lldb][libc++] Adds system_clock data formatters. (#78609)

Added: 


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

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 21c73e6361904e5..f0fe6c9e06d9d47 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1032,6 +1032,31 @@ static void 
LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   TypeSummaryImplSP(new StringSummaryFormat(
   eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} s")));
 
+  // Chrono time point types
+
+  AddCXXSummary(cpp_category_sp,
+
lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider,
+"libc++ std::chrono::sys_seconds summary provider",
+"^std::__[[:alnum:]]+::chrono::time_point<"
+"std::__[[:alnum:]]+::chrono::system_clock, "
+"std::__[[:alnum:]]+::chrono::duration "
+"> >$",
+eTypeOptionHideChildren | eTypeOptionHideValue |
+eTypeOptionCascade,
+true);
+  AddCXXSummary(cpp_category_sp,
+lldb_private::formatters::LibcxxChronoSysDaysSummaryProvider,
+"libc++ std::chrono::sys_seconds summary provider",
+"^std::__[[:alnum:]]+::chrono::time_point<"
+"std::__[[:alnum:]]+::chrono::system_clock, "
+"std::__[[:alnum:]]+::chrono::duration "
+"> >$",
+eTypeOptionHideChildren | eTypeOptionHideValue |
+eTypeOptionCascade,
+true);
+
   // Chrono calendar types
 
   cpp_category_sp->AddTypeSummary(

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index d232a38adc029ad..060324e2fcfe263 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -1073,18 +1073,87 @@ bool 
lldb_private::formatters::LibcxxWStringViewSummaryProvider(
   bool success;
   ValueObjectSP dataobj;
   size_t size;
-  std::tie( success, dataobj, size ) = LibcxxExtractStringViewData(valobj);
+  std::tie(success, dataobj, size) = LibcxxExtractStringViewData(valobj);
 
   if (!success) {
 stream << "Summary Unavailable";
 return true;
   }
 
-
   return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
 dataobj, size);
 }
 
+bool lldb_private::formatters::LibcxxChronoSysSecondsSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_");
+  if (!ptr_sp)
+return false;
+  ptr_sp = ptr_sp->GetChildMemberWithName("__rep_");
+  if (!ptr_sp)
+return false;
+
+  // The date time in the chrono library is valid in the range
+  // [-32767-01-01T00:00:00Z, 32767-12-31T23:59:59Z]. A 64-bit time_t has a
+  // larger range, the function strftime is not able to format the entire range
+  // of time_t. The exact point has not been investigated; it's limited to
+  // chrono's range.
+  const std::time_t chrono_timestamp_min =
+  -1'096'193'779'200; // -32767-01-01T00:00:00Z
+  const std::time_t chrono_timestamp_max =
+  971'890'963'199; // 32767-12-31T23:59:59Z
+
+  const std::time_t seconds = ptr_sp->GetValueAsSigned(0);
+  if (seconds < chrono_timestamp_min || seconds > chrono_timestamp_max)
+stream.Printf("timestamp=%ld s", seconds);
+  else {
+std::array str;
+std::size_t size =
+std::strftime(str.data(), str.size(), "%FT%H:%M:%SZ", 
gmtime(&seconds));
+if (size == 0)
+  return false;
+
+stream.Printf("date/time=%s timestamp=%ld s", str.data(), seconds);
+  }
+
+  return true;
+}
+
+bool lldb_private::formatters::LibcxxChronoSysDaysSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  ValueObjectSP ptr_sp = valobj.GetChildMemberWithName("__d_");
+  if (!ptr_sp)
+return false;
+  ptr_sp = ptr_sp->GetChildMemberWithName("__rep_");
+  if (!ptr_sp)
+ 

[Lldb-commits] [lldb] [lldb][libc++] Adds system_clock data formatters. (PR #78609)

2024-01-22 Thread Mark de Wever via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support DW_OP_WASM_location in DWARFExpression (PR #78977)

2024-01-22 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

Is it possible to write a test for this in `DWARFExpressionTest.cpp`? 

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


[Lldb-commits] [libc] [libcxxabi] [libcxx] [lld] [flang] [libclc] [clang] [compiler-rt] [clang-tools-extra] [lldb] [llvm] [Thumb, ELF] Fix access to dso_preemptable __stack_chk_guard with static reloc

2024-01-22 Thread Fangrui Song via lldb-commits

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


[Lldb-commits] [flang] [clang-tools-extra] [libc] [compiler-rt] [lldb] [libcxx] [libcxxabi] [lld] [clang] [libclc] [llvm] [Thumb, ELF] Fix access to dso_preemptable __stack_chk_guard with static reloc

2024-01-22 Thread Fangrui Song via lldb-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/78950

>From 2ce57488682873d2dc005144db57fbb555f29d8a Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Mon, 22 Jan 2024 00:29:09 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 llvm/lib/Target/ARM/Thumb1InstrInfo.cpp  |  5 ++--
 llvm/lib/Target/ARM/Thumb2InstrInfo.cpp  |  2 +-
 llvm/test/CodeGen/ARM/stack-guard-elf.ll | 30 +++-
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp 
b/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
index e2f3fad2007904..e3104e8ee765f9 100644
--- a/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
+++ b/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
@@ -135,14 +135,15 @@ void 
Thumb1InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
 void Thumb1InstrInfo::expandLoadStackGuard(
 MachineBasicBlock::iterator MI) const {
   MachineFunction &MF = *MI->getParent()->getParent();
-  const TargetMachine &TM = MF.getTarget();
   const ARMSubtarget &ST = MF.getSubtarget();
+  const GlobalValue *GV =
+  cast((*MI->memoperands_begin())->getValue());
 
   assert(MF.getFunction().getParent()->getStackProtectorGuard() != "tls" &&
  "TLS stack protector not supported for Thumb1 targets");
 
   unsigned Instr;
-  if (TM.isPositionIndependent())
+  if (!GV->isDSOLocal())
 Instr = ARM::tLDRLIT_ga_pcrel;
   else if (ST.genExecuteOnly() && ST.hasV8MBaselineOps())
 Instr = ARM::t2MOVi32imm;
diff --git a/llvm/lib/Target/ARM/Thumb2InstrInfo.cpp 
b/llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
index 2ea0eaa0aad8f5..9e4b51616b56ec 100644
--- a/llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
+++ b/llvm/lib/Target/ARM/Thumb2InstrInfo.cpp
@@ -264,7 +264,7 @@ void Thumb2InstrInfo::expandLoadStackGuard(
   const GlobalValue *GV =
   cast((*MI->memoperands_begin())->getValue());
 
-  if (MF.getSubtarget().isGVInGOT(GV))
+  if (!GV->isDSOLocal())
 expandLoadStackGuardBase(MI, ARM::t2LDRLIT_ga_pcrel, ARM::t2LDRi12);
   else if (MF.getTarget().isPositionIndependent())
 expandLoadStackGuardBase(MI, ARM::t2MOV_ga_pcrel, ARM::t2LDRi12);
diff --git a/llvm/test/CodeGen/ARM/stack-guard-elf.ll 
b/llvm/test/CodeGen/ARM/stack-guard-elf.ll
index 250f2ad9ed1093..d0e5db7e5711b0 100644
--- a/llvm/test/CodeGen/ARM/stack-guard-elf.ll
+++ b/llvm/test/CodeGen/ARM/stack-guard-elf.ll
@@ -59,6 +59,8 @@ define i32 @test1() #0 {
 ; THUMB1-NEXT:.pad #16
 ; THUMB1-NEXT:sub sp, #16
 ; THUMB1-NEXT:ldr r0, .LCPI0_0
+; THUMB1-NEXT:  .LPC0_0:
+; THUMB1-NEXT:add r0, pc
 ; THUMB1-NEXT:ldr r0, [r0]
 ; THUMB1-NEXT:ldr r0, [r0]
 ; THUMB1-NEXT:add r1, sp, #904
@@ -67,7 +69,9 @@ define i32 @test1() #0 {
 ; THUMB1-NEXT:bl foo
 ; THUMB1-NEXT:add r0, sp, #904
 ; THUMB1-NEXT:ldr r0, [r0, #124]
-; THUMB1-NEXT:ldr r1, .LCPI0_0
+; THUMB1-NEXT:ldr r1, .LCPI0_1
+; THUMB1-NEXT:  .LPC0_1:
+; THUMB1-NEXT:add r1, pc
 ; THUMB1-NEXT:ldr r1, [r1]
 ; THUMB1-NEXT:ldr r1, [r1]
 ; THUMB1-NEXT:cmp r1, r0
@@ -83,7 +87,11 @@ define i32 @test1() #0 {
 ; THUMB1-NEXT:.p2align 2
 ; THUMB1-NEXT:  @ %bb.3:
 ; THUMB1-NEXT:  .LCPI0_0:
-; THUMB1-NEXT:.long __stack_chk_guard
+; THUMB1-NEXT:  .Ltmp0:
+; THUMB1-NEXT:.long __stack_chk_guard(GOT_PREL)-((.LPC0_0+4)-.Ltmp0)
+; THUMB1-NEXT:  .LCPI0_1:
+; THUMB1-NEXT:  .Ltmp1:
+; THUMB1-NEXT:.long __stack_chk_guard(GOT_PREL)-((.LPC0_1+4)-.Ltmp1)
 ;
 ; THUMB1-PIC-LABEL: test1:
 ; THUMB1-PIC:   @ %bb.0:
@@ -136,16 +144,18 @@ define i32 @test1() #0 {
 ; THUMB2-NEXT:push {r7, lr}
 ; THUMB2-NEXT:.pad #1032
 ; THUMB2-NEXT:sub.w sp, sp, #1032
-; THUMB2-NEXT:movw r0, :lower16:__stack_chk_guard
-; THUMB2-NEXT:movt r0, :upper16:__stack_chk_guard
+; THUMB2-NEXT:ldr r0, .LCPI0_0
+; THUMB2-NEXT:  .LPC0_0:
+; THUMB2-NEXT:add r0, pc
 ; THUMB2-NEXT:ldr r0, [r0]
 ; THUMB2-NEXT:ldr r0, [r0]
 ; THUMB2-NEXT:str.w r0, [sp, #1028]
 ; THUMB2-NEXT:add r0, sp, #4
 ; THUMB2-NEXT:bl foo
-; THUMB2-NEXT:movw r1, :lower16:__stack_chk_guard
 ; THUMB2-NEXT:ldr.w r0, [sp, #1028]
-; THUMB2-NEXT:movt r1, :upper16:__stack_chk_guard
+; THUMB2-NEXT:ldr r1, .LCPI0_1
+; THUMB2-NEXT:  .LPC0_1:
+; THUMB2-NEXT:add r1, pc
 ; THUMB2-NEXT:ldr r1, [r1]
 ; THUMB2-NEXT:ldr r1, [r1]
 ; THUMB2-NEXT:cmp r1, r0
@@ -155,6 +165,14 @@ define i32 @test1() #0 {
 ; THUMB2-NEXT:popeq {r7, pc}
 ; THUMB2-NEXT:  .LBB0_1:
 ; THUMB2-NEXT:bl __stack_chk_fail
+; THUMB2-NEXT:.p2align 2
+; THUMB2-NEXT:  @ %bb.2:
+; THUMB2-NEXT:  .LCPI0_0:
+; THUMB2-NEXT:  .Ltmp0:
+; THUMB2-NEXT:.long __stack_chk_guard(GOT_PREL)-((.LPC0_0+4)-.Ltmp0)
+; THUMB2-NEXT:  .LCPI0_1:
+; THUMB2-NEXT:  .Ltmp1:
+; THUMB2-NEXT:.long __stack_chk_guard(GOT_PREL)-((.LPC0_1+4)-.Ltmp1)
 ;
 ; THUMB2-PIC-LABEL: test1:
 ; THUMB2-PIC

[Lldb-commits] [flang] [clang-tools-extra] [libc] [compiler-rt] [lldb] [libcxx] [libcxxabi] [lld] [clang] [libclc] [llvm] [Thumb, ELF] Fix access to dso_preemptable __stack_chk_guard with static reloc

2024-01-22 Thread Fangrui Song via lldb-commits


@@ -135,14 +135,15 @@ void 
Thumb1InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
 void Thumb1InstrInfo::expandLoadStackGuard(
 MachineBasicBlock::iterator MI) const {
   MachineFunction &MF = *MI->getParent()->getParent();
-  const TargetMachine &TM = MF.getTarget();
   const ARMSubtarget &ST = MF.getSubtarget();
+  const GlobalValue *GV =
+  cast((*MI->memoperands_begin())->getValue());

MaskRay wrote:

Thanks for the suggestion. Done

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


[Lldb-commits] [flang] [clang-tools-extra] [libc] [compiler-rt] [lldb] [libcxx] [libcxxabi] [lld] [clang] [libclc] [llvm] [Thumb, ELF] Fix access to dso_preemptable __stack_chk_guard with static reloc

2024-01-22 Thread Fangrui Song via lldb-commits

MaskRay wrote:

> (the commit message seems odd; intentional?)

Hopefully clarified:)

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


[Lldb-commits] [lldb] [lldb][NFCI] Remove EventData* parameter from BroadcastEventIfUnique (PR #79045)

2024-01-22 Thread Alex Langford via lldb-commits

https://github.com/bulbazord created 
https://github.com/llvm/llvm-project/pull/79045

Instead of passing the data to BroadcastEventIfUnique to create an Event object 
on the behalf of the caller, the caller can create the Event up-front.

>From 9cb80e3f334d3cf3dafed4bda6f87289ad330054 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Mon, 22 Jan 2024 11:51:30 -0800
Subject: [PATCH] [lldb][NFCI] Remove EventData* parameter from
 BroadcastEventIfUnique

Instead of passing the data to BroadcastEventIfUnique to create an Event
object on the behalf of the caller, the caller can create the Event
up-front.
---
 lldb/include/lldb/Target/Process.h  |  2 ++
 lldb/include/lldb/Utility/Broadcaster.h |  8 +++-
 lldb/source/Target/Process.cpp  | 18 --
 lldb/source/Utility/Broadcaster.cpp |  5 ++---
 4 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 24c599e044c78fa..4599a0dc8821966 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -3216,6 +3216,8 @@ void PruneThreadPlans();
   Status LaunchPrivate(ProcessLaunchInfo &launch_info, lldb::StateType &state,
lldb::EventSP &event_sp);
 
+  lldb::EventSP CreateEventFromProcessState(uint32_t event_type);
+
   Process(const Process &) = delete;
   const Process &operator=(const Process &) = delete;
 };
diff --git a/lldb/include/lldb/Utility/Broadcaster.h 
b/lldb/include/lldb/Utility/Broadcaster.h
index c8127f0a921d882..f39e677fe9ee041 100644
--- a/lldb/include/lldb/Utility/Broadcaster.h
+++ b/lldb/include/lldb/Utility/Broadcaster.h
@@ -181,9 +181,8 @@ class Broadcaster {
 m_broadcaster_sp->BroadcastEvent(event_type);
   }
 
-  void BroadcastEventIfUnique(uint32_t event_type,
-  EventData *event_data = nullptr) {
-m_broadcaster_sp->BroadcastEventIfUnique(event_type, event_data);
+  void BroadcastEventIfUnique(uint32_t event_type) {
+m_broadcaster_sp->BroadcastEventIfUnique(event_type);
   }
 
   void Clear() { m_broadcaster_sp->Clear(); }
@@ -351,8 +350,7 @@ class Broadcaster {
 void BroadcastEvent(uint32_t event_type,
 const lldb::EventDataSP &event_data_sp);
 
-void BroadcastEventIfUnique(uint32_t event_type,
-EventData *event_data = nullptr);
+void BroadcastEventIfUnique(uint32_t event_type);
 
 void Clear();
 
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index e1c16ca21643227..23a8a66645c02d6 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4281,25 +4281,31 @@ void 
Process::CalculateExecutionContext(ExecutionContext &exe_ctx) {
 //return Host::GetArchSpecForExistingProcess (process_name);
 //}
 
+EventSP Process::CreateEventFromProcessState(uint32_t event_type) {
+  auto event_data_sp =
+  std::make_shared(shared_from_this(), GetState());
+  return std::make_shared(event_type, event_data_sp);
+}
+
 void Process::AppendSTDOUT(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stdout_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDOUT,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDOUT);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::AppendSTDERR(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stderr_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDERR,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDERR);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::BroadcastAsyncProfileData(const std::string &one_profile_data) {
   std::lock_guard guard(m_profile_data_comm_mutex);
   m_profile_data.push_back(one_profile_data);
-  BroadcastEventIfUnique(eBroadcastBitProfileData,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitProfileData);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::BroadcastStructuredData(const StructuredData::ObjectSP 
&object_sp,
diff --git a/lldb/source/Utility/Broadcaster.cpp 
b/lldb/source/Utility/Broadcaster.cpp
index 33cd49963e7c74c..12903edc36b1b98 100644
--- a/lldb/source/Utility/Broadcaster.cpp
+++ b/lldb/source/Utility/Broadcaster.cpp
@@ -311,9 +311,8 @@ void Broadcaster::BroadcasterImpl::BroadcastEvent(
   PrivateBroadcastEvent(event_sp, false);
 }
 
-void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(
-uint32_t event_type, EventData *event_data) {
-  auto event_sp = std::make_shared(event_type, event_data);
+void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(uint32_t event_type) 
{
+  auto event_sp = std::make_shared(event_type, /*data = */ null

[Lldb-commits] [lldb] [lldb][NFCI] Remove EventData* parameter from BroadcastEventIfUnique (PR #79045)

2024-01-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes

Instead of passing the data to BroadcastEventIfUnique to create an Event object 
on the behalf of the caller, the caller can create the Event up-front.

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


4 Files Affected:

- (modified) lldb/include/lldb/Target/Process.h (+2) 
- (modified) lldb/include/lldb/Utility/Broadcaster.h (+3-5) 
- (modified) lldb/source/Target/Process.cpp (+12-6) 
- (modified) lldb/source/Utility/Broadcaster.cpp (+2-3) 


``diff
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 24c599e044c78f..4599a0dc882196 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -3216,6 +3216,8 @@ void PruneThreadPlans();
   Status LaunchPrivate(ProcessLaunchInfo &launch_info, lldb::StateType &state,
lldb::EventSP &event_sp);
 
+  lldb::EventSP CreateEventFromProcessState(uint32_t event_type);
+
   Process(const Process &) = delete;
   const Process &operator=(const Process &) = delete;
 };
diff --git a/lldb/include/lldb/Utility/Broadcaster.h 
b/lldb/include/lldb/Utility/Broadcaster.h
index c8127f0a921d88..f39e677fe9ee04 100644
--- a/lldb/include/lldb/Utility/Broadcaster.h
+++ b/lldb/include/lldb/Utility/Broadcaster.h
@@ -181,9 +181,8 @@ class Broadcaster {
 m_broadcaster_sp->BroadcastEvent(event_type);
   }
 
-  void BroadcastEventIfUnique(uint32_t event_type,
-  EventData *event_data = nullptr) {
-m_broadcaster_sp->BroadcastEventIfUnique(event_type, event_data);
+  void BroadcastEventIfUnique(uint32_t event_type) {
+m_broadcaster_sp->BroadcastEventIfUnique(event_type);
   }
 
   void Clear() { m_broadcaster_sp->Clear(); }
@@ -351,8 +350,7 @@ class Broadcaster {
 void BroadcastEvent(uint32_t event_type,
 const lldb::EventDataSP &event_data_sp);
 
-void BroadcastEventIfUnique(uint32_t event_type,
-EventData *event_data = nullptr);
+void BroadcastEventIfUnique(uint32_t event_type);
 
 void Clear();
 
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index e1c16ca2164322..23a8a66645c02d 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4281,25 +4281,31 @@ void 
Process::CalculateExecutionContext(ExecutionContext &exe_ctx) {
 //return Host::GetArchSpecForExistingProcess (process_name);
 //}
 
+EventSP Process::CreateEventFromProcessState(uint32_t event_type) {
+  auto event_data_sp =
+  std::make_shared(shared_from_this(), GetState());
+  return std::make_shared(event_type, event_data_sp);
+}
+
 void Process::AppendSTDOUT(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stdout_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDOUT,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDOUT);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::AppendSTDERR(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stderr_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDERR,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDERR);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::BroadcastAsyncProfileData(const std::string &one_profile_data) {
   std::lock_guard guard(m_profile_data_comm_mutex);
   m_profile_data.push_back(one_profile_data);
-  BroadcastEventIfUnique(eBroadcastBitProfileData,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitProfileData);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::BroadcastStructuredData(const StructuredData::ObjectSP 
&object_sp,
diff --git a/lldb/source/Utility/Broadcaster.cpp 
b/lldb/source/Utility/Broadcaster.cpp
index 33cd49963e7c74..12903edc36b1b9 100644
--- a/lldb/source/Utility/Broadcaster.cpp
+++ b/lldb/source/Utility/Broadcaster.cpp
@@ -311,9 +311,8 @@ void Broadcaster::BroadcasterImpl::BroadcastEvent(
   PrivateBroadcastEvent(event_sp, false);
 }
 
-void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(
-uint32_t event_type, EventData *event_data) {
-  auto event_sp = std::make_shared(event_type, event_data);
+void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(uint32_t event_type) 
{
+  auto event_sp = std::make_shared(event_type, /*data = */ nullptr);
   PrivateBroadcastEvent(event_sp, true);
 }
 

``




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


[Lldb-commits] [clang-tools-extra] [lld] [llvm] [compiler-rt] [clang] [libc] [libcxx] [flang] [lldb] [AMDGPU][GFX12] VOP encoding and codegen - add support for v_cvt fp8/… (PR #78414)

2024-01-22 Thread Joe Nash via lldb-commits
Mirko =?utf-8?q?Brkušanin?= ,
Mirko =?utf-8?q?Brkušanin?= 
Message-ID:
In-Reply-To: 



@@ -305,6 +305,11 @@ class VOP3OpSel_gfx10 op, VOPProfile p> : 
VOP3e_gfx10 {
 
 class VOP3OpSel_gfx11_gfx12 op, VOPProfile p> : VOP3OpSel_gfx10;
 
+class VOP3FP8OpSel_gfx11_gfx12 op, VOPProfile p> : VOP3e_gfx10 
{
+  let Inst{11} = !if(p.HasSrc0, src0_modifiers{2}, 0);
+  let Inst{12} = !if(p.HasSrc0, src0_modifiers{3}, 0);

Sisyph wrote:

 A couple points related to this. 
- I don't think the rules for forming op_sel with dpp are currently being 
checked correctly. In GCNDPPCombine.cpp:369, we check the named op_sel operand 
and op_sel_hi operand. We use src_modifier operands through most of the 
compiler, and typically don't (if ever?) copy the bits to the named op_sel 
operands. This should be fixed regardless of this patch.
- The rules we should enforce for dpp with op_sel is that for the alu to be 
combined, op_sel must be 0 and op_sel_hi must be 0b111
- My conclusion is that it is only safe to form the dpp alu with these 
instructions if op_sel bits are all zero
- We are emitting those alu based on this patch that probably shouldn't be 
allowed ( e.g. v_cvt_f32_fp8_e64_dpp v0, v0 op_sel:[1,1] quad_perm:[0,1,2,3] 
row_mask:0xf bank_mask:0xf bound_ctrl:1)
- The cleanup Ivan suggested using the dst_op_sel bit of src0 (equivalent to 
the op_sel_hi bit of src0) would require a special case in GCNDppCombine to 
check the correct bit. Otherwise, we might allow an alu to be formed if 
op_sel:[0,1] 


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


[Lldb-commits] [flang] [lldb] [libcxx] [lld] [clang-tools-extra] [clang] [llvm] [libclc] [compiler-rt] [libc] [libcxxabi] [Thumb, ELF] Fix access to dso_preemptable __stack_chk_guard with static reloc

2024-01-22 Thread Nick Desaulniers via lldb-commits


@@ -135,14 +135,14 @@ void 
Thumb1InstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
 void Thumb1InstrInfo::expandLoadStackGuard(
 MachineBasicBlock::iterator MI) const {
   MachineFunction &MF = *MI->getParent()->getParent();
-  const TargetMachine &TM = MF.getTarget();
   const ARMSubtarget &ST = MF.getSubtarget();
+  const auto *GV = cast((*MI->memoperands_begin())->getValue());
 
   assert(MF.getFunction().getParent()->getStackProtectorGuard() != "tls" &&
  "TLS stack protector not supported for Thumb1 targets");
 
   unsigned Instr;
-  if (TM.isPositionIndependent())
+  if (!GV->isDSOLocal())

nickdesaulniers wrote:

does Thumb1 need similar guards for whether the target is elf?

https://github.com/llvm/llvm-project/pull/78950
___
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] [clang] [lld] [compiler-rt] [libunwind] [libcxx] [flang] [lldb] [libc] [libcxxabi] Fix a bug in implementation of Smith's algorithm used in complex div. (PR #

2024-01-22 Thread Zahira Ammarguellat via lldb-commits

https://github.com/zahiraam edited 
https://github.com/llvm/llvm-project/pull/78330
___
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] [clang] [lld] [compiler-rt] [libunwind] [libcxx] [flang] [lldb] [libc] [libcxxabi] Fix a bug in implementation of Smith's algorithm used in complex div. (PR #

2024-01-22 Thread Zahira Ammarguellat via lldb-commits

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


[Lldb-commits] [lldb] [clang-tools-extra] [libunwind] [compiler-rt] [lld] [flang] [libc] [llvm] [libclc] [libcxxabi] [libcxx] [clang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #

2024-01-22 Thread Paul Kirth via lldb-commits

ilovepi wrote:

@topperc Is there anything else you think needs to be done for the code 
generation?

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


[Lldb-commits] [clang] [libunwind] [libc] [libcxx] [clang-tools-extra] [lld] [lldb] [libclc] [flang] [llvm] [libcxxabi] [compiler-rt] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #

2024-01-22 Thread Fangrui Song via lldb-commits

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


[Lldb-commits] [clang-tools-extra] [libclc] [compiler-rt] [lldb] [libcxxabi] [libunwind] [llvm] [libcxx] [lld] [flang] [libc] [clang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #

2024-01-22 Thread Fangrui Song via lldb-commits


@@ -89,8 +89,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine 
&TM,
   if ((ABI == RISCVABI::ABI_ILP32F || ABI == RISCVABI::ABI_LP64F) &&
   !Subtarget.hasStdExtF()) {
 errs() << "Hard-float 'f' ABI can't be used for a target that "
-"doesn't support the F instruction set extension (ignoring "
-  "target-abi)\n";
+  "doesn't support the F instruction set extension (ignoring "

MaskRay wrote:

Ah, I only use `git diff -U0 --no-color --relative main... -- | 
path/to/clang/tools/clang-format/clang-format-diff.py -p1  -i` :)

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


[Lldb-commits] [clang-tools-extra] [libc] [lldb] [compiler-rt] [flang] [libcxxabi] [llvm] [lld] [libcxx] [mlir] [clang] [libc++] Fix the behavior of throwing `operator new` under -fno-exceptions (PR #

2024-01-22 Thread Louis Dionne via lldb-commits

https://github.com/ldionne updated 
https://github.com/llvm/llvm-project/pull/69498

>From 6f89b118ed56ad7a3af1996e19ccd30cc893c51e Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Wed, 14 Jun 2023 17:49:22 -0700
Subject: [PATCH 01/11] [libc++] Fix the behavior of throwing `operator new`
 under -fno-exceptions

In D144319, Clang tried to land a change that would cause some functions
that are not supposed to return nullptr to optimize better. As reported
in https://reviews.llvm.org/D144319#4203982, libc++ started seeing failures
in its CI shortly after this change was landed.

As explained in D146379, the reason for these failures is that libc++'s
throwing `operator new` can in fact return nullptr when compiled with
exceptions disabled. However, this contradicts the Standard, which
clearly says that the throwing version of `operator new(size_t)`
should never return nullptr. This is actually a long standing issue.
I've previously seen a case where LTO would optimize incorrectly based
on the assumption that `operator new` doesn't return nullptr, an
assumption that was violated in that case because libc++.dylib was
compiled with -fno-exceptions.

Unfortunately, fixing this is kind of tricky. The Standard has a few
requirements for the allocation functions, some of which are impossible
to satisfy under -fno-exceptions:
1. `operator new(size_t)` must never return nullptr
2. `operator new(size_t, nothrow_t)` must call the throwing version
 and return nullptr on failure to allocate
3. We can't throw exceptions when compiled with -fno-exceptions

In the case where exceptions are enabled, things work nicely. `new(size_t)`
throws and `new(size_t, nothrow_t)` uses a try-catch to return nullptr.
However, when compiling the library with -fno-exceptions, we can't throw
an exception from `new(size_t)`, and we can't catch anything from
`new(size_t, nothrow_t)`. The only thing we can do from `new(size_t)`
is actually abort the program, which does not make it possible for
`new(size_t, nothrow_t)` to catch something and return nullptr.

This patch makes the following changes:
1. When compiled with -fno-exceptions, the throwing version of
   `operator new` will now abort on failure instead of returning
   nullptr on failure. This resolves the issue that the compiler
   could mis-compile based on the assumption that nullptr is never
   returned. This constitutes an API and ABI breaking change for
   folks compiling the library with -fno-exceptions (which is not
   the general public, who merely uses libc++ headers but use a
   shared library that has already been compiled). This should mostly
   impact vendors and other folks who compile libc++.dylib themselves.

2. When the library is compiled with -fexceptions, the nothrow version
   of `operator new` has no change. When the library is compiled with
   -fno-exceptions, the nothrow version of `operator new` will now check
   whether the throwing version of `operator new` has been overridden.
   If it has not been overridden, then it will use an implementation
   equivalent to that of the throwing `operator new`, except it will
   return nullptr on failure to allocate (instead of terminating).
   However, if the throwing `operator new` has been overridden, it is
   now an error NOT to also override the nothrow `operator new`. Indeed,
   there is no way for us to implement a valid nothrow `operator new`
   without knowing the exact implementation of the throwing version.

rdar://103958777

Differential Revision: https://reviews.llvm.org/D150610
---
 libcxx/docs/ReleaseNotes/18.rst   |  23 +++
 libcxx/include/CMakeLists.txt |   1 +
 libcxx/include/__overridable_function | 119 +
 libcxx/src/new.cpp|  99 ---
 ...new_not_overridden_fno_exceptions.pass.cpp |  59 ++
 .../new_dont_return_nullptr.pass.cpp  |  37 
 libcxx/test/support/check_assertion.h |   6 +
 libcxx/utils/generate_iwyu_mapping.py |   2 +
 libcxxabi/src/stdlib_new_delete.cpp   | 168 +++---
 9 files changed, 426 insertions(+), 88 deletions(-)
 create mode 100644 libcxx/include/__overridable_function
 create mode 100644 
libcxx/test/libcxx/language.support/support.dynamic/assert.nothrow_new_not_overridden_fno_exceptions.pass.cpp
 create mode 100644 
libcxx/test/libcxx/language.support/support.dynamic/new_dont_return_nullptr.pass.cpp

diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 9e509db6359c4aa..405f1e172893bc1 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -142,6 +142,29 @@ LLVM 20
 ABI Affecting Changes
 -
 
+- When the shared/static library is built with ``-fno-exceptions``, the 
behavior of ``operator new`` was changed
+  to make it standards-conforming. In LLVM 17 and before, the throwing 
versions of ``operator new`` would return
+  ``nullptr`` upon failure to allocate, when the 

[Lldb-commits] [lldb] [lldb][NFCI] Remove Broadcaster::BroadcastEvent overload with EventData param (PR #79064)

2024-01-22 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb][NFCI] Remove Broadcaster::BroadcastEvent overload with EventData param (PR #79064)

2024-01-22 Thread Alex Langford via lldb-commits

bulbazord wrote:

I thought about this more and talked with Jim offline. I think that it makes 
sense for Broadcaster to create Events with the event_type and the EventDataSP. 
I'm going to switch my approach and abandon this one.

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


[Lldb-commits] [flang] [clang] [lldb] [compiler-rt] [llvm] [clang-tools-extra] [mlir] [libcxxabi] [libc] [libcxx] [lld] [libc++] Fix the behavior of throwing `operator new` under -fno-exceptions (PR #

2024-01-22 Thread Quentin Dian via lldb-commits

DianQK wrote:

Thanks for the fix! I'll merge the blocked patches in a later two days.

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


[Lldb-commits] [clang] [llvm] [libunwind] [compiler-rt] [libc] [flang] [lld] [libcxx] [lldb] [libclc] [clang-tools-extra] [libcxxabi] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #

2024-01-22 Thread Fangrui Song via lldb-commits

MaskRay wrote:

This PR needs a rebase.. There are quite a few merge commits. Hmm, I don't know 
how to squash the changes to rebase them to latest main branch. `git rebase 
--keep-base -i main` has quite a few merge conflicts.

(My lld change (https://github.com/maskray/llvm-project/tree/rv-tlsdesc) is 
almost complete. I want to rebase it onto the latest revision of this LLVM PR.)

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


[Lldb-commits] [lldb] [lldb] Add support for updating string during debug process (PR #67782)

2024-01-22 Thread Pavel Kosov via lldb-commits

https://github.com/kpdev updated https://github.com/llvm/llvm-project/pull/67782

>From 374784cbaaffe9ca2bac716c996485783b959364 Mon Sep 17 00:00:00 2001
From: Pavel Kosov 
Date: Tue, 23 Jan 2024 09:37:54 +0300
Subject: [PATCH] [LLDB] Add ability to update string during debugging

This is the last patch needed for adding an ability to update 
std::string/wstring/etc during debug process.

std::string/std::wstring/std::u16(32)string synthetic frontend implemented
Also tests for the frontend added.

~~

Huawei RRI, OS Lab
---
 lldb/source/DataFormatters/FormatManager.cpp  |   8 +-
 .../Plugins/Language/CPlusPlus/CMakeLists.txt |   1 +
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  |  88 +
 .../Plugins/Language/CPlusPlus/LibCxx.cpp |  96 +-
 .../Plugins/Language/CPlusPlus/LibCxx.h   |  15 ++
 .../Language/CPlusPlus/LibCxxString.cpp   | 171 ++
 .../CPlusPlus/LibCxxStringInfoExtractor.h | 119 
 .../change_values/libcxx/string/Makefile  |   6 +
 .../libcxx/string/TestChangeStringValue.py|  56 ++
 .../change_values/libcxx/string/main.cpp  |  21 +++
 10 files changed, 453 insertions(+), 128 deletions(-)
 create mode 100644 lldb/source/Plugins/Language/CPlusPlus/LibCxxString.cpp
 create mode 100644 
lldb/source/Plugins/Language/CPlusPlus/LibCxxStringInfoExtractor.h
 create mode 100644 
lldb/test/API/python_api/value/change_values/libcxx/string/Makefile
 create mode 100644 
lldb/test/API/python_api/value/change_values/libcxx/string/TestChangeStringValue.py
 create mode 100644 
lldb/test/API/python_api/value/change_values/libcxx/string/main.cpp

diff --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index f1f135de32ca874..b57b9b864ac5819 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -502,8 +502,12 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject 
&valobj) {
   // wait.. wat? just get out of here..
   if (!synth_sp)
 return false;
-  // but if we only have them to provide a value, keep going
-  if (!synth_sp->MightHaveChildren() &&
+  // but if they can fit in one line or ...
+  if (auto format = synth_sp->GetSummaryFormat()) {
+is_synth_val = format->IsOneLiner();
+  }
+  // ... if we only have them to provide a value, keep going
+  else if (!synth_sp->MightHaveChildren() &&
   synth_sp->DoesProvideSyntheticValue())
 is_synth_val = true;
   else
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt 
b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
index 21108b27896a1a9..224f6bd205d7d2e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -14,6 +14,7 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
   LibCxxQueue.cpp
   LibCxxRangesRefView.cpp
   LibCxxSpan.cpp
+  LibCxxString.cpp
   LibCxxTuple.cpp
   LibCxxUnorderedMap.cpp
   LibCxxVariant.cpp
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 586cc08a6f1233b..e5afab44d5dc90e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -645,51 +645,52 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   .SetShowMembersOneLiner(false)
   .SetHideItemNames(false);
 
+  static ConstString std_string_regex{
+  "^std::__[[:alnum:]]+::string$"
+  "|"
+  "^std::__[[:alnum:]]+::basic_string, "
+  "std::__[[:alnum:]]+::allocator >$"
+  "|"
+  "^std::__[[:alnum:]]+::basic_string, "
+  "std::__[[:alnum:]]+::allocator >$"};
+
+  static ConstString std_u16string_regex{
+  "^std::__[[:alnum:]]+::basic_string, "
+  "std::__[[:alnum:]]+::allocator >$"};
+
+  static ConstString std_u32string_regex{
+  "^std::__[[:alnum:]]+::basic_string, "
+  "std::__[[:alnum:]]+::allocator >$"};
+
+  static ConstString std_wstring_regex{
+  "^std::__[[:alnum:]]+::wstring$"
+  "|"
+  "^std::__[[:alnum:]]+::basic_string, "
+  "std::__[[:alnum:]]+::allocator >$"};
+
   AddCXXSummary(cpp_category_sp,
 lldb_private::formatters::LibcxxStringSummaryProviderASCII,
-"std::string summary provider", 
"^std::__[[:alnum:]]+::string$",
-stl_summary_flags, true);
-  AddCXXSummary(cpp_category_sp,
-lldb_private::formatters::LibcxxStringSummaryProviderASCII,
-"std::string summary provider",
-"^std::__[[:alnum:]]+::basic_string, "
-"std::__[[:alnum:]]+::allocator >$",
-stl_summary_flags, true);
-  AddCXXSummary(cpp_category_sp,
-lldb_private::formatters::LibcxxStringSummaryProviderASCII,
-"std::string summary provider",

[Lldb-commits] [lldb] [lldb] Add support for updating string during debug process (PR #67782)

2024-01-22 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 22764918b5c1496970ab6bb1547535c554a06347 
374784cbaaffe9ca2bac716c996485783b959364 -- 
lldb/source/Plugins/Language/CPlusPlus/LibCxxString.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxStringInfoExtractor.h 
lldb/test/API/python_api/value/change_values/libcxx/string/main.cpp 
lldb/source/DataFormatters/FormatManager.cpp 
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/DataFormatters/FormatManager.cpp 
b/lldb/source/DataFormatters/FormatManager.cpp
index b57b9b864a..350479a611 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -508,7 +508,7 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject 
&valobj) {
   }
   // ... if we only have them to provide a value, keep going
   else if (!synth_sp->MightHaveChildren() &&
-  synth_sp->DoesProvideSyntheticValue())
+   synth_sp->DoesProvideSyntheticValue())
 is_synth_val = true;
   else
 return false;

``




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