[Lldb-commits] [lldb] cf5639d - [lldb][Docs] Fix typo in debugging lldb doc

2023-10-09 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-09T08:18:13+01:00
New Revision: cf5639dd2df406b0ef32031182f2ea5daf2e5fbb

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

LOG: [lldb][Docs] Fix typo in debugging lldb doc

Added: 


Modified: 
lldb/docs/resources/debugging.rst

Removed: 




diff  --git a/lldb/docs/resources/debugging.rst 
b/lldb/docs/resources/debugging.rst
index 0af1de1581c4bd0..63c88477a848c43 100644
--- a/lldb/docs/resources/debugging.rst
+++ b/lldb/docs/resources/debugging.rst
@@ -488,7 +488,7 @@ The program presented `here 
`_.
 
-For either, you'll need to modify that to fit your architecture. An tip for 
this
+For either, you'll need to modify that to fit your architecture. A tip for this
 is to take any constants used in it, find in which function(s) they are used in
 LLDB and then you'll find the equivalent constants in the same LLDB functions
 for your architecture.



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


[Lldb-commits] [lldb] f47914a - [lldb][Docs] Use RST link format in IntelPT doc

2023-10-09 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-09T08:21:21+01:00
New Revision: f47914a7cd733751d6ae4dcb9c240520c34ec492

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

LOG: [lldb][Docs] Use RST link format in IntelPT doc

Added: 


Modified: 
lldb/docs/use/intel_pt.rst

Removed: 




diff  --git a/lldb/docs/use/intel_pt.rst b/lldb/docs/use/intel_pt.rst
index f8afb2cee1b26c6..89ef5d811fb2ad5 100644
--- a/lldb/docs/use/intel_pt.rst
+++ b/lldb/docs/use/intel_pt.rst
@@ -27,7 +27,7 @@ Build Instructions
 --
 
 Clone and build the low level Intel PT
-decoder library [LibIPT library](https://github.com/intel/libipt).
+decoder library `LibIPT library `_.
 ::
 
   $ git clone g...@github.com:intel/libipt.git



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


[Lldb-commits] [lldb] d7b18d5 - Use llvm::endianness{, ::little, ::native} (NFC)

2023-10-09 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2023-10-09T00:54:47-07:00
New Revision: d7b18d5083648c26b94adc2651edb87848138728

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

LOG: Use llvm::endianness{,::little,::native} (NFC)

Now that llvm::support::endianness has been renamed to
llvm::endianness, we can use the shorter form.  This patch replaces
llvm::support::endianness with llvm::endianness.

Added: 


Modified: 
clang/include/clang/Basic/ObjCRuntime.h
clang/include/clang/Basic/Sanitizers.h
clang/include/clang/Lex/HeaderSearchOptions.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
lld/ELF/Config.h
lldb/unittests/tools/lldb-server/tests/MessageObjects.cpp
lldb/unittests/tools/lldb-server/tests/MessageObjects.h
llvm/include/llvm/DebugInfo/GSYM/FileWriter.h
llvm/include/llvm/DebugInfo/GSYM/GsymCreator.h
llvm/include/llvm/DebugInfo/GSYM/GsymReader.h
llvm/include/llvm/Support/BinaryByteStream.h
llvm/include/llvm/Support/BinaryItemStream.h
llvm/include/llvm/Support/BinaryStream.h
llvm/include/llvm/Support/BinaryStreamReader.h
llvm/include/llvm/Support/BinaryStreamRef.h
llvm/include/llvm/Support/BinaryStreamWriter.h
llvm/include/llvm/Support/VersionTuple.h
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/DebugInfo/GSYM/GsymCreator.cpp
llvm/lib/ProfileData/InstrProfReader.cpp
llvm/lib/Support/BinaryStreamRef.cpp
llvm/lib/Support/BinaryStreamWriter.cpp
llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/unittests/ADT/HashingTest.cpp
llvm/unittests/DebugInfo/GSYM/GSYMTest.cpp
llvm/unittests/Support/HashBuilderTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/ObjCRuntime.h 
b/clang/include/clang/Basic/ObjCRuntime.h
index d783154c3f9f135..500b2462f007736 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -482,7 +482,7 @@ class ObjCRuntime {
 return llvm::hash_combine(OCR.getKind(), OCR.getVersion());
   }
 
-  template 
+  template 
   friend void addHash(llvm::HashBuilder &HBuilder,
   const ObjCRuntime &OCR) {
 HBuilder.add(OCR.getKind(), OCR.getVersion());

diff  --git a/clang/include/clang/Basic/Sanitizers.h 
b/clang/include/clang/Basic/Sanitizers.h
index 090a3a7fa907625..8fdaf2e4ba8ab18 100644
--- a/clang/include/clang/Basic/Sanitizers.h
+++ b/clang/include/clang/Basic/Sanitizers.h
@@ -77,7 +77,7 @@ class SanitizerMask {
 
   llvm::hash_code hash_value() const;
 
-  template 
+  template 
   friend void addHash(llvm::HashBuilder &HBuilder,
   const SanitizerMask &SM) {
 HBuilder.addRange(&SM.maskLoToHigh[0], &SM.maskLoToHigh[kNumElem]);

diff  --git a/clang/include/clang/Lex/HeaderSearchOptions.h 
b/clang/include/clang/Lex/HeaderSearchOptions.h
index 206bc69d7b2cdcb..c7d95006bb779ad 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -267,7 +267,7 @@ inline llvm::hash_code hash_value(const 
HeaderSearchOptions::Entry &E) {
   return llvm::hash_combine(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot);
 }
 
-template 
+template 
 inline void addHash(llvm::HashBuilder &HBuilder,
 const HeaderSearchOptions::Entry &E) {
   HBuilder.add(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot);
@@ -278,7 +278,7 @@ hash_value(const HeaderSearchOptions::SystemHeaderPrefix 
&SHP) {
   return llvm::hash_combine(SHP.Prefix, SHP.IsSystemHeader);
 }
 
-template 
+template 
 inline void addHash(llvm::HashBuilder &HBuilder,
 const HeaderSearchOptions::SystemHeaderPrefix &SHP) {
   HBuilder.add(SHP.Prefix, SHP.IsSystemHeader);

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index f2fe9046a6c1fe2..bb442495f58359c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4630,7 +4630,7 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Invocation,
 
 std::string CompilerInvocation::getModuleHash() const {
   // FIXME: Consider using SHA1 instead of MD5.
-  llvm::HashBuilder HBuilder;
+  llvm::HashBuilder HBuilder;
 
   // Note: For QoI reasons, the things we use as a hash here should all be
   // dumped via the -module-info flag.

diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 5e028c4431fe90f..40115b7b5ae25b3 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepC

[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-09 Thread Kiran Chandramohan via lldb-commits

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

Thanks for the detailed summary. LG.

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


[Lldb-commits] [lldb] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (PR #68574)

2023-10-09 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/68574

Since D101206 the `__hash_node::__value_` member is wrapped in an anonymous 
union. `ValueObject::GetChildMemberWithName` doesn't see through the union.

This patch accounts for this possible new layout by getting a handle to the 
union before doing the by-name `__value_` lookup.

>From b9313eb779d08ceb0a5dd3603db74b04866fc786 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 9 Oct 2023 11:54:56 +0100
Subject: [PATCH] [lldb][DataFormatter] unordered_map: account for new libc++
 __hash_node layout

Since D101206 the `__hash_node::__value_` member is wrapped in an
anonymous union. `ValueObject::GetChildMemberWithName` doesn't see
through the union.

This patch accounts for this possible new layout by getting a handle
to the union before doing the by-name `__value_` lookup.

(cherry picked from commit 49233f786c986e2796af7a432c728596758495c5)
---
 .../Language/CPlusPlus/LibCxxUnorderedMap.cpp| 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 14776cdf808157d..03619385b7d9968 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -162,10 +162,18 @@ lldb::ValueObjectSP lldb_private::formatters::
   if (!node_sp || error.Fail())
   return nullptr;
 
-  value_sp = node_sp->GetChildMemberWithName("__value_");
   hash_sp = node_sp->GetChildMemberWithName("__hash_");
-  if (!value_sp || !hash_sp)
+  if (!hash_sp)
 return nullptr;
+
+  value_sp = node_sp->GetChildMemberWithName("__value_");
+  if (!value_sp) {
+// Newer libc++ versions wrap the `__value_` in an anonymous union.
+auto anon_union = node_sp->GetChildAtIndex(2);
+value_sp = anon_union->GetChildMemberWithName("__value_");
+if (!value_sp)
+  return nullptr;
+  }
 }
 m_elements_cache.push_back(
 {value_sp.get(), hash_sp->GetValueAsUnsigned(0)});

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


[Lldb-commits] [lldb] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (PR #68574)

2023-10-09 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb


Changes

Since D101206 the `__hash_node::__value_` member is wrapped in an anonymous 
union. `ValueObject::GetChildMemberWithName` doesn't see through the union.

This patch accounts for this possible new layout by getting a handle to the 
union before doing the by-name `__value_` lookup.

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


1 Files Affected:

- (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
(+10-2) 


``diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 14776cdf808157d..03619385b7d9968 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -162,10 +162,18 @@ lldb::ValueObjectSP lldb_private::formatters::
   if (!node_sp || error.Fail())
   return nullptr;
 
-  value_sp = node_sp->GetChildMemberWithName("__value_");
   hash_sp = node_sp->GetChildMemberWithName("__hash_");
-  if (!value_sp || !hash_sp)
+  if (!hash_sp)
 return nullptr;
+
+  value_sp = node_sp->GetChildMemberWithName("__value_");
+  if (!value_sp) {
+// Newer libc++ versions wrap the `__value_` in an anonymous union.
+auto anon_union = node_sp->GetChildAtIndex(2);
+value_sp = anon_union->GetChildMemberWithName("__value_");
+if (!value_sp)
+  return nullptr;
+  }
 }
 m_elements_cache.push_back(
 {value_sp.get(), hash_sp->GetValueAsUnsigned(0)});

``




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


[Lldb-commits] [lldb] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (PR #68574)

2023-10-09 Thread Michael Buch via lldb-commits

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

>From 9001e6a7ac69e1a45f9d32153335feda5523 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 9 Oct 2023 11:54:56 +0100
Subject: [PATCH] [lldb][DataFormatter] unordered_map: account for new libc++
 __hash_node layout

Since D101206 the `__hash_node::__value_` member is wrapped in an
anonymous union. `ValueObject::GetChildMemberWithName` doesn't see
through the union.

This patch accounts for this possible new layout by getting a handle
to the union before doing the by-name `__value_` lookup.

(cherry picked from commit 49233f786c986e2796af7a432c728596758495c5)
---
 .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 14776cdf808157d..0200c2b46360c13 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -162,10 +162,21 @@ lldb::ValueObjectSP lldb_private::formatters::
   if (!node_sp || error.Fail())
   return nullptr;
 
-  value_sp = node_sp->GetChildMemberWithName("__value_");
   hash_sp = node_sp->GetChildMemberWithName("__hash_");
-  if (!value_sp || !hash_sp)
+  if (!hash_sp)
 return nullptr;
+
+  value_sp = node_sp->GetChildMemberWithName("__value_");
+  if (!value_sp) {
+// Newer libc++ versions wrap the `__value_` in an anonymous union.
+auto anon_union_sp = node_sp->GetChildAtIndex(2);
+if (!anon_union_sp)
+  return nullptr;
+
+value_sp = anon_union_sp->GetChildMemberWithName("__value_");
+if (!value_sp)
+  return nullptr;
+  }
 }
 m_elements_cache.push_back(
 {value_sp.get(), hash_sp->GetValueAsUnsigned(0)});

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


[Lldb-commits] [lldb] [OpenMPIRBuilder] Remove wrapper function in `createTask`, `createTeams` (PR #67723)

2023-10-09 Thread via lldb-commits

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


[Lldb-commits] [lldb] [InstCombine] Fold zext-of-icmp with no shift (PR #68503)

2023-10-09 Thread via lldb-commits

https://github.com/vfdff updated https://github.com/llvm/llvm-project/pull/68503

>From b4550f7f563287b86b7b99f1d4615782d040252d Mon Sep 17 00:00:00 2001
From: zhongyunde 00443407 
Date: Sat, 7 Oct 2023 23:44:18 -0400
Subject: [PATCH 1/2] [InstCombine] Precommit test for PR68465

---
 llvm/test/Transforms/InstCombine/zext.ll | 13 +
 1 file changed, 13 insertions(+)

diff --git a/llvm/test/Transforms/InstCombine/zext.ll 
b/llvm/test/Transforms/InstCombine/zext.ll
index 8aa2a10e6abb2ea..00147bb523f474e 100644
--- a/llvm/test/Transforms/InstCombine/zext.ll
+++ b/llvm/test/Transforms/InstCombine/zext.ll
@@ -748,3 +748,16 @@ define i64 @zext_icmp_ne_bool_1(ptr %ptr) {
   %len = zext i1 %cmp to i64
   ret i64 %len
 }
+
+define i32  @zext_icmp_eq0_no_shift(ptr %ptr ) {
+; CHECK-LABEL: @zext_icmp_eq0_no_shift(
+; CHECK-NEXT:[[X:%.*]] = load i8, ptr [[PTR:%.*]], align 1, !range 
[[RNG1:![0-9]+]]
+; CHECK-NEXT:[[TMP1:%.*]] = icmp eq i8 [[X]], 0
+; CHECK-NEXT:[[RES:%.*]] = zext i8 [[TMP1]] to i32
+; CHECK-NEXT:ret i32 [[RES]]
+;
+  %X = load i8, ptr %ptr,align 1, !range !{i8 0, i8 2} ; range [0, 2)
+  %cmp = icmp eq i8 %X, 0
+  %res = zext i1 %cmp to i32
+  ret i32 %res
+}

>From d73aa16f21dce989379d677d87ec352c1dc553e4 Mon Sep 17 00:00:00 2001
From: zhongyunde 00443407 
Date: Sat, 7 Oct 2023 04:43:57 -0400
Subject: [PATCH 2/2] [InstCombine] Fold zext-of-icmp with no shift

This regression triggers after commit f400daa to fix infinite loop issue.

In this case, we can known the shift count is 0, so it will not be
triggered by the form of (iN (~X) u>> (N - 1)) in commit 21d3871, of
which N indicates the data type bitwidth of X.

Fixes https://github.com/llvm/llvm-project/issues/68465
---
 .../Transforms/InstCombine/InstCombineCasts.cpp | 17 -
 llvm/test/Transforms/InstCombine/zext.ll|  3 ++-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 20c13de33f8189d..b8b33d9bc382f68 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -904,19 +904,18 @@ Instruction *InstCombinerImpl::transformZExtICmp(ICmpInst 
*Cmp,
 // zext (X == 0) to i32 --> (X>>1)^1 iff X has only the 2nd bit set.
 // zext (X != 0) to i32 --> Xiff X has only the low bit set.
 // zext (X != 0) to i32 --> X>>1 iff X has only the 2nd bit set.
-if (Op1CV->isZero() && Cmp->isEquality() &&
-(Cmp->getOperand(0)->getType() == Zext.getType() ||
- Cmp->getPredicate() == ICmpInst::ICMP_NE)) {
-  // If Op1C some other power of two, convert:
-  KnownBits Known = computeKnownBits(Cmp->getOperand(0), 0, &Zext);
 
+if (Op1CV->isZero() && Cmp->isEquality()) {
   // Exactly 1 possible 1? But not the high-bit because that is
   // canonicalized to this form.
+  KnownBits Known = computeKnownBits(Cmp->getOperand(0), 0, &Zext);
   APInt KnownZeroMask(~Known.Zero);
-  if (KnownZeroMask.isPowerOf2() &&
-  (Zext.getType()->getScalarSizeInBits() !=
-   KnownZeroMask.logBase2() + 1)) {
-uint32_t ShAmt = KnownZeroMask.logBase2();
+  uint32_t ShAmt = KnownZeroMask.logBase2();
+  bool isExpectShAmt = KnownZeroMask.isPowerOf2() &&
+   (Zext.getType()->getScalarSizeInBits() != ShAmt + 
1);
+  if (isExpectShAmt &&
+  (Cmp->getOperand(0)->getType() == Zext.getType() ||
+   Cmp->getPredicate() == ICmpInst::ICMP_NE || ShAmt == 0)) {
 Value *In = Cmp->getOperand(0);
 if (ShAmt) {
   // Perform a logical shr by shiftamt.
diff --git a/llvm/test/Transforms/InstCombine/zext.ll 
b/llvm/test/Transforms/InstCombine/zext.ll
index 00147bb523f474e..f595638ba9e3083 100644
--- a/llvm/test/Transforms/InstCombine/zext.ll
+++ b/llvm/test/Transforms/InstCombine/zext.ll
@@ -749,10 +749,11 @@ define i64 @zext_icmp_ne_bool_1(ptr %ptr) {
   ret i64 %len
 }
 
+; https://alive2.llvm.org/ce/z/k7qosS
 define i32  @zext_icmp_eq0_no_shift(ptr %ptr ) {
 ; CHECK-LABEL: @zext_icmp_eq0_no_shift(
 ; CHECK-NEXT:[[X:%.*]] = load i8, ptr [[PTR:%.*]], align 1, !range 
[[RNG1:![0-9]+]]
-; CHECK-NEXT:[[TMP1:%.*]] = icmp eq i8 [[X]], 0
+; CHECK-NEXT:[[TMP1:%.*]] = xor i8 [[X]], 1
 ; CHECK-NEXT:[[RES:%.*]] = zext i8 [[TMP1]] to i32
 ; CHECK-NEXT:ret i32 [[RES]]
 ;

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


[Lldb-commits] [lldb] 2e82696 - [lldb][NFCI] Remove use of ConstString from FilterRule in StructuredDataDarwinLog (#68347)

2023-10-09 Thread via lldb-commits

Author: Alex Langford
Date: 2023-10-09T10:36:56-07:00
New Revision: 2e8269690909ddeced2bb9dd783ff88bf179c246

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

LOG: [lldb][NFCI] Remove use of ConstString from FilterRule in 
StructuredDataDarwinLog (#68347)

There are only ever 2 FilterRules and their operations are either
"regex" or "match". This does not benefit from deduplication since the
strings have static lifetime and we can just compare StringRefs pointing
to them. This is also not on a fast path, so it doesn't really benefit
from the pointer comparisons of ConstStrings.

Added: 


Modified: 
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp 
b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index 61e04900da342d2..f8a8df84ca37f29 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -32,6 +32,8 @@
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegularExpression.h"
 
+#include "llvm/ADT/StringMap.h"
+
 #define DARWIN_LOG_TYPE_VALUE "DarwinLog"
 
 using namespace lldb;
@@ -183,21 +185,20 @@ class FilterRule {
   std::function;
 
-  static void RegisterOperation(ConstString operation,
+  static void RegisterOperation(llvm::StringRef operation,
 const OperationCreationFunc &creation_func) {
 GetCreationFuncMap().insert(std::make_pair(operation, creation_func));
   }
 
   static FilterRuleSP CreateRule(bool match_accepts, size_t attribute,
- ConstString operation,
+ llvm::StringRef operation,
  const std::string &op_arg, Status &error) {
 // Find the creation func for this type of filter rule.
 auto map = GetCreationFuncMap();
 auto find_it = map.find(operation);
 if (find_it == map.end()) {
-  error.SetErrorStringWithFormat("unknown filter operation \""
- "%s\"",
- operation.GetCString());
+  error.SetErrorStringWithFormatv("unknown filter operation \"{0}\"",
+  operation);
   return FilterRuleSP();
 }
 
@@ -217,7 +218,7 @@ class FilterRule {
 dict_p->AddStringItem("attribute", s_filter_attributes[m_attribute_index]);
 
 // Indicate the type of the rule.
-dict_p->AddStringItem("type", GetOperationType().GetCString());
+dict_p->AddStringItem("type", GetOperationType());
 
 // Let the rule add its own specific details here.
 DoSerialization(*dict_p);
@@ -227,10 +228,10 @@ class FilterRule {
 
   virtual void Dump(Stream &stream) const = 0;
 
-  ConstString GetOperationType() const { return m_operation; }
+  llvm::StringRef GetOperationType() const { return m_operation; }
 
 protected:
-  FilterRule(bool accept, size_t attribute_index, ConstString operation)
+  FilterRule(bool accept, size_t attribute_index, llvm::StringRef operation)
   : m_accept(accept), m_attribute_index(attribute_index),
 m_operation(operation) {}
 
@@ -243,7 +244,7 @@ class FilterRule {
   }
 
 private:
-  using CreationFuncMap = std::map;
+  using CreationFuncMap = llvm::StringMap;
 
   static CreationFuncMap &GetCreationFuncMap() {
 static CreationFuncMap s_map;
@@ -252,7 +253,8 @@ class FilterRule {
 
   const bool m_accept;
   const size_t m_attribute_index;
-  const ConstString m_operation;
+  // The lifetime of m_operation should be static.
+  const llvm::StringRef m_operation;
 };
 
 using FilterRules = std::vector;
@@ -296,8 +298,8 @@ class RegexFilterRule : public FilterRule {
 return FilterRuleSP(new RegexFilterRule(accept, attribute_index, op_arg));
   }
 
-  static ConstString StaticGetOperation() {
-static ConstString s_operation("regex");
+  static llvm::StringRef StaticGetOperation() {
+static constexpr llvm::StringLiteral s_operation("regex");
 return s_operation;
   }
 
@@ -341,8 +343,8 @@ class ExactMatchFilterRule : public FilterRule {
 new ExactMatchFilterRule(accept, attribute_index, op_arg));
   }
 
-  static ConstString StaticGetOperation() {
-static ConstString s_operation("match");
+  static llvm::StringRef StaticGetOperation() {
+static constexpr llvm::StringLiteral s_operation("match");
 return s_operation;
   }
 
@@ -701,7 +703,7 @@ class EnableOptions : public Options {
 
 // add filter spec
 auto rule_sp = FilterRule::CreateRule(
-accept, attribute_index, ConstString(operation),
+accept, attribute_index, operation,
 std::string(rule

[Lldb-commits] [lldb] [lldb][NFCI] Remove use of ConstString from FilterRule in StructuredDataDarwinLog (PR #68347)

2023-10-09 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (PR #68574)

2023-10-09 Thread Alex Langford via lldb-commits


@@ -162,10 +162,21 @@ lldb::ValueObjectSP lldb_private::formatters::
   if (!node_sp || error.Fail())
   return nullptr;
 
-  value_sp = node_sp->GetChildMemberWithName("__value_");
   hash_sp = node_sp->GetChildMemberWithName("__hash_");
-  if (!value_sp || !hash_sp)
+  if (!hash_sp)
 return nullptr;
+
+  value_sp = node_sp->GetChildMemberWithName("__value_");
+  if (!value_sp) {
+// Newer libc++ versions wrap the `__value_` in an anonymous union.

bulbazord wrote:

It might be useful to specify when this was introduced in libc++ in case this 
logic gets updated again in the future for an even newer libc++.

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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread Greg Clayton via lldb-commits
=?utf-8?q?Jos=C3=A9?= L. Junior ,
=?utf-8?q?Jos=C3=A9?= L. Junior 
Message-ID:
In-Reply-To: 


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


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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread Med Ismail Bennani via lldb-commits
=?utf-8?q?José?= L. Junior ,
=?utf-8?q?José?= L. Junior 
Message-ID:
In-Reply-To: 


medismailben wrote:

@junior-jl I think everyone approved the PR so you just need to address the 
formatting issues so we can merge it. Would you mind squashing your 3 commits 
into a single one and running `git clang-format HEAD~` and `git commit --amend 
--no-edit` and pushing your branch again ? Thanks! 

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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/67019

From 5e03656813dfa9ff5985a9e1aa7a001872115500 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 3 Oct 2023 15:28:45 -0300
Subject: [PATCH] [lldb] add stop-at-user-entry option to process launch

[lldb] add stop-at-user-entry option to process launch

refactor CreateBreakpointAtUserEntry method

remove unecessary includes
---
 lldb/include/lldb/Target/Language.h   |  4 ++
 lldb/include/lldb/Target/Target.h |  2 +
 .../Commands/CommandOptionsProcessLaunch.cpp  |  8 ++--
 lldb/source/Commands/Options.td   |  4 ++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  2 +
 .../Plugins/Language/ObjC/ObjCLanguage.h  |  2 +
 .../ObjCPlusPlus/ObjCPlusPlusLanguage.h   |  2 +
 lldb/source/Target/Target.cpp | 41 +++
 .../command-process-launch-user-entry.test|  8 
 9 files changed, 70 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/Shell/Commands/command-process-launch-user-entry.test

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index a6b9ccaf31b3c42..d53089ba4a59974 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -160,6 +160,10 @@ class Language : public PluginInterface {
 
   virtual lldb::LanguageType GetLanguageType() const = 0;
 
+  // Implement this function to return the user-defined entry point name
+  // for the language
+  virtual llvm::StringRef GetUserEntryPointName() const { return {}; }
+
   virtual bool IsTopLevelFunction(Function &function);
 
   virtual bool IsSourceFile(llvm::StringRef file_path) const = 0;
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e9e531d0e12640a..8752b42a9518983 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -654,6 +654,8 @@ class Target : public std::enable_shared_from_this,
 
   lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id);
 
+  lldb::BreakpointSP CreateBreakpointAtUserEntry(Status &error);
+
   // Use this to create a file and line breakpoint to a given module or all
   // module it is nullptr
   lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp 
b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
index 85ad8ff5e07132c..b1c13d4df79e0ee 100644
--- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
+++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
@@ -34,11 +34,15 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   Status error;
   const int short_option = g_process_launch_options[option_idx].short_option;
 
+  TargetSP target_sp =
+  execution_context ? execution_context->GetTargetSP() : TargetSP();
   switch (short_option) {
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at user entry point
+target_sp->CreateBreakpointAtUserEntry(error);
+break;
   case 'i': // STDIN for read only
   {
 FileAction action;
@@ -89,8 +93,6 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
 break;
 
   case 'a': {
-TargetSP target_sp =
-execution_context ? execution_context->GetTargetSP() : TargetSP();
 PlatformSP platform_sp =
 target_sp ? target_sp->GetPlatform() : PlatformSP();
 launch_info.GetArchitecture() =
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 04830b8b990efae..dd4cf5c4dc043e7 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -675,6 +675,10 @@ let Command = "platform shell" in {
 let Command = "process launch" in {
   def process_launch_stop_at_entry : Option<"stop-at-entry", "s">,
 Desc<"Stop at the entry point of the program when launching a process.">;
+  def process_launch_stop_at_user_entry : Option<"stop-at-user-entry", "m">,
+Desc<"Stop at the user entry point when launching a process. For C based "
+"languages this will be the 'main' function, but this might differ for "
+"other languages.">;
   def process_launch_disable_aslr : Option<"disable-aslr", "A">, 
Arg<"Boolean">,
 Desc<"Set whether to disable address space layout randomization when 
launching a process.">;
   def process_launch_plugin : Option<"plugin", "P">, Arg<"Plugin">,
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 7712a60b7795951..623d481bf117f48 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -103,6 +103,8 @@ class CPlusPlusLanguage : public Language {
 return lldb::eLanguageTypeC_plus_plus;
   }
 
+  llvm::StringRef GetUserEntryPointName() const override { return "main"; }
+
   st

[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/67019

From c5466f3d06b1859e5ea880a4c88dca91e85f5b4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 3 Oct 2023 15:28:45 -0300
Subject: [PATCH] [lldb] add stop-at-user-entry option to process launch

[lldb] add stop-at-user-entry option to process launch

refactor CreateBreakpointAtUserEntry method

remove unecessary includes
---
 lldb/include/lldb/Target/Language.h   |  4 ++
 lldb/include/lldb/Target/Target.h |  2 +
 .../Commands/CommandOptionsProcessLaunch.cpp  |  8 ++--
 lldb/source/Commands/Options.td   |  4 ++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  2 +
 .../Plugins/Language/ObjC/ObjCLanguage.h  |  2 +
 .../ObjCPlusPlus/ObjCPlusPlusLanguage.h   |  2 +
 lldb/source/Target/Target.cpp | 41 +++
 .../command-process-launch-user-entry.test|  8 
 9 files changed, 70 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/Shell/Commands/command-process-launch-user-entry.test

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index a6b9ccaf31b3c42..d53089ba4a59974 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -160,6 +160,10 @@ class Language : public PluginInterface {
 
   virtual lldb::LanguageType GetLanguageType() const = 0;
 
+  // Implement this function to return the user-defined entry point name
+  // for the language
+  virtual llvm::StringRef GetUserEntryPointName() const { return {}; }
+
   virtual bool IsTopLevelFunction(Function &function);
 
   virtual bool IsSourceFile(llvm::StringRef file_path) const = 0;
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e9e531d0e12640a..8752b42a9518983 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -654,6 +654,8 @@ class Target : public std::enable_shared_from_this,
 
   lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id);
 
+  lldb::BreakpointSP CreateBreakpointAtUserEntry(Status &error);
+
   // Use this to create a file and line breakpoint to a given module or all
   // module it is nullptr
   lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp 
b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
index 85ad8ff5e07132c..b1c13d4df79e0ee 100644
--- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
+++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
@@ -34,11 +34,15 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   Status error;
   const int short_option = g_process_launch_options[option_idx].short_option;
 
+  TargetSP target_sp =
+  execution_context ? execution_context->GetTargetSP() : TargetSP();
   switch (short_option) {
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at user entry point
+target_sp->CreateBreakpointAtUserEntry(error);
+break;
   case 'i': // STDIN for read only
   {
 FileAction action;
@@ -89,8 +93,6 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
 break;
 
   case 'a': {
-TargetSP target_sp =
-execution_context ? execution_context->GetTargetSP() : TargetSP();
 PlatformSP platform_sp =
 target_sp ? target_sp->GetPlatform() : PlatformSP();
 launch_info.GetArchitecture() =
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index cfdeaabfa007743..7af20e93a16d438 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -675,6 +675,10 @@ let Command = "platform shell" in {
 let Command = "process launch" in {
   def process_launch_stop_at_entry : Option<"stop-at-entry", "s">,
 Desc<"Stop at the entry point of the program when launching a process.">;
+  def process_launch_stop_at_user_entry : Option<"stop-at-user-entry", "m">,
+Desc<"Stop at the user entry point when launching a process. For C based "
+"languages this will be the 'main' function, but this might differ for "
+"other languages.">;
   def process_launch_disable_aslr : Option<"disable-aslr", "A">, 
Arg<"Boolean">,
 Desc<"Set whether to disable address space layout randomization when 
launching a process.">;
   def process_launch_plugin : Option<"plugin", "P">, Arg<"Plugin">,
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 7712a60b7795951..623d481bf117f48 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -103,6 +103,8 @@ class CPlusPlusLanguage : public Language {
 return lldb::eLanguageTypeC_plus_plus;
   }
 
+  llvm::StringRef GetUserEntryPointName() const override { return "main"; }
+
   st

[Lldb-commits] [lldb] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (PR #68574)

2023-10-09 Thread Michael Buch via lldb-commits

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

>From 9001e6a7ac69e1a45f9d32153335feda5523 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 9 Oct 2023 11:54:56 +0100
Subject: [PATCH 1/2] [lldb][DataFormatter] unordered_map: account for new
 libc++ __hash_node layout

Since D101206 the `__hash_node::__value_` member is wrapped in an
anonymous union. `ValueObject::GetChildMemberWithName` doesn't see
through the union.

This patch accounts for this possible new layout by getting a handle
to the union before doing the by-name `__value_` lookup.

(cherry picked from commit 49233f786c986e2796af7a432c728596758495c5)
---
 .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 14776cdf808157d..0200c2b46360c13 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -162,10 +162,21 @@ lldb::ValueObjectSP lldb_private::formatters::
   if (!node_sp || error.Fail())
   return nullptr;
 
-  value_sp = node_sp->GetChildMemberWithName("__value_");
   hash_sp = node_sp->GetChildMemberWithName("__hash_");
-  if (!value_sp || !hash_sp)
+  if (!hash_sp)
 return nullptr;
+
+  value_sp = node_sp->GetChildMemberWithName("__value_");
+  if (!value_sp) {
+// Newer libc++ versions wrap the `__value_` in an anonymous union.
+auto anon_union_sp = node_sp->GetChildAtIndex(2);
+if (!anon_union_sp)
+  return nullptr;
+
+value_sp = anon_union_sp->GetChildMemberWithName("__value_");
+if (!value_sp)
+  return nullptr;
+  }
 }
 m_elements_cache.push_back(
 {value_sp.get(), hash_sp->GetValueAsUnsigned(0)});

>From 8ff81e25de4f991d8eae6e5ec1d31868d57a41cf Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 9 Oct 2023 21:51:15 +0100
Subject: [PATCH 2/2] fixup! provide more context in comment

---
 .../source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 0200c2b46360c13..ac3362b3dbb601c 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -168,7 +168,10 @@ lldb::ValueObjectSP lldb_private::formatters::
 
   value_sp = node_sp->GetChildMemberWithName("__value_");
   if (!value_sp) {
-// Newer libc++ versions wrap the `__value_` in an anonymous union.
+// Since D101206, libc++ wraps the `__value_` in an anonymous union.
+// Child 0: __hash_node_base base class
+// Child 1: __hash_
+// Child 2: anonymous union
 auto anon_union_sp = node_sp->GetChildAtIndex(2);
 if (!anon_union_sp)
   return nullptr;

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


[Lldb-commits] [lldb] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (PR #68574)

2023-10-09 Thread Michael Buch via lldb-commits


@@ -162,10 +162,21 @@ lldb::ValueObjectSP lldb_private::formatters::
   if (!node_sp || error.Fail())
   return nullptr;
 
-  value_sp = node_sp->GetChildMemberWithName("__value_");
   hash_sp = node_sp->GetChildMemberWithName("__hash_");
-  if (!value_sp || !hash_sp)
+  if (!hash_sp)
 return nullptr;
+
+  value_sp = node_sp->GetChildMemberWithName("__value_");
+  if (!value_sp) {
+// Newer libc++ versions wrap the `__value_` in an anonymous union.

Michael137 wrote:

Agreed

Let me know if latest comment provides enough context/info

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


[Lldb-commits] [lldb] [lldb][DataFormatter] unordered_map: account for new libc++ __hash_node layout (PR #68574)

2023-10-09 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread Jonas Devlieghere via lldb-commits


@@ -335,6 +335,47 @@ BreakpointSP Target::GetBreakpointByID(break_id_t 
break_id) {
   return bp_sp;
 }
 
+lldb::BreakpointSP
+lldb_private::Target::CreateBreakpointAtUserEntry(Status &error) {
+  ModuleSP main_module_sp = GetExecutableModule();
+  FileSpecList shared_lib_filter;
+  shared_lib_filter.Append(main_module_sp->GetFileSpec());
+  llvm::SetVector,
+  std::unordered_set>
+  entryPointNamesSet;
+  for (LanguageType lang_type : Language::GetSupportedLanguages()) {
+Language *lang = Language::FindPlugin(lang_type);
+if (!lang) {
+  error.SetErrorString("Language not found\n");
+  return lldb::BreakpointSP();
+}
+std::string entryPointName = lang->GetUserEntryPointName().str();
+if (!entryPointName.empty())
+  entryPointNamesSet.insert(entryPointName);
+  }
+  if (entryPointNamesSet.empty()) {
+error.SetErrorString("No entry point name found\n");
+return lldb::BreakpointSP();
+  }
+  BreakpointSP bp_sp =
+  CreateBreakpoint(&shared_lib_filter,
+   nullptr, // containingSourceFiles
+   entryPointNamesSet.takeVector(),
+   eFunctionNameTypeFull, // func_name_type_mask
+   eLanguageTypeUnknown,  // language
+   0, // offset
+   eLazyBoolNo,   // skip_prologue
+   false, // internal
+   false  // hardware

JDevlieghere wrote:

Is there prior art in Target.cpp for specifying the arguments like this? I 
think most of the code base uses inline comments (e.g. 
`/*containingSourceFiles=*/nullptr`)

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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,8 @@
+# RUN: %clang_host -g %S/Inputs/main.c -o %t
+# RUN: %lldb %t -s %s -o exit | FileCheck %s
+
+process launch -m
+# CHECK-LABEL: process launch -m
+# CHECK: Process {{.*}} stopped
+# CHECK: stop reason = one-shot breakpoint 1
+# CHECK:   frame #0: {{.*}}`main at main.c

JDevlieghere wrote:

No newline at the end of this file?

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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread Jonas Devlieghere via lldb-commits


@@ -160,6 +160,10 @@ class Language : public PluginInterface {
 
   virtual lldb::LanguageType GetLanguageType() const = 0;
 
+  // Implement this function to return the user-defined entry point name
+  // for the language

JDevlieghere wrote:

Missing period

https://github.com/llvm/llvm-project/pull/67019
___
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 use of ConstString from FilterRule in StructuredDataDarwinLog (PR #68347)

2023-10-09 Thread Jonas Devlieghere via lldb-commits


@@ -252,7 +253,8 @@ class FilterRule {
 
   const bool m_accept;
   const size_t m_attribute_index;
-  const ConstString m_operation;
+  // The lifetime of m_operation should be static.

JDevlieghere wrote:

Static seems confusing in this context. Do you mean should be fixed for the 
lifetime of this object?

https://github.com/llvm/llvm-project/pull/68347
___
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 use of ConstString from FilterRule in StructuredDataDarwinLog (PR #68347)

2023-10-09 Thread Alex Langford via lldb-commits


@@ -252,7 +253,8 @@ class FilterRule {
 
   const bool m_accept;
   const size_t m_attribute_index;
-  const ConstString m_operation;
+  // The lifetime of m_operation should be static.

bulbazord wrote:

Ah, yeah it is a little confusing now that I look at it. I wanted to convey 
that the lifetime of the StringRef should be as long as the lifetime of the 
program (since it's backed by a static string literal right now). Maybe 
something like:

"m_operation is backed by a static string literal, so lifetime should not be a 
concern"

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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread José Lira Junior via lldb-commits

https://github.com/junior-jl updated 
https://github.com/llvm/llvm-project/pull/67019

From 6fd515e6e6cd392128410b30d243714c4bcc549b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= 
Date: Tue, 3 Oct 2023 15:28:45 -0300
Subject: [PATCH] [lldb] add stop-at-user-entry option to process launch

[lldb] add stop-at-user-entry option to process launch

refactor CreateBreakpointAtUserEntry method

remove unecessary includes
---
 lldb/include/lldb/Target/Language.h   |  4 ++
 lldb/include/lldb/Target/Target.h |  2 +
 .../Commands/CommandOptionsProcessLaunch.cpp  |  8 ++--
 lldb/source/Commands/Options.td   |  4 ++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  2 +
 .../Plugins/Language/ObjC/ObjCLanguage.h  |  2 +
 .../ObjCPlusPlus/ObjCPlusPlusLanguage.h   |  2 +
 lldb/source/Target/Target.cpp | 39 +++
 .../command-process-launch-user-entry.test|  8 
 9 files changed, 68 insertions(+), 3 deletions(-)
 create mode 100644 
lldb/test/Shell/Commands/command-process-launch-user-entry.test

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index a6b9ccaf31b3c42..0cbd8a32dccd54e 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -160,6 +160,10 @@ class Language : public PluginInterface {
 
   virtual lldb::LanguageType GetLanguageType() const = 0;
 
+  // Implement this function to return the user-defined entry point name
+  // for the language.
+  virtual llvm::StringRef GetUserEntryPointName() const { return {}; }
+
   virtual bool IsTopLevelFunction(Function &function);
 
   virtual bool IsSourceFile(llvm::StringRef file_path) const = 0;
diff --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e9e531d0e12640a..8752b42a9518983 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -654,6 +654,8 @@ class Target : public std::enable_shared_from_this,
 
   lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id);
 
+  lldb::BreakpointSP CreateBreakpointAtUserEntry(Status &error);
+
   // Use this to create a file and line breakpoint to a given module or all
   // module it is nullptr
   lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,
diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp 
b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
index 85ad8ff5e07132c..b1c13d4df79e0ee 100644
--- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
+++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
@@ -34,11 +34,15 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   Status error;
   const int short_option = g_process_launch_options[option_idx].short_option;
 
+  TargetSP target_sp =
+  execution_context ? execution_context->GetTargetSP() : TargetSP();
   switch (short_option) {
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at user entry point
+target_sp->CreateBreakpointAtUserEntry(error);
+break;
   case 'i': // STDIN for read only
   {
 FileAction action;
@@ -89,8 +93,6 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
 break;
 
   case 'a': {
-TargetSP target_sp =
-execution_context ? execution_context->GetTargetSP() : TargetSP();
 PlatformSP platform_sp =
 target_sp ? target_sp->GetPlatform() : PlatformSP();
 launch_info.GetArchitecture() =
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index cfdeaabfa007743..7af20e93a16d438 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -675,6 +675,10 @@ let Command = "platform shell" in {
 let Command = "process launch" in {
   def process_launch_stop_at_entry : Option<"stop-at-entry", "s">,
 Desc<"Stop at the entry point of the program when launching a process.">;
+  def process_launch_stop_at_user_entry : Option<"stop-at-user-entry", "m">,
+Desc<"Stop at the user entry point when launching a process. For C based "
+"languages this will be the 'main' function, but this might differ for "
+"other languages.">;
   def process_launch_disable_aslr : Option<"disable-aslr", "A">, 
Arg<"Boolean">,
 Desc<"Set whether to disable address space layout randomization when 
launching a process.">;
   def process_launch_plugin : Option<"plugin", "P">, Arg<"Plugin">,
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 7712a60b7795951..623d481bf117f48 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -103,6 +103,8 @@ class CPlusPlusLanguage : public Language {
 return lldb::eLanguageTypeC_plus_plus;
   }
 
+  llvm::StringRef GetUserEntryPointName() const override { return "main"; }
+
   s

[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread José Lira Junior via lldb-commits

junior-jl wrote:

Addressed @JDevlieghere comments regarding formatting and inlined comments.

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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread Jonas Devlieghere via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread José Lira Junior via lldb-commits

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


[Lldb-commits] [lldb] ac0dda8 - [lldb] add stop-at-user-entry option to process launch (#67019)

2023-10-09 Thread via lldb-commits

Author: José Lira Junior
Date: 2023-10-09T16:43:59-07:00
New Revision: ac0dda894231e6281e7739aa0ea01a4e9697c747

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

LOG: [lldb] add stop-at-user-entry option to process launch (#67019)

## Description
This pull request adds a new `stop-at-user-entry` option to LLDB
`process launch` command, allowing users to launch a process and pause
execution at the entry point of the program (for C-based languages,
`main` function).

## Motivation
This option provides a convenient way to begin debugging a program by
launching it and breaking at the desired entry point.

## Changes Made
- Added `stop-at-user-entry` option to `Options.td` and the
corresponding case in `CommandOptionsProcessLaunch.cpp` (short option is
'm')
- Implemented `GetUserEntryPointName` method in the Language plugins
available at the moment.
- Declared the `CreateBreakpointAtUserEntry` method in the Target API.
- Create Shell test for the command
`command-process-launch-user-entry.test`.

## Usage
`process launch --stop-at-user-entry` or `process launch -m` launches
the process and pauses execution at the entry point of the program.

Added: 
lldb/test/Shell/Commands/command-process-launch-user-entry.test

Modified: 
lldb/include/lldb/Target/Language.h
lldb/include/lldb/Target/Target.h
lldb/source/Commands/CommandOptionsProcessLaunch.cpp
lldb/source/Commands/Options.td
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index a6b9ccaf31b3c42..0cbd8a32dccd54e 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -160,6 +160,10 @@ class Language : public PluginInterface {
 
   virtual lldb::LanguageType GetLanguageType() const = 0;
 
+  // Implement this function to return the user-defined entry point name
+  // for the language.
+  virtual llvm::StringRef GetUserEntryPointName() const { return {}; }
+
   virtual bool IsTopLevelFunction(Function &function);
 
   virtual bool IsSourceFile(llvm::StringRef file_path) const = 0;

diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index e9e531d0e12640a..8752b42a9518983 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -654,6 +654,8 @@ class Target : public std::enable_shared_from_this,
 
   lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id);
 
+  lldb::BreakpointSP CreateBreakpointAtUserEntry(Status &error);
+
   // Use this to create a file and line breakpoint to a given module or all
   // module it is nullptr
   lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules,

diff  --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp 
b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
index 85ad8ff5e07132c..b1c13d4df79e0ee 100644
--- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
+++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
@@ -34,11 +34,15 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
   Status error;
   const int short_option = g_process_launch_options[option_idx].short_option;
 
+  TargetSP target_sp =
+  execution_context ? execution_context->GetTargetSP() : TargetSP();
   switch (short_option) {
   case 's': // Stop at program entry point
 launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
 break;
-
+  case 'm': // Stop at user entry point
+target_sp->CreateBreakpointAtUserEntry(error);
+break;
   case 'i': // STDIN for read only
   {
 FileAction action;
@@ -89,8 +93,6 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
 break;
 
   case 'a': {
-TargetSP target_sp =
-execution_context ? execution_context->GetTargetSP() : TargetSP();
 PlatformSP platform_sp =
 target_sp ? target_sp->GetPlatform() : PlatformSP();
 launch_info.GetArchitecture() =

diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index cfdeaabfa007743..7af20e93a16d438 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -675,6 +675,10 @@ let Command = "platform shell" in {
 let Command = "process launch" in {
   def process_launch_stop_at_entry : Option<"stop-at-entry", "s">,
 Desc<"Stop at the entry point of the program when launching a process.">;
+  def process_launch_stop_at_user_entry : Option<"stop-at-user-entry", "m">,
+Desc<"Stop at the user entry point when launching a process. For C based "
+"languages this will be the 'main' function, but this might 
diff er for 

[Lldb-commits] [lldb] [lldb] add stop-at-user-entry option to process launch (PR #67019)

2023-10-09 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [ELF] Making cdsort default for function reordering (PR #68638)

2023-10-09 Thread via lldb-commits

https://github.com/spupyrev updated 
https://github.com/llvm/llvm-project/pull/68638

>From 9ae8e860296e77dbb4f0ba4332c133827ff0dd9f Mon Sep 17 00:00:00 2001
From: spupyrev 
Date: Mon, 9 Oct 2023 14:11:21 -0700
Subject: [PATCH] [ELF] Making cdsort default for function reordering

---
 lld/ELF/Driver.cpp| 2 +-
 lld/docs/ld.lld.1 | 4 ++--
 lld/test/ELF/cgprofile-bad-clusters.s | 2 +-
 lld/test/ELF/cgprofile-icf.s  | 4 ++--
 lld/test/ELF/cgprofile-rela.test  | 2 +-
 lld/test/ELF/cgprofile-txt.s  | 6 +++---
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 6272276e94b2d35..e2100d00d54ede6 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1095,7 +1095,7 @@ static void 
ltoValidateAllVtablesHaveTypeInfos(opt::InputArgList &args) {
 }
 
 static CGProfileSortKind getCGProfileSortKind(opt::InputArgList &args) {
-  StringRef s = args.getLastArgValue(OPT_call_graph_profile_sort, "hfsort");
+  StringRef s = args.getLastArgValue(OPT_call_graph_profile_sort, "cdsort");
   if (s == "hfsort")
 return CGProfileSortKind::Hfsort;
   if (s == "cdsort")
diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1
index 2e46fc18132f3e0..12b17dd37796d13 100644
--- a/lld/docs/ld.lld.1
+++ b/lld/docs/ld.lld.1
@@ -128,9 +128,9 @@ may be:
 .It Cm none
 Ignore call graph profile.
 .It Cm hfsort
-Use hfsort (default).
+Use hfsort.
 .It Cm cdsort
-Use cdsort.
+Use cdsort (default).
 .El
 .Pp
 .It Fl -color-diagnostics Ns = Ns Ar value
diff --git a/lld/test/ELF/cgprofile-bad-clusters.s 
b/lld/test/ELF/cgprofile-bad-clusters.s
index c162e981acdd633..88e68bfb7b2c0a1 100644
--- a/lld/test/ELF/cgprofile-bad-clusters.s
+++ b/lld/test/ELF/cgprofile-bad-clusters.s
@@ -10,7 +10,7 @@
 # RUN: echo "F G 6" >> %t.call_graph
 # RUN: echo "G H 5" >> %t.call_graph
 # RUN: echo "H I 4" >> %t.call_graph
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort  -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s
 
 .section.text.A,"ax",@progbits
diff --git a/lld/test/ELF/cgprofile-icf.s b/lld/test/ELF/cgprofile-icf.s
index a9de5613917cbf1..e28630d0eb30bf0 100644
--- a/lld/test/ELF/cgprofile-icf.s
+++ b/lld/test/ELF/cgprofile-icf.s
@@ -5,9 +5,9 @@
 # RUN: echo "A B 100" > %t.call_graph
 # RUN: echo "A C 40" >> %t.call_graph
 # RUN: echo "C D 61" >> %t.call_graph
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t.out 
-icf=all
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t.out -icf=all
 # RUN: llvm-readobj --symbols %t.out | FileCheck %s
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2.out
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t2.out
 # RUN: llvm-readobj --symbols %t2.out | FileCheck %s --check-prefix=NOICF
 
 .section.text.D,"ax",@progbits
diff --git a/lld/test/ELF/cgprofile-rela.test b/lld/test/ELF/cgprofile-rela.test
index 189f169e65481ee..141dfd4c65b1ea1 100644
--- a/lld/test/ELF/cgprofile-rela.test
+++ b/lld/test/ELF/cgprofile-rela.test
@@ -3,7 +3,7 @@
 # REQUIRES: x86
 
 # RUN: yaml2obj %s -o %t.o
-# RUN: ld.lld %t.o -o %t
+# RUN: ld.lld --call-graph-profile-sort=hfsort %t.o -o %t
 # RUN: llvm-nm --no-sort %t | FileCheck %s
 # RUN: ld.lld --no-call-graph-profile-sort %t.o -o %t
 # RUN: llvm-nm --no-sort %t | FileCheck %s --check-prefix=NO-CG
diff --git a/lld/test/ELF/cgprofile-txt.s b/lld/test/ELF/cgprofile-txt.s
index c9194bbbc43cbe0..cf5b17627cfb63c 100644
--- a/lld/test/ELF/cgprofile-txt.s
+++ b/lld/test/ELF/cgprofile-txt.s
@@ -26,12 +26,12 @@
 # RUN: echo "TooManyPreds10 TooManyPreds 11" >> %t.call_graph
 # RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s
-## --call-graph-profile-sort=hfsort is the default.
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2b
-# RUN: cmp %t2 %t2b
 
 # RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=cdsort -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=CDSORT
+## --call-graph-profile-sort=cdsort is the default.
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2b
+# RUN: cmp %t2 %t2b
 
 # RUN: not ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=sort \
 # RUN:   -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN

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


[Lldb-commits] [lldb] [ELF] Making cdsort default for function reordering (PR #68638)

2023-10-09 Thread via lldb-commits

https://github.com/spupyrev updated 
https://github.com/llvm/llvm-project/pull/68638

>From 9ae8e860296e77dbb4f0ba4332c133827ff0dd9f Mon Sep 17 00:00:00 2001
From: spupyrev 
Date: Mon, 9 Oct 2023 14:11:21 -0700
Subject: [PATCH] [ELF] Making cdsort default for function reordering

---
 lld/ELF/Driver.cpp| 2 +-
 lld/docs/ld.lld.1 | 4 ++--
 lld/test/ELF/cgprofile-bad-clusters.s | 2 +-
 lld/test/ELF/cgprofile-icf.s  | 4 ++--
 lld/test/ELF/cgprofile-rela.test  | 2 +-
 lld/test/ELF/cgprofile-txt.s  | 6 +++---
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 6272276e94b2d35..e2100d00d54ede6 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1095,7 +1095,7 @@ static void 
ltoValidateAllVtablesHaveTypeInfos(opt::InputArgList &args) {
 }
 
 static CGProfileSortKind getCGProfileSortKind(opt::InputArgList &args) {
-  StringRef s = args.getLastArgValue(OPT_call_graph_profile_sort, "hfsort");
+  StringRef s = args.getLastArgValue(OPT_call_graph_profile_sort, "cdsort");
   if (s == "hfsort")
 return CGProfileSortKind::Hfsort;
   if (s == "cdsort")
diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1
index 2e46fc18132f3e0..12b17dd37796d13 100644
--- a/lld/docs/ld.lld.1
+++ b/lld/docs/ld.lld.1
@@ -128,9 +128,9 @@ may be:
 .It Cm none
 Ignore call graph profile.
 .It Cm hfsort
-Use hfsort (default).
+Use hfsort.
 .It Cm cdsort
-Use cdsort.
+Use cdsort (default).
 .El
 .Pp
 .It Fl -color-diagnostics Ns = Ns Ar value
diff --git a/lld/test/ELF/cgprofile-bad-clusters.s 
b/lld/test/ELF/cgprofile-bad-clusters.s
index c162e981acdd633..88e68bfb7b2c0a1 100644
--- a/lld/test/ELF/cgprofile-bad-clusters.s
+++ b/lld/test/ELF/cgprofile-bad-clusters.s
@@ -10,7 +10,7 @@
 # RUN: echo "F G 6" >> %t.call_graph
 # RUN: echo "G H 5" >> %t.call_graph
 # RUN: echo "H I 4" >> %t.call_graph
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort  -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s
 
 .section.text.A,"ax",@progbits
diff --git a/lld/test/ELF/cgprofile-icf.s b/lld/test/ELF/cgprofile-icf.s
index a9de5613917cbf1..e28630d0eb30bf0 100644
--- a/lld/test/ELF/cgprofile-icf.s
+++ b/lld/test/ELF/cgprofile-icf.s
@@ -5,9 +5,9 @@
 # RUN: echo "A B 100" > %t.call_graph
 # RUN: echo "A C 40" >> %t.call_graph
 # RUN: echo "C D 61" >> %t.call_graph
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t.out 
-icf=all
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t.out -icf=all
 # RUN: llvm-readobj --symbols %t.out | FileCheck %s
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2.out
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t2.out
 # RUN: llvm-readobj --symbols %t2.out | FileCheck %s --check-prefix=NOICF
 
 .section.text.D,"ax",@progbits
diff --git a/lld/test/ELF/cgprofile-rela.test b/lld/test/ELF/cgprofile-rela.test
index 189f169e65481ee..141dfd4c65b1ea1 100644
--- a/lld/test/ELF/cgprofile-rela.test
+++ b/lld/test/ELF/cgprofile-rela.test
@@ -3,7 +3,7 @@
 # REQUIRES: x86
 
 # RUN: yaml2obj %s -o %t.o
-# RUN: ld.lld %t.o -o %t
+# RUN: ld.lld --call-graph-profile-sort=hfsort %t.o -o %t
 # RUN: llvm-nm --no-sort %t | FileCheck %s
 # RUN: ld.lld --no-call-graph-profile-sort %t.o -o %t
 # RUN: llvm-nm --no-sort %t | FileCheck %s --check-prefix=NO-CG
diff --git a/lld/test/ELF/cgprofile-txt.s b/lld/test/ELF/cgprofile-txt.s
index c9194bbbc43cbe0..cf5b17627cfb63c 100644
--- a/lld/test/ELF/cgprofile-txt.s
+++ b/lld/test/ELF/cgprofile-txt.s
@@ -26,12 +26,12 @@
 # RUN: echo "TooManyPreds10 TooManyPreds 11" >> %t.call_graph
 # RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s
-## --call-graph-profile-sort=hfsort is the default.
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2b
-# RUN: cmp %t2 %t2b
 
 # RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=cdsort -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=CDSORT
+## --call-graph-profile-sort=cdsort is the default.
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2b
+# RUN: cmp %t2 %t2b
 
 # RUN: not ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=sort \
 # RUN:   -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN

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


[Lldb-commits] [lldb] [ELF] Making cdsort default for function reordering (PR #68638)

2023-10-09 Thread via lldb-commits

https://github.com/spupyrev updated 
https://github.com/llvm/llvm-project/pull/68638

>From 9ae8e860296e77dbb4f0ba4332c133827ff0dd9f Mon Sep 17 00:00:00 2001
From: spupyrev 
Date: Mon, 9 Oct 2023 14:11:21 -0700
Subject: [PATCH 1/3] [ELF] Making cdsort default for function reordering

---
 lld/ELF/Driver.cpp| 2 +-
 lld/docs/ld.lld.1 | 4 ++--
 lld/test/ELF/cgprofile-bad-clusters.s | 2 +-
 lld/test/ELF/cgprofile-icf.s  | 4 ++--
 lld/test/ELF/cgprofile-rela.test  | 2 +-
 lld/test/ELF/cgprofile-txt.s  | 6 +++---
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 6272276e94b2d35..e2100d00d54ede6 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1095,7 +1095,7 @@ static void 
ltoValidateAllVtablesHaveTypeInfos(opt::InputArgList &args) {
 }
 
 static CGProfileSortKind getCGProfileSortKind(opt::InputArgList &args) {
-  StringRef s = args.getLastArgValue(OPT_call_graph_profile_sort, "hfsort");
+  StringRef s = args.getLastArgValue(OPT_call_graph_profile_sort, "cdsort");
   if (s == "hfsort")
 return CGProfileSortKind::Hfsort;
   if (s == "cdsort")
diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1
index 2e46fc18132f3e0..12b17dd37796d13 100644
--- a/lld/docs/ld.lld.1
+++ b/lld/docs/ld.lld.1
@@ -128,9 +128,9 @@ may be:
 .It Cm none
 Ignore call graph profile.
 .It Cm hfsort
-Use hfsort (default).
+Use hfsort.
 .It Cm cdsort
-Use cdsort.
+Use cdsort (default).
 .El
 .Pp
 .It Fl -color-diagnostics Ns = Ns Ar value
diff --git a/lld/test/ELF/cgprofile-bad-clusters.s 
b/lld/test/ELF/cgprofile-bad-clusters.s
index c162e981acdd633..88e68bfb7b2c0a1 100644
--- a/lld/test/ELF/cgprofile-bad-clusters.s
+++ b/lld/test/ELF/cgprofile-bad-clusters.s
@@ -10,7 +10,7 @@
 # RUN: echo "F G 6" >> %t.call_graph
 # RUN: echo "G H 5" >> %t.call_graph
 # RUN: echo "H I 4" >> %t.call_graph
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort  -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s
 
 .section.text.A,"ax",@progbits
diff --git a/lld/test/ELF/cgprofile-icf.s b/lld/test/ELF/cgprofile-icf.s
index a9de5613917cbf1..e28630d0eb30bf0 100644
--- a/lld/test/ELF/cgprofile-icf.s
+++ b/lld/test/ELF/cgprofile-icf.s
@@ -5,9 +5,9 @@
 # RUN: echo "A B 100" > %t.call_graph
 # RUN: echo "A C 40" >> %t.call_graph
 # RUN: echo "C D 61" >> %t.call_graph
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t.out 
-icf=all
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t.out -icf=all
 # RUN: llvm-readobj --symbols %t.out | FileCheck %s
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2.out
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t2.out
 # RUN: llvm-readobj --symbols %t2.out | FileCheck %s --check-prefix=NOICF
 
 .section.text.D,"ax",@progbits
diff --git a/lld/test/ELF/cgprofile-rela.test b/lld/test/ELF/cgprofile-rela.test
index 189f169e65481ee..141dfd4c65b1ea1 100644
--- a/lld/test/ELF/cgprofile-rela.test
+++ b/lld/test/ELF/cgprofile-rela.test
@@ -3,7 +3,7 @@
 # REQUIRES: x86
 
 # RUN: yaml2obj %s -o %t.o
-# RUN: ld.lld %t.o -o %t
+# RUN: ld.lld --call-graph-profile-sort=hfsort %t.o -o %t
 # RUN: llvm-nm --no-sort %t | FileCheck %s
 # RUN: ld.lld --no-call-graph-profile-sort %t.o -o %t
 # RUN: llvm-nm --no-sort %t | FileCheck %s --check-prefix=NO-CG
diff --git a/lld/test/ELF/cgprofile-txt.s b/lld/test/ELF/cgprofile-txt.s
index c9194bbbc43cbe0..cf5b17627cfb63c 100644
--- a/lld/test/ELF/cgprofile-txt.s
+++ b/lld/test/ELF/cgprofile-txt.s
@@ -26,12 +26,12 @@
 # RUN: echo "TooManyPreds10 TooManyPreds 11" >> %t.call_graph
 # RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=hfsort -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s
-## --call-graph-profile-sort=hfsort is the default.
-# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2b
-# RUN: cmp %t2 %t2b
 
 # RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=cdsort -o %t2
 # RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=CDSORT
+## --call-graph-profile-sort=cdsort is the default.
+# RUN: ld.lld -e A %t --call-graph-ordering-file %t.call_graph -o %t2b
+# RUN: cmp %t2 %t2b
 
 # RUN: not ld.lld -e A %t --call-graph-ordering-file %t.call_graph 
--call-graph-profile-sort=sort \
 # RUN:   -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN

>From d4cf51be5f09c20466dfac2100fdc552932e0d9b Mon Sep 17 00:00:00 2001
From: spupyrev 
Date: Mon, 9 Oct 2023 14:11:21 -0700
Subject: [PATCH 2/3] [ELF] Making cdsort default for function reordering

---
 lld/test/ELF/cgprofile-print.s | 5 +
 lld/test/ELF/cgprofile-reproduce.s | 5 +
 2 files changed, 2 insertions(+), 8 deletions(-)

di

[Lldb-commits] [lldb] [LLDB][NFC] Create a namespace for the DWARF plugin (PR #68150)

2023-10-09 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

ping @clayborg 

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


[Lldb-commits] [lldb] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-10-09 Thread Denali Lumma via lldb-commits

dlumma wrote:

It seems like this PR is ready to land. Any reason why it has not been 
integrated @christiankissig ?

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


[Lldb-commits] [lldb] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-10-09 Thread Christian Kissig via lldb-commits

https://github.com/christiankissig updated 
https://github.com/llvm/llvm-project/pull/67788

>From 5d86936c3a48c613460983c980271fcab8128b75 Mon Sep 17 00:00:00 2001
From: Christian Kissig 
Date: Tue, 26 Sep 2023 12:18:59 +
Subject: [PATCH 1/5] [Support] Add KnownBits::computeForSubBorrow

* Implements computeForSubBorrow as alias for computeforAddCarry. Borrow
  is expected to be 1-bit wide.
* Adds exhaustive unit test.
---
 llvm/include/llvm/Support/KnownBits.h|  4 +++
 llvm/lib/Support/KnownBits.cpp   | 12 +
 llvm/unittests/Support/KnownBitsTest.cpp | 31 
 3 files changed, 47 insertions(+)

diff --git a/llvm/include/llvm/Support/KnownBits.h 
b/llvm/include/llvm/Support/KnownBits.h
index 8462aa11202d5d7..711ca8c12129a1b 100644
--- a/llvm/include/llvm/Support/KnownBits.h
+++ b/llvm/include/llvm/Support/KnownBits.h
@@ -332,6 +332,10 @@ struct KnownBits {
   static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS,
 KnownBits RHS);
 
+  /// Compute known bits results from subtracting RHS from LHS.
+  static KnownBits computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+   const KnownBits &Borrow);
+
   /// Compute knownbits resulting from llvm.sadd.sat(LHS, RHS)
   static KnownBits sadd_sat(const KnownBits &LHS, const KnownBits &RHS);
 
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index 097c22d33dd12ba..99ac50a34666fce 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -85,6 +85,18 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW,
   return KnownOut;
 }
 
+KnownBits KnownBits::computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+ const KnownBits &Borrow) {
+  assert(Borrow.getBitWidth() == 1 && "Borrow must be 1-bit");
+
+  // LHS - RHS = LHS + ~RHS + 1
+  // Carry 1 - Borrow in ::computeForAddCarry
+  std::swap(RHS.Zero, RHS.One);
+  return ::computeForAddCarry(LHS, RHS,
+  /*CarryZero*/ Borrow.One.getBoolValue(),
+  /*CarryOne*/ Borrow.Zero.getBoolValue());
+}
+
 KnownBits KnownBits::sextInReg(unsigned SrcBitWidth) const {
   unsigned BitWidth = getBitWidth();
   assert(0 < SrcBitWidth && SrcBitWidth <= BitWidth &&
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp 
b/llvm/unittests/Support/KnownBitsTest.cpp
index 9d184beea3ba9e9..5597d69ab248d23 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -213,6 +213,37 @@ TEST(KnownBitsTest, AddSubExhaustive) {
   TestAddSubExhaustive(false);
 }
 
+TEST(KnownBitsTest, SubBorrowExhaustive) {
+  unsigned Bits = 4;
+  ForeachKnownBits(Bits, [&](const KnownBits &Known1) {
+ForeachKnownBits(Bits, [&](const KnownBits &Known2) {
+  ForeachKnownBits(1, [&](const KnownBits &KnownBorrow) {
+// Explicitly compute known bits of the addition by trying all
+// possibilities.
+KnownBits Known(Bits);
+Known.Zero.setAllBits();
+Known.One.setAllBits();
+ForeachNumInKnownBits(Known1, [&](const APInt &N1) {
+  ForeachNumInKnownBits(Known2, [&](const APInt &N2) {
+ForeachNumInKnownBits(KnownBorrow, [&](const APInt &Borrow) {
+  APInt Sub = N1 - N2;
+  if (Borrow.getBoolValue())
+--Sub;
+
+  Known.One &= Sub;
+  Known.Zero &= ~Sub;
+});
+  });
+});
+
+KnownBits KnownComputed =
+KnownBits::computeForSubBorrow(Known1, Known2, KnownBorrow);
+EXPECT_EQ(Known, KnownComputed);
+  });
+});
+  });
+}
+
 TEST(KnownBitsTest, BinaryExhaustive) {
   testBinaryOpExhaustive(
   [](const KnownBits &Known1, const KnownBits &Known2) {

>From f84c882cf429df238054d88ee07e41a08ae3fd6c Mon Sep 17 00:00:00 2001
From: Christian Kissig 
Date: Tue, 26 Sep 2023 18:02:49 +
Subject: [PATCH 2/5] [CodeGen] Implement USUBC, USUBO_CARRY, and SSUBO_CARRY
 with KnownBits::computeForSubBorrow

---
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 12 ++
 .../CodeGen/AArch64SelectionDAGTest.cpp   | 24 +++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index cd21af770e1a4d9..ab3e9b4bdc67402 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, 
const APInt &DemandedElts,
 assert(Op.getResNo() == 0 &&
"We only compute knownbits for the difference here.");
 
-// TODO: Compute influence of the carry operand.
+// With UADDO_CARRY and SSUBO_CARRY a borrow bit may be added in.
+KnownBits Borrow(1);
 if (Opcode == ISD::USUBO_CARRY || Opcode == ISD:

[Lldb-commits] [lldb] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-10-09 Thread Christian Kissig via lldb-commits

https://github.com/christiankissig updated 
https://github.com/llvm/llvm-project/pull/67788

>From 5d86936c3a48c613460983c980271fcab8128b75 Mon Sep 17 00:00:00 2001
From: Christian Kissig 
Date: Tue, 26 Sep 2023 12:18:59 +
Subject: [PATCH 1/6] [Support] Add KnownBits::computeForSubBorrow

* Implements computeForSubBorrow as alias for computeforAddCarry. Borrow
  is expected to be 1-bit wide.
* Adds exhaustive unit test.
---
 llvm/include/llvm/Support/KnownBits.h|  4 +++
 llvm/lib/Support/KnownBits.cpp   | 12 +
 llvm/unittests/Support/KnownBitsTest.cpp | 31 
 3 files changed, 47 insertions(+)

diff --git a/llvm/include/llvm/Support/KnownBits.h 
b/llvm/include/llvm/Support/KnownBits.h
index 8462aa11202d5d7..711ca8c12129a1b 100644
--- a/llvm/include/llvm/Support/KnownBits.h
+++ b/llvm/include/llvm/Support/KnownBits.h
@@ -332,6 +332,10 @@ struct KnownBits {
   static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS,
 KnownBits RHS);
 
+  /// Compute known bits results from subtracting RHS from LHS.
+  static KnownBits computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+   const KnownBits &Borrow);
+
   /// Compute knownbits resulting from llvm.sadd.sat(LHS, RHS)
   static KnownBits sadd_sat(const KnownBits &LHS, const KnownBits &RHS);
 
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index 097c22d33dd12ba..99ac50a34666fce 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -85,6 +85,18 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW,
   return KnownOut;
 }
 
+KnownBits KnownBits::computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+ const KnownBits &Borrow) {
+  assert(Borrow.getBitWidth() == 1 && "Borrow must be 1-bit");
+
+  // LHS - RHS = LHS + ~RHS + 1
+  // Carry 1 - Borrow in ::computeForAddCarry
+  std::swap(RHS.Zero, RHS.One);
+  return ::computeForAddCarry(LHS, RHS,
+  /*CarryZero*/ Borrow.One.getBoolValue(),
+  /*CarryOne*/ Borrow.Zero.getBoolValue());
+}
+
 KnownBits KnownBits::sextInReg(unsigned SrcBitWidth) const {
   unsigned BitWidth = getBitWidth();
   assert(0 < SrcBitWidth && SrcBitWidth <= BitWidth &&
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp 
b/llvm/unittests/Support/KnownBitsTest.cpp
index 9d184beea3ba9e9..5597d69ab248d23 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -213,6 +213,37 @@ TEST(KnownBitsTest, AddSubExhaustive) {
   TestAddSubExhaustive(false);
 }
 
+TEST(KnownBitsTest, SubBorrowExhaustive) {
+  unsigned Bits = 4;
+  ForeachKnownBits(Bits, [&](const KnownBits &Known1) {
+ForeachKnownBits(Bits, [&](const KnownBits &Known2) {
+  ForeachKnownBits(1, [&](const KnownBits &KnownBorrow) {
+// Explicitly compute known bits of the addition by trying all
+// possibilities.
+KnownBits Known(Bits);
+Known.Zero.setAllBits();
+Known.One.setAllBits();
+ForeachNumInKnownBits(Known1, [&](const APInt &N1) {
+  ForeachNumInKnownBits(Known2, [&](const APInt &N2) {
+ForeachNumInKnownBits(KnownBorrow, [&](const APInt &Borrow) {
+  APInt Sub = N1 - N2;
+  if (Borrow.getBoolValue())
+--Sub;
+
+  Known.One &= Sub;
+  Known.Zero &= ~Sub;
+});
+  });
+});
+
+KnownBits KnownComputed =
+KnownBits::computeForSubBorrow(Known1, Known2, KnownBorrow);
+EXPECT_EQ(Known, KnownComputed);
+  });
+});
+  });
+}
+
 TEST(KnownBitsTest, BinaryExhaustive) {
   testBinaryOpExhaustive(
   [](const KnownBits &Known1, const KnownBits &Known2) {

>From f84c882cf429df238054d88ee07e41a08ae3fd6c Mon Sep 17 00:00:00 2001
From: Christian Kissig 
Date: Tue, 26 Sep 2023 18:02:49 +
Subject: [PATCH 2/6] [CodeGen] Implement USUBC, USUBO_CARRY, and SSUBO_CARRY
 with KnownBits::computeForSubBorrow

---
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 12 ++
 .../CodeGen/AArch64SelectionDAGTest.cpp   | 24 +++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index cd21af770e1a4d9..ab3e9b4bdc67402 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, 
const APInt &DemandedElts,
 assert(Op.getResNo() == 0 &&
"We only compute knownbits for the difference here.");
 
-// TODO: Compute influence of the carry operand.
+// With UADDO_CARRY and SSUBO_CARRY a borrow bit may be added in.
+KnownBits Borrow(1);
 if (Opcode == ISD::USUBO_CARRY || Opcode == ISD:

[Lldb-commits] [lldb] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

2023-10-09 Thread Christian Kissig via lldb-commits

https://github.com/christiankissig updated 
https://github.com/llvm/llvm-project/pull/67788

>From 5d86936c3a48c613460983c980271fcab8128b75 Mon Sep 17 00:00:00 2001
From: Christian Kissig 
Date: Tue, 26 Sep 2023 12:18:59 +
Subject: [PATCH 1/7] [Support] Add KnownBits::computeForSubBorrow

* Implements computeForSubBorrow as alias for computeforAddCarry. Borrow
  is expected to be 1-bit wide.
* Adds exhaustive unit test.
---
 llvm/include/llvm/Support/KnownBits.h|  4 +++
 llvm/lib/Support/KnownBits.cpp   | 12 +
 llvm/unittests/Support/KnownBitsTest.cpp | 31 
 3 files changed, 47 insertions(+)

diff --git a/llvm/include/llvm/Support/KnownBits.h 
b/llvm/include/llvm/Support/KnownBits.h
index 8462aa11202d5d7..711ca8c12129a1b 100644
--- a/llvm/include/llvm/Support/KnownBits.h
+++ b/llvm/include/llvm/Support/KnownBits.h
@@ -332,6 +332,10 @@ struct KnownBits {
   static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS,
 KnownBits RHS);
 
+  /// Compute known bits results from subtracting RHS from LHS.
+  static KnownBits computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+   const KnownBits &Borrow);
+
   /// Compute knownbits resulting from llvm.sadd.sat(LHS, RHS)
   static KnownBits sadd_sat(const KnownBits &LHS, const KnownBits &RHS);
 
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index 097c22d33dd12ba..99ac50a34666fce 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -85,6 +85,18 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW,
   return KnownOut;
 }
 
+KnownBits KnownBits::computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+ const KnownBits &Borrow) {
+  assert(Borrow.getBitWidth() == 1 && "Borrow must be 1-bit");
+
+  // LHS - RHS = LHS + ~RHS + 1
+  // Carry 1 - Borrow in ::computeForAddCarry
+  std::swap(RHS.Zero, RHS.One);
+  return ::computeForAddCarry(LHS, RHS,
+  /*CarryZero*/ Borrow.One.getBoolValue(),
+  /*CarryOne*/ Borrow.Zero.getBoolValue());
+}
+
 KnownBits KnownBits::sextInReg(unsigned SrcBitWidth) const {
   unsigned BitWidth = getBitWidth();
   assert(0 < SrcBitWidth && SrcBitWidth <= BitWidth &&
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp 
b/llvm/unittests/Support/KnownBitsTest.cpp
index 9d184beea3ba9e9..5597d69ab248d23 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -213,6 +213,37 @@ TEST(KnownBitsTest, AddSubExhaustive) {
   TestAddSubExhaustive(false);
 }
 
+TEST(KnownBitsTest, SubBorrowExhaustive) {
+  unsigned Bits = 4;
+  ForeachKnownBits(Bits, [&](const KnownBits &Known1) {
+ForeachKnownBits(Bits, [&](const KnownBits &Known2) {
+  ForeachKnownBits(1, [&](const KnownBits &KnownBorrow) {
+// Explicitly compute known bits of the addition by trying all
+// possibilities.
+KnownBits Known(Bits);
+Known.Zero.setAllBits();
+Known.One.setAllBits();
+ForeachNumInKnownBits(Known1, [&](const APInt &N1) {
+  ForeachNumInKnownBits(Known2, [&](const APInt &N2) {
+ForeachNumInKnownBits(KnownBorrow, [&](const APInt &Borrow) {
+  APInt Sub = N1 - N2;
+  if (Borrow.getBoolValue())
+--Sub;
+
+  Known.One &= Sub;
+  Known.Zero &= ~Sub;
+});
+  });
+});
+
+KnownBits KnownComputed =
+KnownBits::computeForSubBorrow(Known1, Known2, KnownBorrow);
+EXPECT_EQ(Known, KnownComputed);
+  });
+});
+  });
+}
+
 TEST(KnownBitsTest, BinaryExhaustive) {
   testBinaryOpExhaustive(
   [](const KnownBits &Known1, const KnownBits &Known2) {

>From f84c882cf429df238054d88ee07e41a08ae3fd6c Mon Sep 17 00:00:00 2001
From: Christian Kissig 
Date: Tue, 26 Sep 2023 18:02:49 +
Subject: [PATCH 2/7] [CodeGen] Implement USUBC, USUBO_CARRY, and SSUBO_CARRY
 with KnownBits::computeForSubBorrow

---
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 12 ++
 .../CodeGen/AArch64SelectionDAGTest.cpp   | 24 +++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index cd21af770e1a4d9..ab3e9b4bdc67402 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, 
const APInt &DemandedElts,
 assert(Op.getResNo() == 0 &&
"We only compute knownbits for the difference here.");
 
-// TODO: Compute influence of the carry operand.
+// With UADDO_CARRY and SSUBO_CARRY a borrow bit may be added in.
+KnownBits Borrow(1);
 if (Opcode == ISD::USUBO_CARRY || Opcode == ISD:

[Lldb-commits] [lldb] [mlir][OpenMP] Added omp.region operation (PR #65243)

2023-10-09 Thread Kiran Chandramohan via lldb-commits

kiranchandramohan wrote:

Can this have `omp.yield` as the terminator and be capable of 
yielding/returning values?

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