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

2024-01-17 Thread Stanislav Mekhanoshin via lldb-commits

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


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

2024-01-17 Thread Stanislav Mekhanoshin via lldb-commits

https://github.com/rampitec closed 
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] [libc] [clang] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [llvm] [lldb] [flang] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2024-01-17 Thread Stanislav Mekhanoshin via lldb-commits

rampitec wrote:

> > > lgtm, but can still fix the -O0 thing
> > 
> > 
> > But where do I get TM in the getAnalysisUsage?
> 
> MF.getTarget() (or maybe a pass parameter is necessary?)

There is no MF there of course.

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] [compiler-rt] [llvm] [flang] [lldb] [clang] [libcxx] [clang-tools-extra] [libc] [lld] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

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

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


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] [clang] [libcxx] [clang-tools-extra] [llvm] [flang] [lld] [compiler-rt] [libc] [lldb] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

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

arsenm wrote:

> > lgtm, but can still fix the -O0 thing
> 
> But where do I get TM in the getAnalysisUsage?

MF.getTarget()

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] [llvm] [clang-tools-extra] [lldb] [libcxx] [openmp] [clang] [compiler-rt] [libc] [flang] [lld] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)

2024-01-17 Thread Ethan Luis McDonough via lldb-commits

https://github.com/EthanLuisMcDonough updated 
https://github.com/llvm/llvm-project/pull/76587

>From 530eb982b9770190377bb0bd09c5cb715f34d484 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough 
Date: Fri, 15 Dec 2023 20:38:38 -0600
Subject: [PATCH 01/11] Add profiling functions to libomptarget

---
 .../include/llvm/Frontend/OpenMP/OMPKinds.def |  3 +++
 openmp/libomptarget/DeviceRTL/CMakeLists.txt  |  2 ++
 .../DeviceRTL/include/Profiling.h | 21 +++
 .../libomptarget/DeviceRTL/src/Profiling.cpp  | 19 +
 4 files changed, 45 insertions(+)
 create mode 100644 openmp/libomptarget/DeviceRTL/include/Profiling.h
 create mode 100644 openmp/libomptarget/DeviceRTL/src/Profiling.cpp

diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def 
b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index d22d2a8e948b00e..1d887d5cb581276 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -503,6 +503,9 @@ __OMP_RTL(__kmpc_barrier_simple_generic, false, Void, 
IdentPtr, Int32)
 __OMP_RTL(__kmpc_warp_active_thread_mask, false, Int64,)
 __OMP_RTL(__kmpc_syncwarp, false, Void, Int64)
 
+__OMP_RTL(__llvm_profile_register_function, false, Void, VoidPtr)
+__OMP_RTL(__llvm_profile_register_names_function, false, Void, VoidPtr, Int64)
+
 __OMP_RTL(__last, false, Void, )
 
 #undef __OMP_RTL
diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt 
b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 1ce3e1e40a80ab4..55ee15d068c67b7 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -89,6 +89,7 @@ set(include_files
   ${include_directory}/Interface.h
   ${include_directory}/LibC.h
   ${include_directory}/Mapping.h
+  ${include_directory}/Profiling.h
   ${include_directory}/State.h
   ${include_directory}/Synchronization.h
   ${include_directory}/Types.h
@@ -104,6 +105,7 @@ set(src_files
   ${source_directory}/Mapping.cpp
   ${source_directory}/Misc.cpp
   ${source_directory}/Parallelism.cpp
+  ${source_directory}/Profiling.cpp
   ${source_directory}/Reduction.cpp
   ${source_directory}/State.cpp
   ${source_directory}/Synchronization.cpp
diff --git a/openmp/libomptarget/DeviceRTL/include/Profiling.h 
b/openmp/libomptarget/DeviceRTL/include/Profiling.h
new file mode 100644
index 000..68c7744cd60752f
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/include/Profiling.h
@@ -0,0 +1,21 @@
+//=== Profiling.h - OpenMP interface -- 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
+//
+//===--===//
+//
+//
+//===--===//
+
+#ifndef OMPTARGET_DEVICERTL_PROFILING_H
+#define OMPTARGET_DEVICERTL_PROFILING_H
+
+extern "C" {
+
+void __llvm_profile_register_function(void *ptr);
+void __llvm_profile_register_names_function(void *ptr, long int i);
+}
+
+#endif
diff --git a/openmp/libomptarget/DeviceRTL/src/Profiling.cpp 
b/openmp/libomptarget/DeviceRTL/src/Profiling.cpp
new file mode 100644
index 000..799477f5e47d273
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/src/Profiling.cpp
@@ -0,0 +1,19 @@
+//===--- Profiling.cpp  C++ 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Profiling.h"
+
+#pragma omp begin declare target device_type(nohost)
+
+extern "C" {
+
+void __llvm_profile_register_function(void *ptr) {}
+void __llvm_profile_register_names_function(void *ptr, long int i) {}
+}
+
+#pragma omp end declare target

>From fb067d4ffe604fd68cf90b705db1942bce49dbb1 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough 
Date: Sat, 16 Dec 2023 01:18:41 -0600
Subject: [PATCH 02/11] Fix PGO instrumentation for GPU targets

---
 clang/lib/CodeGen/CodeGenPGO.cpp  | 10 --
 .../lib/Transforms/Instrumentation/InstrProfiling.cpp | 11 ---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 81bf8ea696b1647..edae6885b528ac7 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -959,8 +959,14 @@ void CodeGenPGO::emitCounterIncrement(CGBuilderTy 
&Builder, const Stmt *S,
 
   unsigned Counter = (*RegionCounterMap)[S];
 
-  llvm::Value *Args[] = {FuncNameVar,
- Builder.getInt64(FunctionHash),
+  // Make sure that pointer to global is passed in with zero addrsp

[Lldb-commits] [lldb] [lldb][Format] Fix missing inlined function names in frame formatting. (PR #78494)

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

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


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


[Lldb-commits] [lldb] [lldb][Format] Fix missing inlined function names in frame formatting. (PR #78494)

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


@@ -1093,6 +1093,20 @@ static void PrettyPrintFunctionNameWithArgs(Stream 
&out_stream,
 out_stream.PutChar(')');
 }
 
+static void FormatInlinedBlock(Stream &out_stream, Block *block) {
+  if (!block)
+return;
+  Block *inline_block = block->GetContainingInlinedBlock();
+  if (inline_block) {
+const InlineFunctionInfo *inline_info =
+inline_block->GetInlinedFunctionInfo();
+if (inline_info) {
+  out_stream.PutCString(" [inlined] ");
+  inline_info->GetName().Dump(&out_stream);
+}

JDevlieghere wrote:

```
if (const InlineFunctionInfo *inline_info = 
sc->block->GetInlinedFunctionInfo()) {
  ...
}
```

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


[Lldb-commits] [lldb] [lldb][Format] Fix missing inlined function names in frame formatting. (PR #78494)

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

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


[Lldb-commits] [llvm] [lld] [libunwind] [openmp] [libc] [clang] [clang-tools-extra] [libcxxabi] [lldb] [libcxx] [compiler-rt] [flang] [mlir] [clang] static operators should evaluate object argument (P

2024-01-17 Thread Tianlan Zhou via lldb-commits

https://github.com/SuperSodaSea updated 
https://github.com/llvm/llvm-project/pull/68485

>From 03276260c48d9cafb2a0d80825156e77cdf02eba Mon Sep 17 00:00:00 2001
From: SuperSodaSea 
Date: Sat, 7 Oct 2023 21:05:17 +0800
Subject: [PATCH 01/15] [clang] static operators should evaluate object
 argument

---
 clang/lib/AST/ExprConstant.cpp|  3 +-
 clang/lib/CodeGen/CGExpr.cpp  |  2 +-
 clang/lib/CodeGen/CGExprCXX.cpp   | 41 --
 clang/lib/CodeGen/CodeGenFunction.h   |  3 +
 clang/lib/Sema/SemaChecking.cpp   |  5 +-
 clang/lib/Sema/SemaOverload.cpp   | 33 ---
 clang/test/AST/ast-dump-static-operators.cpp  | 55 +++
 .../CodeGenCXX/cxx2b-static-call-operator.cpp | 26 ++---
 .../cxx2b-static-subscript-operator.cpp   | 11 +++-
 9 files changed, 137 insertions(+), 42 deletions(-)
 create mode 100644 clang/test/AST/ast-dump-static-operators.cpp

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5a33e918db8e8c0..a6c81f467fbe01c 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -7806,7 +7806,8 @@ class ExprEvaluatorBase
   // Overloaded operator calls to member functions are represented as 
normal
   // calls with '*this' as the first argument.
   const CXXMethodDecl *MD = dyn_cast(FD);
-  if (MD && MD->isImplicitObjectMemberFunction()) {
+  if (MD &&
+  (MD->isImplicitObjectMemberFunction() || (OCE && MD->isStatic( {
 // FIXME: When selecting an implicit conversion for an overloaded
 // operator delete, we sometimes try to evaluate calls to conversion
 // operators without a 'this' parameter!
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 54a1d300a9ac738..19406ff174dea14 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -5070,7 +5070,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,
   if (const auto *CE = dyn_cast(E))
 if (const auto *MD =
 dyn_cast_if_present(CE->getCalleeDecl());
-MD && MD->isImplicitObjectMemberFunction())
+MD && !MD->isExplicitObjectMemberFunction())
   return EmitCXXOperatorMemberCallExpr(CE, MD, ReturnValue);
 
   CGCallee callee = EmitCallee(E->getCallee());
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 2e7059cc8f5b639..a580c635998510f 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -489,11 +489,42 @@ RValue
 CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
const CXXMethodDecl *MD,
ReturnValueSlot ReturnValue) {
-  assert(MD->isImplicitObjectMemberFunction() &&
- "Trying to emit a member call expr on a static method!");
-  return EmitCXXMemberOrOperatorMemberCallExpr(
-  E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr,
-  /*IsArrow=*/false, E->getArg(0));
+  assert(!MD->isExplicitObjectMemberFunction() &&
+ "Trying to emit a member call expr on an explicit object member "
+ "function!");
+
+  if (MD->isStatic())
+return EmitCXXStaticOperatorMemberCallExpr(E, MD, ReturnValue);
+  else
+return EmitCXXMemberOrOperatorMemberCallExpr(
+E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr,
+/*IsArrow=*/false, E->getArg(0));
+}
+
+RValue CodeGenFunction::EmitCXXStaticOperatorMemberCallExpr(
+const CXXOperatorCallExpr *E, const CXXMethodDecl *MD,
+ReturnValueSlot ReturnValue) {
+  assert(MD->isStatic());
+
+  CGCallee Callee = EmitCallee(E->getCallee());
+
+  // Emit and ignore `this` pointer.
+  EmitIgnoredExpr(E->getArg(0));
+
+  auto ProtoType = MD->getFunctionType()->castAs();
+
+  // Emit the rest of the call args.
+  CallArgList Args;
+  EmitCallArgs(Args, ProtoType, drop_begin(E->arguments(), 1),
+   E->getDirectCallee());
+
+  bool Chain = E == MustTailCall;
+  const CGFunctionInfo &FnInfo =
+  CGM.getTypes().arrangeFreeFunctionCall(Args, ProtoType, Chain);
+  llvm::CallBase *CallOrInvoke = nullptr;
+
+  return EmitCall(FnInfo, Callee, ReturnValue, Args, &CallOrInvoke, Chain,
+  E->getExprLoc());
 }
 
 RValue CodeGenFunction::EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E,
diff --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index d5336382a2b9c95..42de125e7489911 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4163,6 +4163,9 @@ class CodeGenFunction : public CodeGenTypeCache {
   RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
const CXXMethodDecl *MD,
ReturnValueSlot ReturnValue);
+  RValue EmitCXXStaticOperatorMemberCallExpr(const CXXOperatorCal

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

2024-01-17 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 a25b66217f41564f933dd1d6d2993d990615c47b 
0c4bbeb54d189c1461affd37853aa86c3e3ca7d8 -- 
openmp/libomptarget/DeviceRTL/include/Profiling.h 
openmp/libomptarget/DeviceRTL/src/Profiling.cpp 
openmp/libomptarget/test/offloading/pgo1.c clang/lib/CodeGen/CodeGenPGO.cpp 
llvm/include/llvm/ProfileData/InstrProf.h llvm/lib/ProfileData/InstrProf.cpp 
llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp 
openmp/libomptarget/plugins-nextgen/common/include/GlobalHandler.h 
openmp/libomptarget/plugins-nextgen/common/src/GlobalHandler.cpp 
openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
``





View the diff from clang-format here.


``diff
diff --git a/openmp/libomptarget/test/offloading/pgo1.c 
b/openmp/libomptarget/test/offloading/pgo1.c
index ca8a6f502a..56ab7da874 100644
--- a/openmp/libomptarget/test/offloading/pgo1.c
+++ b/openmp/libomptarget/test/offloading/pgo1.c
@@ -1,5 +1,6 @@
-// RUN: %libomptarget-compile-generic -fprofile-instr-generate -Xclang 
"-fprofile-instrument=clang"
-// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic
+// RUN: %libomptarget-compile-generic -fprofile-instr-generate -Xclang
+// "-fprofile-instrument=clang" RUN: %libomptarget-run-generic 2>&1 |
+// %fcheck-generic
 
 // UNSUPPORTED: x86_64-pc-linux-gnu
 // UNSUPPORTED: x86_64-pc-linux-gnu-LTO
@@ -30,9 +31,12 @@ int main() {
 // CHECK-NEXT: [ 10 ]
 // CHECK-NEXT: [ 20 ]
 // CHECK-NEXT: == Data ===
-// CHECK-NEXT: { {{[0-9]*}} {{[0-9]*}} {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} 
{{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} {{[0-9]*}} {{[0-9]*}} {{[0-9]*}} }
-// CHECK-NEXT: { {{[0-9]*}} {{[0-9]*}} {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} 
{{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} {{[0-9]*}} {{[0-9]*}} {{[0-9]*}} }
-// CHECK-NEXT: { {{[0-9]*}} {{[0-9]*}} {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} 
{{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} {{[0-9]*}} {{[0-9]*}} {{[0-9]*}} }
+// CHECK-NEXT: { {{[0-9]*}} {{[0-9]*}} {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}}
+// {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} {{[0-9]*}} {{[0-9]*}} {{[0-9]*}} }
+// CHECK-NEXT: { {{[0-9]*}} {{[0-9]*}} {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}}
+// {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} {{[0-9]*}} {{[0-9]*}} {{[0-9]*}} }
+// CHECK-NEXT: { {{[0-9]*}} {{[0-9]*}} {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}}
+// {{0x[0-9a-fA-F]*}} {{0x[0-9a-fA-F]*}} {{[0-9]*}} {{[0-9]*}} {{[0-9]*}} }
 // CHECK-NEXT:  Functions 
 // CHECK-NEXT: pgo1.c:__omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}
 // CHECK-NEXT: test1

``




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


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

2024-01-17 Thread Ethan Luis McDonough via lldb-commits

https://github.com/EthanLuisMcDonough updated 
https://github.com/llvm/llvm-project/pull/76587

>From 530eb982b9770190377bb0bd09c5cb715f34d484 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough 
Date: Fri, 15 Dec 2023 20:38:38 -0600
Subject: [PATCH 01/10] Add profiling functions to libomptarget

---
 .../include/llvm/Frontend/OpenMP/OMPKinds.def |  3 +++
 openmp/libomptarget/DeviceRTL/CMakeLists.txt  |  2 ++
 .../DeviceRTL/include/Profiling.h | 21 +++
 .../libomptarget/DeviceRTL/src/Profiling.cpp  | 19 +
 4 files changed, 45 insertions(+)
 create mode 100644 openmp/libomptarget/DeviceRTL/include/Profiling.h
 create mode 100644 openmp/libomptarget/DeviceRTL/src/Profiling.cpp

diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def 
b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index d22d2a8e948b00..1d887d5cb58127 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -503,6 +503,9 @@ __OMP_RTL(__kmpc_barrier_simple_generic, false, Void, 
IdentPtr, Int32)
 __OMP_RTL(__kmpc_warp_active_thread_mask, false, Int64,)
 __OMP_RTL(__kmpc_syncwarp, false, Void, Int64)
 
+__OMP_RTL(__llvm_profile_register_function, false, Void, VoidPtr)
+__OMP_RTL(__llvm_profile_register_names_function, false, Void, VoidPtr, Int64)
+
 __OMP_RTL(__last, false, Void, )
 
 #undef __OMP_RTL
diff --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt 
b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index 1ce3e1e40a80ab..55ee15d068c67b 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -89,6 +89,7 @@ set(include_files
   ${include_directory}/Interface.h
   ${include_directory}/LibC.h
   ${include_directory}/Mapping.h
+  ${include_directory}/Profiling.h
   ${include_directory}/State.h
   ${include_directory}/Synchronization.h
   ${include_directory}/Types.h
@@ -104,6 +105,7 @@ set(src_files
   ${source_directory}/Mapping.cpp
   ${source_directory}/Misc.cpp
   ${source_directory}/Parallelism.cpp
+  ${source_directory}/Profiling.cpp
   ${source_directory}/Reduction.cpp
   ${source_directory}/State.cpp
   ${source_directory}/Synchronization.cpp
diff --git a/openmp/libomptarget/DeviceRTL/include/Profiling.h 
b/openmp/libomptarget/DeviceRTL/include/Profiling.h
new file mode 100644
index 00..68c7744cd60752
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/include/Profiling.h
@@ -0,0 +1,21 @@
+//=== Profiling.h - OpenMP interface -- 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
+//
+//===--===//
+//
+//
+//===--===//
+
+#ifndef OMPTARGET_DEVICERTL_PROFILING_H
+#define OMPTARGET_DEVICERTL_PROFILING_H
+
+extern "C" {
+
+void __llvm_profile_register_function(void *ptr);
+void __llvm_profile_register_names_function(void *ptr, long int i);
+}
+
+#endif
diff --git a/openmp/libomptarget/DeviceRTL/src/Profiling.cpp 
b/openmp/libomptarget/DeviceRTL/src/Profiling.cpp
new file mode 100644
index 00..799477f5e47d27
--- /dev/null
+++ b/openmp/libomptarget/DeviceRTL/src/Profiling.cpp
@@ -0,0 +1,19 @@
+//===--- Profiling.cpp  C++ 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Profiling.h"
+
+#pragma omp begin declare target device_type(nohost)
+
+extern "C" {
+
+void __llvm_profile_register_function(void *ptr) {}
+void __llvm_profile_register_names_function(void *ptr, long int i) {}
+}
+
+#pragma omp end declare target

>From fb067d4ffe604fd68cf90b705db1942bce49dbb1 Mon Sep 17 00:00:00 2001
From: Ethan Luis McDonough 
Date: Sat, 16 Dec 2023 01:18:41 -0600
Subject: [PATCH 02/10] Fix PGO instrumentation for GPU targets

---
 clang/lib/CodeGen/CodeGenPGO.cpp  | 10 --
 .../lib/Transforms/Instrumentation/InstrProfiling.cpp | 11 ---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index 81bf8ea696b164..edae6885b528ac 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -959,8 +959,14 @@ void CodeGenPGO::emitCounterIncrement(CGBuilderTy 
&Builder, const Stmt *S,
 
   unsigned Counter = (*RegionCounterMap)[S];
 
-  llvm::Value *Args[] = {FuncNameVar,
- Builder.getInt64(FunctionHash),
+  // Make sure that pointer to global is passed in with zero addrspace
+  // 

[Lldb-commits] [llvm] [lldb] [compiler-rt] [clang] [lld] [mlir] [libc] [clang-tools-extra] [flang] [AMDGPU] Reapply 'Sign extend simm16 in setreg intrinsic' (PR #78492)

2024-01-17 Thread Stanislav Mekhanoshin via lldb-commits

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


[Lldb-commits] [clang-tools-extra] [flang] [lld] [libc] [clang] [llvm] [mlir] [compiler-rt] [lldb] [AMDGPU] Reapply 'Sign extend simm16 in setreg intrinsic' (PR #78492)

2024-01-17 Thread Stanislav Mekhanoshin via lldb-commits

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

>From 01af6c9d8e80b810bbdec35dee38b1cf5d73cfe0 Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Fri, 12 Jan 2024 15:07:53 -0800
Subject: [PATCH 1/3] [AMDGPU] Sign extend simm16 in setreg intrinsic

We currently force users to use a negative contant in the
intrinsic call. Changing it zext would break existing programs,
so just sign extend an argument.
---
 llvm/lib/Target/AMDGPU/SOPInstructions.td | 11 ++--
 .../CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll| 66 +++
 2 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SOPInstructions.td 
b/llvm/lib/Target/AMDGPU/SOPInstructions.td
index 46fa3d57a21cb2..5b35d4dcac2e4f 100644
--- a/llvm/lib/Target/AMDGPU/SOPInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SOPInstructions.td
@@ -1117,14 +1117,12 @@ def S_GETREG_B32 : SOPK_Pseudo <
 let Defs = [MODE], Uses = [MODE] in {
 
 // FIXME: Need to truncate immediate to 16-bits.
-class S_SETREG_B32_Pseudo  pattern=[]> : SOPK_Pseudo <
+class S_SETREG_B32_Pseudo : SOPK_Pseudo <
   "s_setreg_b32",
   (outs), (ins SReg_32:$sdst, hwreg:$simm16),
-  "$simm16, $sdst",
-  pattern>;
+  "$simm16, $sdst">;
 
-def S_SETREG_B32 : S_SETREG_B32_Pseudo <
-  [(int_amdgcn_s_setreg (i32 timm:$simm16), i32:$sdst)]> {
+def S_SETREG_B32 : S_SETREG_B32_Pseudo {
   // Use custom inserter to optimize some cases to
   // S_DENORM_MODE/S_ROUND_MODE/S_SETREG_B32_mode.
   let usesCustomInserter = 1;
@@ -1160,6 +1158,9 @@ def S_SETREG_IMM32_B32_mode : S_SETREG_IMM32_B32_Pseudo {
 
 } // End Defs = [MODE], Uses = [MODE]
 
+def : GCNPat<(int_amdgcn_s_setreg (i32 timm:$simm16), i32:$sdst),
+ (S_SETREG_B32 $sdst, (as_i16timm $simm16))>;
+
 class SOPK_WAITCNT pat=[]> :
 SOPK_Pseudo<
 opName,
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
index d2c14f2401fc35..99d80b5dd14b33 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
@@ -1433,6 +1433,72 @@ define amdgpu_kernel void 
@test_setreg_set_4_bits_straddles_round_and_denorm() {
   ret void
 }
 
+define amdgpu_ps void @test_63489(i32 inreg %var.mode) {
+; GFX6-LABEL: test_63489:
+; GFX6:   ; %bb.0:
+; GFX6-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x80,0xb9]
+; GFX6-NEXT:;;#ASMSTART
+; GFX6-NEXT:;;#ASMEND
+; GFX6-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
+;
+; GFX789-LABEL: test_63489:
+; GFX789:   ; %bb.0:
+; GFX789-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x00,0xb9]
+; GFX789-NEXT:;;#ASMSTART
+; GFX789-NEXT:;;#ASMEND
+; GFX789-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
+;
+; GFX10-LABEL: test_63489:
+; GFX10:   ; %bb.0:
+; GFX10-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x80,0xb9]
+; GFX10-NEXT:;;#ASMSTART
+; GFX10-NEXT:;;#ASMEND
+; GFX10-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
+;
+; GFX11-LABEL: test_63489:
+; GFX11:   ; %bb.0:
+; GFX11-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x00,0xb9]
+; GFX11-NEXT:;;#ASMSTART
+; GFX11-NEXT:;;#ASMEND
+; GFX11-NEXT:s_endpgm ; encoding: [0x00,0x00,0xb0,0xbf]
+  call void @llvm.amdgcn.s.setreg(i32 63489, i32 %var.mode)
+  call void asm sideeffect "", ""()
+  ret void
+}
+
+define amdgpu_ps void @test_minus_2047(i32 inreg %var.mode) {
+; GFX6-LABEL: test_minus_2047:
+; GFX6:   ; %bb.0:
+; GFX6-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x80,0xb9]
+; GFX6-NEXT:;;#ASMSTART
+; GFX6-NEXT:;;#ASMEND
+; GFX6-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
+;
+; GFX789-LABEL: test_minus_2047:
+; GFX789:   ; %bb.0:
+; GFX789-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x00,0xb9]
+; GFX789-NEXT:;;#ASMSTART
+; GFX789-NEXT:;;#ASMEND
+; GFX789-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
+;
+; GFX10-LABEL: test_minus_2047:
+; GFX10:   ; %bb.0:
+; GFX10-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x80,0xb9]
+; GFX10-NEXT:;;#ASMSTART
+; GFX10-NEXT:;;#ASMEND
+; GFX10-NEXT:s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
+;
+; GFX11-LABEL: test_minus_2047:
+; GFX11:   ; %bb.0:
+; GFX11-NEXT:s_setreg_b32 hwreg(HW_REG_MODE), s0 ; encoding: 
[0x01,0xf8,0x00,0xb9]
+; GFX11-NEXT:;;#ASMSTART
+; GFX11-NEXT:;;#ASMEND
+; GFX11-NEXT:s_endpgm ; encoding: [0x00,0x00,0xb0,0xbf]
+  call void @llvm.amdgcn.s.setreg(i32 -2047, i32 %var.mode)
+  call void asm sideeffect "", ""()
+  ret void
+}
+
 ; FIXME: Broken for DAG
 ; define void @test_setreg_roundingmode_var_vgpr(i32 %var.mode) {
 ;   call void @llvm.amdgcn.s.setreg(i32 4097, i32 %var.mode)

>From daeef9d3780bcfc9f48a2bf4fff313f3e5575f6b Mon Sep 17 00:00:00 2001
From: Stanislav Mekhanoshin 
Date: Mon, 15 Jan 2024 11:21:05 -0

[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

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


@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}

clayborg wrote:

I am not saying that this works needs to be done, just pointing out that this 
might not be as efficient as you want it to be and might cause all DIEs to be 
parsed. 

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


[Lldb-commits] [lldb] [lldb][Format] Fix missing inlined function names in frame formatting. (PR #78494)

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

clayborg wrote:

LGTM

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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

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


@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}

clayborg wrote:

If the attribute isn't in the current DIE (it is in a `DW_AT_specification` or 
`DW_AT_abstract_origin`), the `DWARFDebugInfoEntry::GetAttributeValue(...)` 
function will just run this code:
```
if (GetAttributeValue(cu, DW_AT_specification, form_value)) {
  DWARFDIE die = form_value.Reference();
  if (die) {
```
or
```
if (GetAttributeValue(cu, DW_AT_abstract_origin, form_value)) {
  DWARFDIE die = form_value.Reference();
  if (die) {
```
Both of these go back to the DWARFDIE class which will cause all of the DIEs to 
be parsed in the DWARFUnit anyway. So the peek function will work, it will just 
do a lot more work than you expected. Note that if the `DW_AT_specification` or 
`DW_AT_abstract_origin` attributes can represent a DIE from another compile 
unit of they use the `DW_FORM_ref_addr`, which can point across compile units. 
So it will take some more work to make the `DWARFUnit::PeekDIEName` work and be 
as efficient as needed.

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


[Lldb-commits] [lldb] [lldb] Stop creating BreakpointEventData raw pointers (PR #78508)

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

clayborg wrote:

lgtm!

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


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

2024-01-17 Thread Juergen Ributzka via lldb-commits

ributzka wrote:

@jansvoboda11 gentle ping

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] [lldb] [lldb] Stop creating BreakpointEventData raw pointers (PR #78508)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits

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

LGTM! Thanks for doing this

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


[Lldb-commits] [libc] [lldb] [lld] [libcxx] [compiler-rt] [flang] [clang] [llvm] [Clang] Support MSPropertyRefExpr as placement arg to new-expression (PR #75883)

2024-01-17 Thread Erich Keane via lldb-commits

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


[Lldb-commits] [libc] [lldb] [lld] [libcxx] [compiler-rt] [flang] [clang] [llvm] [Clang] Support MSPropertyRefExpr as placement arg to new-expression (PR #75883)

2024-01-17 Thread Erich Keane via lldb-commits

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

>From 849b21f202f3c643c12f237920b137c3506996e7 Mon Sep 17 00:00:00 2001
From: Sirraide 
Date: Tue, 19 Dec 2023 02:48:25 +0100
Subject: [PATCH 1/6] [Clang] Support MSPropertyRefExpr as placement arg to
 new-expression

---
 clang/include/clang/Sema/Sema.h   |  4 ++
 clang/lib/Sema/SemaExpr.cpp   | 12 ++
 clang/lib/Sema/SemaExprCXX.cpp|  3 ++
 clang/test/CodeGenCXX/ms-property-new.cpp | 52 +++
 clang/test/SemaCXX/ms-property-new.cpp| 44 +++
 5 files changed, 107 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/ms-property-new.cpp
 create mode 100644 clang/test/SemaCXX/ms-property-new.cpp

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4ef1fe542ea54f..aeb4075374022f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2108,6 +2108,10 @@ class Sema final {
 
   bool CheckFunctionReturnType(QualType T, SourceLocation Loc);
 
+  /// Check an argument list for placeholders that we won't try to
+  /// handle later.
+  bool CheckArgsForPlaceholders(MultiExprArg args);
+
   /// Build a function type.
   ///
   /// This routine checks the function type according to C++ rules and
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 049fdae09bb185..fcc227cf7a74f6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5058,8 +5058,6 @@ static QualType getDependentArraySubscriptType(Expr *LHS, 
Expr *RHS,
   return Result->isDependentType() ? Result : Ctx.DependentTy;
 }
 
-static bool checkArgsForPlaceholders(Sema &S, MultiExprArg args);
-
 ExprResult Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base,
  SourceLocation lbLoc,
  MultiExprArg ArgExprs,
@@ -5163,7 +5161,7 @@ ExprResult Sema::ActOnArraySubscriptExpr(Scope *S, Expr 
*base,
   return ExprError();
 ArgExprs[0] = result.get();
   } else {
-if (checkArgsForPlaceholders(*this, ArgExprs))
+if (CheckArgsForPlaceholders(ArgExprs))
   return ExprError();
   }
 
@@ -6912,15 +6910,13 @@ static bool isPlaceholderToRemoveAsArg(QualType type) {
   llvm_unreachable("bad builtin type kind");
 }
 
-/// Check an argument list for placeholders that we won't try to
-/// handle later.
-static bool checkArgsForPlaceholders(Sema &S, MultiExprArg args) {
+bool Sema::CheckArgsForPlaceholders(MultiExprArg args) {
   // Apply this processing to all the arguments at once instead of
   // dying at the first failure.
   bool hasInvalid = false;
   for (size_t i = 0, e = args.size(); i != e; i++) {
 if (isPlaceholderToRemoveAsArg(args[i]->getType())) {
-  ExprResult result = S.CheckPlaceholderExpr(args[i]);
+  ExprResult result = CheckPlaceholderExpr(args[i]);
   if (result.isInvalid()) hasInvalid = true;
   else args[i] = result.get();
 }
@@ -7194,7 +7190,7 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
   if (Result.isInvalid()) return ExprError();
   Fn = Result.get();
 
-  if (checkArgsForPlaceholders(*this, ArgExprs))
+  if (CheckArgsForPlaceholders(ArgExprs))
 return ExprError();
 
   if (getLangOpts().CPlusPlus) {
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 4ae04358d5df7c..0ca9e5b59e3c32 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2286,6 +2286,9 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool 
UseGlobal,
   bool PassAlignment = getLangOpts().AlignedAllocation &&
Alignment > NewAlignment;
 
+  if (CheckArgsForPlaceholders(PlacementArgs))
+return ExprError();
+
   AllocationFunctionScope Scope = UseGlobal ? AFS_Global : AFS_Both;
   if (!AllocType->isDependentType() &&
   !Expr::hasAnyTypeDependentArguments(PlacementArgs) &&
diff --git a/clang/test/CodeGenCXX/ms-property-new.cpp 
b/clang/test/CodeGenCXX/ms-property-new.cpp
new file mode 100644
index 00..e21ec3d6702f62
--- /dev/null
+++ b/clang/test/CodeGenCXX/ms-property-new.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -fms-compatibility %s -o 
- | FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fms-compatibility -emit-pch -o %t 
%s
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -fms-compatibility 
-include-pch %t -verify %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+struct S {
+  int GetX() { return 42; }
+  __declspec(property(get=GetX)) int x;
+
+  int GetY(int i, int j) { return i+j; }
+  __declspec(property(get=GetY)) int y[];
+
+  void* operator new(__SIZE_TYPE__, int);
+};
+
+template 
+struct TS {
+  T GetT() { return T(); }
+  __declspec(property(get=GetT)) T t;
+
+  T GetR(T i, T j) { return i+j; }
+  __declspec(property(get=GetR)) T r[];
+

[Lldb-commits] [lldb] [lldb] Stop creating BreakpointEventData raw pointers (PR #78508)

2024-01-17 Thread via lldb-commits

jimingham wrote:

LGTM

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


[Lldb-commits] [lldb] [lldb] Stop creating BreakpointEventData raw pointers (PR #78508)

2024-01-17 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes

The lifetime of these BreakpointEventData objects is difficult to reason about. 
These BreakpointEventData pointers are created and passed along to `Event` 
which takes the raw pointer and sticks them in a shared pointer. Instead of 
manually managing the lifetime and memory, it would be simpler to have them be 
shared pointers from the start.

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


2 Files Affected:

- (modified) lldb/include/lldb/Breakpoint/Breakpoint.h (+1-1) 
- (modified) lldb/source/Breakpoint/Breakpoint.cpp (+23-30) 


``diff
diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index 3a8b29aee544c63..8c4308ab0bc12d5 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -672,7 +672,7 @@ class Breakpoint : public 
std::enable_shared_from_this,
 
   void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind);
 
-  void SendBreakpointChangedEvent(BreakpointEventData *data);
+  void SendBreakpointChangedEvent(const lldb::EventDataSP &breakpoint_data_sp);
 
   Breakpoint(const Breakpoint &) = delete;
   const Breakpoint &operator=(const Breakpoint &) = delete;
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 6e6b51b562496c6..af5dcc9cd88d4fa 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -460,17 +460,13 @@ void Breakpoint::ResolveBreakpointInModules(ModuleList 
&module_list,
 // If this is not an internal breakpoint, set up to record the new
 // locations, then dispatch an event with the new locations.
 if (!IsInternal() && send_event) {
-  BreakpointEventData *new_locations_event = new BreakpointEventData(
-  eBreakpointEventTypeLocationsAdded, shared_from_this());
-
+  std::shared_ptr new_locations_event =
+  std::make_shared(
+  eBreakpointEventTypeLocationsAdded, shared_from_this());
   ResolveBreakpointInModules(
   module_list, new_locations_event->GetBreakpointLocationCollection());
-
-  if (new_locations_event->GetBreakpointLocationCollection().GetSize() !=
-  0) {
+  if (new_locations_event->GetBreakpointLocationCollection().GetSize() != 
0)
 SendBreakpointChangedEvent(new_locations_event);
-  } else
-delete new_locations_event;
 } else {
   ElapsedTime elapsed(m_resolve_time);
   m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
@@ -565,12 +561,10 @@ void Breakpoint::ModulesChanged(ModuleList &module_list, 
bool load,
 // the module list, then remove their breakpoint sites, and their locations
 // if asked to.
 
-BreakpointEventData *removed_locations_event;
+std::shared_ptr removed_locations_event;
 if (!IsInternal())
-  removed_locations_event = new BreakpointEventData(
+  removed_locations_event = std::make_shared(
   eBreakpointEventTypeLocationsRemoved, shared_from_this());
-else
-  removed_locations_event = nullptr;
 
 for (ModuleSP module_sp : module_list.Modules()) {
   if (m_filter_sp->ModulePasses(module_sp)) {
@@ -795,31 +789,30 @@ void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
 // about telling the world about removing a location we didn't tell them
 // about adding.
 
-BreakpointEventData *locations_event;
+std::shared_ptr removed_locations_event;
 if (!IsInternal())
-  locations_event = new BreakpointEventData(
+  removed_locations_event = std::make_shared(
   eBreakpointEventTypeLocationsRemoved, shared_from_this());
-else
-  locations_event = nullptr;
 
 for (BreakpointLocationSP loc_sp :
  locations_to_remove.BreakpointLocations()) {
   m_locations.RemoveLocation(loc_sp);
-  if (locations_event)
-locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+  if (removed_locations_event)
+removed_locations_event->GetBreakpointLocationCollection().Add(loc_sp);
 }
-SendBreakpointChangedEvent(locations_event);
+SendBreakpointChangedEvent(removed_locations_event);
 
 // And announce the new ones.
 
 if (!IsInternal()) {
-  locations_event = new BreakpointEventData(
-  eBreakpointEventTypeLocationsAdded, shared_from_this());
+  std::shared_ptr added_locations_event =
+  std::make_shared(
+  eBreakpointEventTypeLocationsAdded, shared_from_this());
   for (BreakpointLocationSP loc_sp :
locations_to_announce.BreakpointLocations())
-locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+added_locations_event->GetBreakpointLocationCollection().Add(loc_sp);
 
-  SendBreakpointChangedEvent(locations_event);
+  SendBreakpointChangedEvent(added_locations_event);
 }
 m_locations.C

[Lldb-commits] [lldb] [lldb] Stop creating BreakpointEventData raw pointers (PR #78508)

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

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

The lifetime of these BreakpointEventData objects is difficult to reason about. 
These BreakpointEventData pointers are created and passed along to `Event` 
which takes the raw pointer and sticks them in a shared pointer. Instead of 
manually managing the lifetime and memory, it would be simpler to have them be 
shared pointers from the start.

>From e3ca69b047515fabbaff5fcde9545d201bc6aeb7 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Wed, 17 Jan 2024 13:27:24 -0800
Subject: [PATCH] [lldb] Stop creating BreakpointEventData raw pointers

The lifetime of these BreakpointEventData objects is difficult to
reason about. These BreakpointEventData pointers are created and passed
along to `Event` which takes the raw pointer and sticks them in a shared
pointer. Instead of manually managing the lifetime and memory, it would
be simpler to have them be shared pointers from the start.
---
 lldb/include/lldb/Breakpoint/Breakpoint.h |  2 +-
 lldb/source/Breakpoint/Breakpoint.cpp | 53 ++-
 2 files changed, 24 insertions(+), 31 deletions(-)

diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index 3a8b29aee544c6..8c4308ab0bc12d 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -672,7 +672,7 @@ class Breakpoint : public 
std::enable_shared_from_this,
 
   void SendBreakpointChangedEvent(lldb::BreakpointEventType eventKind);
 
-  void SendBreakpointChangedEvent(BreakpointEventData *data);
+  void SendBreakpointChangedEvent(const lldb::EventDataSP &breakpoint_data_sp);
 
   Breakpoint(const Breakpoint &) = delete;
   const Breakpoint &operator=(const Breakpoint &) = delete;
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 6e6b51b562496c..af5dcc9cd88d4f 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -460,17 +460,13 @@ void Breakpoint::ResolveBreakpointInModules(ModuleList 
&module_list,
 // If this is not an internal breakpoint, set up to record the new
 // locations, then dispatch an event with the new locations.
 if (!IsInternal() && send_event) {
-  BreakpointEventData *new_locations_event = new BreakpointEventData(
-  eBreakpointEventTypeLocationsAdded, shared_from_this());
-
+  std::shared_ptr new_locations_event =
+  std::make_shared(
+  eBreakpointEventTypeLocationsAdded, shared_from_this());
   ResolveBreakpointInModules(
   module_list, new_locations_event->GetBreakpointLocationCollection());
-
-  if (new_locations_event->GetBreakpointLocationCollection().GetSize() !=
-  0) {
+  if (new_locations_event->GetBreakpointLocationCollection().GetSize() != 
0)
 SendBreakpointChangedEvent(new_locations_event);
-  } else
-delete new_locations_event;
 } else {
   ElapsedTime elapsed(m_resolve_time);
   m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
@@ -565,12 +561,10 @@ void Breakpoint::ModulesChanged(ModuleList &module_list, 
bool load,
 // the module list, then remove their breakpoint sites, and their locations
 // if asked to.
 
-BreakpointEventData *removed_locations_event;
+std::shared_ptr removed_locations_event;
 if (!IsInternal())
-  removed_locations_event = new BreakpointEventData(
+  removed_locations_event = std::make_shared(
   eBreakpointEventTypeLocationsRemoved, shared_from_this());
-else
-  removed_locations_event = nullptr;
 
 for (ModuleSP module_sp : module_list.Modules()) {
   if (m_filter_sp->ModulePasses(module_sp)) {
@@ -795,31 +789,30 @@ void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
 // about telling the world about removing a location we didn't tell them
 // about adding.
 
-BreakpointEventData *locations_event;
+std::shared_ptr removed_locations_event;
 if (!IsInternal())
-  locations_event = new BreakpointEventData(
+  removed_locations_event = std::make_shared(
   eBreakpointEventTypeLocationsRemoved, shared_from_this());
-else
-  locations_event = nullptr;
 
 for (BreakpointLocationSP loc_sp :
  locations_to_remove.BreakpointLocations()) {
   m_locations.RemoveLocation(loc_sp);
-  if (locations_event)
-locations_event->GetBreakpointLocationCollection().Add(loc_sp);
+  if (removed_locations_event)
+removed_locations_event->GetBreakpointLocationCollection().Add(loc_sp);
 }
-SendBreakpointChangedEvent(locations_event);
+SendBreakpointChangedEvent(removed_locations_event);
 
 // And announce the new ones.
 
 if (!IsInternal()) {
-  locations_event = new BreakpointEventData(
-  eBreakpointEventTypeLocationsAdded, shared_from_this());
+  std::shared_ptr added_locations_event =
+ 

[Lldb-commits] [compiler-rt] [clang-tools-extra] [flang] [llvm] [lldb] [mlir] [clang] [lld] [libcxx] [DWARFLinker][NFC] Decrease DWARFLinker dependence on DwarfStreamer. (PR #77932)

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


@@ -30,6 +30,20 @@ using namespace llvm;
 using namespace dwarf_linker;
 using namespace dwarf_linker::classic;
 
+Expected> DwarfStreamer::createStreamer(
+const Triple &TheTriple, DWARFLinkerBase::OutputFileType FileType,
+raw_pwrite_stream &OutFile, DWARFLinkerBase::TranslatorFuncTy Translator,
+DWARFLinkerBase::MessageHandlerTy Warning) {
+  DwarfStreamer *Streamer =
+  new DwarfStreamer(FileType, OutFile, Translator, Warning);
+  if (Error Err = Streamer->init(TheTriple, "__DWARF")) {
+delete Streamer;
+return std::move(Err);
+  }
+
+  return std::unique_ptr(Streamer);

JDevlieghere wrote:

Can we use `make_unique` above and avoid the naked `delete`? 

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


[Lldb-commits] [clang] [flang] [lldb] [lld] [libcxx] [mlir] [compiler-rt] [clang-tools-extra] [llvm] [DWARFLinker][NFC] Decrease DWARFLinker dependence on DwarfStreamer. (PR #77932)

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

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

Before this patch, the DWARFLinker was the one responsible for creating the 
streamer, which meant that both the classic and parallel implementation needed 
to conform to the same interface. After this patch, the concrete 
implementations instantiate their own streamer, which means that the classic 
linker can support the Swift sections while the parallel implementation can 
ignore them for now. 

Makes sense to me. LGTM! 

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


[Lldb-commits] [flang] [llvm] [compiler-rt] [lldb] [clang] [libcxx] [mlir] [lld] [clang-tools-extra] [DWARFLinker][NFC] Decrease DWARFLinker dependence on DwarfStreamer. (PR #77932)

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

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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan updated 
https://github.com/llvm/llvm-project/pull/78486

>From b0a33481162e24a7106cbd554b33ddb098df7612 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 11:26:52 -0800
Subject: [PATCH 1/3] [lldb][DWARFUnit] Implement PeekDIEName query

This allows us to query the AT_Name of a DIE without parsing the entire CU.

Part of the ongoing effort to support IDX_Parent in accelerator tables [1].

[1]: 
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44
---
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   |  7 +++
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  5 ++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|  8 +++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  5 ++
 .../SymbolFile/DWARF/DWARFDIETest.cpp | 59 +++
 5 files changed, 84 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 553b6a4c551d20..775b7a2e73f512 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -191,3 +191,10 @@ DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
 return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
   return DWARFDIE(); // Not found
 }
+
+llvm::StringRef
+DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) {
+  if(DWARFUnit *cu = GetUnit(die_ref))
+return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset());
+  return llvm::StringRef();
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index d5e48f312ea0e9..a8b5abc3beed2d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -43,6 +43,11 @@ class DWARFDebugInfo {
   bool ContainsTypeUnits();
   DWARFDIE GetDIE(const DIERef &die_ref);
 
+  /// Returns the AT_Name of this DIE, if it exists, without parsing the entire
+  /// compile unit. An empty is string is returned upon error or if the
+  /// attribute is not present.
+  llvm::StringRef PeekDIEName(const DIERef &die_ref);
+
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
 eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 0e2f4d45543bb5..7db279ed37d04a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}
+
 DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
   ExtractUnitDIEIfNeeded();
   if (m_dwo)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 3f528e913d8cfa..bc225a52e1d030 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -187,6 +187,11 @@ class DWARFUnit : public UserID {
 
   DWARFDIE GetDIE(dw_offset_t die_offset);
 
+  /// Returns the AT_Name of the DIE at `die_offset`, if it exists, without
+  /// parsing the entire compile unit. An empty is string is returned upon
+  /// error or if the attribute is not present.
+  llvm::StringRef PeekDIEName(dw_offset_t die_offset);
+
   DWARFUnit &GetNonSkeletonUnit();
 
   static uint8_t GetAddressByteSize(const DWARFUnit *cu);
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 8497855b2f3db5..ff433c7a14ef7b 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "llvm/ADT/STLExtras.h"
 #include "gmock/gmock.h"
@@ -104,3 +105,61 @@ TEST(DWARFDIETest, ChildIteration) {
   DWARFDIE no_children_die(unit, die_child0);
   EXPECT_TRUE(no_children_die.children().empty());
 }
+
+TEST(DWARFDIETest, PeekName) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'NameType1'
+- 'NameType2'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   D

[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

Added tests for AT_specification and AT_abstract origin.

@clayborg I didn't change the implementation because IIUC the "parsed DIE" is 
merely a structure with computed parent/child/sibling relationship, we don't 
build any data structures for the attributes themselves. 

If we were to go through the parsed DIE (i.e. `DWARFDIE` instead of `DIERef`), 
the implementation will still boil down to the same thing, so we would be 
adding one more code path to `PeekDIEName` without any benefits. Does that make 
sense?

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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan updated 
https://github.com/llvm/llvm-project/pull/78486

>From b0a33481162e24a7106cbd554b33ddb098df7612 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 11:26:52 -0800
Subject: [PATCH 1/2] [lldb][DWARFUnit] Implement PeekDIEName query

This allows us to query the AT_Name of a DIE without parsing the entire CU.

Part of the ongoing effort to support IDX_Parent in accelerator tables [1].

[1]: 
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44
---
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   |  7 +++
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  5 ++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|  8 +++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  5 ++
 .../SymbolFile/DWARF/DWARFDIETest.cpp | 59 +++
 5 files changed, 84 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 553b6a4c551d20..775b7a2e73f512 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -191,3 +191,10 @@ DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
 return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
   return DWARFDIE(); // Not found
 }
+
+llvm::StringRef
+DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) {
+  if(DWARFUnit *cu = GetUnit(die_ref))
+return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset());
+  return llvm::StringRef();
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index d5e48f312ea0e9..a8b5abc3beed2d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -43,6 +43,11 @@ class DWARFDebugInfo {
   bool ContainsTypeUnits();
   DWARFDIE GetDIE(const DIERef &die_ref);
 
+  /// Returns the AT_Name of this DIE, if it exists, without parsing the entire
+  /// compile unit. An empty is string is returned upon error or if the
+  /// attribute is not present.
+  llvm::StringRef PeekDIEName(const DIERef &die_ref);
+
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
 eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 0e2f4d45543bb5..7db279ed37d04a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}
+
 DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
   ExtractUnitDIEIfNeeded();
   if (m_dwo)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 3f528e913d8cfa..bc225a52e1d030 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -187,6 +187,11 @@ class DWARFUnit : public UserID {
 
   DWARFDIE GetDIE(dw_offset_t die_offset);
 
+  /// Returns the AT_Name of the DIE at `die_offset`, if it exists, without
+  /// parsing the entire compile unit. An empty is string is returned upon
+  /// error or if the attribute is not present.
+  llvm::StringRef PeekDIEName(dw_offset_t die_offset);
+
   DWARFUnit &GetNonSkeletonUnit();
 
   static uint8_t GetAddressByteSize(const DWARFUnit *cu);
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 8497855b2f3db5..ff433c7a14ef7b 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "llvm/ADT/STLExtras.h"
 #include "gmock/gmock.h"
@@ -104,3 +105,61 @@ TEST(DWARFDIETest, ChildIteration) {
   DWARFDIE no_children_die(unit, die_child0);
   EXPECT_TRUE(no_children_die.children().empty());
 }
+
+TEST(DWARFDIETest, PeekName) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'NameType1'
+- 'NameType2'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   D

[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}

felipepiovezan wrote:

Actually, the current approach should take care of that already; we call 
`DWARFDebugInfoEntry::GetName`, whose implementation is:

```
const char *DWARFDebugInfoEntry::GetName(const DWARFUnit *cu) const {
  return GetAttributeValueAsString(cu, DW_AT_name, nullptr, true);
}
```

This is going to look through AT_specification and AT_abstract_origin.

I should still add a  test to verify this though!

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


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

2024-01-17 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Zahira Ammarguellat (zahiraam)


Changes

This patch fixes a bug in Smith's algorithm (thanks to @andykaylor who 
detected it) and makes sure that last option in command line rules.

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


4 Files Affected:

- (modified) clang/lib/CodeGen/CGExprComplex.cpp (+6-2) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+10-9) 
- (modified) clang/test/CodeGen/cx-complex-range.c (+16) 
- (modified) clang/test/Driver/range.c (+7) 


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

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

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

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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}

felipepiovezan wrote:

> One option here is to check if all of the DIEs have been already parsed in 
> the DWARFUnit and if so, grab the existing DIE, and if it hasn't been parsed 
> do this.

Correct me if I am wrong, but even if we take an already parsed DIE, won't we 
be doing the exact same thing? It eventually calls 
`DWARFDebugInfoEntry::GetAttributeValue`, which is a more complicated way of 
doing the above (but it still creates the extractor, etc...)


> This approach doesn't take care of cases where the current DIE doesn't have a 
> DW_AT_name, but it has a DW_AT_specification or DW_AT_abstract_origin

Oh great point, we need this for sure! I will update the implementation and add 
tests for it




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


[Lldb-commits] [lldb] [lldb][Format] Fix missing inlined function names in frame formatting. (PR #78494)

2024-01-17 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Zequan Wu (ZequanWu)


Changes

This fixes missing inlined function names when formatting frame and the `Block` 
in `SymbolContext` is a lexical block (e.g. `DW_TAG_lexical_block` in Dwarf).

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


5 Files Affected:

- (modified) lldb/source/Core/FormatEntity.cpp (+18-21) 
- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
(+1-1) 
- (modified) lldb/test/Shell/Settings/Inputs/names.cpp (+7-1) 
- (added) lldb/test/Shell/Settings/TestFrameFormatName.test (+55) 
- (removed) lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test (-26) 


``diff
diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 94986457552d949..b7fb1e06e75b9e9 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1093,6 +1093,20 @@ static void PrettyPrintFunctionNameWithArgs(Stream 
&out_stream,
 out_stream.PutChar(')');
 }
 
+static void FormatInlinedBlock(Stream &out_stream, Block *block) {
+  if (!block)
+return;
+  Block *inline_block = block->GetContainingInlinedBlock();
+  if (inline_block) {
+const InlineFunctionInfo *inline_info =
+inline_block->GetInlinedFunctionInfo();
+if (inline_info) {
+  out_stream.PutCString(" [inlined] ");
+  inline_info->GetName().Dump(&out_stream);
+}
+  }
+}
+
 bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream 
&s,
const SymbolContext *sc,
const ExecutionContext *exe_ctx,
@@ -1592,18 +1606,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 
   if (name) {
 s.PutCString(name);
-
-if (sc->block) {
-  Block *inline_block = sc->block->GetContainingInlinedBlock();
-  if (inline_block) {
-const InlineFunctionInfo *inline_info =
-sc->block->GetInlinedFunctionInfo();
-if (inline_info) {
-  s.PutCString(" [inlined] ");
-  inline_info->GetName().Dump(&s);
-}
-  }
-}
+FormatInlinedBlock(s, sc->block);
 return true;
   }
 }
@@ -1638,6 +1641,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 name = sc->symbol->GetNameNoArguments();
   if (name) {
 s.PutCString(name.GetCString());
+FormatInlinedBlock(s, sc->block);
 return true;
   }
 }
@@ -1678,7 +1682,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 
 if (inline_block) {
   get_function_vars = false;
-  inline_info = sc->block->GetInlinedFunctionInfo();
+  inline_info = inline_block->GetInlinedFunctionInfo();
   if (inline_info)
 variable_list_sp = inline_block->GetBlockVariableList(true);
 }
@@ -1733,14 +1737,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 if (!name)
   return false;
 s.PutCString(name);
-
-if (sc->block && sc->block->GetContainingInlinedBlock()) {
-  if (const InlineFunctionInfo *inline_info =
-  sc->block->GetInlinedFunctionInfo()) {
-s.PutCString(" [inlined] ");
-inline_info->GetName().Dump(&s);
-  }
-}
+FormatInlinedBlock(s, sc->block);
 return true;
   }
   case Entry::Type::FunctionAddrOffset:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 7131ccb9d05ecae..21c73e6361904e5 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1646,7 +1646,7 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
 
   if (inline_block) {
 get_function_vars = false;
-inline_info = sc->block->GetInlinedFunctionInfo();
+inline_info = inline_block->GetInlinedFunctionInfo();
 if (inline_info)
   variable_list_sp = inline_block->GetBlockVariableList(true);
   }
diff --git a/lldb/test/Shell/Settings/Inputs/names.cpp 
b/lldb/test/Shell/Settings/Inputs/names.cpp
index cf6982abb8f3546..79ff93be6b76ed3 100644
--- a/lldb/test/Shell/Settings/Inputs/names.cpp
+++ b/lldb/test/Shell/Settings/Inputs/names.cpp
@@ -26,6 +26,12 @@ int anon_bar() { return 1; }
 auto anon_lambda = [] {};
 } // namespace
 
+__attribute__((always_inline)) int inlined_foo(const char *str) {
+  if (bool b = bar())
+return 1;
+  return 2;
+}
+
 int main() {
   ns::foo(bar);
   ns::foo("bar");
@@ -37,6 +43,6 @@ int main() {
   f.foo(anon_bar);
   f.operator<< <(2 > 1)>(0);
   f.returns_func_ptr(detail::Quux{});
-
+  inlined_foo("bar");
   return 0;
 }
diff --git a/lldb/test/Shell/Settings/TestFrameFormatName.test 
b/lldb/test/Shell/Settings/TestFrameFormatName.test
new file mode 100644
index 0

[Lldb-commits] [lldb] [lldb][Format] Fix missing inlined function names in frame formatting. (PR #78494)

2024-01-17 Thread Zequan Wu via lldb-commits

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

This fixes missing inlined function names when formatting frame and the `Block` 
in `SymbolContext` is a lexical block (e.g. `DW_TAG_lexical_block` in Dwarf).

>From dbd04f25ccb37a18b316078df7817a603f007396 Mon Sep 17 00:00:00 2001
From: Zequan Wu 
Date: Wed, 17 Jan 2024 14:22:01 -0500
Subject: [PATCH 1/2] [lldb][Format] Fix missing inlined function names in
 frame formatting.

---
 lldb/source/Core/FormatEntity.cpp | 29 +++---
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  |  2 +-
 lldb/test/Shell/Settings/Inputs/names.cpp |  8 ++-
 .../Shell/Settings/TestFrameFormatName.test   | 55 +++
 .../Settings/TestFrameFormatNameWithArgs.test | 26 -
 5 files changed, 85 insertions(+), 35 deletions(-)
 create mode 100644 lldb/test/Shell/Settings/TestFrameFormatName.test
 delete mode 100644 lldb/test/Shell/Settings/TestFrameFormatNameWithArgs.test

diff --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 94986457552d949..d5adcb9d863f334 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1597,7 +1597,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
   Block *inline_block = sc->block->GetContainingInlinedBlock();
   if (inline_block) {
 const InlineFunctionInfo *inline_info =
-sc->block->GetInlinedFunctionInfo();
+inline_block->GetInlinedFunctionInfo();
 if (inline_info) {
   s.PutCString(" [inlined] ");
   inline_info->GetName().Dump(&s);
@@ -1638,6 +1638,17 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 name = sc->symbol->GetNameNoArguments();
   if (name) {
 s.PutCString(name.GetCString());
+if (sc->block) {
+  Block *inline_block = sc->block->GetContainingInlinedBlock();
+  if (inline_block) {
+const InlineFunctionInfo *inline_info =
+inline_block->GetInlinedFunctionInfo();
+if (inline_info) {
+  s.PutCString(" [inlined] ");
+  inline_info->GetName().Dump(&s);
+}
+  }
+}
 return true;
   }
 }
@@ -1678,7 +1689,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
 
 if (inline_block) {
   get_function_vars = false;
-  inline_info = sc->block->GetInlinedFunctionInfo();
+  inline_info = inline_block->GetInlinedFunctionInfo();
   if (inline_info)
 variable_list_sp = inline_block->GetBlockVariableList(true);
 }
@@ -1734,11 +1745,15 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
   return false;
 s.PutCString(name);
 
-if (sc->block && sc->block->GetContainingInlinedBlock()) {
-  if (const InlineFunctionInfo *inline_info =
-  sc->block->GetInlinedFunctionInfo()) {
-s.PutCString(" [inlined] ");
-inline_info->GetName().Dump(&s);
+if (sc->block) {
+  Block *inline_block = sc->block->GetContainingInlinedBlock();
+  if (inline_block) {
+const InlineFunctionInfo *inline_info =
+inline_block->GetInlinedFunctionInfo();
+if (inline_info) {
+  s.PutCString(" [inlined] ");
+  inline_info->GetName().Dump(&s);
+}
   }
 }
 return true;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 7131ccb9d05ecae..21c73e6361904e5 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1646,7 +1646,7 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
 
   if (inline_block) {
 get_function_vars = false;
-inline_info = sc->block->GetInlinedFunctionInfo();
+inline_info = inline_block->GetInlinedFunctionInfo();
 if (inline_info)
   variable_list_sp = inline_block->GetBlockVariableList(true);
   }
diff --git a/lldb/test/Shell/Settings/Inputs/names.cpp 
b/lldb/test/Shell/Settings/Inputs/names.cpp
index cf6982abb8f3546..79ff93be6b76ed3 100644
--- a/lldb/test/Shell/Settings/Inputs/names.cpp
+++ b/lldb/test/Shell/Settings/Inputs/names.cpp
@@ -26,6 +26,12 @@ int anon_bar() { return 1; }
 auto anon_lambda = [] {};
 } // namespace
 
+__attribute__((always_inline)) int inlined_foo(const char *str) {
+  if (bool b = bar())
+return 1;
+  return 2;
+}
+
 int main() {
   ns::foo(bar);
   ns::foo("bar");
@@ -37,6 +43,6 @@ int main() {
   f.foo(anon_bar);
   f.operator<< <(2 > 1)>(0);
   f.returns_func_ptr(detail::Quux{});
-
+  inlined_foo("bar");
   return 0;
 }
diff --git a/lldb/test/Shell/Settings/TestFrameFormatName.test 
b/lldb/test/Shell/Settings/TestFrameFormatName.test
new file mode 100644
index 000

[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

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

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


[Lldb-commits] [lldb] a451c3b - [lldb] Support changes to TLS on macOS (#77988)

2024-01-17 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-17T11:20:26-08:00
New Revision: a451c3b9e2124ba2875be678aaafde322057d575

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

LOG: [lldb] Support changes to TLS on macOS (#77988)

The TLS implementation on apple platforms has changed. Instead of
invoking pthread_getspecific with a pthread_key_t, we instead perform a
virtual function call.

Note: Some versions of Apple's new linker do not emit debug symbols for
TLS symbols. This causes the TLS tests to fail because LLDB and dsymutil
expects there to be debug symbols to resolve the relevant TLS block. You
may work around this by switching to the older linker (ld-classic) or by
disabling the TLS tests until you have a newer version of the new
linker.

rdar://120676969

Added: 


Modified: 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 1e3e2e5641ad835..33bb7f076848e17 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -1048,74 +1048,104 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 
   std::lock_guard guard(m_mutex);
 
+  lldb_private::Address tls_addr;
+  if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
+return LLDB_INVALID_ADDRESS;
+
+  Target &target = m_process->GetTarget();
+  TypeSystemClangSP scratch_ts_sp =
+  ScratchTypeSystemClang::GetForTarget(target);
+  if (!scratch_ts_sp)
+return LLDB_INVALID_ADDRESS;
+
+  CompilerType clang_void_ptr_type =
+  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
+
+  auto evaluate_tls_address = [this, &thread_sp, &clang_void_ptr_type](
+  Address func_ptr,
+  llvm::ArrayRef args) -> addr_t {
+EvaluateExpressionOptions options;
+
+lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
+*thread_sp, func_ptr, clang_void_ptr_type, args, options));
+
+DiagnosticManager execution_errors;
+ExecutionContext exe_ctx(thread_sp);
+lldb::ExpressionResults results = m_process->RunThreadPlan(
+exe_ctx, thread_plan_sp, options, execution_errors);
+
+if (results == lldb::eExpressionCompleted) {
+  if (lldb::ValueObjectSP result_valobj_sp =
+  thread_plan_sp->GetReturnValueObject()) {
+return result_valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+  }
+}
+return LLDB_INVALID_ADDRESS;
+  };
+
+  // On modern apple platforms, there is a small data structure that looks
+  // approximately like this:
+  // struct TLS_Thunk {
+  //  void *(*get_addr)(struct TLS_Thunk *);
+  //  size_t key;
+  //  size_t offset;
+  // }
+  //
+  // The strategy is to take get_addr, call it with the address of the
+  // containing TLS_Thunk structure, and add the offset to the resulting
+  // pointer to get the data block.
+  //
+  // On older apple platforms, the key is treated as a pthread_key_t and passed
+  // to pthread_getspecific. The pointer returned from that call is added to
+  // offset to get the relevant data block.
+
   const uint32_t addr_size = m_process->GetAddressByteSize();
-  uint8_t buf[sizeof(lldb::addr_t) * 3];
+  uint8_t buf[sizeof(addr_t) * 3];
+  Status error;
+  const size_t tls_data_size = addr_size * 3;
+  const size_t bytes_read = target.ReadMemory(
+  tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true);
+  if (bytes_read != tls_data_size || error.Fail())
+return LLDB_INVALID_ADDRESS;
 
-  lldb_private::Address tls_addr;
-  if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) {
-Status error;
-const size_t tsl_data_size = addr_size * 3;
-Target &target = m_process->GetTarget();
-if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) ==
-tsl_data_size) {
-  const ByteOrder byte_order = m_process->GetByteOrder();
-  DataExtractor data(buf, sizeof(buf), byte_order, addr_size);
-  lldb::offset_t offset = addr_size; // Skip the first pointer
-  const lldb::addr_t pthread_key = data.GetAddress(&offset);
-  const lldb::addr_t tls_offset = data.GetAddress(&offset);
-  if (pthread_key != 0) {
-// First check to see if we have already figured out the location of
-// TLS data for the pthread_key on a specific thread yet. If we have we
-// can re-use it since its location will not change unless the process
-// execs.
-const tid_t tid = thread_sp->GetID();
-auto tid_pos = m_tid_to_tls_map.find(tid);
-if (tid_p

[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

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

https://github.com/bulbazord updated 
https://github.com/llvm/llvm-project/pull/77988

>From cf2597f907fd2566e202d763a91834515d9c8ae4 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Fri, 12 Jan 2024 13:03:27 -0800
Subject: [PATCH 1/6] [lldb][NFCI] Re-organize
 DynamicLoaderDarwin::GetThreadLocalData

This is a small re-organization of GetThreadLocalData. This makes it
easier for me to add support for a newer way of getting thread local
data on apple platforms.
---
 .../MacOSX-DYLD/DynamicLoaderDarwin.cpp   | 120 +-
 1 file changed, 59 insertions(+), 61 deletions(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 1e3e2e5641ad83..2deb7663b42e02 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -1048,70 +1048,68 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 
   std::lock_guard guard(m_mutex);
 
+  lldb_private::Address tls_addr;
+  if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
+return LLDB_INVALID_ADDRESS;
+
   const uint32_t addr_size = m_process->GetAddressByteSize();
   uint8_t buf[sizeof(lldb::addr_t) * 3];
+  Status error;
+  const size_t tls_data_size = addr_size * 3;
+  Target &target = m_process->GetTarget();
+  const size_t bytes_read = target.ReadMemory(
+  tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true);
+  if (bytes_read != tls_data_size || error.Fail())
+return LLDB_INVALID_ADDRESS;
 
-  lldb_private::Address tls_addr;
-  if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) {
-Status error;
-const size_t tsl_data_size = addr_size * 3;
-Target &target = m_process->GetTarget();
-if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) ==
-tsl_data_size) {
-  const ByteOrder byte_order = m_process->GetByteOrder();
-  DataExtractor data(buf, sizeof(buf), byte_order, addr_size);
-  lldb::offset_t offset = addr_size; // Skip the first pointer
-  const lldb::addr_t pthread_key = data.GetAddress(&offset);
-  const lldb::addr_t tls_offset = data.GetAddress(&offset);
-  if (pthread_key != 0) {
-// First check to see if we have already figured out the location of
-// TLS data for the pthread_key on a specific thread yet. If we have we
-// can re-use it since its location will not change unless the process
-// execs.
-const tid_t tid = thread_sp->GetID();
-auto tid_pos = m_tid_to_tls_map.find(tid);
-if (tid_pos != m_tid_to_tls_map.end()) {
-  auto tls_pos = tid_pos->second.find(pthread_key);
-  if (tls_pos != tid_pos->second.end()) {
-return tls_pos->second + tls_offset;
-  }
-}
-StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
-if (frame_sp) {
-  TypeSystemClangSP scratch_ts_sp =
-  ScratchTypeSystemClang::GetForTarget(target);
-
-  if (!scratch_ts_sp)
-return LLDB_INVALID_ADDRESS;
-
-  CompilerType clang_void_ptr_type =
-  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
-  Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
-  if (pthread_getspecific_addr.IsValid()) {
-EvaluateExpressionOptions options;
-
-lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
-*thread_sp, pthread_getspecific_addr, clang_void_ptr_type,
-llvm::ArrayRef(pthread_key), options));
-
-DiagnosticManager execution_errors;
-ExecutionContext exe_ctx(thread_sp);
-lldb::ExpressionResults results = m_process->RunThreadPlan(
-exe_ctx, thread_plan_sp, options, execution_errors);
-
-if (results == lldb::eExpressionCompleted) {
-  lldb::ValueObjectSP result_valobj_sp =
-  thread_plan_sp->GetReturnValueObject();
-  if (result_valobj_sp) {
-const lldb::addr_t pthread_key_data =
-result_valobj_sp->GetValueAsUnsigned(0);
-if (pthread_key_data) {
-  m_tid_to_tls_map[tid].insert(
-  std::make_pair(pthread_key, pthread_key_data));
-  return pthread_key_data + tls_offset;
-}
-  }
-}
+  DataExtractor data(buf, sizeof(buf), m_process->GetByteOrder(), addr_size);
+  lldb::offset_t offset = addr_size; // Skip the first pointer
+  const lldb::addr_t pthread_key = data.GetAddress(&offset);
+  const lldb::addr_t tls_offset = data.GetAddress(&offset);
+  if (pthread_key != 0) {
+// First check to see if we have already figured out the location of
+// TLS data for the pthread_key on a specific thread yet. If we have we
+// ca

[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

2024-01-17 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 9f8c818141720c1bb69f9e023396a9aa0733ccf6 
cef8673c1d20203d5072571b898f1ef738b14fb4 -- 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 6f0eff5472..33bb7f0768 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -1141,8 +1141,8 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 }
 Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
 if (pthread_getspecific_addr.IsValid()) {
-  const addr_t tls_data = evaluate_tls_address(
-  pthread_getspecific_addr, llvm::ArrayRef(key));
+  const addr_t tls_data = evaluate_tls_address(pthread_getspecific_addr,
+   
llvm::ArrayRef(key));
   if (tls_data != LLDB_INVALID_ADDRESS)
 return tls_data + tls_offset;
 }

``




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


[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

2024-01-17 Thread Jason Molenda via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

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

https://github.com/bulbazord updated 
https://github.com/llvm/llvm-project/pull/77988

>From cf2597f907fd2566e202d763a91834515d9c8ae4 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Fri, 12 Jan 2024 13:03:27 -0800
Subject: [PATCH 1/5] [lldb][NFCI] Re-organize
 DynamicLoaderDarwin::GetThreadLocalData

This is a small re-organization of GetThreadLocalData. This makes it
easier for me to add support for a newer way of getting thread local
data on apple platforms.
---
 .../MacOSX-DYLD/DynamicLoaderDarwin.cpp   | 120 +-
 1 file changed, 59 insertions(+), 61 deletions(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 1e3e2e5641ad835..2deb7663b42e029 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -1048,70 +1048,68 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 
   std::lock_guard guard(m_mutex);
 
+  lldb_private::Address tls_addr;
+  if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
+return LLDB_INVALID_ADDRESS;
+
   const uint32_t addr_size = m_process->GetAddressByteSize();
   uint8_t buf[sizeof(lldb::addr_t) * 3];
+  Status error;
+  const size_t tls_data_size = addr_size * 3;
+  Target &target = m_process->GetTarget();
+  const size_t bytes_read = target.ReadMemory(
+  tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true);
+  if (bytes_read != tls_data_size || error.Fail())
+return LLDB_INVALID_ADDRESS;
 
-  lldb_private::Address tls_addr;
-  if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) {
-Status error;
-const size_t tsl_data_size = addr_size * 3;
-Target &target = m_process->GetTarget();
-if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) ==
-tsl_data_size) {
-  const ByteOrder byte_order = m_process->GetByteOrder();
-  DataExtractor data(buf, sizeof(buf), byte_order, addr_size);
-  lldb::offset_t offset = addr_size; // Skip the first pointer
-  const lldb::addr_t pthread_key = data.GetAddress(&offset);
-  const lldb::addr_t tls_offset = data.GetAddress(&offset);
-  if (pthread_key != 0) {
-// First check to see if we have already figured out the location of
-// TLS data for the pthread_key on a specific thread yet. If we have we
-// can re-use it since its location will not change unless the process
-// execs.
-const tid_t tid = thread_sp->GetID();
-auto tid_pos = m_tid_to_tls_map.find(tid);
-if (tid_pos != m_tid_to_tls_map.end()) {
-  auto tls_pos = tid_pos->second.find(pthread_key);
-  if (tls_pos != tid_pos->second.end()) {
-return tls_pos->second + tls_offset;
-  }
-}
-StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
-if (frame_sp) {
-  TypeSystemClangSP scratch_ts_sp =
-  ScratchTypeSystemClang::GetForTarget(target);
-
-  if (!scratch_ts_sp)
-return LLDB_INVALID_ADDRESS;
-
-  CompilerType clang_void_ptr_type =
-  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
-  Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
-  if (pthread_getspecific_addr.IsValid()) {
-EvaluateExpressionOptions options;
-
-lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
-*thread_sp, pthread_getspecific_addr, clang_void_ptr_type,
-llvm::ArrayRef(pthread_key), options));
-
-DiagnosticManager execution_errors;
-ExecutionContext exe_ctx(thread_sp);
-lldb::ExpressionResults results = m_process->RunThreadPlan(
-exe_ctx, thread_plan_sp, options, execution_errors);
-
-if (results == lldb::eExpressionCompleted) {
-  lldb::ValueObjectSP result_valobj_sp =
-  thread_plan_sp->GetReturnValueObject();
-  if (result_valobj_sp) {
-const lldb::addr_t pthread_key_data =
-result_valobj_sp->GetValueAsUnsigned(0);
-if (pthread_key_data) {
-  m_tid_to_tls_map[tid].insert(
-  std::make_pair(pthread_key, pthread_key_data));
-  return pthread_key_data + tls_offset;
-}
-  }
-}
+  DataExtractor data(buf, sizeof(buf), m_process->GetByteOrder(), addr_size);
+  lldb::offset_t offset = addr_size; // Skip the first pointer
+  const lldb::addr_t pthread_key = data.GetAddress(&offset);
+  const lldb::addr_t tls_offset = data.GetAddress(&offset);
+  if (pthread_key != 0) {
+// First check to see if we have already figured out the location of
+// TLS data for the pthread_key on a specific thread yet. If we have we
+// 

[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

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


@@ -1048,74 +1048,103 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 
   std::lock_guard guard(m_mutex);
 
+  lldb_private::Address tls_addr;
+  if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
+return LLDB_INVALID_ADDRESS;
+
+  Target &target = m_process->GetTarget();
+  TypeSystemClangSP scratch_ts_sp =
+  ScratchTypeSystemClang::GetForTarget(target);
+  if (!scratch_ts_sp)
+return LLDB_INVALID_ADDRESS;
+
+  CompilerType clang_void_ptr_type =
+  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
+
+  auto evaluate_tls_address = [this, &thread_sp, &clang_void_ptr_type](
+  Address func_ptr,
+  llvm::ArrayRef args) -> lldb::addr_t 
{
+EvaluateExpressionOptions options;
+
+lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
+*thread_sp, func_ptr, clang_void_ptr_type, args, options));
+
+DiagnosticManager execution_errors;
+ExecutionContext exe_ctx(thread_sp);
+lldb::ExpressionResults results = m_process->RunThreadPlan(
+exe_ctx, thread_plan_sp, options, execution_errors);
+
+if (results == lldb::eExpressionCompleted) {
+  if (lldb::ValueObjectSP result_valobj_sp =
+  thread_plan_sp->GetReturnValueObject()) {
+return result_valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+  }
+}
+return LLDB_INVALID_ADDRESS;
+  };
+
+  // On modern apple platforms, there is a small data structure that looks
+  // approximately like this:
+  // struct TLS_Thunk {
+  //  void *(*get_addr)(struct TLS_Thunk *);
+  //  size_t key;
+  //  size_t offset;
+  // }
+  //
+  // The strategy is to take get_addr, call it with the address of the
+  // containing TLS_Thunk structure, and add the offset to the resulting
+  // pointer to get the data block.
+  //
+  // On older apple platforms, the key is treated as a pthread_key_t and passed
+  // to pthread_getspecific. The pointer returned from that call is added to
+  // offset to get the relevant data block.
+
   const uint32_t addr_size = m_process->GetAddressByteSize();
   uint8_t buf[sizeof(lldb::addr_t) * 3];
+  Status error;
+  const size_t tls_data_size = addr_size * 3;
+  const size_t bytes_read = target.ReadMemory(
+  tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true);
+  if (bytes_read != tls_data_size || error.Fail())
+return LLDB_INVALID_ADDRESS;
 
-  lldb_private::Address tls_addr;
-  if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) {
-Status error;
-const size_t tsl_data_size = addr_size * 3;
-Target &target = m_process->GetTarget();
-if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) ==
-tsl_data_size) {
-  const ByteOrder byte_order = m_process->GetByteOrder();
-  DataExtractor data(buf, sizeof(buf), byte_order, addr_size);
-  lldb::offset_t offset = addr_size; // Skip the first pointer
-  const lldb::addr_t pthread_key = data.GetAddress(&offset);
-  const lldb::addr_t tls_offset = data.GetAddress(&offset);
-  if (pthread_key != 0) {
-// First check to see if we have already figured out the location of
-// TLS data for the pthread_key on a specific thread yet. If we have we
-// can re-use it since its location will not change unless the process
-// execs.
-const tid_t tid = thread_sp->GetID();
-auto tid_pos = m_tid_to_tls_map.find(tid);
-if (tid_pos != m_tid_to_tls_map.end()) {
-  auto tls_pos = tid_pos->second.find(pthread_key);
-  if (tls_pos != tid_pos->second.end()) {
-return tls_pos->second + tls_offset;
-  }
-}
-StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
-if (frame_sp) {
-  TypeSystemClangSP scratch_ts_sp =
-  ScratchTypeSystemClang::GetForTarget(target);
-
-  if (!scratch_ts_sp)
-return LLDB_INVALID_ADDRESS;
-
-  CompilerType clang_void_ptr_type =
-  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
-  Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
-  if (pthread_getspecific_addr.IsValid()) {
-EvaluateExpressionOptions options;
-
-lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
-*thread_sp, pthread_getspecific_addr, clang_void_ptr_type,
-llvm::ArrayRef(pthread_key), options));
-
-DiagnosticManager execution_errors;
-ExecutionContext exe_ctx(thread_sp);
-lldb::ExpressionResults results = m_process->RunThreadPlan(
-exe_ctx, thread_plan_sp, options, execution_errors);
-
-if (results == lldb::eExpressionCompleted) {
-  lldb::ValueObjectSP result_valobj_sp =
-  thread_plan_sp->GetReturnValueObject();
-  if (result_valobj_sp) {
- 

[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

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

https://github.com/bulbazord updated 
https://github.com/llvm/llvm-project/pull/77988

>From cf2597f907fd2566e202d763a91834515d9c8ae4 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Fri, 12 Jan 2024 13:03:27 -0800
Subject: [PATCH 1/4] [lldb][NFCI] Re-organize
 DynamicLoaderDarwin::GetThreadLocalData

This is a small re-organization of GetThreadLocalData. This makes it
easier for me to add support for a newer way of getting thread local
data on apple platforms.
---
 .../MacOSX-DYLD/DynamicLoaderDarwin.cpp   | 120 +-
 1 file changed, 59 insertions(+), 61 deletions(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 1e3e2e5641ad83..2deb7663b42e02 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -1048,70 +1048,68 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 
   std::lock_guard guard(m_mutex);
 
+  lldb_private::Address tls_addr;
+  if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
+return LLDB_INVALID_ADDRESS;
+
   const uint32_t addr_size = m_process->GetAddressByteSize();
   uint8_t buf[sizeof(lldb::addr_t) * 3];
+  Status error;
+  const size_t tls_data_size = addr_size * 3;
+  Target &target = m_process->GetTarget();
+  const size_t bytes_read = target.ReadMemory(
+  tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true);
+  if (bytes_read != tls_data_size || error.Fail())
+return LLDB_INVALID_ADDRESS;
 
-  lldb_private::Address tls_addr;
-  if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) {
-Status error;
-const size_t tsl_data_size = addr_size * 3;
-Target &target = m_process->GetTarget();
-if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) ==
-tsl_data_size) {
-  const ByteOrder byte_order = m_process->GetByteOrder();
-  DataExtractor data(buf, sizeof(buf), byte_order, addr_size);
-  lldb::offset_t offset = addr_size; // Skip the first pointer
-  const lldb::addr_t pthread_key = data.GetAddress(&offset);
-  const lldb::addr_t tls_offset = data.GetAddress(&offset);
-  if (pthread_key != 0) {
-// First check to see if we have already figured out the location of
-// TLS data for the pthread_key on a specific thread yet. If we have we
-// can re-use it since its location will not change unless the process
-// execs.
-const tid_t tid = thread_sp->GetID();
-auto tid_pos = m_tid_to_tls_map.find(tid);
-if (tid_pos != m_tid_to_tls_map.end()) {
-  auto tls_pos = tid_pos->second.find(pthread_key);
-  if (tls_pos != tid_pos->second.end()) {
-return tls_pos->second + tls_offset;
-  }
-}
-StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
-if (frame_sp) {
-  TypeSystemClangSP scratch_ts_sp =
-  ScratchTypeSystemClang::GetForTarget(target);
-
-  if (!scratch_ts_sp)
-return LLDB_INVALID_ADDRESS;
-
-  CompilerType clang_void_ptr_type =
-  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
-  Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
-  if (pthread_getspecific_addr.IsValid()) {
-EvaluateExpressionOptions options;
-
-lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
-*thread_sp, pthread_getspecific_addr, clang_void_ptr_type,
-llvm::ArrayRef(pthread_key), options));
-
-DiagnosticManager execution_errors;
-ExecutionContext exe_ctx(thread_sp);
-lldb::ExpressionResults results = m_process->RunThreadPlan(
-exe_ctx, thread_plan_sp, options, execution_errors);
-
-if (results == lldb::eExpressionCompleted) {
-  lldb::ValueObjectSP result_valobj_sp =
-  thread_plan_sp->GetReturnValueObject();
-  if (result_valobj_sp) {
-const lldb::addr_t pthread_key_data =
-result_valobj_sp->GetValueAsUnsigned(0);
-if (pthread_key_data) {
-  m_tid_to_tls_map[tid].insert(
-  std::make_pair(pthread_key, pthread_key_data));
-  return pthread_key_data + tls_offset;
-}
-  }
-}
+  DataExtractor data(buf, sizeof(buf), m_process->GetByteOrder(), addr_size);
+  lldb::offset_t offset = addr_size; // Skip the first pointer
+  const lldb::addr_t pthread_key = data.GetAddress(&offset);
+  const lldb::addr_t tls_offset = data.GetAddress(&offset);
+  if (pthread_key != 0) {
+// First check to see if we have already figured out the location of
+// TLS data for the pthread_key on a specific thread yet. If we have we
+// ca

[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

2024-01-17 Thread Jason Molenda via lldb-commits


@@ -1048,74 +1048,103 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 
   std::lock_guard guard(m_mutex);
 
+  lldb_private::Address tls_addr;
+  if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
+return LLDB_INVALID_ADDRESS;
+
+  Target &target = m_process->GetTarget();
+  TypeSystemClangSP scratch_ts_sp =
+  ScratchTypeSystemClang::GetForTarget(target);
+  if (!scratch_ts_sp)
+return LLDB_INVALID_ADDRESS;
+
+  CompilerType clang_void_ptr_type =
+  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
+
+  auto evaluate_tls_address = [this, &thread_sp, &clang_void_ptr_type](
+  Address func_ptr,
+  llvm::ArrayRef args) -> lldb::addr_t 
{
+EvaluateExpressionOptions options;
+
+lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
+*thread_sp, func_ptr, clang_void_ptr_type, args, options));
+
+DiagnosticManager execution_errors;
+ExecutionContext exe_ctx(thread_sp);
+lldb::ExpressionResults results = m_process->RunThreadPlan(
+exe_ctx, thread_plan_sp, options, execution_errors);
+
+if (results == lldb::eExpressionCompleted) {
+  if (lldb::ValueObjectSP result_valobj_sp =
+  thread_plan_sp->GetReturnValueObject()) {
+return result_valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+  }
+}
+return LLDB_INVALID_ADDRESS;
+  };
+
+  // On modern apple platforms, there is a small data structure that looks
+  // approximately like this:
+  // struct TLS_Thunk {
+  //  void *(*get_addr)(struct TLS_Thunk *);
+  //  size_t key;
+  //  size_t offset;
+  // }
+  //
+  // The strategy is to take get_addr, call it with the address of the
+  // containing TLS_Thunk structure, and add the offset to the resulting
+  // pointer to get the data block.
+  //
+  // On older apple platforms, the key is treated as a pthread_key_t and passed
+  // to pthread_getspecific. The pointer returned from that call is added to
+  // offset to get the relevant data block.
+
   const uint32_t addr_size = m_process->GetAddressByteSize();
   uint8_t buf[sizeof(lldb::addr_t) * 3];
+  Status error;
+  const size_t tls_data_size = addr_size * 3;
+  const size_t bytes_read = target.ReadMemory(
+  tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true);
+  if (bytes_read != tls_data_size || error.Fail())
+return LLDB_INVALID_ADDRESS;
 
-  lldb_private::Address tls_addr;
-  if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) {
-Status error;
-const size_t tsl_data_size = addr_size * 3;
-Target &target = m_process->GetTarget();
-if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) ==
-tsl_data_size) {
-  const ByteOrder byte_order = m_process->GetByteOrder();
-  DataExtractor data(buf, sizeof(buf), byte_order, addr_size);
-  lldb::offset_t offset = addr_size; // Skip the first pointer
-  const lldb::addr_t pthread_key = data.GetAddress(&offset);
-  const lldb::addr_t tls_offset = data.GetAddress(&offset);
-  if (pthread_key != 0) {
-// First check to see if we have already figured out the location of
-// TLS data for the pthread_key on a specific thread yet. If we have we
-// can re-use it since its location will not change unless the process
-// execs.
-const tid_t tid = thread_sp->GetID();
-auto tid_pos = m_tid_to_tls_map.find(tid);
-if (tid_pos != m_tid_to_tls_map.end()) {
-  auto tls_pos = tid_pos->second.find(pthread_key);
-  if (tls_pos != tid_pos->second.end()) {
-return tls_pos->second + tls_offset;
-  }
-}
-StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
-if (frame_sp) {
-  TypeSystemClangSP scratch_ts_sp =
-  ScratchTypeSystemClang::GetForTarget(target);
-
-  if (!scratch_ts_sp)
-return LLDB_INVALID_ADDRESS;
-
-  CompilerType clang_void_ptr_type =
-  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
-  Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
-  if (pthread_getspecific_addr.IsValid()) {
-EvaluateExpressionOptions options;
-
-lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
-*thread_sp, pthread_getspecific_addr, clang_void_ptr_type,
-llvm::ArrayRef(pthread_key), options));
-
-DiagnosticManager execution_errors;
-ExecutionContext exe_ctx(thread_sp);
-lldb::ExpressionResults results = m_process->RunThreadPlan(
-exe_ctx, thread_plan_sp, options, execution_errors);
-
-if (results == lldb::eExpressionCompleted) {
-  lldb::ValueObjectSP result_valobj_sp =
-  thread_plan_sp->GetReturnValueObject();
-  if (result_valobj_sp) {
- 

[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

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


@@ -104,3 +105,61 @@ TEST(DWARFDIETest, ChildIteration) {
   DWARFDIE no_children_die(unit, die_child0);
   EXPECT_TRUE(no_children_die.children().empty());
 }
+
+TEST(DWARFDIETest, PeekName) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:

clayborg wrote:

This test could be improved to handle the `DW_AT_specification` and 
`DW_AT_abstract_origin` case I mentioned above.

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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

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


@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}

clayborg wrote:

One option here is to check if all of the DIEs have been already parsed in the 
DWARFUnit and if so, grab the existing DIE, and if it hasn't been parsed do 
this. 

This approach doesn't take care of cases where the current DIE doesn't have a 
`DW_AT_name`, but it has a `DW_AT_specification` or `DW_AT_abstract_origin` 
attribute that points to another DIE that does have a name. In this case we 
will get no name back from this function because it doesn't recurse into the 
`DW_AT_specification` or `DW_AT_abstract_origin` die.

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


[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

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


@@ -1048,74 +1048,103 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 
   std::lock_guard guard(m_mutex);
 
+  lldb_private::Address tls_addr;
+  if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
+return LLDB_INVALID_ADDRESS;
+
+  Target &target = m_process->GetTarget();
+  TypeSystemClangSP scratch_ts_sp =
+  ScratchTypeSystemClang::GetForTarget(target);
+  if (!scratch_ts_sp)
+return LLDB_INVALID_ADDRESS;
+
+  CompilerType clang_void_ptr_type =
+  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
+
+  auto evaluate_tls_address = [this, &thread_sp, &clang_void_ptr_type](
+  Address func_ptr,
+  llvm::ArrayRef args) -> lldb::addr_t 
{
+EvaluateExpressionOptions options;
+
+lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
+*thread_sp, func_ptr, clang_void_ptr_type, args, options));
+
+DiagnosticManager execution_errors;
+ExecutionContext exe_ctx(thread_sp);
+lldb::ExpressionResults results = m_process->RunThreadPlan(
+exe_ctx, thread_plan_sp, options, execution_errors);
+
+if (results == lldb::eExpressionCompleted) {
+  if (lldb::ValueObjectSP result_valobj_sp =
+  thread_plan_sp->GetReturnValueObject()) {
+return result_valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+  }
+}
+return LLDB_INVALID_ADDRESS;
+  };
+
+  // On modern apple platforms, there is a small data structure that looks
+  // approximately like this:
+  // struct TLS_Thunk {
+  //  void *(*get_addr)(struct TLS_Thunk *);
+  //  size_t key;
+  //  size_t offset;
+  // }
+  //
+  // The strategy is to take get_addr, call it with the address of the
+  // containing TLS_Thunk structure, and add the offset to the resulting
+  // pointer to get the data block.
+  //
+  // On older apple platforms, the key is treated as a pthread_key_t and passed
+  // to pthread_getspecific. The pointer returned from that call is added to
+  // offset to get the relevant data block.
+
   const uint32_t addr_size = m_process->GetAddressByteSize();
   uint8_t buf[sizeof(lldb::addr_t) * 3];
+  Status error;
+  const size_t tls_data_size = addr_size * 3;
+  const size_t bytes_read = target.ReadMemory(
+  tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true);
+  if (bytes_read != tls_data_size || error.Fail())
+return LLDB_INVALID_ADDRESS;
 
-  lldb_private::Address tls_addr;
-  if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) {
-Status error;
-const size_t tsl_data_size = addr_size * 3;
-Target &target = m_process->GetTarget();
-if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) ==
-tsl_data_size) {
-  const ByteOrder byte_order = m_process->GetByteOrder();
-  DataExtractor data(buf, sizeof(buf), byte_order, addr_size);
-  lldb::offset_t offset = addr_size; // Skip the first pointer
-  const lldb::addr_t pthread_key = data.GetAddress(&offset);
-  const lldb::addr_t tls_offset = data.GetAddress(&offset);
-  if (pthread_key != 0) {
-// First check to see if we have already figured out the location of
-// TLS data for the pthread_key on a specific thread yet. If we have we
-// can re-use it since its location will not change unless the process
-// execs.
-const tid_t tid = thread_sp->GetID();
-auto tid_pos = m_tid_to_tls_map.find(tid);
-if (tid_pos != m_tid_to_tls_map.end()) {
-  auto tls_pos = tid_pos->second.find(pthread_key);
-  if (tls_pos != tid_pos->second.end()) {
-return tls_pos->second + tls_offset;
-  }
-}
-StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
-if (frame_sp) {
-  TypeSystemClangSP scratch_ts_sp =
-  ScratchTypeSystemClang::GetForTarget(target);
-
-  if (!scratch_ts_sp)
-return LLDB_INVALID_ADDRESS;
-
-  CompilerType clang_void_ptr_type =
-  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
-  Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
-  if (pthread_getspecific_addr.IsValid()) {
-EvaluateExpressionOptions options;
-
-lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
-*thread_sp, pthread_getspecific_addr, clang_void_ptr_type,
-llvm::ArrayRef(pthread_key), options));
-
-DiagnosticManager execution_errors;
-ExecutionContext exe_ctx(thread_sp);
-lldb::ExpressionResults results = m_process->RunThreadPlan(
-exe_ctx, thread_plan_sp, options, execution_errors);
-
-if (results == lldb::eExpressionCompleted) {
-  lldb::ValueObjectSP result_valobj_sp =
-  thread_plan_sp->GetReturnValueObject();
-  if (result_valobj_sp) {
- 

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

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


@@ -2780,24 +2781,24 @@ static void RenderFloatingPointOptions(const ToolChain 
&TC, const Driver &D,
 case options::OPT_fcx_limited_range: {
   EmitComplexRangeDiag(D, Range, 
LangOptions::ComplexRangeKind::CX_Limited);
   Range = LangOptions::ComplexRangeKind::CX_Limited;
-  std::string ComplexRangeStr = RenderComplexRangeOption("limited");
-  if (!ComplexRangeStr.empty())
-CmdArgs.push_back(Args.MakeArgString(ComplexRangeStr));
+  ComplexRangeStr = RenderComplexRangeOption("limited");

andykaylor wrote:

I think it would be better to move the rendering of this option to the bottom 
of this function (around line 3124) to avoid inserting multiple, conflicting 
options if more than one -f[no-]cx-* option is used.

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


[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

2024-01-17 Thread Jason Molenda via lldb-commits


@@ -1048,74 +1048,103 @@ DynamicLoaderDarwin::GetThreadLocalData(const 
lldb::ModuleSP module_sp,
 
   std::lock_guard guard(m_mutex);
 
+  lldb_private::Address tls_addr;
+  if (!module_sp->ResolveFileAddress(tls_file_addr, tls_addr))
+return LLDB_INVALID_ADDRESS;
+
+  Target &target = m_process->GetTarget();
+  TypeSystemClangSP scratch_ts_sp =
+  ScratchTypeSystemClang::GetForTarget(target);
+  if (!scratch_ts_sp)
+return LLDB_INVALID_ADDRESS;
+
+  CompilerType clang_void_ptr_type =
+  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
+
+  auto evaluate_tls_address = [this, &thread_sp, &clang_void_ptr_type](
+  Address func_ptr,
+  llvm::ArrayRef args) -> lldb::addr_t 
{
+EvaluateExpressionOptions options;
+
+lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
+*thread_sp, func_ptr, clang_void_ptr_type, args, options));
+
+DiagnosticManager execution_errors;
+ExecutionContext exe_ctx(thread_sp);
+lldb::ExpressionResults results = m_process->RunThreadPlan(
+exe_ctx, thread_plan_sp, options, execution_errors);
+
+if (results == lldb::eExpressionCompleted) {
+  if (lldb::ValueObjectSP result_valobj_sp =
+  thread_plan_sp->GetReturnValueObject()) {
+return result_valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
+  }
+}
+return LLDB_INVALID_ADDRESS;
+  };
+
+  // On modern apple platforms, there is a small data structure that looks
+  // approximately like this:
+  // struct TLS_Thunk {
+  //  void *(*get_addr)(struct TLS_Thunk *);
+  //  size_t key;
+  //  size_t offset;
+  // }
+  //
+  // The strategy is to take get_addr, call it with the address of the
+  // containing TLS_Thunk structure, and add the offset to the resulting
+  // pointer to get the data block.
+  //
+  // On older apple platforms, the key is treated as a pthread_key_t and passed
+  // to pthread_getspecific. The pointer returned from that call is added to
+  // offset to get the relevant data block.
+
   const uint32_t addr_size = m_process->GetAddressByteSize();
   uint8_t buf[sizeof(lldb::addr_t) * 3];
+  Status error;
+  const size_t tls_data_size = addr_size * 3;
+  const size_t bytes_read = target.ReadMemory(
+  tls_addr, buf, tls_data_size, error, /*force_live_memory = */ true);
+  if (bytes_read != tls_data_size || error.Fail())
+return LLDB_INVALID_ADDRESS;
 
-  lldb_private::Address tls_addr;
-  if (module_sp->ResolveFileAddress(tls_file_addr, tls_addr)) {
-Status error;
-const size_t tsl_data_size = addr_size * 3;
-Target &target = m_process->GetTarget();
-if (target.ReadMemory(tls_addr, buf, tsl_data_size, error, true) ==
-tsl_data_size) {
-  const ByteOrder byte_order = m_process->GetByteOrder();
-  DataExtractor data(buf, sizeof(buf), byte_order, addr_size);
-  lldb::offset_t offset = addr_size; // Skip the first pointer
-  const lldb::addr_t pthread_key = data.GetAddress(&offset);
-  const lldb::addr_t tls_offset = data.GetAddress(&offset);
-  if (pthread_key != 0) {
-// First check to see if we have already figured out the location of
-// TLS data for the pthread_key on a specific thread yet. If we have we
-// can re-use it since its location will not change unless the process
-// execs.
-const tid_t tid = thread_sp->GetID();
-auto tid_pos = m_tid_to_tls_map.find(tid);
-if (tid_pos != m_tid_to_tls_map.end()) {
-  auto tls_pos = tid_pos->second.find(pthread_key);
-  if (tls_pos != tid_pos->second.end()) {
-return tls_pos->second + tls_offset;
-  }
-}
-StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
-if (frame_sp) {
-  TypeSystemClangSP scratch_ts_sp =
-  ScratchTypeSystemClang::GetForTarget(target);
-
-  if (!scratch_ts_sp)
-return LLDB_INVALID_ADDRESS;
-
-  CompilerType clang_void_ptr_type =
-  scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
-  Address pthread_getspecific_addr = GetPthreadSetSpecificAddress();
-  if (pthread_getspecific_addr.IsValid()) {
-EvaluateExpressionOptions options;
-
-lldb::ThreadPlanSP thread_plan_sp(new ThreadPlanCallFunction(
-*thread_sp, pthread_getspecific_addr, clang_void_ptr_type,
-llvm::ArrayRef(pthread_key), options));
-
-DiagnosticManager execution_errors;
-ExecutionContext exe_ctx(thread_sp);
-lldb::ExpressionResults results = m_process->RunThreadPlan(
-exe_ctx, thread_plan_sp, options, execution_errors);
-
-if (results == lldb::eExpressionCompleted) {
-  lldb::ValueObjectSP result_valobj_sp =
-  thread_plan_sp->GetReturnValueObject();
-  if (result_valobj_sp) {
- 

[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 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 2d5cc1c9b3c8b8b7cd0ed9dec79489940161d73a 
b0a33481162e24a7106cbd554b33ddb098df7612 -- 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 775b7a2e73..340b9acf80 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -192,9 +192,8 @@ DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
   return DWARFDIE(); // Not found
 }
 
-llvm::StringRef
-DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) {
-  if(DWARFUnit *cu = GetUnit(die_ref))
+llvm::StringRef DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) {
+  if (DWARFUnit *cu = GetUnit(die_ref))
 return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset());
   return llvm::StringRef();
 }

``




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


[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan updated 
https://github.com/llvm/llvm-project/pull/78486

>From b0a33481162e24a7106cbd554b33ddb098df7612 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 11:26:52 -0800
Subject: [PATCH] [lldb][DWARFUnit] Implement PeekDIEName query

This allows us to query the AT_Name of a DIE without parsing the entire CU.

Part of the ongoing effort to support IDX_Parent in accelerator tables [1].

[1]: 
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44
---
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   |  7 +++
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  5 ++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|  8 +++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  5 ++
 .../SymbolFile/DWARF/DWARFDIETest.cpp | 59 +++
 5 files changed, 84 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 553b6a4c551d20..775b7a2e73f512 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -191,3 +191,10 @@ DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
 return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
   return DWARFDIE(); // Not found
 }
+
+llvm::StringRef
+DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) {
+  if(DWARFUnit *cu = GetUnit(die_ref))
+return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset());
+  return llvm::StringRef();
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index d5e48f312ea0e9..a8b5abc3beed2d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -43,6 +43,11 @@ class DWARFDebugInfo {
   bool ContainsTypeUnits();
   DWARFDIE GetDIE(const DIERef &die_ref);
 
+  /// Returns the AT_Name of this DIE, if it exists, without parsing the entire
+  /// compile unit. An empty is string is returned upon error or if the
+  /// attribute is not present.
+  llvm::StringRef PeekDIEName(const DIERef &die_ref);
+
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
 eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 0e2f4d45543bb5..7db279ed37d04a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}
+
 DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
   ExtractUnitDIEIfNeeded();
   if (m_dwo)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 3f528e913d8cfa..bc225a52e1d030 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -187,6 +187,11 @@ class DWARFUnit : public UserID {
 
   DWARFDIE GetDIE(dw_offset_t die_offset);
 
+  /// Returns the AT_Name of the DIE at `die_offset`, if it exists, without
+  /// parsing the entire compile unit. An empty is string is returned upon
+  /// error or if the attribute is not present.
+  llvm::StringRef PeekDIEName(dw_offset_t die_offset);
+
   DWARFUnit &GetNonSkeletonUnit();
 
   static uint8_t GetAddressByteSize(const DWARFUnit *cu);
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 8497855b2f3db5..ff433c7a14ef7b 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "llvm/ADT/STLExtras.h"
 #include "gmock/gmock.h"
@@ -104,3 +105,61 @@ TEST(DWARFDIETest, ChildIteration) {
   DWARFDIE no_children_die(unit, die_child0);
   EXPECT_TRUE(no_children_die.children().empty());
 }
+
+TEST(DWARFDIETest, PeekName) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'NameType1'
+- 'NameType2'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT

[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Felipe de Azevedo Piovezan (felipepiovezan)


Changes

This allows us to query the AT_Name of a DIE without parsing the entire CU.

Part of the ongoing effort to support IDX_Parent in accelerator tables [1].

[1]: 
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44

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


5 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (+7) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h (+5) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (+8) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h (+5) 
- (modified) lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp (+58) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 553b6a4c551d20..775b7a2e73f512 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -191,3 +191,10 @@ DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
 return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
   return DWARFDIE(); // Not found
 }
+
+llvm::StringRef
+DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) {
+  if(DWARFUnit *cu = GetUnit(die_ref))
+return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset());
+  return llvm::StringRef();
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index d5e48f312ea0e9..a8b5abc3beed2d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -43,6 +43,11 @@ class DWARFDebugInfo {
   bool ContainsTypeUnits();
   DWARFDIE GetDIE(const DIERef &die_ref);
 
+  /// Returns the AT_Name of this DIE, if it exists, without parsing the entire
+  /// compile unit. An empty is string is returned upon error or if the
+  /// attribute is not present.
+  llvm::StringRef PeekDIEName(const DIERef &die_ref);
+
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
 eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 0e2f4d45543bb5..7db279ed37d04a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}
+
 DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
   ExtractUnitDIEIfNeeded();
   if (m_dwo)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 3f528e913d8cfa..bc225a52e1d030 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -187,6 +187,11 @@ class DWARFUnit : public UserID {
 
   DWARFDIE GetDIE(dw_offset_t die_offset);
 
+  /// Returns the AT_Name of the DIE at `die_offset`, if it exists, without
+  /// parsing the entire compile unit. An empty is string is returned upon
+  /// error or if the attribute is not present.
+  llvm::StringRef PeekDIEName(dw_offset_t die_offset);
+
   DWARFUnit &GetNonSkeletonUnit();
 
   static uint8_t GetAddressByteSize(const DWARFUnit *cu);
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 8497855b2f3db5..074873b65bc8dd 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "llvm/ADT/STLExtras.h"
 #include "gmock/gmock.h"
@@ -104,3 +105,60 @@ TEST(DWARFDIETest, ChildIteration) {
   DWARFDIE no_children_die(unit, die_child0);
   EXPECT_TRUE(no_children_die.children().empty());
 }
+
+TEST(DWARFDIETest, PeekName) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'NameType1'
+- 'NameType2'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+ 

[Lldb-commits] [lldb] [lldb][DWARFUnit] Implement PeekDIEName query (PR #78486)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan created 
https://github.com/llvm/llvm-project/pull/78486

This allows us to query the AT_Name of a DIE without parsing the entire CU.

Part of the ongoing effort to support IDX_Parent in accelerator tables [1].

[1]: 
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44

>From 0bfe58000b8d643efde8b84a6f80fc25dd48d48d Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Thu, 7 Dec 2023 11:26:52 -0800
Subject: [PATCH] [lldb][DWARFUnit] Implement PeekDIEName query

This allows us to query the AT_Name of a DIE without parsing the entire CU.

Part of the ongoing effort to support IDX_Parent in accelerator tables [1].

[1]: 
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44
---
 .../SymbolFile/DWARF/DWARFDebugInfo.cpp   |  7 +++
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h |  5 ++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|  8 +++
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  5 ++
 .../SymbolFile/DWARF/DWARFDIETest.cpp | 58 +++
 5 files changed, 83 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 553b6a4c551d205..775b7a2e73f512f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -191,3 +191,10 @@ DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
 return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
   return DWARFDIE(); // Not found
 }
+
+llvm::StringRef
+DWARFDebugInfo::PeekDIEName(const DIERef &die_ref) {
+  if(DWARFUnit *cu = GetUnit(die_ref))
+return cu->GetNonSkeletonUnit().PeekDIEName(die_ref.die_offset());
+  return llvm::StringRef();
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index d5e48f312ea0e98..a8b5abc3beed2d0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -43,6 +43,11 @@ class DWARFDebugInfo {
   bool ContainsTypeUnits();
   DWARFDIE GetDIE(const DIERef &die_ref);
 
+  /// Returns the AT_Name of this DIE, if it exists, without parsing the entire
+  /// compile unit. An empty is string is returned upon error or if the
+  /// attribute is not present.
+  llvm::StringRef PeekDIEName(const DIERef &die_ref);
+
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
 eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 0e2f4d45543bb53..7db279ed37d04aa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -663,6 +663,14 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
   return DWARFDIE(); // Not found
 }
 
+llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
+  const DWARFDataExtractor &data = GetData();
+  DWARFDebugInfoEntry die;
+  if (!die.Extract(data, this, &die_offset))
+return llvm::StringRef();
+  return die.GetName(this);
+}
+
 DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
   ExtractUnitDIEIfNeeded();
   if (m_dwo)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 3f528e913d8cfab..bc225a52e1d0309 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -187,6 +187,11 @@ class DWARFUnit : public UserID {
 
   DWARFDIE GetDIE(dw_offset_t die_offset);
 
+  /// Returns the AT_Name of the DIE at `die_offset`, if it exists, without
+  /// parsing the entire compile unit. An empty is string is returned upon
+  /// error or if the attribute is not present.
+  llvm::StringRef PeekDIEName(dw_offset_t die_offset);
+
   DWARFUnit &GetNonSkeletonUnit();
 
   static uint8_t GetAddressByteSize(const DWARFUnit *cu);
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 8497855b2f3db59..074873b65bc8dd4 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "llvm/ADT/STLExtras.h"
 #include "gmock/gmock.h"
@@ -104,3 +105,60 @@ TEST(DWARFDIETest, ChildIteration) {
   DWARFDIE no_children_die(unit, die_child0);
   EXPECT_TRUE(no_children_die.children().empty());
 }
+
+TEST(DWARFDIETest, PeekName) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debu

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

2024-01-17 Thread John McCall via lldb-commits

https://github.com/rjmccall commented:

It's bad that we don't have a IR test that breaks when you change the IR output 
like this.  Please add one.

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


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

2024-01-17 Thread John McCall via lldb-commits


@@ -978,7 +978,11 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const 
BinOpInfo &Op) {
   return EmitRangeReductionDiv(LHSr, LHSi, RHSr, RHSi);
 else if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Limited)
   return EmitAlgebraicDiv(LHSr, LHSi, RHSr, RHSi);
-else if (!CGF.getLangOpts().FastMath) {
+else if (!CGF.getLangOpts().FastMath ||
+ // '-ffast-math' is used in the command line but followed by an
+ // '-fno-cx-limited-range'.
+ (CGF.getLangOpts().FastMath &&
+  Op.FPFeatures.getComplexRange() == LangOptions::CX_Full)) {

rjmccall wrote:

`FastMath` is tautologically true here.

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


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

2024-01-17 Thread John McCall via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

2024-01-17 Thread Felipe de Azevedo Piovezan via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Support changes to TLS on macOS (PR #77988)

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

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

LGTM. Thanks for breaking this up! 

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


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

2024-01-17 Thread Stanislav Mekhanoshin via lldb-commits

rampitec wrote:

> > lgtm, but can still fix the -O0 thing
> 
> But where do I get TM in the getAnalysisUsage?

Found addUsedIfAvailable() which does the trick.

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] [libcxx] [llvm] [lld] [compiler-rt] [clang-tools-extra] [clang] [libc] [lldb] [flang] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2024-01-17 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 01/13] [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

[Lldb-commits] [lldb] [clang] [clang] Upstream XROS support in Clang (PR #78392)

2024-01-17 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 5aea6ba8f5f06e06887fe5c5c8740895907f6540 
868dd57be1d046d2f66823662bca10323aec05a3 -- clang/test/Driver/xros-driver.c 
clang/test/Frontend/xros-version.c 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.cpp 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.h 
clang/lib/Basic/Targets/OSTargets.h clang/lib/CodeGen/CGObjC.cpp 
clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/lib/Driver/ToolChains/Darwin.cpp 
clang/lib/Driver/ToolChains/Darwin.h 
clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp 
lldb/include/lldb/Utility/XcodeSDK.h 
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp 
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp 
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h
 lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp 
lldb/source/Utility/XcodeSDK.cpp lldb/tools/debugserver/source/RNBRemote.cpp 
lldb/unittests/Utility/XcodeSDKTest.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 4128ac1cdf..fff08408cd 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -167,7 +167,7 @@ DynamicLoader 
*DynamicLoaderDarwinKernel::CreateInstance(Process *process,
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
 case llvm::Triple::XROS:
-// NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
+  // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
   if (triple_ref.getVendor() != llvm::Triple::Apple) {
 return nullptr;
   }
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 2615925580..d337de9a68 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -56,7 +56,7 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process 
*process,
   case llvm::Triple::TvOS:
   case llvm::Triple::WatchOS:
   case llvm::Triple::XROS:
-  // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
+// NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
 create = triple_ref.getVendor() == llvm::Triple::Apple;
 break;
   default:
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 7e589b0d7a..f8412aa72b 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -76,7 +76,7 @@ DynamicLoader 
*DynamicLoaderMacOSXDYLD::CreateInstance(Process *process,
   case llvm::Triple::TvOS:
   case llvm::Triple::WatchOS:
   case llvm::Triple::XROS:
-  // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
+// NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
 create = triple_ref.getVendor() == llvm::Triple::Apple;
 break;
   default:
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp 
b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index b652ede9b1..3423fbe223 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -831,7 +831,7 @@ uint32_t 
EmulateInstructionARM::GetFramePointerRegisterNumber() const {
   case llvm::Triple::TvOS:
   case llvm::Triple::WatchOS:
   case llvm::Triple::XROS:
-  // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
+// NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
 is_apple = true;
 break;
   default:
diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp 
b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
index a97e51cc7b..ba0f68e47e 100644
--- a/lldb/source/Plu

[Lldb-commits] [lldb] [clang] [clang] Upstream XROS support in Clang (PR #78392)

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

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/78392

>From 6f6d93b6cc413d54dbdec05f30ede00ffdb4 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 10 Jan 2024 17:35:47 -0800
Subject: [PATCH 1/2] [lldb] Upstream xros support in lldb

Upstream support for debugging xros applications through LLDB.
---
 lldb/include/lldb/Utility/XcodeSDK.h  |   2 +
 .../Host/macosx/objcxx/HostInfoMacOSX.mm  |   3 +
 .../DynamicLoaderDarwinKernel.cpp |   1 +
 .../MacOSX-DYLD/DynamicLoaderMacOS.cpp|   1 +
 .../MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp   |   1 +
 .../Instruction/ARM/EmulateInstructionARM.cpp |   1 +
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp |  11 +-
 .../Plugins/Platform/MacOSX/CMakeLists.txt|   1 +
 .../MacOSX/PlatformAppleSimulator.cpp |  37 +
 .../Platform/MacOSX/PlatformDarwin.cpp|  17 +-
 .../Platform/MacOSX/PlatformMacOSX.cpp|   3 +
 .../Platform/MacOSX/PlatformRemoteAppleXR.cpp | 157 ++
 .../Platform/MacOSX/PlatformRemoteAppleXR.h   |  38 +
 ...PlatformiOSSimulatorCoreSimulatorSupport.h |   3 +-
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |   1 +
 .../GDBRemoteCommunicationClient.cpp  |   3 +-
 .../MacOSX/SystemRuntimeMacOSX.cpp|   1 +
 lldb/source/Utility/XcodeSDK.cpp  |  23 +++
 .../debugserver/source/MacOSX/MachProcess.mm  |  12 ++
 lldb/tools/debugserver/source/RNBRemote.cpp   |  11 +-
 lldb/unittests/Utility/XcodeSDKTest.cpp   |  22 +++
 21 files changed, 340 insertions(+), 9 deletions(-)
 create mode 100644 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.cpp
 create mode 100644 lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.h

diff --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index f8528995d549c9..673ea578ffce85 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -34,6 +34,8 @@ class XcodeSDK {
 AppleTVOS,
 WatchSimulator,
 watchOS,
+XRSimulator,
+XROS,
 bridgeOS,
 Linux,
 unknown = -1
diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 110a01732b2473..f96e2cf80c5fac 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -276,6 +276,9 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 #elif defined(TARGET_OS_WATCHOS) && TARGET_OS_WATCHOS == 1
 arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
 arch_64.GetTriple().setOS(llvm::Triple::WatchOS);
+#elif defined(TARGET_OS_XR) && TARGET_OS_XR == 1
+arch_32.GetTriple().setOS(llvm::Triple::XROS);
+arch_64.GetTriple().setOS(llvm::Triple::XROS);
 #elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
 arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
 arch_64.GetTriple().setOS(llvm::Triple::MacOSX);
diff --git 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 7df917d03ceeda..4128ac1cdf1bba 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -166,6 +166,7 @@ DynamicLoader 
*DynamicLoaderDarwinKernel::CreateInstance(Process *process,
 case llvm::Triple::IOS:
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
+case llvm::Triple::XROS:
 // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
   if (triple_ref.getVendor() != llvm::Triple::Apple) {
 return nullptr;
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 4451d8c7689a28..261592558095b4 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -55,6 +55,7 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process 
*process,
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case llvm::Triple::WatchOS:
+  case llvm::Triple::XROS:
   // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
 create = triple_ref.getVendor() == llvm::Triple::Apple;
 break;
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 0bd465aba2d8a2..7e589b0d7af2c7 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -75,6 +75,7 @@ DynamicLoader 
*DynamicLoaderMacOSXDYLD::CreateInstance(Process *process,
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case

[Lldb-commits] [lldb] 3b6a8f8 - [lldb] Upstream xros support in lldb (#78389)

2024-01-17 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-01-17T09:47:08-08:00
New Revision: 3b6a8f823bf873aa74cdb738f517e7333e20de7a

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

LOG: [lldb] Upstream xros support in lldb (#78389)

Upstream support for debugging xros applications through LLDB.

Added: 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.h

Modified: 
lldb/include/lldb/Utility/XcodeSDK.h
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp

lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
lldb/source/Utility/XcodeSDK.cpp
lldb/tools/debugserver/source/MacOSX/MachProcess.mm
lldb/tools/debugserver/source/RNBRemote.cpp
lldb/unittests/Utility/XcodeSDKTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index f8528995d549c9c..673ea578ffce85e 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -34,6 +34,8 @@ class XcodeSDK {
 AppleTVOS,
 WatchSimulator,
 watchOS,
+XRSimulator,
+XROS,
 bridgeOS,
 Linux,
 unknown = -1

diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 110a01732b2473a..f96e2cf80c5facb 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -276,6 +276,9 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 #elif defined(TARGET_OS_WATCHOS) && TARGET_OS_WATCHOS == 1
 arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
 arch_64.GetTriple().setOS(llvm::Triple::WatchOS);
+#elif defined(TARGET_OS_XR) && TARGET_OS_XR == 1
+arch_32.GetTriple().setOS(llvm::Triple::XROS);
+arch_64.GetTriple().setOS(llvm::Triple::XROS);
 #elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
 arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
 arch_64.GetTriple().setOS(llvm::Triple::MacOSX);

diff  --git 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 7df917d03ceeda5..4128ac1cdf1bbae 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -166,6 +166,7 @@ DynamicLoader 
*DynamicLoaderDarwinKernel::CreateInstance(Process *process,
 case llvm::Triple::IOS:
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
+case llvm::Triple::XROS:
 // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
   if (triple_ref.getVendor() != llvm::Triple::Apple) {
 return nullptr;

diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 4451d8c7689a28d..261592558095b4f 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -55,6 +55,7 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process 
*process,
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case llvm::Triple::WatchOS:
+  case llvm::Triple::XROS:
   // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
 create = triple_ref.getVendor() == llvm::Triple::Apple;
 break;

diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 0bd465aba2d8a2f..7e589b0d7af2c7d 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -75,6 +75,7 @@ DynamicLoader 
*DynamicLoaderMacOSXDYLD::

[Lldb-commits] [lldb] [lldb] Upstream xros support in lldb (PR #78389)

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

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


[Lldb-commits] [lldb] [lldb] Upstream xros support in lldb (PR #78389)

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

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/78389

>From 6f6d93b6cc413d54dbdec05f30ede00ffdb4 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 10 Jan 2024 17:35:47 -0800
Subject: [PATCH] [lldb] Upstream xros support in lldb

Upstream support for debugging xros applications through LLDB.
---
 lldb/include/lldb/Utility/XcodeSDK.h  |   2 +
 .../Host/macosx/objcxx/HostInfoMacOSX.mm  |   3 +
 .../DynamicLoaderDarwinKernel.cpp |   1 +
 .../MacOSX-DYLD/DynamicLoaderMacOS.cpp|   1 +
 .../MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp   |   1 +
 .../Instruction/ARM/EmulateInstructionARM.cpp |   1 +
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp |  11 +-
 .../Plugins/Platform/MacOSX/CMakeLists.txt|   1 +
 .../MacOSX/PlatformAppleSimulator.cpp |  37 +
 .../Platform/MacOSX/PlatformDarwin.cpp|  17 +-
 .../Platform/MacOSX/PlatformMacOSX.cpp|   3 +
 .../Platform/MacOSX/PlatformRemoteAppleXR.cpp | 157 ++
 .../Platform/MacOSX/PlatformRemoteAppleXR.h   |  38 +
 ...PlatformiOSSimulatorCoreSimulatorSupport.h |   3 +-
 .../Process/MacOSX-Kernel/ProcessKDP.cpp  |   1 +
 .../GDBRemoteCommunicationClient.cpp  |   3 +-
 .../MacOSX/SystemRuntimeMacOSX.cpp|   1 +
 lldb/source/Utility/XcodeSDK.cpp  |  23 +++
 .../debugserver/source/MacOSX/MachProcess.mm  |  12 ++
 lldb/tools/debugserver/source/RNBRemote.cpp   |  11 +-
 lldb/unittests/Utility/XcodeSDKTest.cpp   |  22 +++
 21 files changed, 340 insertions(+), 9 deletions(-)
 create mode 100644 
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.cpp
 create mode 100644 lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleXR.h

diff --git a/lldb/include/lldb/Utility/XcodeSDK.h 
b/lldb/include/lldb/Utility/XcodeSDK.h
index f8528995d549c9..673ea578ffce85 100644
--- a/lldb/include/lldb/Utility/XcodeSDK.h
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -34,6 +34,8 @@ class XcodeSDK {
 AppleTVOS,
 WatchSimulator,
 watchOS,
+XRSimulator,
+XROS,
 bridgeOS,
 Linux,
 unknown = -1
diff --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 110a01732b2473..f96e2cf80c5fac 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -276,6 +276,9 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
 #elif defined(TARGET_OS_WATCHOS) && TARGET_OS_WATCHOS == 1
 arch_32.GetTriple().setOS(llvm::Triple::WatchOS);
 arch_64.GetTriple().setOS(llvm::Triple::WatchOS);
+#elif defined(TARGET_OS_XR) && TARGET_OS_XR == 1
+arch_32.GetTriple().setOS(llvm::Triple::XROS);
+arch_64.GetTriple().setOS(llvm::Triple::XROS);
 #elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
 arch_32.GetTriple().setOS(llvm::Triple::MacOSX);
 arch_64.GetTriple().setOS(llvm::Triple::MacOSX);
diff --git 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 7df917d03ceeda..4128ac1cdf1bba 100644
--- 
a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -166,6 +166,7 @@ DynamicLoader 
*DynamicLoaderDarwinKernel::CreateInstance(Process *process,
 case llvm::Triple::IOS:
 case llvm::Triple::TvOS:
 case llvm::Triple::WatchOS:
+case llvm::Triple::XROS:
 // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
   if (triple_ref.getVendor() != llvm::Triple::Apple) {
 return nullptr;
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 4451d8c7689a28..261592558095b4 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -55,6 +55,7 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process 
*process,
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case llvm::Triple::WatchOS:
+  case llvm::Triple::XROS:
   // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
 create = triple_ref.getVendor() == llvm::Triple::Apple;
 break;
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 0bd465aba2d8a2..7e589b0d7af2c7 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -75,6 +75,7 @@ DynamicLoader 
*DynamicLoaderMacOSXDYLD::CreateInstance(Process *process,
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS:
   case llv

[Lldb-commits] [lldb] Ensure that the executable module is ModuleList[0] (PR #78360)

2024-01-17 Thread via lldb-commits

jimingham wrote:

So long as ObjectFileELF::CalculateType never returns ET_EXEC, this won't be an 
issue.  But if some ObjectFile that's not in fact the main binary says it has 
this type, not only will this change to Append not do the right thing, 
Target::GetExecutableModule will also return this module.  I'm not sure this 
actually matters much on Linux.  For Swift we use the main executable because 
that has some info we need to reconstruct the swift debugging environment, so 
it's somewhat important for us.  But maybe it doesn't matter much for Linux.

But it would still be nice to know whether to take this return seriously or 
nowt.

Jim


> On Jan 17, 2024, at 9:37 AM, Jim Ingham ***@***.***> wrote:
> 
> Will the value of ObjectFile::GetType ever be meaningful, then?  Do you 
> change it after running based on what the loader tells you?  If that's not 
> meaningful, then we probably should have some "ObjectFile::TypeIsMeaningful" 
> and gate all this logic on that as well.
> 
> Jim
> 
> 
>> On Jan 17, 2024, at 2:43 AM, Pavel Labath ***@***.***> wrote:
>> 
>> 
>> The problem is that linux/elf does not really have hard line between shared 
>> libraries, (position-independent) executables and the dynamic linker. they 
>> all have e_type = ET_DYN in their header. It is possible to create a shared 
>> library that can also be executed (unless one is extremely careful it will 
>> crash very quickly, but that crash may exactly be something that one may 
>> want to observe in a debugger). It's probably also possible to create a 
>> library that will also serve as the dynamic loader.
>> 
>> So, the "is this module an executable" question is not really well defined. 
>> This isn't an intrinsic property of the module, but rather a role that the 
>> module plays in a specific process. Once a process starts, this can be (and 
>> is) determined by the dynamic linker plugin. Before that, we need to rely on 
>> some external signal for that (if we need to know that at all).
>> 
>> With that in mind, I'm going to disable the before-run part of the test for 
>> elf.
>> 
>> —
>> Reply to this email directly, view it on GitHub 
>> , 
>> or unsubscribe 
>> .
>> You are receiving this because you modified the open/close state.
>> 
> 



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


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

2024-01-17 Thread Stanislav Mekhanoshin via lldb-commits

rampitec wrote:

> lgtm, but can still fix the -O0 thing

But where do I get TM in the getAnalysisUsage?

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] [clang-tools-extra] [lldb] [libc] [libcxx] [clang] [compiler-rt] [lld] [flang] [llvm] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2024-01-17 Thread Stanislav Mekhanoshin via lldb-commits


@@ -707,7 +723,40 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 (TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
   // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
   // written can be accessed. A load from LDS to VMEM does not need a wait.
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal
+// in general, but this is so for LDS DMA in practice.
+auto AAI = MemOp->getAAInfo();
+// Alias scope information gives a way to definitely identify an
+// original memory object and practically produced in the module LDS
+// lowering pass. If there is no scope available we will not be able
+// to disambiguate LDS aliasing as after the module lowering all LDS
+// is squashed into a single big object. Do not attemt to use one of

rampitec wrote:

Done

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] [libcxx] [compiler-rt] [clang] [clang-tools-extra] [libc] [flang] [lldb] [lld] [llvm] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)

2024-01-17 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 01/12] [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

[Lldb-commits] [lldb] Ensure that the executable module is ModuleList[0] (PR #78360)

2024-01-17 Thread via lldb-commits

jimingham wrote:

Will the value of ObjectFile::GetType ever be meaningful, then?  Do you change 
it after running based on what the loader tells you?  If that's not meaningful, 
then we probably should have some "ObjectFile::TypeIsMeaningful" and gate all 
this logic on that as well.

Jim


> On Jan 17, 2024, at 2:43 AM, Pavel Labath ***@***.***> wrote:
> 
> 
> The problem is that linux/elf does not really have hard line between shared 
> libraries, (position-independent) executables and the dynamic linker. they 
> all have e_type = ET_DYN in their header. It is possible to create a shared 
> library that can also be executed (unless one is extremely careful it will 
> crash very quickly, but that crash may exactly be something that one may want 
> to observe in a debugger). It's probably also possible to create a library 
> that will also serve as the dynamic loader.
> 
> So, the "is this module an executable" question is not really well defined. 
> This isn't an intrinsic property of the module, but rather a role that the 
> module plays in a specific process. Once a process starts, this can be (and 
> is) determined by the dynamic linker plugin. Before that, we need to rely on 
> some external signal for that (if we need to know that at all).
> 
> With that in mind, I'm going to disable the before-run part of the test for 
> elf.
> 
> —
> Reply to this email directly, view it on GitHub 
> , or 
> unsubscribe 
> .
> You are receiving this because you modified the open/close state.
> 



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


[Lldb-commits] [lldb] Ensure that the executable module is ModuleList[0] (PR #78360)

2024-01-17 Thread via lldb-commits

jimingham wrote:

This one should have been fixed by the follow-on commit.  When you use a shared 
library on Linux you have to bless it somehow - which in the test suite means 
adding an "extra_images" argument to run_to_***_breakpoint, which I forgot to 
do.

Jim


> On Jan 17, 2024, at 12:17 AM, Petr Hosek ***@***.***> wrote:
> 
> 
> lldb-api :: functionalities/executable_first/TestExecutableFirst.py is 
> failing on our Linux builders with the following error:
> 
> Script:
> --
> /b/s/w/ir/x/w/lldb_install/python3/bin/python3 
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS 
> --env ARCHIVER=/b/s/w/ir/x/w/cipd/bin/llvm-ar --env 
> OBJCOPY=/b/s/w/ir/x/w/cipd/bin/llvm-objcopy --env 
> LLVM_LIBS_DIR=/b/s/w/ir/x/w/llvm_build/./lib --env 
> LLVM_INCLUDE_DIR=/b/s/w/ir/x/w/llvm_build/include --env 
> LLVM_TOOLS_DIR=/b/s/w/ir/x/w/llvm_build/./bin --libcxx-include-dir 
> /b/s/w/ir/x/w/llvm_build/include/c++/v1 --libcxx-include-target-dir 
> /b/s/w/ir/x/w/llvm_build/include/x86_64-unknown-linux-gnu/c++/v1 
> --libcxx-library-dir /b/s/w/ir/x/w/llvm_build/./lib/x86_64-unknown-linux-gnu 
> --arch x86_64 --build-dir /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex 
> --lldb-module-cache-dir 
> /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-lldb/lldb-api 
> --clang-module-cache-dir 
> /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/module-cache-clang/lldb-api 
> --executable /b/s/w/ir/x/w/llvm_build/./bin/lldb --compiler 
> /b/s/w/ir/x/w/llvm_build/./bin/clang --dsymutil 
> /b/s/w/ir/x/w/llvm_build/./bin/dsymutil --llvm-tools-dir 
> /b/s/w/ir/x/w/llvm_build/./bin --lldb-libs-dir /b/s/w/ir/x/w/llvm_build/./lib 
> /b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/functionalities/executable_first
>  -p TestExecutableFirst.py
> --
> Exit Code: 1
> 
> Command Output (stdout):
> --
> lldb version 18.0.0git (https://llvm.googlesource.com/a/llvm-project revision 
> a4cd99ea8736eda2b8b4de34453f55008bcf9c30)
>   clang revision a4cd99ea8736eda2b8b4de34453f55008bcf9c30
>   llvm revision a4cd99ea8736eda2b8b4de34453f55008bcf9c30
> Skipping the following test categories: ['dsym', 'gmodules', 'debugserver', 
> 'objc']
> This is the first test, this one succeeds
> 
> --
> Command Output (stderr):
> --
> FAIL: LLDB (/b/s/w/ir/x/w/llvm_build/bin/clang-x86_64) :: 
> test_executable_is_first_before_run 
> (TestExecutableFirst.TestExecutableIsFirst)
> FAIL: LLDB (/b/s/w/ir/x/w/llvm_build/bin/clang-x86_64) :: 
> test_executable_is_first_during_run 
> (TestExecutableFirst.TestExecutableIsFirst)
> ==
> FAIL: test_executable_is_first_before_run 
> (TestExecutableFirst.TestExecutableIsFirst)
> --
> Traceback (most recent call last):
>   File 
> "/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py",
>  line 32, in test_executable_is_first_before_run
> self.assertEqual(module, first_module, "This executable is the first 
> module")
> AssertionError: (x86_64) 
> /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/functionalities/executable_first/TestExecutableFirst.test_executable_is_first_before_run/a.out
>  != (x86_64) 
> /b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/functionalities/executable_first/TestExecutableFirst.test_executable_is_first_before_run/libbar.so
>  : This executable is the first module
> Config=x86_64-/b/s/w/ir/x/w/llvm_build/bin/clang
> ==
> FAIL: test_executable_is_first_during_run 
> (TestExecutableFirst.TestExecutableIsFirst)
> --
> Traceback (most recent call last):
>   File 
> "/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py",
>  line 43, in test_executable_is_first_during_run
> (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
>   ^^
>   File 
> "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/lldbutil.py",
>  line 1009, in run_to_source_breakpoint
> return run_to_breakpoint_do_run(
>^
>   File 
> "/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/lldbutil.py",
>  line 906, in run_to_breakpoint_do_run
> test.fail(
> AssertionError: Test process is not stopped at breakpoint: state: exited, 
> exit code: 127, stdout: 
> '/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/functionalities/executable_first/TestExecutableFirst.test_executable_is_first_during_run/a.out:
>  error while loading shared libraries: libbar.so: cannot open shared object 
> file: No such file or directory
> '
> Config=x86_64-/b/s/w/ir/x/w/llvm_build/bin/clang
> --
> Ran 2 tests in 0.298s
> 
> RESULT

[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)

2024-01-17 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] 4ea1994 - [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (#78005)

2024-01-17 Thread via lldb-commits

Author: John Harrison
Date: 2024-01-17T09:00:22-08:00
New Revision: 4ea1994a0307b09532d519292d34dad798ca

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

LOG: [lldb-dap] Adjusting how repl-mode auto determines commands vs variable 
expressions. (#78005)

The previous logic for determining if an expression was a command or
variable expression in the repl would incorrectly identify the context
in many common cases where a local variable name partially overlaps with
the repl input.

For example:
```
int foo() {
  int var = 1; // break point, evaluating "p var", previously emitted a warning
}
```

Instead of checking potentially multiple conflicting values against the
expression input, I updated the heuristic to only consider the first
term. This is much more reliable at eliminating false positives when the
input does not actually hide a local variable.

Additionally, I updated the warning on conflicts to occur anytime the
conflict is detected since the specific conflict can change based on the
current input. This also includes additional details on how users can
change the behavior.

Example Debug Console output from
lldb/test/API/tools/lldb-dap/evaluate/main.cpp:11 breakpoint 3.

```
lldb-dap> var + 3
Warning: Expression 'var' is both an LLDB command and variable. It will be 
evaluated as a variable. To evaluate the expression as an LLDB command, use '`' 
as a prefix.
45

lldb-dap> var + 1
Warning: Expression 'var' is both an LLDB command and variable. It will be 
evaluated as a variable. To evaluate the expression as an LLDB command, use '`' 
as a prefix.
43
```

Added: 


Modified: 
lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py 
b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
index 5f6d63392f4d5f..2b3ec656c107a5 100644
--- a/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
+++ b/lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
@@ -41,13 +41,13 @@ def test_completions(self):
 {
 "text": "var",
 "label": "var -- vector &",
-}
-],
-[
+},
 {
 "text": "var",
 "label": "var -- Show variables for the current stack 
frame. Defaults to all arguments and local variables in scope. Names of 
argument, local, file static and file global variables can be specified.",
 },
+],
+[
 {"text": "var1", "label": "var1 -- int &"},
 ],
 )

diff  --git a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py 
b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
index 7651a67b643094..0192746f1277b5 100644
--- a/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
+++ b/lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
@@ -87,7 +87,13 @@ def run_test_evaluate_expressions(
 )
 self.assertEvaluate("struct3", "0x.*0")
 
-self.assertEvaluateFailure("var")  # local variable of a_function
+if context == "repl":
+# In the repl context expressions may be interpreted as lldb
+# commands since no variables have the same name as the command.
+self.assertEvaluate("var", r"\(lldb\) var\n.*")
+else:
+self.assertEvaluateFailure("var")  # local variable of a_function
+
 self.assertEvaluateFailure("my_struct")  # type name
 self.assertEvaluateFailure("int")  # type name
 self.assertEvaluateFailure("foo")  # member of my_struct

diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 4b72c13f9215a8..b254ddfef0d5ff 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -47,8 +47,7 @@ DAP::DAP()
   configuration_done_sent(false), waiting_for_run_in_terminal(false),
   progress_event_reporter(
   [&](const ProgressEvent &event) { SendJSON(event.ToJSON()); }),
-  reverse_request_seq(0), repl_mode(ReplMode::Auto),
-  auto_repl_mode_collision_warning(false) {
+  reverse_request_seq(0), repl_mode(ReplMode::Auto) {
   const char *log_file_path = getenv("LLDBDAP_LOG");
 #if defined(_WIN32)
   // Windows opens stdout and stdin in text mode which converts \n to 13,10
@@ -380,12 +379,12 @@ llvm::json::Value DAP::CreateTopLevelScopes() {
   return llvm::json::Value(std::move(scopes));
 }
 
-ExpressionContext DAP::DetectExpressionContext(lldb::SBFrame &frame,
- 

[Lldb-commits] [clang-tools-extra] [clang] [lldb] [polly] [libcxx] [llvm] [mlir] [compiler-rt] [libunwind] [libc] [libcxxabi] [flang] [libc++][any] LWG3305: `any_cast` (PR #78215)

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

mordante wrote:

> > I see you implemented this code only for C++26. In general we retroactively 
> > apply LWG issues to all previous standard versions. Is there a reason why 
> > you only applied this to C++26?
> 
> I am not familiar with this process. I'm happy to do what's needed to be 
> done. So I assume I need to remove the version guards and test against the 
> original implementation?

Yes that is the general rule for LWG-issues. The other implementations handle 
them in the same fashion.

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


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

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


@@ -14310,8 +14310,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, 
UnaryOperatorKind Opc,
 PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_deleted_oper)
<< UnaryOperator::getOpcodeStr(Opc)
<< Input->getSourceRange()),
-*this, OCD_AllCandidates, ArgsArray, UnaryOperator::getOpcodeStr(Opc),
-OpLoc);
+*this, OCD_AllCandidates, ArgsArray.slice(1),

Fznamznon wrote:

> IMO, ArgsArray.drop_front() makes more sense to me here. 

Okay, done.

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


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

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


@@ -14306,12 +14306,17 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, 
UnaryOperatorKind Opc,
 return ExprError();
 
   case OR_Deleted:
+// CreateOverloadedUnaryOp fills first element of ArgsArray with the object
+// whose method was called. Later in NoteCandidates size of ArgsArray is
+// passed further and it eventually ends up compared to number of function
+// candidate parameters which never includes implicit object parameter, so
+// do a slice to ArgsArray to make sure apples are compared to apples.

Fznamznon wrote:

Ok, done.

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


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

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

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/78316

>From cf33d7ce01aafe0fa29b8a38a9824a0b03d24f05 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Tue, 16 Jan 2024 09:16:10 -0800
Subject: [PATCH 1/4] [clang] Fix assertion failure with deleted overloaded
 unary operators

When emitting notes related to wrong number of arguments do not consider
implicit object argument.

Fixes https://github.com/llvm/llvm-project/issues/78314
---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/Sema/SemaOverload.cpp|  4 ++--
 clang/test/SemaCXX/overloaded-operator.cpp | 27 ++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6e31849ce16dd4..8382e5d55f6c6e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -750,6 +750,8 @@ Bug Fixes in This Version
   Fixes (`#77583 `_)
 - Fix an issue where CTAD fails for function-type/array-type arguments.
   Fixes (`#51710 `_)
+- Fixed assertion failure with deleted overloaded unary operators.
+  Fixes (`#78314 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 37c62b306b3cd3..83ab7cb0f3411b 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14310,8 +14310,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, 
UnaryOperatorKind Opc,
 PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_deleted_oper)
<< UnaryOperator::getOpcodeStr(Opc)
<< Input->getSourceRange()),
-*this, OCD_AllCandidates, ArgsArray, UnaryOperator::getOpcodeStr(Opc),
-OpLoc);
+*this, OCD_AllCandidates, ArgsArray.slice(1),
+UnaryOperator::getOpcodeStr(Opc), OpLoc);
 return ExprError();
   }
 
diff --git a/clang/test/SemaCXX/overloaded-operator.cpp 
b/clang/test/SemaCXX/overloaded-operator.cpp
index 83a7e65b43dd01..60332019f516cf 100644
--- a/clang/test/SemaCXX/overloaded-operator.cpp
+++ b/clang/test/SemaCXX/overloaded-operator.cpp
@@ -598,3 +598,30 @@ namespace B {
 }
 void g(B::X x) { A::f(x); }
 }
+
+namespace GH78314 {
+
+class a {
+public:
+  void operator--() = delete; // expected-note {{candidate function has been 
explicitly deleted}} \
+  // expected-note {{candidate function not 
viable: requires 0 arguments, but 1 was provided}}
+  void operator--(int) = delete; // expected-note {{candidate function has 
been explicitly deleted}} \
+ // expected-note {{candidate function not 
viable: requires 1 argument, but 0 were provided}}
+};
+
+void foo() {
+  a aa;
+  --aa; // expected-error {{overload resolution selected deleted operator 
'--'}}
+  aa--; // expected-error {{overload resolution selected deleted operator 
'--'}}
+}
+
+class b {
+  void operator++() = delete; // expected-note {{candidate function has been 
explicitly deleted}}
+  template  void operator++(int) { // expected-note {{function template 
not viable: requires 1 argument, but 0 were provided}}
+b bb;
+++bb; // expected-error {{overload resolution selected deleted operator 
'++'}}
+  }
+};
+
+
+}

>From 03daf97e74c05c1fa0c0c4b1637cbc76d3184404 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Wed, 17 Jan 2024 02:30:04 -0800
Subject: [PATCH 2/4] Add a test with explicit object parameter

---
 clang/test/SemaCXX/overloaded-operator.cpp | 30 ++
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/clang/test/SemaCXX/overloaded-operator.cpp 
b/clang/test/SemaCXX/overloaded-operator.cpp
index 60332019f516cf..887848c29b83c5 100644
--- a/clang/test/SemaCXX/overloaded-operator.cpp
+++ b/clang/test/SemaCXX/overloaded-operator.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx23 -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx23 -std=c++23 %s
+
 class X { };
 
 X operator+(X, X);
@@ -33,7 +35,9 @@ struct A {
 
 A make_A();
 
-bool operator==(A&, Z&); // expected-note 3{{candidate function}}
+bool operator==(A&, Z&); // expected-note 3{{candidate function}} \
+ // cxx23-note 2{{candidate function}}
+
 
 void h(A a, const A ac, Z z) {
   make_A() == z; // expected-warning{{equality comparison result unused}}
@@ -68,7 +72,9 @@ struct E2 {
 };
 
 // C++ [over.match.oper]p3 - enum restriction.
-float& operator==(E1, E2);  // expected-note{{candidate function}}
+float& operator==(E1, E2);  // expected-note{{candidate function}} \
+// cxx23-note{{candidate function}}
+
 
 void enum_test(Enum1 enum1, 

[Lldb-commits] [clang] [libunwind] [llvm] [mlir] [lldb] [libc] [flang] [polly] [libcxx] [compiler-rt] [clang-tools-extra] [libcxxabi] [libc++][any] LWG3305: `any_cast` (PR #78215)

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

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/78215

>From 328c55879848d98a9bc068436d959b409b239bcc Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Thu, 11 Jan 2024 09:46:26 +0200
Subject: [PATCH 1/2] [libc++][any] LWG3305: `any_cast`

Implements: https://wg21.link/LWG3305
- https://eel.is/c++draft/any.nonmembers
---
 libcxx/docs/Status/Cxx2cIssues.csv|  2 +-
 libcxx/include/any|  7 
 .../any.nonmembers/any.cast/void.verify.cpp   | 34 +++
 3 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/utilities/any/any.nonmembers/any.cast/void.verify.cpp

diff --git a/libcxx/docs/Status/Cxx2cIssues.csv 
b/libcxx/docs/Status/Cxx2cIssues.csv
index fe0f13f6e8cb2c2..29f25b63ccb863f 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -19,7 +19,7 @@
 "","","","","",""
 "`2392 `__","""character type"" is used but not 
defined","Kona November 2023","","",""
 "`3203 `__","``span`` element access 
invalidation","Kona November 2023","","",""
-"`3305 `__","``any_cast``","Kona November 
2023","","",""
+"`3305 `__","``any_cast``","Kona November 
2023","|Complete|","18.0",""
 "`3431 `__","``<=>`` for containers should require 
``three_way_comparable`` instead of ``<=>``","Kona November 2023","","",""
 "`3749 `__","``common_iterator`` should handle 
integer-class difference types","Kona November 2023","","",""
 "`3809 `__","Is 
``std::subtract_with_carry_engine`` supposed to work","Kona November 
2023","","",""
diff --git a/libcxx/include/any b/libcxx/include/any
index b9e0a8d94550ccd..a157d763c63121c 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -98,6 +98,7 @@ namespace std {
 #include <__type_traits/is_nothrow_move_constructible.h>
 #include <__type_traits/is_reference.h>
 #include <__type_traits/is_same.h>
+#include <__type_traits/is_void.h>
 #include <__type_traits/remove_cv.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
@@ -555,6 +556,9 @@ inline _LIBCPP_HIDE_FROM_ABI 
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType
 
 template 
 inline _LIBCPP_HIDE_FROM_ABI add_pointer_t> 
any_cast(any const* __any) _NOEXCEPT {
+#  if _LIBCPP_STD_VER >= 26
+  static_assert(!is_void_v<_ValueType>, "_ValueType may not be void.");
+#  endif
   static_assert(!is_reference<_ValueType>::value, "_ValueType may not be a 
reference.");
   return std::any_cast<_ValueType>(const_cast(__any));
 }
@@ -572,6 +576,9 @@ inline _LIBCPP_HIDE_FROM_ABI _RetType 
__pointer_or_func_cast(void*, /*IsFunction
 template 
 _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) _NOEXCEPT 
{
   using __any_imp::_Action;
+#  if _LIBCPP_STD_VER >= 26
+  static_assert(!is_void_v<_ValueType>, "_ValueType may not be void.");
+#  endif
   static_assert(!is_reference<_ValueType>::value, "_ValueType may not be a 
reference.");
   typedef add_pointer_t<_ValueType> _ReturnType;
   if (__any && __any->__h_) {
diff --git 
a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/void.verify.cpp 
b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/void.verify.cpp
new file mode 100644
index 000..c0733e544dcb24c
--- /dev/null
+++ b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/void.verify.cpp
@@ -0,0 +1,34 @@
+//===--===//
+//
+// 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
+
+// 
+
+// template
+// const T* any_cast(const any* operand) noexcept;
+
+// template
+// T* any_cast(any* operand) noexcept;
+
+#include 
+
+void test() {
+  {
+const std::any ca = 1;
+
+// expected-error-re@any:* {{static assertion failed{{.*}}_ValueType may 
not be void.}}
+std::any_cast(&ca); // expected-note {{requested here}}
+  }
+  {
+std::any a = 1;
+
+// expected-error-re@any:* {{static assertion failed{{.*}}_ValueType may 
not be void.}}
+std::any_cast(&a); // expected-note {{requested here}}
+  }
+}

>From 80fc2ca1ce009aa892f148b319129356e2c818c4 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Wed, 17 Jan 2024 18:16:04 +0200
Subject: [PATCH 2/2] Addressed comments

---
 libcxx/include/any| 4 
 .../std/utilities/any/any.nonmembers/any.cast/void.verify.cpp | 2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/libcxx/include/any b/libcxx/include/any
index a157d763c63121c..378dfb6e21b5360 100644
--- a/libcxx/include

[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)

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


@@ -1125,21 +1126,33 @@ void request_completions(const llvm::json::Object 
&request) {
   }
   llvm::json::Array targets;
 
-  if (g_dap.DetectExpressionContext(frame, text) ==
-  ExpressionContext::Variable) {
-char command[] = "expression -- ";
-text = command + text;
-offset += strlen(command);
-  }
-  lldb::SBStringList matches;
-  lldb::SBStringList descriptions;
+  if (!text.empty() &&
+  llvm::StringRef(text).starts_with(g_dap.command_escape_prefix)) {
+text = text.substr(g_dap.command_escape_prefix.size());
+  }
+
+  // While the user is typing then we likely have an incomplete input and 
cannot
+  // reliably determine the precise intent (command vs variable), try 
completing
+  // the text as both a command and variable expression, if applicable.

walter-erquinigo wrote:

good idea!

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


[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)

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

https://github.com/walter-erquinigo approved this pull request.


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


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

2024-01-17 Thread Erich Keane via lldb-commits


@@ -14310,8 +14310,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, 
UnaryOperatorKind Opc,
 PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_deleted_oper)
<< UnaryOperator::getOpcodeStr(Opc)
<< Input->getSourceRange()),
-*this, OCD_AllCandidates, ArgsArray, UnaryOperator::getOpcodeStr(Opc),
-OpLoc);
+*this, OCD_AllCandidates, ArgsArray.slice(1),

erichkeane wrote:

IMO, `ArgsArray.drop_front()` makes more sense to me here.  It does the same 
thing, but is, IMO, more 'clear'.

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


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

2024-01-17 Thread Erich Keane via lldb-commits

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


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

2024-01-17 Thread Erich Keane via lldb-commits

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

1 suggestion, not necessary, but I think it is beneficial.

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


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

2024-01-17 Thread via lldb-commits

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


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

2024-01-17 Thread via lldb-commits

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

LGTM (modulo nit)

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


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

2024-01-17 Thread via lldb-commits


@@ -14306,12 +14306,17 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, 
UnaryOperatorKind Opc,
 return ExprError();
 
   case OR_Deleted:
+// CreateOverloadedUnaryOp fills first element of ArgsArray with the object
+// whose method was called. Later in NoteCandidates size of ArgsArray is
+// passed further and it eventually ends up compared to number of function
+// candidate parameters which never includes implicit object parameter, so
+// do a slice to ArgsArray to make sure apples are compared to apples.

cor3ntin wrote:

```suggestion
// CreateOverloadedUnaryOp fills the first element of ArgsArray with the 
object
// whose method was called. Later in NoteCandidates size of ArgsArray is
// passed further and it eventually ends up compared to number of function
// candidate parameters which never includes the implicit object parameter, 
so
// slice ArgsArray to make sure apples are compared to apples.
```

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


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

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

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/78316

>From cf33d7ce01aafe0fa29b8a38a9824a0b03d24f05 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Tue, 16 Jan 2024 09:16:10 -0800
Subject: [PATCH 1/3] [clang] Fix assertion failure with deleted overloaded
 unary operators

When emitting notes related to wrong number of arguments do not consider
implicit object argument.

Fixes https://github.com/llvm/llvm-project/issues/78314
---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/Sema/SemaOverload.cpp|  4 ++--
 clang/test/SemaCXX/overloaded-operator.cpp | 27 ++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6e31849ce16dd4..8382e5d55f6c6e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -750,6 +750,8 @@ Bug Fixes in This Version
   Fixes (`#77583 `_)
 - Fix an issue where CTAD fails for function-type/array-type arguments.
   Fixes (`#51710 `_)
+- Fixed assertion failure with deleted overloaded unary operators.
+  Fixes (`#78314 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 37c62b306b3cd3..83ab7cb0f3411b 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14310,8 +14310,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, 
UnaryOperatorKind Opc,
 PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_deleted_oper)
<< UnaryOperator::getOpcodeStr(Opc)
<< Input->getSourceRange()),
-*this, OCD_AllCandidates, ArgsArray, UnaryOperator::getOpcodeStr(Opc),
-OpLoc);
+*this, OCD_AllCandidates, ArgsArray.slice(1),
+UnaryOperator::getOpcodeStr(Opc), OpLoc);
 return ExprError();
   }
 
diff --git a/clang/test/SemaCXX/overloaded-operator.cpp 
b/clang/test/SemaCXX/overloaded-operator.cpp
index 83a7e65b43dd01..60332019f516cf 100644
--- a/clang/test/SemaCXX/overloaded-operator.cpp
+++ b/clang/test/SemaCXX/overloaded-operator.cpp
@@ -598,3 +598,30 @@ namespace B {
 }
 void g(B::X x) { A::f(x); }
 }
+
+namespace GH78314 {
+
+class a {
+public:
+  void operator--() = delete; // expected-note {{candidate function has been 
explicitly deleted}} \
+  // expected-note {{candidate function not 
viable: requires 0 arguments, but 1 was provided}}
+  void operator--(int) = delete; // expected-note {{candidate function has 
been explicitly deleted}} \
+ // expected-note {{candidate function not 
viable: requires 1 argument, but 0 were provided}}
+};
+
+void foo() {
+  a aa;
+  --aa; // expected-error {{overload resolution selected deleted operator 
'--'}}
+  aa--; // expected-error {{overload resolution selected deleted operator 
'--'}}
+}
+
+class b {
+  void operator++() = delete; // expected-note {{candidate function has been 
explicitly deleted}}
+  template  void operator++(int) { // expected-note {{function template 
not viable: requires 1 argument, but 0 were provided}}
+b bb;
+++bb; // expected-error {{overload resolution selected deleted operator 
'++'}}
+  }
+};
+
+
+}

>From 03daf97e74c05c1fa0c0c4b1637cbc76d3184404 Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Wed, 17 Jan 2024 02:30:04 -0800
Subject: [PATCH 2/3] Add a test with explicit object parameter

---
 clang/test/SemaCXX/overloaded-operator.cpp | 30 ++
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/clang/test/SemaCXX/overloaded-operator.cpp 
b/clang/test/SemaCXX/overloaded-operator.cpp
index 60332019f516cf..887848c29b83c5 100644
--- a/clang/test/SemaCXX/overloaded-operator.cpp
+++ b/clang/test/SemaCXX/overloaded-operator.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx23 -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx23 -std=c++23 %s
+
 class X { };
 
 X operator+(X, X);
@@ -33,7 +35,9 @@ struct A {
 
 A make_A();
 
-bool operator==(A&, Z&); // expected-note 3{{candidate function}}
+bool operator==(A&, Z&); // expected-note 3{{candidate function}} \
+ // cxx23-note 2{{candidate function}}
+
 
 void h(A a, const A ac, Z z) {
   make_A() == z; // expected-warning{{equality comparison result unused}}
@@ -68,7 +72,9 @@ struct E2 {
 };
 
 // C++ [over.match.oper]p3 - enum restriction.
-float& operator==(E1, E2);  // expected-note{{candidate function}}
+float& operator==(E1, E2);  // expected-note{{candidate function}} \
+// cxx23-note{{candidate function}}
+
 
 void enum_test(Enum1 enum1, 

[Lldb-commits] [compiler-rt] [libunwind] [libcxx] [clang] [flang] [libc] [lldb] [libcxxabi] [clang-tools-extra] [llvm] [libc++][any] LWG3305: `any_cast` (PR #78215)

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

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/78215

>From 328c55879848d98a9bc068436d959b409b239bcc Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Thu, 11 Jan 2024 09:46:26 +0200
Subject: [PATCH] [libc++][any] LWG3305: `any_cast`

Implements: https://wg21.link/LWG3305
- https://eel.is/c++draft/any.nonmembers
---
 libcxx/docs/Status/Cxx2cIssues.csv|  2 +-
 libcxx/include/any|  7 
 .../any.nonmembers/any.cast/void.verify.cpp   | 34 +++
 3 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/utilities/any/any.nonmembers/any.cast/void.verify.cpp

diff --git a/libcxx/docs/Status/Cxx2cIssues.csv 
b/libcxx/docs/Status/Cxx2cIssues.csv
index fe0f13f6e8cb2c..29f25b63ccb863 100644
--- a/libcxx/docs/Status/Cxx2cIssues.csv
+++ b/libcxx/docs/Status/Cxx2cIssues.csv
@@ -19,7 +19,7 @@
 "","","","","",""
 "`2392 `__","""character type"" is used but not 
defined","Kona November 2023","","",""
 "`3203 `__","``span`` element access 
invalidation","Kona November 2023","","",""
-"`3305 `__","``any_cast``","Kona November 
2023","","",""
+"`3305 `__","``any_cast``","Kona November 
2023","|Complete|","18.0",""
 "`3431 `__","``<=>`` for containers should require 
``three_way_comparable`` instead of ``<=>``","Kona November 2023","","",""
 "`3749 `__","``common_iterator`` should handle 
integer-class difference types","Kona November 2023","","",""
 "`3809 `__","Is 
``std::subtract_with_carry_engine`` supposed to work","Kona November 
2023","","",""
diff --git a/libcxx/include/any b/libcxx/include/any
index b9e0a8d94550cc..a157d763c63121 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -98,6 +98,7 @@ namespace std {
 #include <__type_traits/is_nothrow_move_constructible.h>
 #include <__type_traits/is_reference.h>
 #include <__type_traits/is_same.h>
+#include <__type_traits/is_void.h>
 #include <__type_traits/remove_cv.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
@@ -555,6 +556,9 @@ inline _LIBCPP_HIDE_FROM_ABI 
_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType
 
 template 
 inline _LIBCPP_HIDE_FROM_ABI add_pointer_t> 
any_cast(any const* __any) _NOEXCEPT {
+#  if _LIBCPP_STD_VER >= 26
+  static_assert(!is_void_v<_ValueType>, "_ValueType may not be void.");
+#  endif
   static_assert(!is_reference<_ValueType>::value, "_ValueType may not be a 
reference.");
   return std::any_cast<_ValueType>(const_cast(__any));
 }
@@ -572,6 +576,9 @@ inline _LIBCPP_HIDE_FROM_ABI _RetType 
__pointer_or_func_cast(void*, /*IsFunction
 template 
 _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) _NOEXCEPT 
{
   using __any_imp::_Action;
+#  if _LIBCPP_STD_VER >= 26
+  static_assert(!is_void_v<_ValueType>, "_ValueType may not be void.");
+#  endif
   static_assert(!is_reference<_ValueType>::value, "_ValueType may not be a 
reference.");
   typedef add_pointer_t<_ValueType> _ReturnType;
   if (__any && __any->__h_) {
diff --git 
a/libcxx/test/std/utilities/any/any.nonmembers/any.cast/void.verify.cpp 
b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/void.verify.cpp
new file mode 100644
index 00..c0733e544dcb24
--- /dev/null
+++ b/libcxx/test/std/utilities/any/any.nonmembers/any.cast/void.verify.cpp
@@ -0,0 +1,34 @@
+//===--===//
+//
+// 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
+
+// 
+
+// template
+// const T* any_cast(const any* operand) noexcept;
+
+// template
+// T* any_cast(any* operand) noexcept;
+
+#include 
+
+void test() {
+  {
+const std::any ca = 1;
+
+// expected-error-re@any:* {{static assertion failed{{.*}}_ValueType may 
not be void.}}
+std::any_cast(&ca); // expected-note {{requested here}}
+  }
+  {
+std::any a = 1;
+
+// expected-error-re@any:* {{static assertion failed{{.*}}_ValueType may 
not be void.}}
+std::any_cast(&a); // expected-note {{requested here}}
+  }
+}

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


[Lldb-commits] [compiler-rt] [libunwind] [libcxx] [clang] [flang] [libc] [lldb] [libcxxabi] [clang-tools-extra] [llvm] [libc++][span] P2447R4: `std::span` over an initializer list (PR #78157)

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

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/78157

>From 01f0ed005f2037fa4a4ec64ad5e1a114da1f5e99 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Thu, 11 Jan 2024 10:42:55 +0200
Subject: [PATCH 1/9] [libc++][span] P2447R4: `std::span` over an initializer
 list

Implements: https://wg21.link/P2447R6
- https://eel.is/c++draft/span.syn
- https://eel.is/c++draft/span.overview
- https://eel.is/c++draft/span.cons
- https://eel.is/c++draft/diff
---
 libcxx/docs/ReleaseNotes/18.rst   |   1 +
 libcxx/docs/Status/Cxx2cPapers.csv|   2 +-
 libcxx/include/span   |  18 +++
 .../views/views.span/span.cons/array.pass.cpp |   4 +
 .../initializer_list.assert.pass.cpp  |  45 ++
 .../span.cons/initializer_list.pass.cpp   | 131 --
 .../span.cons/iterator_len.verify.cpp |  24 +++-
 .../generate_feature_test_macro_components.py |   1 -
 8 files changed, 204 insertions(+), 22 deletions(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.cons/initializer_list.assert.pass.cpp

diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 62a1fec627d0ca..bf0ef8d447a3a5 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -60,6 +60,7 @@ Implemented Papers
 - P0521R0 - Proposed Resolution for CA 14 (``shared_ptr`` ``use_count/unique``)
 - P1759R6 - Native handles and file streams
 - P2517R1 - Add a conditional ``noexcept`` specification to ``std::apply``
+- P2447R6 - ``span`` over initializer list
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index 5701717f39766c..2a7ee46816e9d9 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -34,7 +34,7 @@
 "`P2918R2 `__","LWG","Runtime format strings 
II","Kona November 2023","|Complete|","18.0","|format|"
 "`P2909R4 `__","LWG","Fix formatting of code units 
as integers (Dude, where’s my ``char``?)","Kona November 
2023","|Complete|","18.0","|format| |DR|"
 "`P0952R2 `__","LWG","A new specification for 
``std::generate_canonical``","Kona November 2023","","",""
-"`P2447R6 `__","LWG","``std::span`` over an 
initializer list","Kona November 2023","","",""
+"`P2447R6 `__","LWG","``std::span`` over an 
initializer list","Kona November 2023","|Complete","18.0",""
 "`P2821R5 `__","LWG","``span.at()``","Kona November 
2023","|Complete|","18.0",""
 "`P2868R3 `__","LWG","Remove Deprecated 
``std::allocator`` Typedef From C++26","Kona November 2023","","",""
 "`P2870R3 `__","LWG","Remove 
``basic_string::reserve()`` From C++26","Kona November 
2023","|Complete|","18.0",""
diff --git a/libcxx/include/span b/libcxx/include/span
index 007a32597f965b..7ce0faa9457099 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -68,6 +68,7 @@ public:
 constexpr span(const array& arr) noexcept;
 template
   constexpr explicit(Extent != dynamic_extent) span(R&& r);
+constexpr explicit(extent != dynamic_extent) 
span(std::initializer_list il); // Since C++26
 constexpr span(const span& other) noexcept = default;
 template 
 constexpr explicit(Extent != dynamic_extent) span(const 
span& s) noexcept;
@@ -228,6 +229,15 @@ public:
 requires(_Sz == 0)
   _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr} {}
 
+#  if _LIBCPP_STD_VER >= 26
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit 
span(std::initializer_list __il)
+requires is_const_v
+  : __data_{__il.begin()} {
+// static_assert(false, "constructor (static extent) called");
+_LIBCPP_ASSERT_INTERNAL(_Extent == __il.size(), "Size mismatch in span's 
constructor _Extent != __il.size().");
+  }
+#  endif
+
   constexpr span(const span&) noexcept= default;
   constexpr span& operator=(const span&) noexcept = default;
 
@@ -397,6 +407,14 @@ public:
   // [span.cons], span constructors, copy, assignment, and destructor
   _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr}, 
__size_{0} {}
 
+#  if _LIBCPP_STD_VER >= 26
+  _LIBCPP_HIDE_FROM_ABI constexpr span(std::initializer_list __il)
+requires is_const_v
+  : __data_{__il.begin()}, __size_{__il.size()} {
+// static_assert(false, "constructor (dynamic extent) called");
+  }
+#  endif
+
   constexpr span(const span&) noexcept= default;
   constexpr span& operator=(const span&) noexcept = default;
 
diff --git 
a/libcxx/test/std/containers/views/views.span/span.cons/array.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.cons/array.pass.cpp
index 8fa7692c3b6370..b01fdda84789ce 100644
--- a/libcxx/test/std/containers/views/views.span/span.cons/array.pass.cpp
+++ b/libcxx

[Lldb-commits] [flang] [libc] [mlir] [clang-tools-extra] [lld] [openmp] [llvm] [libcxx] [clang] [compiler-rt] [lldb] [libc++][memory] P1132R8: `out_ptr` - a scalable output pointer abstraction (PR #73

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


@@ -0,0 +1,102 @@
+// -*- 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
+//
+//===--===//
+
+#ifndef _LIBCPP___INOUT_PTR_H
+#define _LIBCPP___INOUT_PTR_H
+
+#include <__config>
+#include <__memory/addressof.h>
+#include <__memory/pointer_traits.h>
+#include <__memory/shared_ptr.h>
+#include <__memory/unique_ptr.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_specialization.h>
+#include <__type_traits/is_void.h>
+#include 
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 23
+
+template 
+class _LIBCPP_TEMPLATE_VIS inout_ptr_t {
+  static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> 
is not supported");
+
+public:
+  _LIBCPP_HIDE_FROM_ABI explicit inout_ptr_t(_Smart& __s, _Args... __args)
+  : __s_(__s), __a_(std::forward<_Args>(__args)...), __p_([&__s] {
+  if constexpr (is_pointer_v<_Smart>) {
+return __s;
+  } else {
+return __s.get();
+  }
+}()) {
+if constexpr (requires { __s.release(); }) {
+  __s.release();
+} else {
+  __s = _Smart();
+}
+  }
+
+  _LIBCPP_HIDE_FROM_ABI inout_ptr_t(const inout_ptr_t&) = delete;
+
+  _LIBCPP_HIDE_FROM_ABI ~inout_ptr_t() {
+if constexpr (!is_pointer_v<_Smart>) {
+  if (!__p_) {
+return;
+  }
+}
+
+using _SP = __pointer_of_or_t<_Smart, _Pointer>;
+if constexpr (is_pointer_v<_Smart>) {
+  std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), 
std::forward<_Args>(__args)...); },
+ std::move(__a_));
+} else if constexpr (__resettable_smart_pointer_with_args<_Smart, 
_Pointer, _Args...>) {
+  std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SP>(__p_), 
std::forward<_Args>(__args)...); },
+ std::move(__a_));
+} else if constexpr (is_constructible_v<_Smart, _SP, _Args...>) {
+  std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SP>(__p_), 
std::forward<_Args>(__args)...); },
+ std::move(__a_));
+} else {
+  static_assert(is_pointer_v<_Smart> || 
__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...> ||
+is_constructible_v<_Smart, _SP, _Args...>);
+}
+  }
+
+  _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept { return 
std::addressof(const_cast<_Pointer&>(__p_)); }
+
+  _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept
+requires(!is_same_v<_Pointer, void*>)
+  {
+static_assert(is_pointer_v<_Pointer>);
+
+return reinterpret_cast(static_cast<_Pointer*>(*this));
+  }
+
+private:
+  _Smart& __s_;
+  tuple<_Args...> __a_;
+  _Pointer __p_;
+};
+
+template 
+_LIBCPP_HIDE_FROM_ABI auto inout_ptr(_Smart& __s, _Args&&... __args) {
+  using _Ptr = conditional_t, __pointer_of_t<_Smart>, 
_Pointer>;
+  return std::inout_ptr_t<_Smart, _Ptr, _Args&&...>(__s, 
std::forward<_Args>(__args)...);

H-G-Hristov wrote:

Maybe I don't understand but the following fails to compile: 
https://godbolt.org/z/cseMEfdj5

> opt/compiler-explorer/gcc-trunk-20240117/include/c++/14.0.1/bits/out_ptr.h:212:42:
>  error: use of deleted function 'constexpr Foo& Foo::operator=(const Foo&)'
  212 |   _M_smart._M_t._M_deleter() = std::forward<_Del2>(_M_del);
  |   ~~~^

```c++
#include 
#include 

struct Foo {
Foo() = default;
Foo(Foo const&) = delete;  // not copyable
Foo(Foo&&) = delete;   // not movable either!

void operator()(int*) {};
};

int main() {
std::unique_ptr smart;
Foo arg;
// std::ignore = std::out_ptr(smart, arg);
std::ignore = std::inout_ptr(smart, arg);
}
```

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


[Lldb-commits] [lldb] [mlir] [libc] [clang] [lld] [openmp] [clang-tools-extra] [compiler-rt] [flang] [llvm] [libcxx] [libc++][memory] P1132R8: `out_ptr` - a scalable output pointer abstraction (PR #73

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

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/73618
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

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

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

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

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

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

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

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

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

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

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

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

[Lldb-commits] [libcxxabi] [flang] [llvm] [libc] [libunwind] [clang-tools-extra] [lld] [clang] [lldb] [compiler-rt] [mlir] [libcxx] [libc++][numeric] P0543R3: Saturation arithmetic (PR #77967)

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

H-G-Hristov wrote:

How do I fix the following generated files check error:

```diff
[8/9] cd 
/home/runner/work/llvm-project/llvm-project/build/check-generated-output/libcxx/utils
 && /usr/bin/python3.10 
/home/runner/work/llvm-project/llvm-project/libcxx/utils/generate_iwyu_mapping.py
[9/9] cd 
/home/runner/work/llvm-project/llvm-project/build/check-generated-output/libcxx/utils
 && /usr/bin/python3.10 
/home/runner/work/llvm-project/llvm-project/libcxx/utils/generate_escaped_output_table.py
 
/home/runner/work/llvm-project/llvm-project/libcxx/include/__format/escaped_output_table.h
diff --git a/libcxx/include/libcxx.imp b/libcxx/include/libcxx.imp
index 8616f9639..45fa4a954 100644
--- a/libcxx/include/libcxx.imp
+++ b/libcxx/include/libcxx.imp
@@ -559,6 +559,7 @@
   { include: [ "<__numeric/pstl_reduce.h>", "private", "", "public" ] 
},
   { include: [ "<__numeric/pstl_transform_reduce.h>", "private", "", 
"public" ] },
   { include: [ "<__numeric/reduce.h>", "private", "", "public" ] },
+  { include: [ "<__numeric/saturation_arithmetic.h>", "private", "", 
"public" ] },
   { include: [ "<__numeric/transform_exclusive_scan.h>", "private", 
"", "public" ] },
   { include: [ "<__numeric/transform_inclusive_scan.h>", "private", 
"", "public" ] },
   { include: [ "<__numeric/transform_reduce.h>", "private", "", 
"public" ] },
```

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


[Lldb-commits] [lldb] Ensure that the executable module is ModuleList[0] (PR #78360)

2024-01-17 Thread Pavel Labath via lldb-commits

labath wrote:

The problem is that linux/elf does not really have hard line between shared 
libraries, (position-independent) executables and the dynamic linker. they all 
have `e_type = ET_DYN` in their header. It is possible to create a shared 
library that can also be executed (unless one is *extremely* careful it will 
crash very quickly, but that crash may exactly be something that one may want 
to observe in a debugger). It's probably also possible to create a library that 
will also serve as the dynamic loader.

So, the "is this module an executable" question is not really well defined. 
This isn't an intrinsic property of the module, but rather a role that the 
module plays in a specific process. Once a process starts, this can be (and is) 
determined by the dynamic linker plugin. Before that, we need to rely on some 
external signal for that (if we need to know that at all).

With that in mind, I'm going to disable the before-run part of the test for elf.

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


[Lldb-commits] [lldb] 15311d5 - [lldb] Skip TestExecutableFirst.test_executable_is_first_before_run on ELF

2024-01-17 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2024-01-17T10:36:44Z
New Revision: 15311d5822f5fcaf53bc7cfc728ad2b477a430e4

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

LOG: [lldb] Skip TestExecutableFirst.test_executable_is_first_before_run on ELF

ELF does not have a hard distinction between shared libraries (and
position-independent) executables. It is possible to create a shared
library that will also be executable.

Added: 


Modified: 
lldb/test/API/functionalities/executable_first/TestExecutableFirst.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py 
b/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
index 957628f695c128..4f753239f3dbb8 100644
--- a/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
+++ b/lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
@@ -10,6 +10,9 @@
 class TestExecutableIsFirst(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+# ELF does not have a hard distinction between shared libraries and
+# (position-independent) executables
+@skipIf(oslist=no_match(lldbplatformutil.getDarwinOSTriples()+["windows"]))
 def test_executable_is_first_before_run(self):
 self.build()
 



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


[Lldb-commits] [compiler-rt] [lldb] [flang] [clang-tools-extra] [libc] [libcxxabi] [llvm] [clang] [libunwind] [libcxx] [ASan][AMDGPU] Fix Assertion Failure. (PR #78410)

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


@@ -0,0 +1,23 @@
+;RUN: opt < %s -passes=asan -S | FileCheck %s
+
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"
+
+@__const.__assert_fail.fmt = private unnamed_addr addrspace(4) constant [47 x 
i8] c"%s:%u: %s: Device-side assertion `%s' failed.\0A\00", align 16
+
+declare void @llvm.memcpy.p0.p4.i64(ptr noalias nocapture writeonly, ptr 
addrspace(4) noalias nocapture readonly, i64, i1 immarg) #1
+
+define weak hidden void @test_mem_intrinsic() sanitize_address #0 {
+; CHECK: define weak hidden void @test_mem_intrinsic() #1 {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[FMT:%.*]] = alloca [47 x i8], align 16, addrspace(5)
+; CHECK-NEXT: [[FADDRC:%.*]] = addrspacecast ptr addrspace(5) [[FMT]] to ptr
+; CHECK-NEXT: [[ITMP:%.*]] = call ptr @__asan_memcpy(ptr [[FADDRC]], ptr 
addrspacecast (ptr addrspace(4) @__const.__assert_fail.fmt to ptr), i64 47)
+; CHECK-NEXT: ret
+entry:
+%fmt = alloca [47 x i8], align 16, addrspace(5)
+%fmt.ascast = addrspacecast ptr addrspace(5) %fmt to ptr
+call void @llvm.memcpy.p0.p4.i64(ptr align 16 %fmt.ascast, ptr addrspace(4) 
align 16 @__const.__assert_fail.fmt, i64 47, i1 false)
+ret void
+}
+

arsenm wrote:

Also another test where both operands require the cast, as well as the integer 
cast.

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


[Lldb-commits] [clang] [compiler-rt] [flang] [libc] [libcxxabi] [libcxx] [clang-tools-extra] [llvm] [lldb] [libunwind] [ASan][AMDGPU] Fix Assertion Failure. (PR #78410)

2024-01-17 Thread via lldb-commits

https://github.com/ampandey-1995 updated 
https://github.com/llvm/llvm-project/pull/78410

>From ed9754939ffb4d5ef405f80c20b6de6f5e3e1eed Mon Sep 17 00:00:00 2001
From: Amit Pandey 
Date: Mon, 11 Dec 2023 14:23:44 +0530
Subject: [PATCH] [ASan][AMDGPU] Fix Assertion Failure.

Assertion failure `(i >= FTy->getNumParams() || FTy->getParamType(i) ==
Args[i]->getType()) && "Calling a function with a bad signature!"'.  The
'llvm.memcpy' intercepted by ASan instrumentation pass is implemented by it's
own __asan_memcpy implementation. The second argument of llvm.memcpy accepts ptr
to addrspace(4), __asan_memcpy also has to follow ptr to addrspace(4)
convention.
---
 .../Instrumentation/AddressSanitizer.cpp  |  3 ++-
 .../AMDGPU/asan_instrument_mem_intrinsics.ll  | 23 +++
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 
llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_instrument_mem_intrinsics.ll

diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp 
b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index fb5838bb7941ad..4d0be4715497a1 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1255,7 +1255,8 @@ void 
AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI) {
   InstrumentationIRBuilder IRB(MI);
   if (isa(MI)) {
 IRB.CreateCall(isa(MI) ? AsanMemmove : AsanMemcpy,
-   {MI->getOperand(0), MI->getOperand(1),
+   {MI->getOperand(0),
+IRB.CreateAddrSpaceCast(MI->getOperand(1), PtrTy),
 IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
   } else if (isa(MI)) {
 IRB.CreateCall(
diff --git 
a/llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_instrument_mem_intrinsics.ll
 
b/llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_instrument_mem_intrinsics.ll
new file mode 100644
index 00..bc905e24f40878
--- /dev/null
+++ 
b/llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_instrument_mem_intrinsics.ll
@@ -0,0 +1,23 @@
+;RUN: opt < %s -passes=asan -S | FileCheck %s
+
+target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
+target triple = "amdgcn-amd-amdhsa"
+
+@__const.__assert_fail.fmt = private unnamed_addr addrspace(4) constant [47 x 
i8] c"%s:%u: %s: Device-side assertion `%s' failed.\0A\00", align 16
+
+declare void @llvm.memcpy.p0.p4.i64(ptr noalias nocapture writeonly, ptr 
addrspace(4) noalias nocapture readonly, i64, i1 immarg) #1
+
+define weak hidden void @test_mem_intrinsic() sanitize_address #0 {
+; CHECK: define weak hidden void @test_mem_intrinsic() #1 {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[FMT:%.*]] = alloca [47 x i8], align 16, addrspace(5)
+; CHECK-NEXT: [[FADDRC:%.*]] = addrspacecast ptr addrspace(5) [[FMT]] to ptr
+; CHECK-NEXT: [[ITMP:%.*]] = call ptr @__asan_memcpy(ptr [[FADDRC]], ptr 
addrspacecast (ptr addrspace(4) @__const.__assert_fail.fmt to ptr), i64 47)
+; CHECK-NEXT: ret
+entry:
+%fmt = alloca [47 x i8], align 16, addrspace(5)
+%fmt.ascast = addrspacecast ptr addrspace(5) %fmt to ptr
+call void @llvm.memcpy.p0.p4.i64(ptr align 16 %fmt.ascast, ptr addrspace(4) 
align 16 @__const.__assert_fail.fmt, i64 47, i1 false)
+ret void
+}
+

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


  1   2   >