[Lldb-commits] [clang-tools-extra] [lld] [llvm] [clang] [compiler-rt] [flang] [libc] [lldb] [libcxx] Don't emit relax relocs like R_X86_64_REX_GOTPCRELX on X86 target for OPENMP internal vars. (PR #75

2023-12-18 Thread via lldb-commits

https://github.com/UmeshKalappa0 updated 
https://github.com/llvm/llvm-project/pull/75564

>From 4125e4a709c594562fa6c52f045ba7442e3cb523 Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Fri, 15 Dec 2023 11:52:52 +0530
Subject: [PATCH 1/2] Problem :For Kernel Modules ,emitting the relocs like
 R_X86_64_REX_GOTPCRELX  for the OPENMP internal vars like
 https://godbolt.org/z/hhh7ozojz.

Solution : Mark the OpenMP internal variables with dso_local
conditionally for no-pic and no-pie ,then
a)reset the dso_local for thread_local and weak linkage vars.
---
 .../test/OpenMP/gomp_critical_dso_local_var.c | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100644 clang/test/OpenMP/gomp_critical_dso_local_var.c

diff --git a/clang/test/OpenMP/gomp_critical_dso_local_var.c 
b/clang/test/OpenMP/gomp_critical_dso_local_var.c
new file mode 100644
index 00..915f6773bf67bf
--- /dev/null
+++ b/clang/test/OpenMP/gomp_critical_dso_local_var.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s 
--check-prefix=DSO_LOCAL
+
+// DSO_LOCAL-DAG: @.gomp_critical_user_.var = common dso_local global [8 x 
i32] zeroinitializer, align 8
+int omp_critical_test()
+{
+  int sum;
+  int known_sum;
+
+  sum=0;
+#pragma omp parallel
+  {
+int mysum=0;
+int i;
+#pragma omp for
+for (i = 0; i < 1000; i++)
+  mysum = mysum + i;
+#pragma omp critical
+sum = mysum +sum;
+  }
+  known_sum = 999 * 1000 / 2;
+  return (known_sum == sum);
+}
+

>From 842245de490ab15f8a901b94576ae4539c760e1e Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Fri, 15 Dec 2023 12:49:48 +0530
Subject: [PATCH 2/2] testcases are changed accordignly.

---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp   | 2 ++
 clang/test/OpenMP/critical_codegen.cpp  | 6 +++---
 clang/test/OpenMP/critical_codegen_attr.cpp | 6 +++---
 clang/test/OpenMP/for_reduction_codegen.cpp | 8 
 clang/test/OpenMP/gomp_critical_dso_local_var.c | 1 -
 clang/test/OpenMP/simd_codegen.cpp  | 4 ++--
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp   | 8 
 7 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 7f7e6f53066644..183c757d72b8a7 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1793,6 +1793,8 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
   if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPUseTLS &&
   CGM.getTarget().isTLSSupported()) {
 GAddr->setThreadLocal(/*Val=*/true);
+/// reset the dso_local for thread_local.
+GAddr->setDSOLocal(/*Val=*/false);
 return Address(GAddr, GAddr->getValueType(),
CGM.getContext().getTypeAlignInChars(VarType));
   }
diff --git a/clang/test/OpenMP/critical_codegen.cpp 
b/clang/test/OpenMP/critical_codegen.cpp
index 24145d44d962e5..9a613161ac294a 100644
--- a/clang/test/OpenMP/critical_codegen.cpp
+++ b/clang/test/OpenMP/critical_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
diff --git a/clang/test/OpenMP/critical_codegen_attr.cpp 
b/clang/test/OpenMP/critical_codegen_attr.cpp
index 34d90a9e3a6e48..5f1a76e2ad0f1f 100644
--- a/clang/test/OpenMP/critical_codegen_attr.cpp
+++ b/clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
diff --git a/clang/test/OpenMP/for_reduction_codegen.cpp 
b/clang/test/OpenMP/for_reduction_codegen.cpp
index 893c606f8d7b9f..b128bd5d79c251 100644
--- a/clang/test/OpenMP/for_reduction_codegen.cpp
+++ b/clang/test/OpenMP/for_reduction_codegen.cpp
@@ -528,12 +528,12 @@ int main() {
 
 #endif
 //.
-// CHECK1: @.gomp_critical_user_.red

[Lldb-commits] [openmp] [lldb] [mlir] [clang] [flang] [libcxx] [libc] [compiler-rt] [llvm] [clang-tools-extra] [libc++][span] P2821R5: span.at() (PR #74994)

2023-12-18 Thread Nikolas Klauser via lldb-commits


@@ -0,0 +1,136 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr void testSpanAt(auto span, int idx, int expectedValue) {
+  // non-const
+  {
+std::same_as decltype(auto) elem = 
span.at(idx);
+assert(elem == expectedValue);
+  }
+
+  // const
+  {
+std::same_as decltype(auto) elem = 
std::as_const(span).at(idx);
+assert(elem == expectedValue);
+  }
+}
+
+constexpr bool test() {
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084};
+std::span arrSpan{arr};
+
+assert(std::dynamic_extent != arrSpan.extent);
+
+testSpanAt(arrSpan, 0, 0);
+testSpanAt(arrSpan, 1, 1);
+testSpanAt(arrSpan, 6, 9084);
+  }
+
+  // With dynamic extent
+  {
+std::vector vec{0, 1, 2, 3, 4, 5, 9084};
+std::span vecSpan{vec};
+
+assert(std::dynamic_extent == vecSpan.extent);
+
+testSpanAt(vecSpan, 0, 0);
+testSpanAt(vecSpan, 1, 1);
+testSpanAt(vecSpan, 6, 9084);
+  }
+
+  return true;
+}
+
+void test_exceptions() {

philnik777 wrote:

I meant that you should test `span.at(numeric_limits::max())`.

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


[Lldb-commits] [lldb] [lldb] Fix a quirk in SBValue::GetDescription (PR #75793)

2023-12-18 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/75793

The function was using the default version of ValueObject::Dump, which has a 
default of using the synthetic-ness of the top-level value for determining 
whether to print _all_ values as synthetic. This resulted in some unusual 
behavior, where e.g. a std::vector is stringified as synthetic if its dumped as 
the top level object, but in its raw form if it is a member of a struct without 
a pretty printer.

The SBValue class already has properties which determine whether one should be 
looking at the synthetic view of the object (and also whether to use dynamic 
types), so it seems more natural to use that.

>From 0c727d2c339893b439c5a17cf9ba6ae03b5cf87e Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 18 Dec 2023 14:25:42 +0100
Subject: [PATCH] [lldb] Fix a quirk in SBValue::GetDescription

The function was using the default version of ValueObject::Dump, which
has a default of using the synthetic-ness of the top-level value for
determining whether to print _all_ values as synthetic. This resulted in
some unusual behavior, where e.g. a std::vector is stringified as
synthetic if its dumped as the top level object, but in its raw form if
it is a member of a struct without a pretty printer.

The SBValue class already has properties which determine whether one
should be looking at the synthetic view of the object (and also whether
to use dynamic types), so it seems more natural to use that.
---
 lldb/source/API/SBValue.cpp   | 11 ---
 .../API/python_api/sbvalue_synthetic/Makefile |  3 +++
 .../sbvalue_synthetic/TestSBValueSynthetic.py | 19 +++
 .../API/python_api/sbvalue_synthetic/main.cpp | 11 +++
 4 files changed, 41 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/API/python_api/sbvalue_synthetic/Makefile
 create mode 100644 
lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
 create mode 100644 lldb/test/API/python_api/sbvalue_synthetic/main.cpp

diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 34d01d759ba55a..89d26a1fbe2824 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -24,6 +24,7 @@
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/Symbol/Block.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Type.h"
@@ -1209,10 +1210,14 @@ bool SBValue::GetDescription(SBStream &description) {
 
   ValueLocker locker;
   lldb::ValueObjectSP value_sp(GetSP(locker));
-  if (value_sp)
-value_sp->Dump(strm);
-  else
+  if (value_sp) {
+DumpValueObjectOptions options;
+options.SetUseDynamicType(m_opaque_sp->GetUseDynamic());
+options.SetUseSyntheticValue(m_opaque_sp->GetUseSynthetic());
+value_sp->Dump(strm, options);
+  } else {
 strm.PutCString("No value");
+  }
 
   return true;
 }
diff --git a/lldb/test/API/python_api/sbvalue_synthetic/Makefile 
b/lldb/test/API/python_api/sbvalue_synthetic/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py 
b/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
new file mode 100644
index 00..5dcf3c1a9c6c44
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
@@ -0,0 +1,19 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestSBValueSynthetic(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_str(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "break here", lldb.SBFileSpec("main.cpp")
+)
+
+vector = self.frame().FindVariable("vector")
+has_vector = self.frame().FindVariable("has_vector")
+self.expect(str(vector), exe=False, substrs=["42", "47"])
+self.expect(str(has_vector), exe=False, substrs=["42", "47"])
diff --git a/lldb/test/API/python_api/sbvalue_synthetic/main.cpp 
b/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
new file mode 100644
index 00..e6b6ec50f307f8
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
@@ -0,0 +1,11 @@
+#include 
+
+struct HasVector {
+  std::vector v;
+};
+
+int main() {
+  std::vector vector = {42, 47};
+  HasVector has_vector = {vector};
+  return 0; // break here
+}

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


[Lldb-commits] [lldb] [lldb] Fix a quirk in SBValue::GetDescription (PR #75793)

2023-12-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The function was using the default version of ValueObject::Dump, which has a 
default of using the synthetic-ness of the top-level value for determining 
whether to print _all_ values as synthetic. This resulted in some unusual 
behavior, where e.g. a std::vector is stringified as synthetic if its dumped as 
the top level object, but in its raw form if it is a member of a struct without 
a pretty printer.

The SBValue class already has properties which determine whether one should be 
looking at the synthetic view of the object (and also whether to use dynamic 
types), so it seems more natural to use that.

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


4 Files Affected:

- (modified) lldb/source/API/SBValue.cpp (+8-3) 
- (added) lldb/test/API/python_api/sbvalue_synthetic/Makefile (+3) 
- (added) lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py 
(+19) 
- (added) lldb/test/API/python_api/sbvalue_synthetic/main.cpp (+11) 


``diff
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 34d01d759ba55a..89d26a1fbe2824 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -24,6 +24,7 @@
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/Symbol/Block.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Type.h"
@@ -1209,10 +1210,14 @@ bool SBValue::GetDescription(SBStream &description) {
 
   ValueLocker locker;
   lldb::ValueObjectSP value_sp(GetSP(locker));
-  if (value_sp)
-value_sp->Dump(strm);
-  else
+  if (value_sp) {
+DumpValueObjectOptions options;
+options.SetUseDynamicType(m_opaque_sp->GetUseDynamic());
+options.SetUseSyntheticValue(m_opaque_sp->GetUseSynthetic());
+value_sp->Dump(strm, options);
+  } else {
 strm.PutCString("No value");
+  }
 
   return true;
 }
diff --git a/lldb/test/API/python_api/sbvalue_synthetic/Makefile 
b/lldb/test/API/python_api/sbvalue_synthetic/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py 
b/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
new file mode 100644
index 00..5dcf3c1a9c6c44
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
@@ -0,0 +1,19 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestSBValueSynthetic(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_str(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "break here", lldb.SBFileSpec("main.cpp")
+)
+
+vector = self.frame().FindVariable("vector")
+has_vector = self.frame().FindVariable("has_vector")
+self.expect(str(vector), exe=False, substrs=["42", "47"])
+self.expect(str(has_vector), exe=False, substrs=["42", "47"])
diff --git a/lldb/test/API/python_api/sbvalue_synthetic/main.cpp 
b/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
new file mode 100644
index 00..e6b6ec50f307f8
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
@@ -0,0 +1,11 @@
+#include 
+
+struct HasVector {
+  std::vector v;
+};
+
+int main() {
+  std::vector vector = {42, 47};
+  HasVector has_vector = {vector};
+  return 0; // break here
+}

``




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


[Lldb-commits] [lldb] [lldb][PDB] Update max matches test for type queries (PR #75813)

2023-12-18 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/75813

NestedClass will be found via Class::NestedClass and ClassTypedef::NestedClass. 
So the first part of the test gets 2 results as the default is to find all 
matching types.

In the next part, we ask for only the first match and expect to get only 1 of 
those two possible results.

>From 4abe9b0de8c2dd006b8fa7d32f795f58eb5b499d Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 18 Dec 2023 15:33:12 +
Subject: [PATCH] [lldb][PDB] Update max matches test for type queries

NestedClass will be found via Class::NestedClass and
ClassTypedef::NestedClass. So the first part of the test
gets 2 results as the default is to find all matching types.

In the next part, we ask for only the first match and
expect to get only 1 of those two possible results.
---
 .../SymbolFile/PDB/SymbolFilePDBTests.cpp| 16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp 
b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 07e3a0c8ee95d2..6a2ea8c4a41b1c 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -579,24 +579,14 @@ TEST_F(SymbolFilePDBTests, TestMaxMatches) {
   static_cast(module->GetSymbolFile());
 
   // Make a type query object we can use for all types and for one type
-  //
-  // TODO: this test was ported as is and before the new FindTypes patch
-  // this test was trying to find all matches, and it would find one. Then
-  // it would limit its number of matches from zero to < the minimum of the
-  // number of matches that were found in the first search, or 10. Then it
-  // would set the max matches to that number (1) and verify it was the
-  // same (1). This test should be fixed in the figure by updating the
-  // lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp file and
-  // recompiling the exe + pdb file so that there are actually multiple
-  // types whose basename is "ClassTypedef" or any other type. Now type
-  // matches only return a single match, or all of the matches.
-  TypeQuery query("ClassTypedef");
+  TypeQuery query("NestedClass");
   {
 // Find all types that match
 TypeResults query_results;
 symfile->FindTypes(query, query_results);
 TypeMap &results = query_results.GetTypeMap();
-EXPECT_EQ(results.GetSize(), 1u);
+// We expect to find Class::NestedClass and ClassTypedef::NestedClass.
+EXPECT_EQ(results.GetSize(), 2u);
   }
   {
 // Find a single type that matches

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


[Lldb-commits] [lldb] [lldb][PDB] Update max matches test for type queries (PR #75813)

2023-12-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

NestedClass will be found via Class::NestedClass and ClassTypedef::NestedClass. 
So the first part of the test gets 2 results as the default is to find all 
matching types.

In the next part, we ask for only the first match and expect to get only 1 of 
those two possible results.

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


1 Files Affected:

- (modified) lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp (+3-13) 


``diff
diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp 
b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 07e3a0c8ee95d2..6a2ea8c4a41b1c 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -579,24 +579,14 @@ TEST_F(SymbolFilePDBTests, TestMaxMatches) {
   static_cast(module->GetSymbolFile());
 
   // Make a type query object we can use for all types and for one type
-  //
-  // TODO: this test was ported as is and before the new FindTypes patch
-  // this test was trying to find all matches, and it would find one. Then
-  // it would limit its number of matches from zero to < the minimum of the
-  // number of matches that were found in the first search, or 10. Then it
-  // would set the max matches to that number (1) and verify it was the
-  // same (1). This test should be fixed in the figure by updating the
-  // lldb/unittests/SymbolFile/PDB/Inputs/test-pdb-types.cpp file and
-  // recompiling the exe + pdb file so that there are actually multiple
-  // types whose basename is "ClassTypedef" or any other type. Now type
-  // matches only return a single match, or all of the matches.
-  TypeQuery query("ClassTypedef");
+  TypeQuery query("NestedClass");
   {
 // Find all types that match
 TypeResults query_results;
 symfile->FindTypes(query, query_results);
 TypeMap &results = query_results.GetTypeMap();
-EXPECT_EQ(results.GetSize(), 1u);
+// We expect to find Class::NestedClass and ClassTypedef::NestedClass.
+EXPECT_EQ(results.GetSize(), 2u);
   }
   {
 // Find a single type that matches

``




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


[Lldb-commits] [lldb] Trying to fix windows buildbots after #74786 (PR #75566)

2023-12-18 Thread David Spickett via lldb-commits

DavidSpickett wrote:

https://github.com/llvm/llvm-project/pull/75813 for the unit test.

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


[Lldb-commits] [compiler-rt] [libcxx] [flang] [clang] [lld] [lldb] [mlir] [llvm] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

2023-12-18 Thread Jon Roelofs via lldb-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/75635

>From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Fri, 15 Dec 2023 11:13:30 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/CMakeLists.txt   |   4 +-
 compiler-rt/lib/builtins/cpu_model/aarch64.c  | 142 +
 .../cpu_model/aarch64/fmv/android.inc |  35 +
 .../cpu_model/aarch64/fmv/freebsd.inc |  27 +
 .../builtins/cpu_model/aarch64/fmv/fucsia.inc |  19 +
 .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++
 .../cpu_model/aarch64/fmv/sysauxv.inc |  17 +
 .../cpu_model/aarch64/fmv/unimplemented.inc   |  11 +
 .../cpu_model/aarch64/lse_atomics/android.inc |  28 +
 .../cpu_model/aarch64/lse_atomics/freebsd.inc |   5 +
 .../cpu_model/aarch64/lse_atomics/fucsia.inc  |  12 +
 .../cpu_model/aarch64/lse_atomics/sysauxv.inc |   6 +
 .../lib/builtins/cpu_model/cpu_model.h|  41 ++
 .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +-
 14 files changed, 729 insertions(+), 593 deletions(-)
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h
 rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%)

diff --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index ea72c595a9b807..e5b52db175d960 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -271,7 +271,7 @@ endif()
 
 # These files are used on 32-bit and 64-bit x86.
 set(x86_ARCH_SOURCES
-  cpu_model.c
+  cpu_model/x86.c
   )
 
 if (NOT MSVC)
@@ -556,7 +556,7 @@ endif()
 set(aarch64_SOURCES
   ${GENERIC_TF_SOURCES}
   ${GENERIC_SOURCES}
-  cpu_model.c
+  cpu_model/aarch64.c
   aarch64/fp_mode.c
 )
 
diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c 
b/compiler-rt/lib/builtins/cpu_model/aarch64.c
new file mode 100644
index 00..98b0c4433d01a1
--- /dev/null
+++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c
@@ -0,0 +1,142 @@
+//===-- cpu_model_aarch64.c - Support for __cpu_model builtin  *- C 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file is based on LLVM's lib/Support/Host.cpp.
+//  It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for 
AArch64.
+//
+//===--===//
+
+#include "cpu_model.h"
+
+#if !defined(__aarch64__)
+#  error This file is intended only for aarch64-based targets
+#endif
+
+
+#if __has_include()
+#include 
+#else
+typedef struct __ifunc_arg_t {
+  unsigned long _size;
+  unsigned long _hwcap;
+  unsigned long _hwcap2;
+} __ifunc_arg_t;
+#endif // __has_include()
+
+
+// LSE support detection for out-of-line atomics
+// using HWCAP and Auxiliary vector
+_Bool __aarch64_have_lse_atomics
+__attribute__((visibility("hidden"), nocommon)) = false;
+
+#if defined(__FreeBSD__)
+#  include "lse_atomics/freebsd.inc"
+#elif defined(__Fucsia__)
+#  include "lse_atomics/fucsia.inc"
+#elif defined(__ANDROID__)
+#  include "lse_atomics/android.inc"
+#elif __has_include()
+#  include "lse_atomics/sysauxv.inc"
+#else
+// When unimplemented, we leave __aarch64_have_lse_atomics initialized to 
false.
+#endif
+
+
+#if !defined(DISABLE_AARCH64_FMV)
+// CPUFeatures must correspond to the same AArch64 features in
+// AArch64TargetParser.h
+enum CPUFeatures {
+  FEAT_RNG,
+  FEAT_FLAGM,
+  FEAT_FLAGM2,
+  FEAT_FP16FML,
+  FEAT_DOTPROD,
+  FEAT_SM4,
+  FEAT_RDM,
+  FEAT_LSE,
+  FEAT_FP,
+  FEAT_SIMD,
+  FEAT_CRC,
+  FEAT_SHA1,
+  FEAT_SHA2,
+  FEAT_SHA3,
+  FEAT_AES,
+  FEAT_PMULL,
+  FEAT_FP16,
+  FEAT_DIT

[Lldb-commits] [compiler-rt] [lldb] [llvm] [mlir] [lld] [flang] [clang] [libcxx] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

2023-12-18 Thread Jon Roelofs via lldb-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/75635

>From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Fri, 15 Dec 2023 11:13:30 -0700
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/CMakeLists.txt   |   4 +-
 compiler-rt/lib/builtins/cpu_model/aarch64.c  | 142 +
 .../cpu_model/aarch64/fmv/android.inc |  35 +
 .../cpu_model/aarch64/fmv/freebsd.inc |  27 +
 .../builtins/cpu_model/aarch64/fmv/fucsia.inc |  19 +
 .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++
 .../cpu_model/aarch64/fmv/sysauxv.inc |  17 +
 .../cpu_model/aarch64/fmv/unimplemented.inc   |  11 +
 .../cpu_model/aarch64/lse_atomics/android.inc |  28 +
 .../cpu_model/aarch64/lse_atomics/freebsd.inc |   5 +
 .../cpu_model/aarch64/lse_atomics/fucsia.inc  |  12 +
 .../cpu_model/aarch64/lse_atomics/sysauxv.inc |   6 +
 .../lib/builtins/cpu_model/cpu_model.h|  41 ++
 .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +-
 14 files changed, 729 insertions(+), 593 deletions(-)
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h
 rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%)

diff --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index ea72c595a9b807..e5b52db175d960 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -271,7 +271,7 @@ endif()
 
 # These files are used on 32-bit and 64-bit x86.
 set(x86_ARCH_SOURCES
-  cpu_model.c
+  cpu_model/x86.c
   )
 
 if (NOT MSVC)
@@ -556,7 +556,7 @@ endif()
 set(aarch64_SOURCES
   ${GENERIC_TF_SOURCES}
   ${GENERIC_SOURCES}
-  cpu_model.c
+  cpu_model/aarch64.c
   aarch64/fp_mode.c
 )
 
diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c 
b/compiler-rt/lib/builtins/cpu_model/aarch64.c
new file mode 100644
index 00..98b0c4433d01a1
--- /dev/null
+++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c
@@ -0,0 +1,142 @@
+//===-- cpu_model_aarch64.c - Support for __cpu_model builtin  *- C 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file is based on LLVM's lib/Support/Host.cpp.
+//  It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for 
AArch64.
+//
+//===--===//
+
+#include "cpu_model.h"
+
+#if !defined(__aarch64__)
+#  error This file is intended only for aarch64-based targets
+#endif
+
+
+#if __has_include()
+#include 
+#else
+typedef struct __ifunc_arg_t {
+  unsigned long _size;
+  unsigned long _hwcap;
+  unsigned long _hwcap2;
+} __ifunc_arg_t;
+#endif // __has_include()
+
+
+// LSE support detection for out-of-line atomics
+// using HWCAP and Auxiliary vector
+_Bool __aarch64_have_lse_atomics
+__attribute__((visibility("hidden"), nocommon)) = false;
+
+#if defined(__FreeBSD__)
+#  include "lse_atomics/freebsd.inc"
+#elif defined(__Fucsia__)
+#  include "lse_atomics/fucsia.inc"
+#elif defined(__ANDROID__)
+#  include "lse_atomics/android.inc"
+#elif __has_include()
+#  include "lse_atomics/sysauxv.inc"
+#else
+// When unimplemented, we leave __aarch64_have_lse_atomics initialized to 
false.
+#endif
+
+
+#if !defined(DISABLE_AARCH64_FMV)
+// CPUFeatures must correspond to the same AArch64 features in
+// AArch64TargetParser.h
+enum CPUFeatures {
+  FEAT_RNG,
+  FEAT_FLAGM,
+  FEAT_FLAGM2,
+  FEAT_FP16FML,
+  FEAT_DOTPROD,
+  FEAT_SM4,
+  FEAT_RDM,
+  FEAT_LSE,
+  FEAT_FP,
+  FEAT_SIMD,
+  FEAT_CRC,
+  FEAT_SHA1,
+  FEAT_SHA2,
+  FEAT_SHA3,
+  FEAT_AES,
+  FEAT_PMULL,
+  FEAT_FP16,
+  FEAT_DIT

[Lldb-commits] [compiler-rt] [libcxx] [flang] [clang] [lld] [lldb] [mlir] [llvm] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

2023-12-18 Thread Jon Roelofs via lldb-commits

https://github.com/jroelofs updated 
https://github.com/llvm/llvm-project/pull/75635

>From 336d1629f38a8681038f026c599a256761b522dc Mon Sep 17 00:00:00 2001
From: Jon Roelofs 
Date: Fri, 15 Dec 2023 11:13:30 -0700
Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 compiler-rt/lib/builtins/CMakeLists.txt   |   4 +-
 compiler-rt/lib/builtins/cpu_model/aarch64.c  | 142 +
 .../cpu_model/aarch64/fmv/android.inc |  35 +
 .../cpu_model/aarch64/fmv/freebsd.inc |  27 +
 .../builtins/cpu_model/aarch64/fmv/fucsia.inc |  19 +
 .../builtins/cpu_model/aarch64/fmv/mrs.inc| 375 +++
 .../cpu_model/aarch64/fmv/sysauxv.inc |  17 +
 .../cpu_model/aarch64/fmv/unimplemented.inc   |  11 +
 .../cpu_model/aarch64/lse_atomics/android.inc |  28 +
 .../cpu_model/aarch64/lse_atomics/freebsd.inc |   5 +
 .../cpu_model/aarch64/lse_atomics/fucsia.inc  |  12 +
 .../cpu_model/aarch64/lse_atomics/sysauxv.inc |   6 +
 .../lib/builtins/cpu_model/cpu_model.h|  41 ++
 .../builtins/{cpu_model.c => cpu_model/x86.c} | 600 +-
 14 files changed, 729 insertions(+), 593 deletions(-)
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64.c
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/android.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/freebsd.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/fucsia.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/mrs.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/fmv/sysauxv.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/fmv/unimplemented.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/android.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/freebsd.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/fucsia.inc
 create mode 100644 
compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/sysauxv.inc
 create mode 100644 compiler-rt/lib/builtins/cpu_model/cpu_model.h
 rename compiler-rt/lib/builtins/{cpu_model.c => cpu_model/x86.c} (60%)

diff --git a/compiler-rt/lib/builtins/CMakeLists.txt 
b/compiler-rt/lib/builtins/CMakeLists.txt
index ea72c595a9b807..e5b52db175d960 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -271,7 +271,7 @@ endif()
 
 # These files are used on 32-bit and 64-bit x86.
 set(x86_ARCH_SOURCES
-  cpu_model.c
+  cpu_model/x86.c
   )
 
 if (NOT MSVC)
@@ -556,7 +556,7 @@ endif()
 set(aarch64_SOURCES
   ${GENERIC_TF_SOURCES}
   ${GENERIC_SOURCES}
-  cpu_model.c
+  cpu_model/aarch64.c
   aarch64/fp_mode.c
 )
 
diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c 
b/compiler-rt/lib/builtins/cpu_model/aarch64.c
new file mode 100644
index 00..98b0c4433d01a1
--- /dev/null
+++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c
@@ -0,0 +1,142 @@
+//===-- cpu_model_aarch64.c - Support for __cpu_model builtin  *- C 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file is based on LLVM's lib/Support/Host.cpp.
+//  It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for 
AArch64.
+//
+//===--===//
+
+#include "cpu_model.h"
+
+#if !defined(__aarch64__)
+#  error This file is intended only for aarch64-based targets
+#endif
+
+
+#if __has_include()
+#include 
+#else
+typedef struct __ifunc_arg_t {
+  unsigned long _size;
+  unsigned long _hwcap;
+  unsigned long _hwcap2;
+} __ifunc_arg_t;
+#endif // __has_include()
+
+
+// LSE support detection for out-of-line atomics
+// using HWCAP and Auxiliary vector
+_Bool __aarch64_have_lse_atomics
+__attribute__((visibility("hidden"), nocommon)) = false;
+
+#if defined(__FreeBSD__)
+#  include "lse_atomics/freebsd.inc"
+#elif defined(__Fucsia__)
+#  include "lse_atomics/fucsia.inc"
+#elif defined(__ANDROID__)
+#  include "lse_atomics/android.inc"
+#elif __has_include()
+#  include "lse_atomics/sysauxv.inc"
+#else
+// When unimplemented, we leave __aarch64_have_lse_atomics initialized to 
false.
+#endif
+
+
+#if !defined(DISABLE_AARCH64_FMV)
+// CPUFeatures must correspond to the same AArch64 features in
+// AArch64TargetParser.h
+enum CPUFeatures {
+  FEAT_RNG,
+  FEAT_FLAGM,
+  FEAT_FLAGM2,
+  FEAT_FP16FML,
+  FEAT_DOTPROD,
+  FEAT_SM4,
+  FEAT_RDM,
+  FEAT_LSE,
+  FEAT_FP,
+  FEAT_SIMD,
+  FEAT_CRC,
+  FEAT_SHA1,
+  FEAT_SHA2,
+  FEAT_SHA3,
+  FEAT_AES,
+  FEAT_PMULL,
+  FEAT_FP16,
+  FEAT_DIT

[Lldb-commits] [lldb] Trying to fix windows buildbots after #74786 (PR #75566)

2023-12-18 Thread David Spickett via lldb-commits

DavidSpickett wrote:

On the subject of `TestUniqueTypes4.py`, the program on Windows contains no 
symbol data, but on Linux I see:
```
[   78]111 Data0x00011038
0x0008 0x0021 ns::Foo::value
```
Which I think is the key here.

The puzzling thing is that despite compiling with `-gdwarf` there is a PDB file 
produced. `llvm-dwarfdump` on the program file seems to show enough information 
for the lookup to succeed but lldb doesn't use it? Perhaps because it's 
thinking there is a pdb file or it's being told that the pdb file is in fact 
dwarf?

Basically, I'm not sure why a pdb file is generated at all here. So that may be 
*one* of the issues, because it doesn't explain why it worked previously.

Unless previously the lookup of `ns::FooDouble::value` did not require that 
there be a symbol present, but I don't see how else it would have found it.

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


[Lldb-commits] [lldb] [lldb] Fix a quirk in SBValue::GetDescription (PR #75793)

2023-12-18 Thread Adrian Prantl via lldb-commits

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


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


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

2023-12-18 Thread Juergen Ributzka via lldb-commits

ributzka wrote:

> This looks pretty nice, I left just a couple of notes. You might want to take 
> a look at the CI failures.

Thanks Jan, I will take a look. At first glance I need to build and fix `flang` 
too.

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] [lldb] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)

2023-12-18 Thread Juergen Ributzka via lldb-commits


@@ -224,19 +233,20 @@ class CompilerInvocation : public CompilerInvocationBase {
   /// @{
   // Note: These need to be pulled in manually. Otherwise, they get hidden by
   // the mutable getters with the same names.
-  using CompilerInvocationBase::getLangOpts;
-  using CompilerInvocationBase::getTargetOpts;
-  using CompilerInvocationBase::getDiagnosticOpts;
-  using CompilerInvocationBase::getHeaderSearchOpts;
-  using CompilerInvocationBase::getPreprocessorOpts;
   using CompilerInvocationBase::getAnalyzerOpts;
-  using CompilerInvocationBase::getMigratorOpts;
   using CompilerInvocationBase::getAPINotesOpts;
   using CompilerInvocationBase::getCodeGenOpts;
+  using CompilerInvocationBase::getDebugOpts;

ributzka wrote:

That was clang-format. I just happened to change one line in there and it 
reordered everything. I will undo the change.

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] [libcxx] [flang] [llvm] [lldb] [libcxxabi] [clang] [clang-tools-extra] [lld] [compiler-rt] [libc] [HLSL][DirectX] Move handling of resource element types into the frontend (PR #75674)

2023-12-18 Thread Justin Bogner via lldb-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/75674

>From 9d6e00bd972a563daefd67b544614e2bb609cc42 Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Fri, 15 Dec 2023 16: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.5-bogner
---
 clang/lib/CodeGen/CGHLSLRuntime.cpp   | 63 +++--
 clang/lib/CodeGen/CGHLSLRuntime.h |  2 +-
 .../builtins/RWBuffer-annotations.hlsl| 14 +--
 .../builtins/RWBuffer-elementtype.hlsl| 52 +++
 .../RasterizerOrderedBuffer-annotations.hlsl  | 12 +--
 clang/test/CodeGenHLSL/cbuf.hlsl  |  4 +-
 .../include/llvm/Frontend/HLSL/HLSLResource.h | 27 +-
 llvm/lib/Frontend/HLSL/HLSLResource.cpp   | 17 ++--
 llvm/lib/Target/DirectX/DXILResource.cpp  | 92 ++-
 llvm/lib/Target/DirectX/DXILResource.h| 37 ++--
 llvm/test/CodeGen/DirectX/UAVMetadata.ll  | 22 ++---
 11 files changed, 204 insertions(+), 138 deletions(-)
 create mode 100644 clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl

diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 3e8a40e7540bef..e887d35198b3c7 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -182,10 +182,8 @@ void CGHLSLRuntime::finishCodeGen() {
 llvm::hlsl::ResourceKind RK = Buf.IsCBuffer
   ? llvm::hlsl::ResourceKind::CBuffer
   : llvm::hlsl::ResourceKind::TBuffer;
-std::string TyName =
-Buf.Name.str() + (Buf.IsCBuffer ? ".cb." : ".tb.") + "ty";
-addBufferResourceAnnotation(GV, TyName, RC, RK, /*IsROV=*/false,
-Buf.Binding);
+addBufferResourceAnnotation(GV, RC, RK, /*IsROV=*/false,
+llvm::hlsl::ElementType::Invalid, Buf.Binding);
   }
 }
 
@@ -194,10 +192,10 @@ CGHLSLRuntime::Buffer::Buffer(const HLSLBufferDecl *D)
   Binding(D->getAttr()) {}
 
 void CGHLSLRuntime::addBufferResourceAnnotation(llvm::GlobalVariable *GV,
-llvm::StringRef TyName,
 llvm::hlsl::ResourceClass RC,
 llvm::hlsl::ResourceKind RK,
 bool IsROV,
+llvm::hlsl::ElementType ET,
 BufferResBinding &Binding) {
   llvm::Module &M = CGM.getModule();
 
@@ -216,15 +214,62 @@ void 
CGHLSLRuntime::addBufferResourceAnnotation(llvm::GlobalVariable *GV,
 assert(false && "Unsupported buffer type!");
 return;
   }
-
   assert(ResourceMD != nullptr &&
  "ResourceMD must have been set by the switch above.");
 
   llvm::hlsl::FrontendResource Res(
-  GV, TyName, RK, IsROV, Binding.Reg.value_or(UINT_MAX), Binding.Space);
+  GV, RK, ET, IsROV, Binding.Reg.value_or(UINT_MAX), Binding.Space);
   ResourceMD->addOperand(Res.getMetadata());
 }
 
+static llvm::hlsl::ElementType
+calculateElementType(const ASTContext &Context, const clang::Type *ResourceTy) 
{
+  using llvm::hlsl::ElementType;
+
+  // TODO: We may need to update this when we add things like ByteAddressBuffer
+  // that don't have a template parameter (or, indeed, an element type).
+  const auto *TST = ResourceTy->getAs();
+  assert(TST && "Resource types must be template specializations");
+  ArrayRef Args = TST->template_arguments();
+  assert(!Args.empty() && "Resource has no element type");
+
+  // At this point we have a resource with an element type, so we can assume
+  // that it's valid or we would have diagnosed the error earlier.
+  QualType ElTy = Args[0].getAsType();
+
+  // We should either have a basic type or a vector of a basic type.
+  if (const auto *VecTy = ElTy->getAs())
+ElTy = VecTy->getElementType();
+
+  if (ElTy->isSignedIntegerType()) {
+switch (Context.getTypeSize(ElTy)) {
+case 16:
+  return ElementType::I16;
+case 32:
+  return ElementType::I32;
+case 64:
+  return ElementType::I64;
+}
+  } else if (ElTy->isUnsignedIntegerType()) {
+switch (Context.getTypeSize(ElTy)) {
+case 16:
+  return ElementType::U16;
+case 32:
+  return ElementType::U32;
+case 64:
+  return ElementType::U64;
+}
+  } else if (ElTy->isSpecificBuiltinType(BuiltinType::Half))
+return ElementType::F16;
+  else if (ElTy->isSpecificBuiltinType(BuiltinType::Float))
+return ElementType::F32;
+  else if (ElTy->isSpecificBuiltinType(BuiltinType::Double))
+return ElementType::F64;
+
+  // TODO: We need to handle unorm/snorm float types here once we support them
+  llvm_unreachable("Invalid element type for resource");
+}
+

[Lldb-commits] [lldb] Remove unused FileSPec::IsResolved() functionality. (PR #75840)

2023-12-18 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/75840

This API seems to be completely unused. Should we just remove it?

>From ce51a6c5b8f023a190023ddd4f189dea04fc1d63 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Mon, 18 Dec 2023 10:25:23 -0800
Subject: [PATCH] Remove unused FileSPec::IsResolved() functionality.

---
 lldb/include/lldb/Utility/FileSpec.h   | 19 ---
 lldb/source/Host/common/FileSystem.cpp |  1 -
 2 files changed, 20 deletions(-)

diff --git a/lldb/include/lldb/Utility/FileSpec.h 
b/lldb/include/lldb/Utility/FileSpec.h
index ccd25a81c11f36..e4276e8398b464 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -386,21 +386,6 @@ class FileSpec {
   /// The triple which is used to set the Path style.
   void SetFile(llvm::StringRef path, const llvm::Triple &triple);
 
-  bool IsResolved() const { return m_is_resolved; }
-
-  /// Set if the file path has been resolved or not.
-  ///
-  /// If you know a file path is already resolved and avoided passing a \b
-  /// true parameter for any functions that take a "bool resolve_path"
-  /// parameter, you can set the value manually using this call to make sure
-  /// we don't try and resolve it later, or try and resolve a path that has
-  /// already been resolved.
-  ///
-  /// \param[in] is_resolved
-  /// A boolean value that will replace the current value that
-  /// indicates if the paths in this object have been resolved.
-  void SetIsResolved(bool is_resolved) { m_is_resolved = is_resolved; }
-
   FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const;
   FileSpec CopyByRemovingLastPathComponent() const;
 
@@ -440,7 +425,6 @@ class FileSpec {
   /// state in this object.
   void PathWasModified() {
 m_checksum = Checksum();
-m_is_resolved = false;
 m_absolute = Absolute::Calculate;
   }
 
@@ -459,9 +443,6 @@ class FileSpec {
   /// The optional MD5 checksum of the file.
   Checksum m_checksum;
 
-  /// True if this path has been resolved.
-  mutable bool m_is_resolved = false;
-
   /// Cache whether this path is absolute.
   mutable Absolute m_absolute = Absolute::Calculate;
 
diff --git a/lldb/source/Host/common/FileSystem.cpp 
b/lldb/source/Host/common/FileSystem.cpp
index 52227a9f63a526..5153a0a9ec5134 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -259,7 +259,6 @@ void FileSystem::Resolve(FileSpec &file_spec) {
 file_spec.SetDirectory(path);
   else
 file_spec.SetPath(path);
-  file_spec.SetIsResolved(true);
 }
 
 template 

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


[Lldb-commits] [lldb] Remove unused FileSPec::IsResolved() functionality. (PR #75840)

2023-12-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

This API seems to be completely unused. Should we just remove it?

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


2 Files Affected:

- (modified) lldb/include/lldb/Utility/FileSpec.h (-19) 
- (modified) lldb/source/Host/common/FileSystem.cpp (-1) 


``diff
diff --git a/lldb/include/lldb/Utility/FileSpec.h 
b/lldb/include/lldb/Utility/FileSpec.h
index ccd25a81c11f36..e4276e8398b464 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -386,21 +386,6 @@ class FileSpec {
   /// The triple which is used to set the Path style.
   void SetFile(llvm::StringRef path, const llvm::Triple &triple);
 
-  bool IsResolved() const { return m_is_resolved; }
-
-  /// Set if the file path has been resolved or not.
-  ///
-  /// If you know a file path is already resolved and avoided passing a \b
-  /// true parameter for any functions that take a "bool resolve_path"
-  /// parameter, you can set the value manually using this call to make sure
-  /// we don't try and resolve it later, or try and resolve a path that has
-  /// already been resolved.
-  ///
-  /// \param[in] is_resolved
-  /// A boolean value that will replace the current value that
-  /// indicates if the paths in this object have been resolved.
-  void SetIsResolved(bool is_resolved) { m_is_resolved = is_resolved; }
-
   FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const;
   FileSpec CopyByRemovingLastPathComponent() const;
 
@@ -440,7 +425,6 @@ class FileSpec {
   /// state in this object.
   void PathWasModified() {
 m_checksum = Checksum();
-m_is_resolved = false;
 m_absolute = Absolute::Calculate;
   }
 
@@ -459,9 +443,6 @@ class FileSpec {
   /// The optional MD5 checksum of the file.
   Checksum m_checksum;
 
-  /// True if this path has been resolved.
-  mutable bool m_is_resolved = false;
-
   /// Cache whether this path is absolute.
   mutable Absolute m_absolute = Absolute::Calculate;
 
diff --git a/lldb/source/Host/common/FileSystem.cpp 
b/lldb/source/Host/common/FileSystem.cpp
index 52227a9f63a526..5153a0a9ec5134 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -259,7 +259,6 @@ void FileSystem::Resolve(FileSpec &file_spec) {
 file_spec.SetDirectory(path);
   else
 file_spec.SetPath(path);
-  file_spec.SetIsResolved(true);
 }
 
 template 

``




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


[Lldb-commits] [compiler-rt] [clang-tools-extra] [libcxx] [lldb] [clang] [libc] [llvm] [libcxxabi] [lld] [flang] [HLSL][DirectX] Move handling of resource element types into the frontend (PR #75674)

2023-12-18 Thread Justin Bogner via lldb-commits

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


[Lldb-commits] [lldb] [lldb][PDB] Update max matches test for type queries (PR #75813)

2023-12-18 Thread Alex Langford via lldb-commits

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

Seems like a good clean up to me!

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


[Lldb-commits] [lldb] [lldb][PDB] Update max matches test for type queries (PR #75813)

2023-12-18 Thread Greg Clayton via lldb-commits

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

Thanks for fixing properly!

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


[Lldb-commits] [lldb] Remove unused FileSPec::IsResolved() functionality. (PR #75840)

2023-12-18 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [clang] [llvm] [libcxx] [lldb] [clang-tools-extra] [libc] [compiler-rt] [flang] [lld] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2023-12-18 Thread Stanislav Mekhanoshin via lldb-commits

https://github.com/rampitec updated 
https://github.com/llvm/llvm-project/pull/74537

>From 7e382620cdc5999c645ed0746f242595f0294c58 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Mon, 4 Dec 2023 16:11:53 -0800
Subject: [PATCH 1/9] [AMDGPU] Use alias info to relax waitcounts for LDS DMA

LDA DMA loads increase VMCNT and a load from the LDS stored must
wait on this counter to only read memory after it is written.
Wait count insertion pass does not track memory dependencies, it
tracks register dependencies. To model the LDS dependency a
psuedo register is used in the scoreboard, acting like if LDS DMA
writes it and LDS load reads it.

This patch adds 8 more pseudo registers to use for independent LDS
locations if we can prove they are disjoint using alias analysis.

Fixes: SWDEV-433427
---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp   |  16 +-
 llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp |  73 +-
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp  |   4 +-
 llvm/lib/Target/AMDGPU/SIInstrInfo.h|   8 +
 llvm/lib/Target/AMDGPU/lds-dma-waits.ll | 154 
 llvm/test/CodeGen/AMDGPU/llc-pipeline.ll|   2 +
 6 files changed, 241 insertions(+), 16 deletions(-)
 create mode 100644 llvm/lib/Target/AMDGPU/lds-dma-waits.ll

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp 
b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index a7f4d63229b7ef..2e079404b087fa 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -1128,11 +1128,10 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
 MachineMemOperand::MOStore |
 MachineMemOperand::MODereferenceable;
 
-  // XXX - Should this be volatile without known ordering?
-  Info.flags |= MachineMemOperand::MOVolatile;
-
   switch (IntrID) {
   default:
+// XXX - Should this be volatile without known ordering?
+Info.flags |= MachineMemOperand::MOVolatile;
 break;
   case Intrinsic::amdgcn_raw_buffer_load_lds:
   case Intrinsic::amdgcn_raw_ptr_buffer_load_lds:
@@ -1140,6 +1139,7 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
   case Intrinsic::amdgcn_struct_ptr_buffer_load_lds: {
 unsigned Width = 
cast(CI.getArgOperand(2))->getZExtValue();
 Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8);
+Info.ptrVal = CI.getArgOperand(1);
 return true;
   }
   }
@@ -1268,8 +1268,8 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo 
&Info,
 Info.opc = ISD::INTRINSIC_VOID;
 unsigned Width = cast(CI.getArgOperand(2))->getZExtValue();
 Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8);
-Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore |
-  MachineMemOperand::MOVolatile;
+Info.ptrVal = CI.getArgOperand(1);
+Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
 return true;
   }
   case Intrinsic::amdgcn_ds_bvh_stack_rtn: {
@@ -9084,7 +9084,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
 MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo();
 
 MachinePointerInfo StorePtrI = LoadPtrI;
-StorePtrI.V = nullptr;
+LoadPtrI.V = UndefValue::get(
+PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS));
+LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS;
 StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS;
 
 auto F = LoadMMO->getFlags() &
@@ -9162,6 +9164,8 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
 MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo();
 LoadPtrI.Offset = Op->getConstantOperandVal(5);
 MachinePointerInfo StorePtrI = LoadPtrI;
+LoadPtrI.V = UndefValue::get(
+PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS));
 LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS;
 StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS;
 auto F = LoadMMO->getFlags() &
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp 
b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index ede4841b8a5fd7..50ad22130e939e 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Sequence.h"
+#include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/CodeGen/MachineLoopInfo.h"
 #include "llvm/CodeGen/MachinePostDominators.h"
 #include "llvm/InitializePasses.h"
@@ -121,8 +122,13 @@ enum RegisterMapping {
   SQ_MAX_PGM_VGPRS = 512, // Maximum programmable VGPRs across all targets.
   AGPR_OFFSET = 256,  // Maximum programmable ArchVGPRs across all targets.
   SQ_MAX_PGM_SGPRS = 256, // Maximum programmable SGPRs across all targets.
-  NUM_EXTRA_VGPRS = 1,// A reserved slot for DS.
-  EXTRA_VGPR_LDS = 0, // An artificial register to track LDS writes.
+  NUM_EXTRA_VGPRS = 9,// Reserved slots f

[Lldb-commits] [clang] [libcxx] [compiler-rt] [lldb] [libc] [llvm] [lld] [flang] [clang-tools-extra] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2023-12-18 Thread Stanislav Mekhanoshin via lldb-commits

rampitec wrote:

All split off parts were merged and this patch is merged with main. Only 
waitcount insertion pass changes remained here.

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


[Lldb-commits] [lldb] Remove unused FileSPec::IsResolved() functionality. (PR #75840)

2023-12-18 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] Remove unused FileSPec::IsResolved() functionality. (PR #75840)

2023-12-18 Thread Jonas Devlieghere via lldb-commits

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

🥳

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


[Lldb-commits] [lldb] [lldb] Fix a quirk in SBValue::GetDescription (PR #75793)

2023-12-18 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] 927926b - [lldb] Fix a quirk in SBValue::GetDescription (#75793)

2023-12-18 Thread via lldb-commits

Author: Pavel Labath
Date: 2023-12-18T21:23:03+01:00
New Revision: 927926b8af4fd6ab966b95d7b6eb31790758ced1

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

LOG: [lldb] Fix a quirk in SBValue::GetDescription (#75793)

The function was using the default version of ValueObject::Dump, which
has a default of using the synthetic-ness of the top-level value for
determining whether to print _all_ values as synthetic. This resulted in
some unusual behavior, where e.g. a std::vector is stringified as
synthetic if its dumped as the top level object, but in its raw form if
it is a member of a struct without a pretty printer.

The SBValue class already has properties which determine whether one
should be looking at the synthetic view of the object (and also whether
to use dynamic types), so it seems more natural to use that.

Added: 
lldb/test/API/python_api/sbvalue_synthetic/Makefile
lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
lldb/test/API/python_api/sbvalue_synthetic/main.cpp

Modified: 
lldb/source/API/SBValue.cpp

Removed: 




diff  --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 34d01d759ba55a..89d26a1fbe2824 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -24,6 +24,7 @@
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/Symbol/Block.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Type.h"
@@ -1209,10 +1210,14 @@ bool SBValue::GetDescription(SBStream &description) {
 
   ValueLocker locker;
   lldb::ValueObjectSP value_sp(GetSP(locker));
-  if (value_sp)
-value_sp->Dump(strm);
-  else
+  if (value_sp) {
+DumpValueObjectOptions options;
+options.SetUseDynamicType(m_opaque_sp->GetUseDynamic());
+options.SetUseSyntheticValue(m_opaque_sp->GetUseSynthetic());
+value_sp->Dump(strm, options);
+  } else {
 strm.PutCString("No value");
+  }
 
   return true;
 }

diff  --git a/lldb/test/API/python_api/sbvalue_synthetic/Makefile 
b/lldb/test/API/python_api/sbvalue_synthetic/Makefile
new file mode 100644
index 00..8b20bcb050
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py 
b/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
new file mode 100644
index 00..5dcf3c1a9c6c44
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/TestSBValueSynthetic.py
@@ -0,0 +1,19 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestSBValueSynthetic(TestBase):
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_str(self):
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "break here", lldb.SBFileSpec("main.cpp")
+)
+
+vector = self.frame().FindVariable("vector")
+has_vector = self.frame().FindVariable("has_vector")
+self.expect(str(vector), exe=False, substrs=["42", "47"])
+self.expect(str(has_vector), exe=False, substrs=["42", "47"])

diff  --git a/lldb/test/API/python_api/sbvalue_synthetic/main.cpp 
b/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
new file mode 100644
index 00..e6b6ec50f307f8
--- /dev/null
+++ b/lldb/test/API/python_api/sbvalue_synthetic/main.cpp
@@ -0,0 +1,11 @@
+#include 
+
+struct HasVector {
+  std::vector v;
+};
+
+int main() {
+  std::vector vector = {42, 47};
+  HasVector has_vector = {vector};
+  return 0; // break here
+}



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


[Lldb-commits] [lldb] [lldb] Fix a quirk in SBValue::GetDescription (PR #75793)

2023-12-18 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [clang] [mlir] [compiler-rt] [libcxx] [lld] [clang-tools-extra] [llvm] [lldb] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-18 Thread via lldb-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsSubrangeIt = requires(Iter1 first1, Sent1 last1, Iter2 
first2, Sent2 last2) {
+  std::ranges::contains_subrange(first1, last1, first2, last2);
+};
+
+static_assert(HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt); // not indirectly 
comparable
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+
+template >
+concept HasContainsSubrangeR = requires(Range1&& range1, Range2&& range2) {
+  std::ranges::contains_subrange(std::forward(range1), 
std::forward(range2)); };
+
+static_assert(HasContainsSubrangeR>);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR, 
UncheckedRange>); // not indirectly comparable
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotDerivedFrom>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotIncrementable>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelSemiregular>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelEqualityComparableWith>);
+
+template 
+constexpr void test_iterators() {
+  {  // simple tests
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 5};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+  std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret = 
std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // no match
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // range consists of just one element
+int a[]   = {3};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 1)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // subrange consists of just one element
+int a[]   = {23, 1, 20, 3, 54, 2};
+int p[]   = {3};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 1)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // range has zero length
+int a[]   = {};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.e

[Lldb-commits] [libcxx] [compiler-rt] [clang-tools-extra] [lldb] [mlir] [llvm] [lld] [clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-18 Thread Nikolas Klauser via lldb-commits


@@ -0,0 +1,145 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+
+#include <__algorithm/ranges_search.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains_subrange {
+struct __fn {
+  template  _Sent1,
+forward_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred,
+class _Proj1,
+class _Proj2,
+class _Offset = int>
+  static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred& __pred,
+  _Proj1& __proj1,
+  _Proj2& __proj2,
+  _Offset __offset) {
+if (__offset < 0)
+  return false;
+else {
+  auto result = ranges::search(
+  std::move(__first1),
+  std::move(__last1),
+  std::move(__first2),
+  std::move(__last2),
+  std::ref(__pred),
+  std::ref(__proj1),
+  std::ref(__proj2));
+  return result.empty() == false;

philnik777 wrote:

```suggestion
  return !result.empty();
```

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


[Lldb-commits] [libcxx] [mlir] [lld] [lldb] [compiler-rt] [llvm] [clang] [clang-tools-extra] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-18 Thread Nikolas Klauser via lldb-commits


@@ -0,0 +1,145 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+
+#include <__algorithm/ranges_search.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains_subrange {
+struct __fn {
+  template  _Sent1,
+forward_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred,
+class _Proj1,
+class _Proj2,
+class _Offset = int>
+  static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred& __pred,
+  _Proj1& __proj1,
+  _Proj2& __proj2,
+  _Offset __offset) {
+if (__offset < 0)
+  return false;
+else {
+  auto result = ranges::search(
+  std::move(__first1),
+  std::move(__last1),
+  std::move(__first2),
+  std::move(__last2),
+  std::ref(__pred),
+  std::ref(__proj1),
+  std::ref(__proj2));
+  return result.empty() == false;
+}
+  }
+
+  template  _Sent1,
+forward_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred  = ranges::equal_to,
+class _Proj1 = identity,
+class _Proj2 = identity>
+requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred __pred   = {},
+  _Proj1 __proj1 = {},
+  _Proj2 __proj2 = {}) const {

philnik777 wrote:

Same here: let's make these static member functions.

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


[Lldb-commits] [llvm] [lldb] [libc] [clang] [flang] [clang-tools-extra] [libcxx] [mlir] [compiler-rt] [lld] GFX12: Add LoopDataPrefetchPass (PR #75625)

2023-12-18 Thread Mariusz Sikora via lldb-commits

https://github.com/mariusz-sikora-at-amd updated 
https://github.com/llvm/llvm-project/pull/75625

>From de5303eb8a9e061dbd365922f85cad02bca5ec26 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Tue, 5 Jul 2022 11:41:29 -0700
Subject: [PATCH 1/3] GFX12: Add LoopDataPrefetchPass

It is currently disabled by default. It will need experiments on a real
HW to tune and decide on the profitability.
---
 .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp |   7 +
 .../AMDGPU/AMDGPUTargetTransformInfo.cpp  |  18 ++
 .../Target/AMDGPU/AMDGPUTargetTransformInfo.h |  10 +
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp|   4 +
 llvm/test/CodeGen/AMDGPU/llc-pipeline.ll  |   8 +-
 .../test/CodeGen/AMDGPU/loop-prefetch-data.ll | 185 ++
 6 files changed, 231 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/loop-prefetch-data.ll

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index e8c04ecf39ba02..fdc2077868cf99 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -345,6 +345,11 @@ static cl::opt EnableImageIntrinsicOptimizer(
 cl::desc("Enable image intrinsic optimizer pass"), cl::init(true),
 cl::Hidden);
 
+static cl::opt
+EnableLoopPrefetch("amdgpu-loop-prefetch",
+   cl::desc("Enable loop data prefetch on AMDGPU"),
+   cl::Hidden, cl::init(false));
+
 static cl::opt EnableMaxIlpSchedStrategy(
 "amdgpu-enable-max-ilp-scheduling-strategy",
 cl::desc("Enable scheduling strategy to maximize ILP for a single wave."),
@@ -982,6 +987,8 @@ void AMDGPUPassConfig::addEarlyCSEOrGVNPass() {
 }
 
 void AMDGPUPassConfig::addStraightLineScalarOptimizationPasses() {
+  if (isPassEnabled(EnableLoopPrefetch, CodeGenOptLevel::Aggressive))
+addPass(createLoopDataPrefetchPass());
   addPass(createSeparateConstOffsetFromGEPPass());
   // ReassociateGEPs exposes more opportunities for SLSR. See
   // the example in reassociate-geps-and-slsr.ll.
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index f1da1a61bf4dd5..218c5b5cfdac87 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -1345,3 +1345,21 @@ GCNTTIImpl::getTypeLegalizationCost(Type *Ty) const {
   Cost.first += (Size + 255) / 256;
   return Cost;
 }
+
+unsigned GCNTTIImpl::getPrefetchDistance() const {
+  return ST->hasPrefetch() ? 128 : 0;
+}
+
+bool GCNTTIImpl::shouldPrefetchAddressSpace(unsigned AS) const {
+  switch (AS) {
+  case AMDGPUAS::FLAT_ADDRESS:
+  case AMDGPUAS::GLOBAL_ADDRESS:
+  case AMDGPUAS::CONSTANT_ADDRESS:
+  case AMDGPUAS::CONSTANT_ADDRESS_32BIT:
+return true;
+  default:
+break;
+  }
+
+  return false;
+}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
index 1e6c5bbfc0d75b..cd8e9fd10bbf21 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
@@ -254,6 +254,16 @@ class GCNTTIImpl final : public 
BasicTTIImplBase {
   InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty,
  FastMathFlags FMF,
  TTI::TargetCostKind CostKind);
+
+  /// Data cache line size for LoopDataPrefetch pass. Has no use before GFX12.
+  unsigned getCacheLineSize() const override { return 128; }
+
+  /// How much before a load we should place the prefetch instruction.
+  /// This is currently measured in number of IR instructions.
+  unsigned getPrefetchDistance() const override;
+
+  /// \return if target want to issue a prefetch in address space \p AS.
+  bool shouldPrefetchAddressSpace(unsigned AS) const override;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 70ef1fff274a40..717f22fb69fdd3 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -245,6 +245,10 @@ bool SIInstrInfo::areLoadsFromSameBasePtr(SDNode *Load0, 
SDNode *Load1,
   if (!get(Opc0).mayLoad() || !get(Opc1).mayLoad())
 return false;
 
+  // A mayLoad instruction without a def is not a load. Likely a prefetch.
+  if (!get(Opc0).getNumDefs() || !get(Opc1).getNumDefs())
+return false;
+
   if (isDS(Opc0) && isDS(Opc1)) {
 
 // FIXME: Handle this case:
diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll 
b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
index 488dbe2e3189bf..8b0b6263832243 100644
--- a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -4,7 +4,7 @@
 ; RUN: llc -O1 -mtriple=amdgcn--amdhsa -disable-verify -debug-pass=Structure < 
%s 2>&1 \
 ; RUN:   | FileCheck -match-full-lines -strict-whitespace -check-prefix=

[Lldb-commits] [llvm] [lldb] [libc] [clang] [flang] [clang-tools-extra] [libcxx] [mlir] [compiler-rt] [lld] GFX12: Add LoopDataPrefetchPass (PR #75625)

2023-12-18 Thread Mariusz Sikora via lldb-commits

https://github.com/mariusz-sikora-at-amd updated 
https://github.com/llvm/llvm-project/pull/75625

>From de5303eb8a9e061dbd365922f85cad02bca5ec26 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Tue, 5 Jul 2022 11:41:29 -0700
Subject: [PATCH 1/4] GFX12: Add LoopDataPrefetchPass

It is currently disabled by default. It will need experiments on a real
HW to tune and decide on the profitability.
---
 .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp |   7 +
 .../AMDGPU/AMDGPUTargetTransformInfo.cpp  |  18 ++
 .../Target/AMDGPU/AMDGPUTargetTransformInfo.h |  10 +
 llvm/lib/Target/AMDGPU/SIInstrInfo.cpp|   4 +
 llvm/test/CodeGen/AMDGPU/llc-pipeline.ll  |   8 +-
 .../test/CodeGen/AMDGPU/loop-prefetch-data.ll | 185 ++
 6 files changed, 231 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/AMDGPU/loop-prefetch-data.ll

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index e8c04ecf39ba02..fdc2077868cf99 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -345,6 +345,11 @@ static cl::opt EnableImageIntrinsicOptimizer(
 cl::desc("Enable image intrinsic optimizer pass"), cl::init(true),
 cl::Hidden);
 
+static cl::opt
+EnableLoopPrefetch("amdgpu-loop-prefetch",
+   cl::desc("Enable loop data prefetch on AMDGPU"),
+   cl::Hidden, cl::init(false));
+
 static cl::opt EnableMaxIlpSchedStrategy(
 "amdgpu-enable-max-ilp-scheduling-strategy",
 cl::desc("Enable scheduling strategy to maximize ILP for a single wave."),
@@ -982,6 +987,8 @@ void AMDGPUPassConfig::addEarlyCSEOrGVNPass() {
 }
 
 void AMDGPUPassConfig::addStraightLineScalarOptimizationPasses() {
+  if (isPassEnabled(EnableLoopPrefetch, CodeGenOptLevel::Aggressive))
+addPass(createLoopDataPrefetchPass());
   addPass(createSeparateConstOffsetFromGEPPass());
   // ReassociateGEPs exposes more opportunities for SLSR. See
   // the example in reassociate-geps-and-slsr.ll.
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index f1da1a61bf4dd5..218c5b5cfdac87 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -1345,3 +1345,21 @@ GCNTTIImpl::getTypeLegalizationCost(Type *Ty) const {
   Cost.first += (Size + 255) / 256;
   return Cost;
 }
+
+unsigned GCNTTIImpl::getPrefetchDistance() const {
+  return ST->hasPrefetch() ? 128 : 0;
+}
+
+bool GCNTTIImpl::shouldPrefetchAddressSpace(unsigned AS) const {
+  switch (AS) {
+  case AMDGPUAS::FLAT_ADDRESS:
+  case AMDGPUAS::GLOBAL_ADDRESS:
+  case AMDGPUAS::CONSTANT_ADDRESS:
+  case AMDGPUAS::CONSTANT_ADDRESS_32BIT:
+return true;
+  default:
+break;
+  }
+
+  return false;
+}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
index 1e6c5bbfc0d75b..cd8e9fd10bbf21 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
@@ -254,6 +254,16 @@ class GCNTTIImpl final : public 
BasicTTIImplBase {
   InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty,
  FastMathFlags FMF,
  TTI::TargetCostKind CostKind);
+
+  /// Data cache line size for LoopDataPrefetch pass. Has no use before GFX12.
+  unsigned getCacheLineSize() const override { return 128; }
+
+  /// How much before a load we should place the prefetch instruction.
+  /// This is currently measured in number of IR instructions.
+  unsigned getPrefetchDistance() const override;
+
+  /// \return if target want to issue a prefetch in address space \p AS.
+  bool shouldPrefetchAddressSpace(unsigned AS) const override;
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 70ef1fff274a40..717f22fb69fdd3 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -245,6 +245,10 @@ bool SIInstrInfo::areLoadsFromSameBasePtr(SDNode *Load0, 
SDNode *Load1,
   if (!get(Opc0).mayLoad() || !get(Opc1).mayLoad())
 return false;
 
+  // A mayLoad instruction without a def is not a load. Likely a prefetch.
+  if (!get(Opc0).getNumDefs() || !get(Opc1).getNumDefs())
+return false;
+
   if (isDS(Opc0) && isDS(Opc1)) {
 
 // FIXME: Handle this case:
diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll 
b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
index 488dbe2e3189bf..8b0b6263832243 100644
--- a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -4,7 +4,7 @@
 ; RUN: llc -O1 -mtriple=amdgcn--amdhsa -disable-verify -debug-pass=Structure < 
%s 2>&1 \
 ; RUN:   | FileCheck -match-full-lines -strict-whitespace -check-prefix=

[Lldb-commits] [llvm] [compiler-rt] [libc] [flang] [libcxx] [clang-tools-extra] [mlir] [lldb] [clang] [lld] GFX12: Add LoopDataPrefetchPass (PR #75625)

2023-12-18 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 33d5f4314f4fd83be21e22054e662220a62fe40b 
6296613d1d3f3e8b63e1af1d12d28f2000facc0e -- 
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp 
llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp 
llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h 
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index c25ccd9ecc..ebe0b8551b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -1351,5 +1351,5 @@ unsigned GCNTTIImpl::getPrefetchDistance() const {
 }
 
 bool GCNTTIImpl::shouldPrefetchAddressSpace(unsigned AS) const {
-  return AMDGPU::isFlatGlobalAddrSpace(AS);
+  return AMDGPU::isFlatGlobalAddrSpace(AS);
 }

``




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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability (and behavior?)… (PR #75865)

2023-12-18 Thread Pete Lawrence via lldb-commits

https://github.com/PortalPete created 
https://github.com/llvm/llvm-project/pull/75865

… by exiting early and consolidating code paths.

As I worked through changes to another PR 
(https://github.com/llvm/llvm-project/pull/74912), I couldn't help but rewrite 
a few methods for readability, maintainability, and possibly some behavior 
correctness too.

1. Exiting early instead of nested `if`-statements, which:
- Reduces indentation levels for all subsequent lines
- Treats missing pre-conditions similar to an error
- Clearly indicates that the full length of the method is the "happy 
path".
2. Explicitly return empty Value Object shared pointers for those error (like) 
situations, which
- Reduces the time it takes a maintainer to figure out what the method 
actually returns based on those conditions.

3. Converting a mix of `if` and `if`-`else`-statements around an enum into one 
`switch` statement, which:
- Consolidates the former branching logic
- Lets the compiler warn you of a (future) missing enum case

4. Consolidating near-identical, "copy-pasta" logic into one place, which:
- Separates the common code to the diverging paths.
- Highlights the differences between the code paths.

rdar://119833526

>From b2fe1adeb707160ba2a7b7f87d43d18cfdf29039 Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Thu, 7 Dec 2023 12:14:01 -1000
Subject: [PATCH] [lldb] Improve maintainability and readability (and
 behavior?) by exiting early and consolidating code paths

As I worked through changes to another PR 
(https://github.com/llvm/llvm-project/pull/74912), I couldn't help but rewrite 
a few methods for readability, maintainability, and possibly some behavior 
correctness too.

1. Exiting early instead of nested `if`-statements, which:
- Reduces indentation levels for all subsequent lines
- Treats missing pre-conditions similar to an error
- Clearly indicates that the full length of the method is the "happy 
path".
2. Explicitly return empty Value Object shared pointers for those error (like) 
situations, which
- Reduces the time it takes a maintainer to figure out what the method 
actually returns based on those conditions.

3. Converting a mix of `if` and `if`-`else`-statements around an enum into one 
`switch` statement, which:
- Consolidates the former branching logic
- Lets the compiler warn you of a (future) missing enum case

4. Consolidating near-identical, "copy-pasta" logic into one place, which:
- Separates the common code to the diverging paths.
- Highlights the differences between the code paths.

rdar://119833526
---
 lldb/source/Core/ValueObject.cpp | 344 ---
 1 file changed, 178 insertions(+), 166 deletions(-)

diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index b13bffa0ca809b..7de4c31b913ed2 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }
+
+  std::string index_str = llvm::formatv("[{0}]", index);
+  ConstString index_const_str(index_str);
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }
+
+  // We haven't made a synthetic array member for INDEX yet, so lets make
+  // one and cache it for any future reference.
+  ValueObject *synthetic_child = CreateChildAtIndex(0, true, index);
+
+  if (!synthetic_child) {
+return ValueObjectSP();
   }
+
+  // Cache the value if we got one back...
+  AddSyntheticChild(index_const_str, synthetic_chi

[Lldb-commits] [lldb] [lldb] Improve maintainability and readability (and behavior?)… (PR #75865)

2023-12-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pete Lawrence (PortalPete)


Changes

… by exiting early and consolidating code paths.

As I worked through changes to another PR 
(https://github.com/llvm/llvm-project/pull/74912), I couldn't help but rewrite 
a few methods for readability, maintainability, and possibly some behavior 
correctness too.

1. Exiting early instead of nested `if`-statements, which:
- Reduces indentation levels for all subsequent lines
- Treats missing pre-conditions similar to an error
- Clearly indicates that the full length of the method is the "happy 
path".
2. Explicitly return empty Value Object shared pointers for those error (like) 
situations, which
- Reduces the time it takes a maintainer to figure out what the method 
actually returns based on those conditions.

3. Converting a mix of `if` and `if`-`else`-statements around an enum into one 
`switch` statement, which:
- Consolidates the former branching logic
- Lets the compiler warn you of a (future) missing enum case

4. Consolidating near-identical, "copy-pasta" logic into one place, which:
- Separates the common code to the diverging paths.
- Highlights the differences between the code paths.

rdar://119833526

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


1 Files Affected:

- (modified) lldb/source/Core/ValueObject.cpp (+178-166) 


``diff
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index b13bffa0ca809b..7de4c31b913ed2 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }
+
+  std::string index_str = llvm::formatv("[{0}]", index);
+  ConstString index_const_str(index_str);
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }
+
+  // We haven't made a synthetic array member for INDEX yet, so lets make
+  // one and cache it for any future reference.
+  ValueObject *synthetic_child = CreateChildAtIndex(0, true, index);
+
+  if (!synthetic_child) {
+return ValueObjectSP();
   }
+
+  // Cache the value if we got one back...
+  AddSyntheticChild(index_const_str, synthetic_child);
+  auto synthetic_child_sp = synthetic_child->GetSP();
+  synthetic_child_sp->SetName(ConstString(index_str));
+  synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
   return synthetic_child_sp;
 }
 
 ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t 
to,
  bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsScalarType()) {
-std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  uint32_t bit_field_size = to - from + 1;
-  uint32_t bit_field_offset = from;
-  if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
-bit_field_offset =
-GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  ValueObjectChild *synthetic_child = new ValueObjectChild(
-  *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
-  0, bit_field_size, bit_field_offset, false, false,

[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Pete Lawrence via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Pete Lawrence via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Pete Lawrence via lldb-commits

https://github.com/PortalPete updated 
https://github.com/llvm/llvm-project/pull/75865

>From 8d67e8c5d38913e4c57690cb09f92a4211d88229 Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Thu, 7 Dec 2023 12:14:01 -1000
Subject: [PATCH] [lldb] Improve maintainability and readability for
 ValueObject methods

As I worked through changes to another PR 
(https://github.com/llvm/llvm-project/pull/74912), I couldn't help but rewrite 
a few methods for readability, maintainability, and possibly some behavior 
correctness too.

1. Exiting early instead of nested `if`-statements, which:
- Reduces indentation levels for all subsequent lines
- Treats missing pre-conditions similar to an error
- Clearly indicates that the full length of the method is the "happy 
path".
2. Explicitly return empty Value Object shared pointers for those error (like) 
situations, which
- Reduces the time it takes a maintainer to figure out what the method 
actually returns based on those conditions.

3. Converting a mix of `if` and `if`-`else`-statements around an enum into one 
`switch` statement, which:
- Consolidates the former branching logic
- Lets the compiler warn you of a (future) missing enum case
- This one may actually change behavior slightly, because what was an 
early test for one enum case, now happens later on in the `switch`.

4. Consolidating near-identical, "copy-pasta" logic into one place, which:
- Separates the common code to the diverging paths.
- Highlights the differences between the code paths.

rdar://119833526
---
 lldb/source/Core/ValueObject.cpp | 344 ---
 1 file changed, 178 insertions(+), 166 deletions(-)

diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index b13bffa0ca809b..7de4c31b913ed2 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }
+
+  std::string index_str = llvm::formatv("[{0}]", index);
+  ConstString index_const_str(index_str);
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }
+
+  // We haven't made a synthetic array member for INDEX yet, so lets make
+  // one and cache it for any future reference.
+  ValueObject *synthetic_child = CreateChildAtIndex(0, true, index);
+
+  if (!synthetic_child) {
+return ValueObjectSP();
   }
+
+  // Cache the value if we got one back...
+  AddSyntheticChild(index_const_str, synthetic_child);
+  auto synthetic_child_sp = synthetic_child->GetSP();
+  synthetic_child_sp->SetName(ConstString(index_str));
+  synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
   return synthetic_child_sp;
 }
 
 ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t 
to,
  bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsScalarType()) {
-std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  uint32_t bit_field_size = to - from + 1;
-  uint32_t bit_field_offset = from;
-  if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
-bit_field_offset =
-GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
-  // We haven't made a synthetic array member for INDEX 

[Lldb-commits] [lldb] [lldb] Remove unused GetChildAtIndexPath(...) methods from ValueObject.cpp (PR #75870)

2023-12-18 Thread Pete Lawrence via lldb-commits

https://github.com/PortalPete created 
https://github.com/llvm/llvm-project/pull/75870

This a follow-up PR from this other one:
https://github.com/llvm/llvm-project/pull/74413

Nothing calls into these two methods, so we (@DavidSpickett, @adrian-prantl, 
and I) agreed to remove them once we merged the previous PR.

>From c27a7a110bda6dbb96757f662c5d5b05e8a0ef75 Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Mon, 18 Dec 2023 13:00:27 -1000
Subject: [PATCH] [lldb] Remove unused GetChildAtIndexPath(...) methods from
 ValueObject.cpp

---
 lldb/include/lldb/Core/ValueObject.h |  8 --
 lldb/source/Core/ValueObject.cpp | 40 
 2 files changed, 48 deletions(-)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index a158199e7fab1a..3f8005ba696ce8 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -468,14 +468,6 @@ class ValueObject {
   virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx,
   bool can_create = true);
 
-  // The method always creates missing children in the path, if necessary.
-  lldb::ValueObjectSP GetChildAtIndexPath(llvm::ArrayRef idxs,
-  size_t *index_of_error = nullptr);
-
-  lldb::ValueObjectSP
-  GetChildAtIndexPath(llvm::ArrayRef> idxs,
-  size_t *index_of_error = nullptr);
-
   // The method always creates missing children in the path, if necessary.
   lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef 
names);
 
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index b13bffa0ca809b..8814c01d93ca01 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -392,46 +392,6 @@ ValueObjectSP ValueObject::GetChildAtIndex(size_t idx, 
bool can_create) {
   return child_sp;
 }
 
-lldb::ValueObjectSP
-ValueObject::GetChildAtIndexPath(llvm::ArrayRef idxs,
- size_t *index_of_error) {
-  if (idxs.size() == 0)
-return GetSP();
-  ValueObjectSP root(GetSP());
-
-  size_t current_index = 0;
-  for (size_t idx : idxs) {
-root = root->GetChildAtIndex(idx);
-if (!root) {
-  if (index_of_error)
-*index_of_error = current_index;
-  return root;
-}
-current_index += 1;
-  }
-  return root;
-}
-
-lldb::ValueObjectSP ValueObject::GetChildAtIndexPath(
-  llvm::ArrayRef> idxs, size_t *index_of_error) {
-  if (idxs.size() == 0)
-return GetSP();
-  ValueObjectSP root(GetSP());
-
-  size_t current_index = 0;
-  for (std::pair idx : idxs) {
-root = root->GetChildAtIndex(idx.first, idx.second);
-if (!root) {
-  if (index_of_error)
-*index_of_error = current_index;
-  return root;
-}
-
-current_index += 1;
-  }
-  return root;
-}
-
 lldb::ValueObjectSP
 ValueObject::GetChildAtNamePath(llvm::ArrayRef names) {
   if (names.size() == 0)

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


[Lldb-commits] [lldb] [lldb] Remove unused GetChildAtIndexPath(...) methods from ValueObject.cpp (PR #75870)

2023-12-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pete Lawrence (PortalPete)


Changes

This a follow-up PR from this other one:
https://github.com/llvm/llvm-project/pull/74413

Nothing calls into these two methods, so we (@DavidSpickett, @adrian-prantl, and I) agreed to remove them once we merged the previous PR.

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


2 Files Affected:

- (modified) lldb/include/lldb/Core/ValueObject.h (-8) 
- (modified) lldb/source/Core/ValueObject.cpp (-40) 


``diff
diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index a158199e7fab1a..3f8005ba696ce8 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -468,14 +468,6 @@ class ValueObject {
   virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx,
   bool can_create = true);
 
-  // The method always creates missing children in the path, if necessary.
-  lldb::ValueObjectSP GetChildAtIndexPath(llvm::ArrayRef idxs,
-  size_t *index_of_error = nullptr);
-
-  lldb::ValueObjectSP
-  GetChildAtIndexPath(llvm::ArrayRef> idxs,
-  size_t *index_of_error = nullptr);
-
   // The method always creates missing children in the path, if necessary.
   lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef 
names);
 
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index b13bffa0ca809b..8814c01d93ca01 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -392,46 +392,6 @@ ValueObjectSP ValueObject::GetChildAtIndex(size_t idx, 
bool can_create) {
   return child_sp;
 }
 
-lldb::ValueObjectSP
-ValueObject::GetChildAtIndexPath(llvm::ArrayRef idxs,
- size_t *index_of_error) {
-  if (idxs.size() == 0)
-return GetSP();
-  ValueObjectSP root(GetSP());
-
-  size_t current_index = 0;
-  for (size_t idx : idxs) {
-root = root->GetChildAtIndex(idx);
-if (!root) {
-  if (index_of_error)
-*index_of_error = current_index;
-  return root;
-}
-current_index += 1;
-  }
-  return root;
-}
-
-lldb::ValueObjectSP ValueObject::GetChildAtIndexPath(
-  llvm::ArrayRef> idxs, size_t *index_of_error) {
-  if (idxs.size() == 0)
-return GetSP();
-  ValueObjectSP root(GetSP());
-
-  size_t current_index = 0;
-  for (std::pair idx : idxs) {
-root = root->GetChildAtIndex(idx.first, idx.second);
-if (!root) {
-  if (index_of_error)
-*index_of_error = current_index;
-  return root;
-}
-
-current_index += 1;
-  }
-  return root;
-}
-
 lldb::ValueObjectSP
 ValueObject::GetChildAtNamePath(llvm::ArrayRef names) {
   if (names.size() == 0)

``




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


[Lldb-commits] [lldb] [lldb] DRAFT All ValueObjectSP instances are now valid (non-null) but have an error state (PR #74912)

2023-12-18 Thread Pete Lawrence via lldb-commits

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


[Lldb-commits] [clang] [lldb] [compiler-rt] [flang] [mlir] [libcxx] [lld] [llvm] [builtins] Refactor cpu_model support to reduce #if nesting. NFCI (PR #75635)

2023-12-18 Thread Pavel Iliin via lldb-commits

https://github.com/ilinpv commented:

Thanks a lot for refactoring! It indeed becomes necessary and looks 
well-structured now, small nit - rename lse_atomics/fucsia.inc and 
fmv/fucsia.inc files as well.

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


[Lldb-commits] [lldb] [lldb] Remove unused GetChildAtIndexPath(...) methods from ValueObject.cpp (PR #75870)

2023-12-18 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits


@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }
+
+  std::string index_str = llvm::formatv("[{0}]", index);
+  ConstString index_const_str(index_str);
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }
+
+  // We haven't made a synthetic array member for INDEX yet, so lets make
+  // one and cache it for any future reference.
+  ValueObject *synthetic_child = CreateChildAtIndex(0, true, index);
+
+  if (!synthetic_child) {
+return ValueObjectSP();
   }

clayborg wrote:

ditto

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits


@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }
+
+  std::string index_str = llvm::formatv("[{0}]", index);
+  ConstString index_const_str(index_str);
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }
+
+  // We haven't made a synthetic array member for INDEX yet, so lets make
+  // one and cache it for any future reference.
+  ValueObject *synthetic_child = CreateChildAtIndex(0, true, index);
+
+  if (!synthetic_child) {
+return ValueObjectSP();
   }
+
+  // Cache the value if we got one back...
+  AddSyntheticChild(index_const_str, synthetic_child);
+  auto synthetic_child_sp = synthetic_child->GetSP();
+  synthetic_child_sp->SetName(ConstString(index_str));
+  synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
   return synthetic_child_sp;
 }
 
 ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t 
to,
  bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsScalarType()) {
-std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  uint32_t bit_field_size = to - from + 1;
-  uint32_t bit_field_offset = from;
-  if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
-bit_field_offset =
-GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  ValueObjectChild *synthetic_child = new ValueObjectChild(
-  *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
-  0, bit_field_size, bit_field_offset, false, false,
-  eAddressTypeInvalid, 0);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_bitfield_for_scalar = true;
-  }
-}
+  if (!IsScalarType()) {
+ValueObjectSP();
   }
+  std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
+  ConstString index_const_str(index_str);
+
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }

clayborg wrote:

remove braces

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits


@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }

clayborg wrote:

remove braces per llvm coding guidelines for single line if statements

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits


@@ -1992,71 +1999,67 @@ void ValueObject::GetExpressionPath(Stream &s,
 }
 
 ValueObjectSP ValueObject::GetValueForExpressionPath(
-llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop,
-ExpressionPathEndResultType *final_value_type,
+llvm::StringRef expression, ExpressionPathScanEndReason 
*reason_to_stop_ptr,
+ExpressionPathEndResultType *final_value_type_ptr,
 const GetValueForExpressionPathOptions &options,
-ExpressionPathAftermath *final_task_on_target) {
-
-  ExpressionPathScanEndReason dummy_reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonUnknown;
-  ExpressionPathEndResultType dummy_final_value_type =
-  ValueObject::eExpressionPathEndResultTypeInvalid;
-  ExpressionPathAftermath dummy_final_task_on_target =
-  ValueObject::eExpressionPathAftermathNothing;
-
-  ValueObjectSP ret_val = GetValueForExpressionPath_Impl(
-  expression, reason_to_stop ? reason_to_stop : &dummy_reason_to_stop,
-  final_value_type ? final_value_type : &dummy_final_value_type, options,
-  final_task_on_target ? final_task_on_target
-   : &dummy_final_task_on_target);
-
-  if (!final_task_on_target ||
-  *final_task_on_target == ValueObject::eExpressionPathAftermathNothing)
-return ret_val;
-
-  if (ret_val.get() &&
-  ((final_value_type ? *final_value_type : dummy_final_value_type) ==
-   eExpressionPathEndResultTypePlain)) // I can only deref and takeaddress
-   // of plain objects
-  {
-if ((final_task_on_target ? *final_task_on_target
-  : dummy_final_task_on_target) ==
-ValueObject::eExpressionPathAftermathDereference) {
-  Status error;
-  ValueObjectSP final_value = ret_val->Dereference(error);
-  if (error.Fail() || !final_value.get()) {
-if (reason_to_stop)
-  *reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonDereferencingFailed;
-if (final_value_type)
-  *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
-return ValueObjectSP();
-  } else {
-if (final_task_on_target)
-  *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
-return final_value;
-  }
-}
-if (*final_task_on_target ==
-ValueObject::eExpressionPathAftermathTakeAddress) {
-  Status error;
-  ValueObjectSP final_value = ret_val->AddressOf(error);
-  if (error.Fail() || !final_value.get()) {
-if (reason_to_stop)
-  *reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonTakingAddressFailed;
-if (final_value_type)
-  *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
-return ValueObjectSP();
-  } else {
-if (final_task_on_target)
-  *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
-return final_value;
-  }
-}
+ExpressionPathAftermath *final_task_on_target_ptr) {
+
+  auto stop_reason_unknown = eExpressionPathScanEndReasonUnknown;
+  auto value_type_invalid = eExpressionPathEndResultTypeInvalid;
+  auto final_task_nothing = eExpressionPathAftermathNothing;
+
+  auto ret_value = GetValueForExpressionPath_Impl(
+  expression,
+  reason_to_stop_ptr ? reason_to_stop_ptr : &stop_reason_unknown,
+  final_value_type_ptr ? final_value_type_ptr : &value_type_invalid,
+  options,
+  final_task_on_target_ptr ? final_task_on_target_ptr
+   : &final_task_nothing);
+
+  // The caller knows nothing happened if `final_task_on_target` doesn't 
change.
+  if (!ret_value)
+return ValueObjectSP();
+
+  if (!final_value_type_ptr)
+return ret_value;
+
+  if ((*final_value_type_ptr) != eExpressionPathEndResultTypePlain)
+return ret_value;
+
+  if (!final_task_on_target_ptr)
+return ret_value;
+
+  ExpressionPathAftermath &final_task_on_target = (*final_task_on_target_ptr);
+  ExpressionPathScanEndReason stop_reason_for_error;
+  Status error;
+  // The method can only dereference and take the address of plain objects.
+  switch (final_task_on_target) {
+  case eExpressionPathAftermathNothing: {
+return ret_value;
+  }
+  case eExpressionPathAftermathDereference: {
+ret_value = ret_value->Dereference(error);
+stop_reason_for_error = eExpressionPathScanEndReasonDereferencingFailed;
+break;
+  }
+  case eExpressionPathAftermathTakeAddress: {
+ret_value = ret_value->AddressOf(error);
+stop_reason_for_error = eExpressionPathScanEndReasonTakingAddressFailed;
+break;
+  }

clayborg wrote:

remove braces for the cases as they are not defining any local variables

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

[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits

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

simple formatting changes and this is good to go

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits


@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }
+
+  std::string index_str = llvm::formatv("[{0}]", index);
+  ConstString index_const_str(index_str);
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }

clayborg wrote:

ditto

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits


@@ -2727,39 +2730,48 @@ ValueObjectSP ValueObject::AddressOf(Status &error) {
   const bool scalar_is_load_address = false;
   addr_t addr = GetAddressOf(scalar_is_load_address, &address_type);
   error.Clear();
-  if (addr != LLDB_INVALID_ADDRESS && address_type != eAddressTypeHost) {
-switch (address_type) {
-case eAddressTypeInvalid: {
-  StreamString expr_path_strm;
-  GetExpressionPath(expr_path_strm);
-  error.SetErrorStringWithFormat("'%s' is not in memory",
- expr_path_strm.GetData());
-} break;
 
-case eAddressTypeFile:
-case eAddressTypeLoad: {
-  CompilerType compiler_type = GetCompilerType();
-  if (compiler_type) {
-std::string name(1, '&');
-name.append(m_name.AsCString(""));
-ExecutionContext exe_ctx(GetExecutionContextRef());
-m_addr_of_valobj_sp = ValueObjectConstResult::Create(
-exe_ctx.GetBestExecutionContextScope(),
-compiler_type.GetPointerType(), ConstString(name.c_str()), addr,
-eAddressTypeInvalid, m_data.GetAddressByteSize());
-  }
-} break;
-default:
-  break;
-}
-  } else {
-StreamString expr_path_strm;
-GetExpressionPath(expr_path_strm);
+  StreamString expr_path_strm;
+  GetExpressionPath(expr_path_strm);
+  const char *expr_path_str = expr_path_strm.GetData();
+
+  ExecutionContext exe_ctx(GetExecutionContextRef());
+  auto scope = exe_ctx.GetBestExecutionContextScope();
+
+  if (addr == LLDB_INVALID_ADDRESS) {
 error.SetErrorStringWithFormat("'%s' doesn't have a valid address",
-   expr_path_strm.GetData());
+   expr_path_str);
+return ValueObjectSP();
   }
 
-  return m_addr_of_valobj_sp;
+  switch (address_type) {
+  case eAddressTypeInvalid: {
+error.SetErrorStringWithFormat("'%s' is not in memory", expr_path_str);
+return ValueObjectSP();
+  }
+  case eAddressTypeHost: {
+error.SetErrorStringWithFormat("'%s' is in host process (LLDB) memory",
+   expr_path_str);
+return ValueObjectSP();
+  }

clayborg wrote:

remove braces as there are no local vars being defined in the case.

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/75880

LLVM supports DWARF 5 linetable extension to store source files inline in 
DWARF. This is particularly useful for compiler-generated source code. This 
implementation tries to materialize them as temporary files lazily, so SBAPI 
clients don't need to be aware of them.

>From 638bd4e7e939ef28bf23ae2cfd1723797040b0a5 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Mon, 18 Dec 2023 15:59:00 -0800
Subject: [PATCH] Add support for inline DWARF source files.

LLVM supports DWARF 5 linetable extension to store source files inline
in DWARF. This is particularly useful for compiler-generated source
code. This implementation tries to materialize them as temporary files
lazily, so SBAPI clients don't need to be aware of them.
---
 lldb/include/lldb/Utility/FileSpecList.h  | 46 ---
 lldb/source/Core/ModuleList.cpp   |  8 ++--
 .../Clang/ClangUserExpression.cpp | 12 ++---
 .../Clang/CppModuleConfiguration.cpp  |  6 +--
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 46 +++
 lldb/source/Utility/FileSpecList.cpp  | 19 
 .../inline-sourcefile/Makefile| 11 +
 .../TestInlineSourceFiles.py  | 17 +++
 .../inline-sourcefile/inline.ll   | 39 
 .../functionalities/inline-sourcefile/main.c  |  8 
 10 files changed, 186 insertions(+), 26 deletions(-)
 create mode 100644 lldb/test/API/functionalities/inline-sourcefile/Makefile
 create mode 100644 
lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py
 create mode 100644 lldb/test/API/functionalities/inline-sourcefile/inline.ll
 create mode 100644 lldb/test/API/functionalities/inline-sourcefile/main.c

diff --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 77587aa917916b..078fd7208e7b5f 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -17,13 +17,40 @@
 namespace lldb_private {
 class Stream;
 
+/// Represents a source file whose contents is known (for example
+/// because it can be reconstructed from debug info), but that
+/// hasn't been written to a local disk yet.
+struct LazyFileSpec {
+  virtual ~LazyFileSpec() {}
+  virtual const FileSpec &Materialize() = 0;
+};
+
+/// Wraps either a FileSpec that represents a local file or a
+/// LazyFileSpec that could be materialized into a local file.
+class FileSpecHolder {
+  FileSpec m_file_spec;
+  std::shared_ptr m_lazy;
+public:
+  FileSpecHolder(const FileSpec &spec, std::shared_ptr lazy = {})
+  : m_file_spec(spec), m_lazy(lazy) {}
+  FileSpecHolder(const FileSpecHolder &other) = default;
+  FileSpecHolder(FileSpecHolder &&other) = default;
+  FileSpecHolder &operator=(const FileSpecHolder &other) = default;
+  const FileSpec &GetSpecOnly() const { return m_file_spec; };
+  const FileSpec &Materialize() const {
+if (m_lazy)
+  return m_lazy->Materialize();
+return m_file_spec;
+  }
+};
+
 /// \class FileSpecList FileSpecList.h "lldb/Utility/FileSpecList.h"
 /// A file collection class.
 ///
 /// A class that contains a mutable list of FileSpec objects.
 class FileSpecList {
 public:
-  typedef std::vector collection;
+  typedef std::vector collection;
   typedef collection::const_iterator const_iterator;
 
   /// Default constructor.
@@ -38,7 +65,10 @@ class FileSpecList {
   FileSpecList(FileSpecList &&rhs) = default;
 
   /// Initialize this object from a vector of FileSpecs
-  FileSpecList(std::vector &&rhs) : m_files(std::move(rhs)) {}
+  FileSpecList(std::vector &&rhs) {
+for (auto &fs : rhs)
+  m_files.emplace_back(fs);
+  }
 
   /// Destructor.
   ~FileSpecList();
@@ -83,7 +113,11 @@ class FileSpecList {
   /// \param[in] args
   /// Arguments to create the FileSpec
   template  void EmplaceBack(Args &&...args) {
-m_files.emplace_back(std::forward(args)...);
+m_files.emplace_back(FileSpec(std::forward(args)...));
+  }
+
+  void Append(FileSpecHolder &&fsh) {
+m_files.push_back(std::move(fsh));
   }
 
   /// Clears the file list.
@@ -175,10 +209,10 @@ class FileSpecList {
 
   bool Insert(size_t idx, const FileSpec &file) {
 if (idx < m_files.size()) {
-  m_files.insert(m_files.begin() + idx, file);
+  m_files.insert(m_files.begin() + idx, FileSpecHolder(file));
   return true;
 } else if (idx == m_files.size()) {
-  m_files.push_back(file);
+  m_files.push_back(FileSpecHolder(file));
   return true;
 }
 return false;
@@ -186,7 +220,7 @@ class FileSpecList {
 
   bool Replace(size_t idx, const FileSpec &file) {
 if (idx < m_files.size()) {
-  m_files[idx] = file;
+  m_files[idx] = FileSpecHolder(file);
   return true;
 }
 return false;
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index aa89c93c8d0521..3b6c3ea899caf7 1006

[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

LLVM supports DWARF 5 linetable extension to store source files inline in 
DWARF. This is particularly useful for compiler-generated source code. This 
implementation tries to materialize them as temporary files lazily, so SBAPI 
clients don't need to be aware of them.

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


10 Files Affected:

- (modified) lldb/include/lldb/Utility/FileSpecList.h (+40-6) 
- (modified) lldb/source/Core/ModuleList.cpp (+5-3) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
(+6-6) 
- (modified) 
lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp (+3-3) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+46) 
- (modified) lldb/source/Utility/FileSpecList.cpp (+11-8) 
- (added) lldb/test/API/functionalities/inline-sourcefile/Makefile (+11) 
- (added) 
lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py (+17) 
- (added) lldb/test/API/functionalities/inline-sourcefile/inline.ll (+39) 
- (added) lldb/test/API/functionalities/inline-sourcefile/main.c (+8) 


``diff
diff --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 77587aa917916b..078fd7208e7b5f 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -17,13 +17,40 @@
 namespace lldb_private {
 class Stream;
 
+/// Represents a source file whose contents is known (for example
+/// because it can be reconstructed from debug info), but that
+/// hasn't been written to a local disk yet.
+struct LazyFileSpec {
+  virtual ~LazyFileSpec() {}
+  virtual const FileSpec &Materialize() = 0;
+};
+
+/// Wraps either a FileSpec that represents a local file or a
+/// LazyFileSpec that could be materialized into a local file.
+class FileSpecHolder {
+  FileSpec m_file_spec;
+  std::shared_ptr m_lazy;
+public:
+  FileSpecHolder(const FileSpec &spec, std::shared_ptr lazy = {})
+  : m_file_spec(spec), m_lazy(lazy) {}
+  FileSpecHolder(const FileSpecHolder &other) = default;
+  FileSpecHolder(FileSpecHolder &&other) = default;
+  FileSpecHolder &operator=(const FileSpecHolder &other) = default;
+  const FileSpec &GetSpecOnly() const { return m_file_spec; };
+  const FileSpec &Materialize() const {
+if (m_lazy)
+  return m_lazy->Materialize();
+return m_file_spec;
+  }
+};
+
 /// \class FileSpecList FileSpecList.h "lldb/Utility/FileSpecList.h"
 /// A file collection class.
 ///
 /// A class that contains a mutable list of FileSpec objects.
 class FileSpecList {
 public:
-  typedef std::vector collection;
+  typedef std::vector collection;
   typedef collection::const_iterator const_iterator;
 
   /// Default constructor.
@@ -38,7 +65,10 @@ class FileSpecList {
   FileSpecList(FileSpecList &&rhs) = default;
 
   /// Initialize this object from a vector of FileSpecs
-  FileSpecList(std::vector &&rhs) : m_files(std::move(rhs)) {}
+  FileSpecList(std::vector &&rhs) {
+for (auto &fs : rhs)
+  m_files.emplace_back(fs);
+  }
 
   /// Destructor.
   ~FileSpecList();
@@ -83,7 +113,11 @@ class FileSpecList {
   /// \param[in] args
   /// Arguments to create the FileSpec
   template  void EmplaceBack(Args &&...args) {
-m_files.emplace_back(std::forward(args)...);
+m_files.emplace_back(FileSpec(std::forward(args)...));
+  }
+
+  void Append(FileSpecHolder &&fsh) {
+m_files.push_back(std::move(fsh));
   }
 
   /// Clears the file list.
@@ -175,10 +209,10 @@ class FileSpecList {
 
   bool Insert(size_t idx, const FileSpec &file) {
 if (idx < m_files.size()) {
-  m_files.insert(m_files.begin() + idx, file);
+  m_files.insert(m_files.begin() + idx, FileSpecHolder(file));
   return true;
 } else if (idx == m_files.size()) {
-  m_files.push_back(file);
+  m_files.push_back(FileSpecHolder(file));
   return true;
 }
 return false;
@@ -186,7 +220,7 @@ class FileSpecList {
 
   bool Replace(size_t idx, const FileSpec &file) {
 if (idx < m_files.size()) {
-  m_files[idx] = file;
+  m_files[idx] = FileSpecHolder(file);
   return true;
 }
 return false;
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index aa89c93c8d0521..3b6c3ea899caf7 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -164,11 +164,13 @@ void ModuleListProperties::UpdateSymlinkMappings() {
   llvm::sys::ScopedWriter lock(m_symlink_paths_mutex);
   const bool notify = false;
   m_symlink_paths.Clear(notify);
-  for (FileSpec symlink : list) {
+  for (auto symlink : list) {
 FileSpec resolved;
-Status status = FileSystem::Instance().Readlink(symlink, resolved);
+Status status =
+FileSystem::Instance().Readlink(symlink.Materialize(), resolved);
 if (status.Success())
-  m_symlink_paths.Append(symlink.GetPath()

[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove unused GetChildAtIndexPath(...) methods from ValueObject.cpp (PR #75870)

2023-12-18 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 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 
5f423b7d1cb3474168d79827d2305b137be7160b...638bd4e7e939ef28bf23ae2cfd1723797040b0a5
 lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py
``





View the diff from darker here.


``diff
--- TestInlineSourceFiles.py2023-12-19 01:01:49.00 +
+++ TestInlineSourceFiles.py2023-12-19 01:05:18.585600 +
@@ -9,9 +9,8 @@
 @skipIf(compiler="gcc")
 @skipIf(compiler="clang", compiler_version=["<", "18.0"])
 def test(self):
 """Test DWARF inline source files."""
 self.build()
-#target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
+# target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
 #self, 'break here', lldb.SBFileSpec('inlined.c'))
-target, process, thread, bkpt = lldbutil.run_to_name_breakpoint(
-self, 'f')
+target, process, thread, bkpt = lldbutil.run_to_name_breakpoint(self, 
"f")

``




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


[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 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 5f423b7d1cb3474168d79827d2305b137be7160b 
638bd4e7e939ef28bf23ae2cfd1723797040b0a5 -- 
lldb/test/API/functionalities/inline-sourcefile/main.c 
lldb/include/lldb/Utility/FileSpecList.h lldb/source/Core/ModuleList.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
lldb/source/Utility/FileSpecList.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Utility/FileSpecList.h 
b/lldb/include/lldb/Utility/FileSpecList.h
index 078fd7208e..8eda721b60 100644
--- a/lldb/include/lldb/Utility/FileSpecList.h
+++ b/lldb/include/lldb/Utility/FileSpecList.h
@@ -30,6 +30,7 @@ struct LazyFileSpec {
 class FileSpecHolder {
   FileSpec m_file_spec;
   std::shared_ptr m_lazy;
+
 public:
   FileSpecHolder(const FileSpec &spec, std::shared_ptr lazy = {})
   : m_file_spec(spec), m_lazy(lazy) {}
@@ -116,9 +117,7 @@ public:
 m_files.emplace_back(FileSpec(std::forward(args)...));
   }
 
-  void Append(FileSpecHolder &&fsh) {
-m_files.push_back(std::move(fsh));
-  }
+  void Append(FileSpecHolder &&fsh) { m_files.push_back(std::move(fsh)); }
 
   /// Clears the file list.
   void Clear();
diff --git a/lldb/source/Utility/FileSpecList.cpp 
b/lldb/source/Utility/FileSpecList.cpp
index 749fdcc643..33586c7752 100644
--- a/lldb/source/Utility/FileSpecList.cpp
+++ b/lldb/source/Utility/FileSpecList.cpp
@@ -68,9 +68,9 @@ size_t FileSpecList::FindFileIndex(size_t start_idx, const 
FileSpec &file_spec,
   for (size_t idx = start_idx; idx < num_files; ++idx) {
 auto f = m_files[idx].GetSpecOnly();
 if (compare_filename_only) {
-  if (ConstString::Equals(
-  f.GetFilename(), file_spec.GetFilename(),
-  file_spec.IsCaseSensitive() || f.IsCaseSensitive()))
+  if (ConstString::Equals(f.GetFilename(), file_spec.GetFilename(),
+  file_spec.IsCaseSensitive() ||
+  f.IsCaseSensitive()))
 return idx;
 } else {
   if (FileSpec::Equal(f, file_spec, full))
diff --git a/lldb/test/API/functionalities/inline-sourcefile/main.c 
b/lldb/test/API/functionalities/inline-sourcefile/main.c
index 29a22d956a..c030d7773f 100644
--- a/lldb/test/API/functionalities/inline-sourcefile/main.c
+++ b/lldb/test/API/functionalities/inline-sourcefile/main.c
@@ -1,8 +1,7 @@
 void f();
 void stop() {}
 
-int main(int argc, char const *argv[])
-{
-f();
-return 0;
+int main(int argc, char const *argv[]) {
+  f();
+  return 0;
 }

``




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


[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

The primary use-case I have in mind for this are Swift macro expansions, which 
may produce hundreds of tiny inline files per source file, hence the lazy 
approach.

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


[Lldb-commits] [llvm] [lldb] [mlir] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)

2023-12-18 Thread Konstantin Varlamov via lldb-commits


@@ -0,0 +1,303 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// 
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200
+
+// template S, class T, class Proj = 
identity>
+// requires indirect_binary_predicate, const T*>
+// constexpr bool ranges::contains(I first, S last, const T& value, Proj 
proj = {});   // since C++23
+
+// template
+// requires indirect_binary_predicate, Proj>, const T*>
+// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); 
// since C++23
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "almost_satisfies_types.h"
+#include "boolean_testable.h"
+#include "test_iterators.h"
+
+struct NotEqualityComparable {};
+
+template 
+concept HasContainsSubrangeIt = requires(Iter1 first1, Sent1 last1, Iter2 
first2, Sent2 last2) {
+  std::ranges::contains_subrange(first1, last1, first2, last2);
+};
+
+static_assert(HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt); // not indirectly 
comparable
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+static_assert(!HasContainsSubrangeIt);
+
+template >
+concept HasContainsSubrangeR = requires(Range1&& range1, Range2&& range2) {
+  std::ranges::contains_subrange(std::forward(range1), 
std::forward(range2)); };
+
+static_assert(HasContainsSubrangeR>);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR);
+static_assert(!HasContainsSubrangeR, 
UncheckedRange>); // not indirectly comparable
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotDerivedFrom>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotIncrementable>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelSemiregular>);
+static_assert(!HasContainsSubrangeR, 
ForwardRangeNotSentinelEqualityComparableWith>);
+
+template 
+constexpr void test_iterators() {
+  {  // simple tests
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 5};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret =
+  std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  [[maybe_unused]] std::same_as decltype(auto) ret = 
std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // no match
+int a[]   = {1, 2, 3, 4, 5, 6};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // range consists of just one element
+int a[]   = {3};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 1)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(!ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(!ret);
+}
+  }
+
+  { // subrange consists of just one element
+int a[]   = {23, 1, 20, 3, 54, 2};
+int p[]   = {3};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 1)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.end(), 
subrange.begin(), subrange.end());
+  assert(ret);
+}
+{
+  bool ret = std::ranges::contains_subrange(whole, subrange);
+  assert(ret);
+}
+  }
+
+  { // range has zero length
+int a[]   = {};
+int p[]   = {3, 4, 2};
+auto whole= std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+auto subrange = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
+{
+  bool ret = std::ranges::contains_subrange(whole.begin(), whole.e

[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 Thread Alex Langford via lldb-commits


@@ -38,7 +65,10 @@ class FileSpecList {
   FileSpecList(FileSpecList &&rhs) = default;
 
   /// Initialize this object from a vector of FileSpecs
-  FileSpecList(std::vector &&rhs) : m_files(std::move(rhs)) {}
+  FileSpecList(std::vector &&rhs) {
+for (auto &fs : rhs)
+  m_files.emplace_back(fs);

bulbazord wrote:

This sidesteps the move semantics and means we're copying again. Why?

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


[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 Thread Alex Langford via lldb-commits


@@ -17,13 +17,40 @@
 namespace lldb_private {
 class Stream;
 
+/// Represents a source file whose contents is known (for example
+/// because it can be reconstructed from debug info), but that
+/// hasn't been written to a local disk yet.
+struct LazyFileSpec {
+  virtual ~LazyFileSpec() {}
+  virtual const FileSpec &Materialize() = 0;
+};
+
+/// Wraps either a FileSpec that represents a local file or a
+/// LazyFileSpec that could be materialized into a local file.
+class FileSpecHolder {
+  FileSpec m_file_spec;
+  std::shared_ptr m_lazy;

bulbazord wrote:

Why does this hold both if it could be either one? Why not use a 
discriminated/tagged/type-safe union like `std::variant` here?

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Alex Langford via lldb-commits


@@ -1992,71 +1999,67 @@ void ValueObject::GetExpressionPath(Stream &s,
 }
 
 ValueObjectSP ValueObject::GetValueForExpressionPath(
-llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop,
-ExpressionPathEndResultType *final_value_type,
+llvm::StringRef expression, ExpressionPathScanEndReason 
*reason_to_stop_ptr,
+ExpressionPathEndResultType *final_value_type_ptr,
 const GetValueForExpressionPathOptions &options,
-ExpressionPathAftermath *final_task_on_target) {
-
-  ExpressionPathScanEndReason dummy_reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonUnknown;
-  ExpressionPathEndResultType dummy_final_value_type =
-  ValueObject::eExpressionPathEndResultTypeInvalid;
-  ExpressionPathAftermath dummy_final_task_on_target =
-  ValueObject::eExpressionPathAftermathNothing;
-
-  ValueObjectSP ret_val = GetValueForExpressionPath_Impl(
-  expression, reason_to_stop ? reason_to_stop : &dummy_reason_to_stop,
-  final_value_type ? final_value_type : &dummy_final_value_type, options,
-  final_task_on_target ? final_task_on_target
-   : &dummy_final_task_on_target);
-
-  if (!final_task_on_target ||
-  *final_task_on_target == ValueObject::eExpressionPathAftermathNothing)
-return ret_val;
-
-  if (ret_val.get() &&
-  ((final_value_type ? *final_value_type : dummy_final_value_type) ==
-   eExpressionPathEndResultTypePlain)) // I can only deref and takeaddress
-   // of plain objects
-  {
-if ((final_task_on_target ? *final_task_on_target
-  : dummy_final_task_on_target) ==
-ValueObject::eExpressionPathAftermathDereference) {
-  Status error;
-  ValueObjectSP final_value = ret_val->Dereference(error);
-  if (error.Fail() || !final_value.get()) {
-if (reason_to_stop)
-  *reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonDereferencingFailed;
-if (final_value_type)
-  *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
-return ValueObjectSP();
-  } else {
-if (final_task_on_target)
-  *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
-return final_value;
-  }
-}
-if (*final_task_on_target ==
-ValueObject::eExpressionPathAftermathTakeAddress) {
-  Status error;
-  ValueObjectSP final_value = ret_val->AddressOf(error);
-  if (error.Fail() || !final_value.get()) {
-if (reason_to_stop)
-  *reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonTakingAddressFailed;
-if (final_value_type)
-  *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
-return ValueObjectSP();
-  } else {
-if (final_task_on_target)
-  *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
-return final_value;
-  }
-}
+ExpressionPathAftermath *final_task_on_target_ptr) {
+
+  auto stop_reason_unknown = eExpressionPathScanEndReasonUnknown;
+  auto value_type_invalid = eExpressionPathEndResultTypeInvalid;
+  auto final_task_nothing = eExpressionPathAftermathNothing;
+
+  auto ret_value = GetValueForExpressionPath_Impl(
+  expression,
+  reason_to_stop_ptr ? reason_to_stop_ptr : &stop_reason_unknown,
+  final_value_type_ptr ? final_value_type_ptr : &value_type_invalid,
+  options,
+  final_task_on_target_ptr ? final_task_on_target_ptr
+   : &final_task_nothing);
+
+  // The caller knows nothing happened if `final_task_on_target` doesn't 
change.
+  if (!ret_value)
+return ValueObjectSP();
+
+  if (!final_value_type_ptr)
+return ret_value;
+
+  if ((*final_value_type_ptr) != eExpressionPathEndResultTypePlain)
+return ret_value;
+
+  if (!final_task_on_target_ptr)
+return ret_value;

bulbazord wrote:

You have 3 early return conditions that return the same thing. You could group 
them into one for conciseness.

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Alex Langford via lldb-commits


@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }
+
+  std::string index_str = llvm::formatv("[{0}]", index);
+  ConstString index_const_str(index_str);
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }
+
+  // We haven't made a synthetic array member for INDEX yet, so lets make
+  // one and cache it for any future reference.
+  ValueObject *synthetic_child = CreateChildAtIndex(0, true, index);
+
+  if (!synthetic_child) {
+return ValueObjectSP();
   }
+
+  // Cache the value if we got one back...
+  AddSyntheticChild(index_const_str, synthetic_child);
+  auto synthetic_child_sp = synthetic_child->GetSP();
+  synthetic_child_sp->SetName(ConstString(index_str));
+  synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
   return synthetic_child_sp;
 }
 
 ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t 
to,
  bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsScalarType()) {
-std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  uint32_t bit_field_size = to - from + 1;
-  uint32_t bit_field_offset = from;
-  if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
-bit_field_offset =
-GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  ValueObjectChild *synthetic_child = new ValueObjectChild(
-  *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
-  0, bit_field_size, bit_field_offset, false, false,
-  eAddressTypeInvalid, 0);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_bitfield_for_scalar = true;
-  }
-}
+  if (!IsScalarType()) {
+ValueObjectSP();

bulbazord wrote:

Needs an explicit `return`.

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Alex Langford via lldb-commits


@@ -1777,30 +1783,31 @@ static const char 
*SkipLeadingExpressionPathSeparators(const char *expression) {
 ValueObjectSP
 ValueObject::GetSyntheticExpressionPathChild(const char *expression,
  bool can_create) {
-  ValueObjectSP synthetic_child_sp;
   ConstString name_const_string(expression);
   // Check if we have already created a synthetic array member in this valid
   // object. If we have we will re-use it.
-  synthetic_child_sp = GetSyntheticChild(name_const_string);
-  if (!synthetic_child_sp) {
-// We haven't made a synthetic array member for expression yet, so lets
-// make one and cache it for any future reference.
-synthetic_child_sp = GetValueForExpressionPath(
-expression, nullptr, nullptr,
-GetValueForExpressionPathOptions().SetSyntheticChildrenTraversal(
-GetValueForExpressionPathOptions::SyntheticChildrenTraversal::
-None));
-
-// Cache the value if we got one back...
-if (synthetic_child_sp.get()) {
-  // FIXME: this causes a "real" child to end up with its name changed to
-  // the contents of expression
-  AddSyntheticChild(name_const_string, synthetic_child_sp.get());
-  synthetic_child_sp->SetName(
-  ConstString(SkipLeadingExpressionPathSeparators(expression)));
-}
-  }
-  return synthetic_child_sp;
+  if (auto existing_synthetic_child = GetSyntheticChild(name_const_string))
+return existing_synthetic_child;
+
+  // We haven't made a synthetic array member for expression yet, so lets
+  // make one and cache it for any future reference.
+  auto path_options = GetValueForExpressionPathOptions();
+  auto traversal_none =

bulbazord wrote:

`traversal_none` is used once, you can probably inline it in the call below.

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


[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Alex Langford via lldb-commits


@@ -1623,62 +1623,68 @@ bool ValueObject::IsUninitializedReference() {
 
 ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsPointerType() || IsArrayType()) {
-std::string index_str = llvm::formatv("[{0}]", index);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  ValueObject *synthetic_child;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  synthetic_child = CreateChildAtIndex(0, true, index);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
-  }
-}
+  if (!IsPointerType() && !IsArrayType()) {
+return ValueObjectSP();
+  }
+
+  std::string index_str = llvm::formatv("[{0}]", index);
+  ConstString index_const_str(index_str);
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }
+
+  // We haven't made a synthetic array member for INDEX yet, so lets make
+  // one and cache it for any future reference.
+  ValueObject *synthetic_child = CreateChildAtIndex(0, true, index);
+
+  if (!synthetic_child) {
+return ValueObjectSP();
   }
+
+  // Cache the value if we got one back...
+  AddSyntheticChild(index_const_str, synthetic_child);
+  auto synthetic_child_sp = synthetic_child->GetSP();
+  synthetic_child_sp->SetName(ConstString(index_str));
+  synthetic_child_sp->m_flags.m_is_array_item_for_pointer = true;
   return synthetic_child_sp;
 }
 
 ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t 
to,
  bool can_create) {
-  ValueObjectSP synthetic_child_sp;
-  if (IsScalarType()) {
-std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
-ConstString index_const_str(index_str);
-// Check if we have already created a synthetic array member in this valid
-// object. If we have we will re-use it.
-synthetic_child_sp = GetSyntheticChild(index_const_str);
-if (!synthetic_child_sp) {
-  uint32_t bit_field_size = to - from + 1;
-  uint32_t bit_field_offset = from;
-  if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
-bit_field_offset =
-GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
-  // We haven't made a synthetic array member for INDEX yet, so lets make
-  // one and cache it for any future reference.
-  ValueObjectChild *synthetic_child = new ValueObjectChild(
-  *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
-  0, bit_field_size, bit_field_offset, false, false,
-  eAddressTypeInvalid, 0);
-
-  // Cache the value if we got one back...
-  if (synthetic_child) {
-AddSyntheticChild(index_const_str, synthetic_child);
-synthetic_child_sp = synthetic_child->GetSP();
-synthetic_child_sp->SetName(ConstString(index_str));
-synthetic_child_sp->m_flags.m_is_bitfield_for_scalar = true;
-  }
-}
+  if (!IsScalarType()) {
+ValueObjectSP();
   }
+  std::string index_str = llvm::formatv("[{0}-{1}]", from, to);
+  ConstString index_const_str(index_str);
+
+  // Check if we have already created a synthetic array member in this valid
+  // object. If we have we will re-use it.
+  if (auto existing_synthetic_child = GetSyntheticChild(index_const_str)) {
+return existing_synthetic_child;
+  }
+
+  uint32_t bit_field_size = to - from + 1;
+  uint32_t bit_field_offset = from;
+  if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
+bit_field_offset =
+GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
+
+  // We haven't made a synthetic array member for INDEX yet, so lets make
+  // one and cache it for any future reference.
+  ValueObjectChild *synthetic_child = new ValueObjectChild(
+  *this, GetCompilerType(), index_const_str, GetByteSize().value_or(0), 0,
+  bit_field_size, bit_field_offset, false, false, eAddressTypeInvalid, 0);
+
+  // Cache the value if we got one back...

bulbazord wrote:

This comment needs to be moved down a few lines.

https://github.com/llvm/llvm-project/pull/75865
___
lldb-commits mailing list
lldb-commi

[Lldb-commits] [lldb] [lldb] Improve maintainability and readability for ValueObject methods (PR #75865)

2023-12-18 Thread Alex Langford via lldb-commits


@@ -1992,71 +1999,67 @@ void ValueObject::GetExpressionPath(Stream &s,
 }
 
 ValueObjectSP ValueObject::GetValueForExpressionPath(
-llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop,
-ExpressionPathEndResultType *final_value_type,
+llvm::StringRef expression, ExpressionPathScanEndReason 
*reason_to_stop_ptr,
+ExpressionPathEndResultType *final_value_type_ptr,
 const GetValueForExpressionPathOptions &options,
-ExpressionPathAftermath *final_task_on_target) {
-
-  ExpressionPathScanEndReason dummy_reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonUnknown;
-  ExpressionPathEndResultType dummy_final_value_type =
-  ValueObject::eExpressionPathEndResultTypeInvalid;
-  ExpressionPathAftermath dummy_final_task_on_target =
-  ValueObject::eExpressionPathAftermathNothing;
-
-  ValueObjectSP ret_val = GetValueForExpressionPath_Impl(
-  expression, reason_to_stop ? reason_to_stop : &dummy_reason_to_stop,
-  final_value_type ? final_value_type : &dummy_final_value_type, options,
-  final_task_on_target ? final_task_on_target
-   : &dummy_final_task_on_target);
-
-  if (!final_task_on_target ||
-  *final_task_on_target == ValueObject::eExpressionPathAftermathNothing)
-return ret_val;
-
-  if (ret_val.get() &&
-  ((final_value_type ? *final_value_type : dummy_final_value_type) ==
-   eExpressionPathEndResultTypePlain)) // I can only deref and takeaddress
-   // of plain objects
-  {
-if ((final_task_on_target ? *final_task_on_target
-  : dummy_final_task_on_target) ==
-ValueObject::eExpressionPathAftermathDereference) {
-  Status error;
-  ValueObjectSP final_value = ret_val->Dereference(error);
-  if (error.Fail() || !final_value.get()) {
-if (reason_to_stop)
-  *reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonDereferencingFailed;
-if (final_value_type)
-  *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
-return ValueObjectSP();
-  } else {
-if (final_task_on_target)
-  *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
-return final_value;
-  }
-}
-if (*final_task_on_target ==
-ValueObject::eExpressionPathAftermathTakeAddress) {
-  Status error;
-  ValueObjectSP final_value = ret_val->AddressOf(error);
-  if (error.Fail() || !final_value.get()) {
-if (reason_to_stop)
-  *reason_to_stop =
-  ValueObject::eExpressionPathScanEndReasonTakingAddressFailed;
-if (final_value_type)
-  *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid;
-return ValueObjectSP();
-  } else {
-if (final_task_on_target)
-  *final_task_on_target = ValueObject::eExpressionPathAftermathNothing;
-return final_value;
-  }
-}
+ExpressionPathAftermath *final_task_on_target_ptr) {
+
+  auto stop_reason_unknown = eExpressionPathScanEndReasonUnknown;
+  auto value_type_invalid = eExpressionPathEndResultTypeInvalid;
+  auto final_task_nothing = eExpressionPathAftermathNothing;
+
+  auto ret_value = GetValueForExpressionPath_Impl(
+  expression,
+  reason_to_stop_ptr ? reason_to_stop_ptr : &stop_reason_unknown,
+  final_value_type_ptr ? final_value_type_ptr : &value_type_invalid,
+  options,
+  final_task_on_target_ptr ? final_task_on_target_ptr
+   : &final_task_nothing);
+
+  // The caller knows nothing happened if `final_task_on_target` doesn't 
change.
+  if (!ret_value)
+return ValueObjectSP();
+
+  if (!final_value_type_ptr)
+return ret_value;
+
+  if ((*final_value_type_ptr) != eExpressionPathEndResultTypePlain)
+return ret_value;
+
+  if (!final_task_on_target_ptr)
+return ret_value;
+
+  ExpressionPathAftermath &final_task_on_target = (*final_task_on_target_ptr);
+  ExpressionPathScanEndReason stop_reason_for_error;
+  Status error;
+  // The method can only dereference and take the address of plain objects.
+  switch (final_task_on_target) {
+  case eExpressionPathAftermathNothing: {
+return ret_value;
+  }
+  case eExpressionPathAftermathDereference: {
+ret_value = ret_value->Dereference(error);
+stop_reason_for_error = eExpressionPathScanEndReasonDereferencingFailed;
+break;
+  }
+  case eExpressionPathAftermathTakeAddress: {
+ret_value = ret_value->AddressOf(error);
+stop_reason_for_error = eExpressionPathScanEndReasonTakingAddressFailed;
+break;
+  }
+  }
+
+  if (ret_value && error.Success()) {
+final_task_on_target = eExpressionPathAftermathNothing;
+return ret_value;

bulbazord wrote:

You can remove the following `else` and unindent the code in the `else` block.

https://github.com/llvm/llvm-project/pull/75865
_

[Lldb-commits] [lldb] [DRAFT] Add support for inline DWARF source files. (PR #75880)

2023-12-18 Thread Greg Clayton via lldb-commits


@@ -235,6 +236,51 @@ ParseSupportFilesFromPrologue(const lldb::ModuleSP &module,
   for (size_t idx = first_file_idx; idx <= last_file_idx; ++idx) {
 std::string remapped_file;
 if (auto file_path = GetFileByIndex(prologue, idx, compile_dir, style)) {
+  auto entry = prologue.getFileNameEntry(idx);
+  auto source = entry.Source.getAsCString();
+  if (!source)
+consumeError(source.takeError());

clayborg wrote:

So if there is no embedded source contents for this file, there will be no 
source here? What happens for older DWARF here?

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


[Lldb-commits] [clang] [libc] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [mlir] [lldb] [lld] [llvm] GFX12: Add LoopDataPrefetchPass (PR #75625)

2023-12-18 Thread Matt Arsenault via lldb-commits

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


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


[Lldb-commits] [clang] [flang] [lld] [llvm] [lldb] [libc] [mlir] [libcxx] [compiler-rt] [clang-tools-extra] Don't emit relax relocs like R_X86_64_REX_GOTPCRELX on X86 target for OPENMP internal vars.

2023-12-18 Thread via lldb-commits

https://github.com/UmeshKalappa0 updated 
https://github.com/llvm/llvm-project/pull/75564

>From 4125e4a709c594562fa6c52f045ba7442e3cb523 Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Fri, 15 Dec 2023 11:52:52 +0530
Subject: [PATCH 1/3] Problem :For Kernel Modules ,emitting the relocs like
 R_X86_64_REX_GOTPCRELX  for the OPENMP internal vars like
 https://godbolt.org/z/hhh7ozojz.

Solution : Mark the OpenMP internal variables with dso_local
conditionally for no-pic and no-pie ,then
a)reset the dso_local for thread_local and weak linkage vars.
---
 .../test/OpenMP/gomp_critical_dso_local_var.c | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100644 clang/test/OpenMP/gomp_critical_dso_local_var.c

diff --git a/clang/test/OpenMP/gomp_critical_dso_local_var.c 
b/clang/test/OpenMP/gomp_critical_dso_local_var.c
new file mode 100644
index 00..915f6773bf67bf
--- /dev/null
+++ b/clang/test/OpenMP/gomp_critical_dso_local_var.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s 
--check-prefix=DSO_LOCAL
+
+// DSO_LOCAL-DAG: @.gomp_critical_user_.var = common dso_local global [8 x 
i32] zeroinitializer, align 8
+int omp_critical_test()
+{
+  int sum;
+  int known_sum;
+
+  sum=0;
+#pragma omp parallel
+  {
+int mysum=0;
+int i;
+#pragma omp for
+for (i = 0; i < 1000; i++)
+  mysum = mysum + i;
+#pragma omp critical
+sum = mysum +sum;
+  }
+  known_sum = 999 * 1000 / 2;
+  return (known_sum == sum);
+}
+

>From 842245de490ab15f8a901b94576ae4539c760e1e Mon Sep 17 00:00:00 2001
From: Umesh Kalappa 
Date: Fri, 15 Dec 2023 12:49:48 +0530
Subject: [PATCH 2/3] testcases are changed accordignly.

---
 clang/lib/CodeGen/CGOpenMPRuntime.cpp   | 2 ++
 clang/test/OpenMP/critical_codegen.cpp  | 6 +++---
 clang/test/OpenMP/critical_codegen_attr.cpp | 6 +++---
 clang/test/OpenMP/for_reduction_codegen.cpp | 8 
 clang/test/OpenMP/gomp_critical_dso_local_var.c | 1 -
 clang/test/OpenMP/simd_codegen.cpp  | 4 ++--
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp   | 8 
 7 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 7f7e6f53066644..183c757d72b8a7 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1793,6 +1793,8 @@ Address 
CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
   if (CGM.getLangOpts().OpenMP && CGM.getLangOpts().OpenMPUseTLS &&
   CGM.getTarget().isTLSSupported()) {
 GAddr->setThreadLocal(/*Val=*/true);
+/// reset the dso_local for thread_local.
+GAddr->setDSOLocal(/*Val=*/false);
 return Address(GAddr, GAddr->getValueType(),
CGM.getContext().getTypeAlignInChars(VarType));
   }
diff --git a/clang/test/OpenMP/critical_codegen.cpp 
b/clang/test/OpenMP/critical_codegen.cpp
index 24145d44d962e5..9a613161ac294a 100644
--- a/clang/test/OpenMP/critical_codegen.cpp
+++ b/clang/test/OpenMP/critical_codegen.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
diff --git a/clang/test/OpenMP/critical_codegen_attr.cpp 
b/clang/test/OpenMP/critical_codegen_attr.cpp
index 34d90a9e3a6e48..5f1a76e2ad0f1f 100644
--- a/clang/test/OpenMP/critical_codegen_attr.cpp
+++ b/clang/test/OpenMP/critical_codegen_attr.cpp
@@ -16,9 +16,9 @@
 #define HEADER
 
 // ALL:   [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, ptr }
-// ALL:   [[UNNAMED_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK:@.+]] = common global [8 x i32] zeroinitializer
-// ALL:   [[THE_NAME_LOCK1:@.+]] = common global [8 x i32] zeroinitializer
+// ALL:   [[UNNAMED_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
+// ALL:   [[THE_NAME_LOCK1:@.+]] = common dso_local global [8 x i32] 
zeroinitializer
 
 // ALL:   define {{.*}}void [[FOO:@.+]]()
 
diff --git a/clang/test/OpenMP/for_reduction_codegen.cpp 
b/clang/test/OpenMP/for_reduction_codegen.cpp
index 893c606f8d7b9f..b128bd5d79c251 100644
--- a/clang/test/OpenMP/for_reduction_codegen.cpp
+++ b/clang/test/OpenMP/for_reduction_codegen.cpp
@@ -528,12 +528,12 @@ int main() {
 
 #endif
 //.
-// CHECK1: @.gomp_critical_user_.red

[Lldb-commits] [lldb] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [llvm] [mlir] [clang] [lld] [flang] Don't emit relax relocs like R_X86_64_REX_GOTPCRELX on X86 target for OPENMP internal vars.

2023-12-18 Thread via lldb-commits

UmeshKalappa0 wrote:

> Scattering around `setDSOLocal(false)` makes the logic hard to understand. 
> I'd strongly prefer to fix the initial setting of dso_local when we create 
> the global variable. We can refactor the code to make that work.

@efriedma-quic  ,thank you for the suggestions and was not sure about adding 
dso_local for openmp weak linkage vars ,but from the weak semantics point ,its 
ok to add the dso_local for no-pic /no-pie code  ,so updated changes 
accordingly .

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


[Lldb-commits] [lldb] [clang] [compiler-rt] [libcxx] [flang] [lld] [clang-tools-extra] [mlir] [llvm] [libc] GFX12: Add LoopDataPrefetchPass (PR #75625)

2023-12-18 Thread Mariusz Sikora via lldb-commits

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