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

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

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

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

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

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

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

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

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

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


@@ -491,17 +491,38 @@ void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
 
 static VPValue *createScalarIVSteps(VPlan &Plan, const InductionDescriptor &ID,
 ScalarEvolution &SE, Instruction *TruncI,
-Type *IVTy, VPValue *StartV,
-VPValue *Step) {
+VPValue *StartV, VPValue *Step) {
   VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
   auto IP = HeaderVPBB->getFirstNonPhi();
   VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
-  Type *TruncTy = TruncI ? TruncI->getType() : IVTy;
-  VPValue *BaseIV = CanonicalIV;
-  if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step, TruncTy)) {
-BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step,
-   TruncI ? TruncI->getType() : nullptr);
-HeaderVPBB->insert(BaseIV->getDefiningRecipe(), IP);
+  VPSingleDefRecipe *BaseIV = CanonicalIV;
+  if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step)) {
+BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step);
+HeaderVPBB->insert(BaseIV, IP);
+  }
+
+  // Truncate base induction if needed.
+  VPTypeAnalysis TypeInfo(SE.getContext());
+  Type *ResultTy = TypeInfo.inferScalarType(BaseIV);
+  if (TruncI) {
+Type *TruncTy = TruncI->getType();
+assert(ResultTy->getScalarSizeInBits() > TruncTy->getScalarSizeInBits() &&
+   "Not truncating.");
+assert(ResultTy->isIntegerTy() && "Truncation requires an integer type");
+BaseIV = new VPScalarCastRecipe(Instruction::Trunc, BaseIV, TruncTy);

fhahn wrote:

Argh, sent the update too early (or too late in the day)! Should be fixed now., 
there were a number of test failures.

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


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

2024-01-26 Thread via lldb-commits

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

Looks good to me, thanks!
Adding a last minor nit.

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


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

2024-01-26 Thread via lldb-commits


@@ -491,17 +491,39 @@ void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
 
 static VPValue *createScalarIVSteps(VPlan &Plan, const InductionDescriptor &ID,
 ScalarEvolution &SE, Instruction *TruncI,
-Type *IVTy, VPValue *StartV,
-VPValue *Step) {
+VPValue *StartV, VPValue *Step) {
   VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
   auto IP = HeaderVPBB->getFirstNonPhi();
   VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
-  Type *TruncTy = TruncI ? TruncI->getType() : IVTy;
-  VPValue *BaseIV = CanonicalIV;
-  if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step, TruncTy)) {
-BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step,
-   TruncI ? TruncI->getType() : nullptr);
-HeaderVPBB->insert(BaseIV->getDefiningRecipe(), IP);
+  VPSingleDefRecipe *BaseIV = CanonicalIV;
+  if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step)) {
+BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step);
+HeaderVPBB->insert(BaseIV, IP);
+  }
+
+  // Truncate base induction if needed.
+  VPTypeAnalysis TypeInfo(SE.getContext());
+  Type *ResultTy = TypeInfo.inferScalarType(BaseIV);
+  if (TruncI) {
+Type *TruncTy = TruncI->getType();
+assert(ResultTy->getScalarSizeInBits() > TruncTy->getScalarSizeInBits() &&
+   "Not truncating.");
+assert(ResultTy->isIntegerTy() && "Truncation requires an integer type");
+BaseIV = new VPScalarCastRecipe(Instruction::Trunc, BaseIV, TruncTy);
+HeaderVPBB->insert(BaseIV, IP);
+ResultTy = TruncTy;
+  }
+
+  // Truncate step if needed.
+  Type *StepTy = TypeInfo.inferScalarType(Step);
+  if (ResultTy != StepTy) {
+assert(StepTy->getScalarSizeInBits() > ResultTy->getScalarSizeInBits() &&
+   "Not truncating.");
+assert(StepTy->isIntegerTy() && "Truncation requires an integer type");
+Step = new VPScalarCastRecipe(Instruction::Trunc, Step, ResultTy);
+auto *VecPreheader =
+cast(Plan.getVectorLoopRegion()->getSinglePredecessor());

ayalz wrote:

```suggestion
auto *VecPreheader =
cast(HeaderVPBB->getSingleHierarchicalPredecessor());
```
?

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


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

2024-01-26 Thread via lldb-commits

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


[Lldb-commits] [compiler-rt] [flang] [lld] [mlir] [libc] [libcxxabi] [libcxx] [lldb] [clang] [openmp] [llvm] [libclc] [clang-tools-extra] [VPlan] Add new VPScalarCastRecipe, use for IV & step trunc. (

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

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

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

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

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

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

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

[Lldb-commits] [lldb] 11d76fd - [lldb][FreeBSD] Fix unused variable warning

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

Author: David Spickett
Date: 2024-01-26T10:36:22Z
New Revision: 11d76fdb0b9c500aace938427bba18602d15b17d

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

LOG: [lldb][FreeBSD] Fix unused variable warning

Added: 


Modified: 

lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
 
b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
index 6d2e17d4eac66e..e504e6cbf69213 100644
--- 
a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
+++ 
b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
@@ -410,8 +410,7 @@ bool 
DynamicLoaderFreeBSDKernel::KModImageInfo::LoadImageUsingMemoryModule(
 
   // Find the slide address
   addr_t fixed_slide = LLDB_INVALID_ADDRESS;
-  if (ObjectFileELF *memory_objfile_elf =
-  llvm::dyn_cast(memory_object_file)) {
+  if (llvm::dyn_cast(memory_object_file)) {
 addr_t load_address = 
memory_object_file->GetBaseAddress().GetFileAddress();
 
 if (load_address != LLDB_INVALID_ADDRESS &&



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


[Lldb-commits] [compiler-rt] [flang] [lld] [mlir] [libc] [libcxxabi] [libcxx] [lldb] [clang] [openmp] [llvm] [libclc] [clang-tools-extra] [VPlan] Add new VPScalarCastRecipe, use for IV & step trunc. (

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

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

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

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

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

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

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

[Lldb-commits] [compiler-rt] [flang] [lld] [libc] [libcxx] [lldb] [clang] [llvm] [clang-tools-extra] [VPlan] Implement cloning of VPlans. (PR #73158)

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

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

>From 13a26e8e7440c3b501730b22588af393a3e543cd Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Thu, 6 Jul 2023 08:07:45 +0100
Subject: [PATCH 1/3] [VPlan] Implement cloning of VPlans.

This patch implements cloning for VPlans and recipes. Cloning is used in
the epilogue vectorization path, to clone the VPlan for the main vector
loop. This means we won't re-use a VPlan when executing the VPlan for
the epilogue vector loop, which in turn will enable us to perform
optimizations based on UF & VF.
---
 .../Transforms/Vectorize/LoopVectorize.cpp|   2 +-
 llvm/lib/Transforms/Vectorize/VPlan.cpp   | 124 
 llvm/lib/Transforms/Vectorize/VPlan.h | 182 ++
 .../Transforms/Vectorize/VPlanTest.cpp|   2 +
 4 files changed, 309 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 10c068e3b5895c2..9ffd44d59ffc6de 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10078,7 +10078,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
 EpilogueVectorizerMainLoop MainILV(L, PSE, LI, DT, TLI, TTI, AC, ORE,
EPI, &LVL, &CM, BFI, PSI, Checks);
 
-VPlan &BestMainPlan = LVP.getBestPlanFor(EPI.MainLoopVF);
+VPlan &BestMainPlan = *LVP.getBestPlanFor(EPI.MainLoopVF).clone();
 const auto &[ExpandedSCEVs, ReductionResumeValues] = LVP.executePlan(
 EPI.MainLoopVF, EPI.MainLoopUF, BestMainPlan, MainILV, DT, true);
 ++LoopsVectorized;
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index b6e56c47c227f77..99b2a3bd59a64df 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -615,6 +615,18 @@ void VPBasicBlock::print(raw_ostream &O, const Twine 
&Indent,
 }
 #endif
 
+VPBlockBase *VPRegionBlock::clone() {
+  DenseMap Old2New;
+  DenseMap Old2NewVPValues;
+  VPBlockBase *NewEntry =
+  VPBlockUtils::cloneCFG(Entry, Old2New, Old2NewVPValues);
+  auto *NewR =
+  new VPRegionBlock(NewEntry, Old2New[Exiting], getName(), isReplicator());
+  for (VPBlockBase *Block : vp_depth_first_shallow(NewEntry))
+Block->setParent(NewR);
+  return NewR;
+}
+
 void VPRegionBlock::dropAllReferences(VPValue *NewValue) {
   for (VPBlockBase *Block : vp_depth_first_shallow(Entry))
 // Drop all references in VPBasicBlocks and replace all uses with
@@ -982,6 +994,65 @@ void VPlan::updateDominatorTree(DominatorTree *DT, 
BasicBlock *LoopHeaderBB,
   assert(DT->verify(DominatorTree::VerificationLevel::Fast));
 }
 
+static void remapVPValues(VPBasicBlock *OldBB, VPBasicBlock *NewBB,
+  DenseMap &Old2NewVPValues,
+  bool Full = false) {
+  for (const auto &[OldR, NewR] : zip(*OldBB, *NewBB)) {
+for (unsigned I = 0, E = NewR.getNumOperands(); I != E; ++I) {
+  VPValue *NewOp = Old2NewVPValues.lookup(OldR.getOperand(I));
+  if (!Full)
+continue;
+  NewR.setOperand(I, NewOp);
+}
+for (const auto &[OldV, NewV] :
+ zip(OldR.definedValues(), NewR.definedValues()))
+  Old2NewVPValues[OldV] = NewV;
+  }
+}
+
+VPlan *VPlan::clone() {
+  DenseMap Old2New;
+  DenseMap Old2NewVPValues;
+
+  auto *NewPlan = new VPlan();
+  SmallVector NewLiveIns;
+  for (VPValue *LI : VPLiveInsToFree) {
+VPValue *NewLI = new VPValue(LI->getLiveInIRValue());
+NewPlan->VPLiveInsToFree.push_back(NewLI);
+Old2NewVPValues[LI] = NewLI;
+  }
+
+  Old2NewVPValues[&VectorTripCount] = &NewPlan->VectorTripCount;
+  Old2NewVPValues[&VFxUF] = &NewPlan->VFxUF;
+  if (BackedgeTakenCount) {
+Old2NewVPValues[BackedgeTakenCount] = new VPValue();
+NewPlan->BackedgeTakenCount = Old2NewVPValues[BackedgeTakenCount];
+  }
+
+  auto NewPH = cast(Preheader->clone());
+  remapVPValues(cast(Preheader), cast(NewPH),
+Old2NewVPValues, /*Full*/ true);
+  VPValue *NewTC = Old2NewVPValues.lookup(TripCount);
+  if (!NewTC)
+Old2NewVPValues[TripCount] = new VPValue(TripCount->getLiveInIRValue());
+  NewPlan->TripCount = Old2NewVPValues[TripCount];
+
+  auto *NewEntry = cast(VPBlockUtils::cloneCFG(
+  getEntry(), Old2New, Old2NewVPValues, /*FullRemapping*/ true));
+
+  NewPlan->Entry = NewEntry;
+  NewPlan->Preheader = NewPH;
+  NewEntry->setPlan(NewPlan);
+  NewPH->setPlan(NewPlan);
+  NewPlan->VFs = VFs;
+  NewPlan->UFs = UFs;
+  NewPlan->Name = Name;
+
+  for (const auto &[_, LO] : LiveOuts)
+NewPlan->addLiveOut(LO->getPhi(), Old2NewVPValues[LO->getOperand(0)]);
+  return NewPlan;
+}
+
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 
 Twine VPlanPrinter::getUID(const VPBlockBase *Block) {
@@ -1200,6 +1271,59 @@ void VPUser::printOperands(raw_ostream &O, VPSlotTracker 
&SlotTracker) const {
 }
 #end

[Lldb-commits] [openmp] [libclc] [clang] [compiler-rt] [llvm] [flang] [libcxx] [lld] [clang-tools-extra] [mlir] [lldb] [libcxxabi] [libc] [VPlan] Add new VPScalarCastRecipe, use for IV & step trunc. (

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


@@ -491,17 +491,39 @@ void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
 
 static VPValue *createScalarIVSteps(VPlan &Plan, const InductionDescriptor &ID,
 ScalarEvolution &SE, Instruction *TruncI,
-Type *IVTy, VPValue *StartV,
-VPValue *Step) {
+VPValue *StartV, VPValue *Step) {
   VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
   auto IP = HeaderVPBB->getFirstNonPhi();
   VPCanonicalIVPHIRecipe *CanonicalIV = Plan.getCanonicalIV();
-  Type *TruncTy = TruncI ? TruncI->getType() : IVTy;
-  VPValue *BaseIV = CanonicalIV;
-  if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step, TruncTy)) {
-BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step,
-   TruncI ? TruncI->getType() : nullptr);
-HeaderVPBB->insert(BaseIV->getDefiningRecipe(), IP);
+  VPSingleDefRecipe *BaseIV = CanonicalIV;
+  if (!CanonicalIV->isCanonical(ID.getKind(), StartV, Step)) {
+BaseIV = new VPDerivedIVRecipe(ID, StartV, CanonicalIV, Step);
+HeaderVPBB->insert(BaseIV, IP);
+  }
+
+  // Truncate base induction if needed.
+  VPTypeAnalysis TypeInfo(SE.getContext());
+  Type *ResultTy = TypeInfo.inferScalarType(BaseIV);
+  if (TruncI) {
+Type *TruncTy = TruncI->getType();
+assert(ResultTy->getScalarSizeInBits() > TruncTy->getScalarSizeInBits() &&
+   "Not truncating.");
+assert(ResultTy->isIntegerTy() && "Truncation requires an integer type");
+BaseIV = new VPScalarCastRecipe(Instruction::Trunc, BaseIV, TruncTy);
+HeaderVPBB->insert(BaseIV, IP);
+ResultTy = TruncTy;
+  }
+
+  // Truncate step if needed.
+  Type *StepTy = TypeInfo.inferScalarType(Step);
+  if (ResultTy != StepTy) {
+assert(StepTy->getScalarSizeInBits() > ResultTy->getScalarSizeInBits() &&
+   "Not truncating.");
+assert(StepTy->isIntegerTy() && "Truncation requires an integer type");
+Step = new VPScalarCastRecipe(Instruction::Trunc, Step, ResultTy);
+auto *VecPreheader =
+cast(Plan.getVectorLoopRegion()->getSinglePredecessor());

fhahn wrote:

Done, thanks!

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


[Lldb-commits] [clang] [lldb] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-26 Thread Balazs Benics via lldb-commits

steakhal wrote:

FYI this caused a crash in the Static Analyzer, tracked here: #79575
We will (well, probably I will) look into this to see what could be done about 
it to workaround/fix the crash for clang-18.

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


[Lldb-commits] [libcxx] [clang] [mlir] [llvm] [clang-tools-extra] [openmp] [flang] [libclc] [lld] [lldb] [libcxxabi] [compiler-rt] [libc] [VPlan] Add new VPScalarCastRecipe, use for IV & step trunc. (

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

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


[Lldb-commits] [libcxx] [clang] [llvm] [clang-tools-extra] [flang] [lld] [lldb] [compiler-rt] [libc] [VPlan] Implement cloning of VPlans. (PR #73158)

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

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

>From 13a26e8e7440c3b501730b22588af393a3e543cd Mon Sep 17 00:00:00 2001
From: Florian Hahn 
Date: Thu, 6 Jul 2023 08:07:45 +0100
Subject: [PATCH 1/4] [VPlan] Implement cloning of VPlans.

This patch implements cloning for VPlans and recipes. Cloning is used in
the epilogue vectorization path, to clone the VPlan for the main vector
loop. This means we won't re-use a VPlan when executing the VPlan for
the epilogue vector loop, which in turn will enable us to perform
optimizations based on UF & VF.
---
 .../Transforms/Vectorize/LoopVectorize.cpp|   2 +-
 llvm/lib/Transforms/Vectorize/VPlan.cpp   | 124 
 llvm/lib/Transforms/Vectorize/VPlan.h | 182 ++
 .../Transforms/Vectorize/VPlanTest.cpp|   2 +
 4 files changed, 309 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp 
b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 10c068e3b5895c..9ffd44d59ffc6d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10078,7 +10078,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
 EpilogueVectorizerMainLoop MainILV(L, PSE, LI, DT, TLI, TTI, AC, ORE,
EPI, &LVL, &CM, BFI, PSI, Checks);
 
-VPlan &BestMainPlan = LVP.getBestPlanFor(EPI.MainLoopVF);
+VPlan &BestMainPlan = *LVP.getBestPlanFor(EPI.MainLoopVF).clone();
 const auto &[ExpandedSCEVs, ReductionResumeValues] = LVP.executePlan(
 EPI.MainLoopVF, EPI.MainLoopUF, BestMainPlan, MainILV, DT, true);
 ++LoopsVectorized;
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp 
b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index b6e56c47c227f7..99b2a3bd59a64d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -615,6 +615,18 @@ void VPBasicBlock::print(raw_ostream &O, const Twine 
&Indent,
 }
 #endif
 
+VPBlockBase *VPRegionBlock::clone() {
+  DenseMap Old2New;
+  DenseMap Old2NewVPValues;
+  VPBlockBase *NewEntry =
+  VPBlockUtils::cloneCFG(Entry, Old2New, Old2NewVPValues);
+  auto *NewR =
+  new VPRegionBlock(NewEntry, Old2New[Exiting], getName(), isReplicator());
+  for (VPBlockBase *Block : vp_depth_first_shallow(NewEntry))
+Block->setParent(NewR);
+  return NewR;
+}
+
 void VPRegionBlock::dropAllReferences(VPValue *NewValue) {
   for (VPBlockBase *Block : vp_depth_first_shallow(Entry))
 // Drop all references in VPBasicBlocks and replace all uses with
@@ -982,6 +994,65 @@ void VPlan::updateDominatorTree(DominatorTree *DT, 
BasicBlock *LoopHeaderBB,
   assert(DT->verify(DominatorTree::VerificationLevel::Fast));
 }
 
+static void remapVPValues(VPBasicBlock *OldBB, VPBasicBlock *NewBB,
+  DenseMap &Old2NewVPValues,
+  bool Full = false) {
+  for (const auto &[OldR, NewR] : zip(*OldBB, *NewBB)) {
+for (unsigned I = 0, E = NewR.getNumOperands(); I != E; ++I) {
+  VPValue *NewOp = Old2NewVPValues.lookup(OldR.getOperand(I));
+  if (!Full)
+continue;
+  NewR.setOperand(I, NewOp);
+}
+for (const auto &[OldV, NewV] :
+ zip(OldR.definedValues(), NewR.definedValues()))
+  Old2NewVPValues[OldV] = NewV;
+  }
+}
+
+VPlan *VPlan::clone() {
+  DenseMap Old2New;
+  DenseMap Old2NewVPValues;
+
+  auto *NewPlan = new VPlan();
+  SmallVector NewLiveIns;
+  for (VPValue *LI : VPLiveInsToFree) {
+VPValue *NewLI = new VPValue(LI->getLiveInIRValue());
+NewPlan->VPLiveInsToFree.push_back(NewLI);
+Old2NewVPValues[LI] = NewLI;
+  }
+
+  Old2NewVPValues[&VectorTripCount] = &NewPlan->VectorTripCount;
+  Old2NewVPValues[&VFxUF] = &NewPlan->VFxUF;
+  if (BackedgeTakenCount) {
+Old2NewVPValues[BackedgeTakenCount] = new VPValue();
+NewPlan->BackedgeTakenCount = Old2NewVPValues[BackedgeTakenCount];
+  }
+
+  auto NewPH = cast(Preheader->clone());
+  remapVPValues(cast(Preheader), cast(NewPH),
+Old2NewVPValues, /*Full*/ true);
+  VPValue *NewTC = Old2NewVPValues.lookup(TripCount);
+  if (!NewTC)
+Old2NewVPValues[TripCount] = new VPValue(TripCount->getLiveInIRValue());
+  NewPlan->TripCount = Old2NewVPValues[TripCount];
+
+  auto *NewEntry = cast(VPBlockUtils::cloneCFG(
+  getEntry(), Old2New, Old2NewVPValues, /*FullRemapping*/ true));
+
+  NewPlan->Entry = NewEntry;
+  NewPlan->Preheader = NewPH;
+  NewEntry->setPlan(NewPlan);
+  NewPH->setPlan(NewPlan);
+  NewPlan->VFs = VFs;
+  NewPlan->UFs = UFs;
+  NewPlan->Name = Name;
+
+  for (const auto &[_, LO] : LiveOuts)
+NewPlan->addLiveOut(LO->getPhi(), Old2NewVPValues[LO->getOperand(0)]);
+  return NewPlan;
+}
+
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 
 Twine VPlanPrinter::getUID(const VPBlockBase *Block) {
@@ -1200,6 +1271,59 @@ void VPUser::printOperands(raw_ostream &O, VPSlotTracker 
&SlotTracker) const {
 }
 #endif
 

[Lldb-commits] [libc] [lld] [llvm] [lldb] [clang-tools-extra] [clang] [flang] [compiler-rt] [libcxx] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -982,6 +1037,92 @@ void VPlan::updateDominatorTree(DominatorTree *DT, 
BasicBlock *LoopHeaderBB,
   assert(DT->verify(DominatorTree::VerificationLevel::Fast));
 }
 
+static void remapOperands(VPBlockBase *Entry, VPBlockBase *NewEntry,
+  DenseMap &Old2NewVPValues) {
+  // Update the operands of all cloned recipes starting at NewEntry. This
+  // traverses all reachable blocks. This is done in two steps, to handle 
cycles
+  // in PHI recipes.
+  ReversePostOrderTraversal>
+  OldDeepRPOT(Entry);
+  ReversePostOrderTraversal>
+  NewDeepRPOT(NewEntry);
+  // First, collect all mappings from old to new VPValues defined by cloned
+  // recipes.
+  for (const auto &[OldBB, NewBB] :
+   zip(VPBlockUtils::blocksOnly(OldDeepRPOT),
+   VPBlockUtils::blocksOnly(NewDeepRPOT))) {
+assert(OldBB->getRecipeList().size() == NewBB->getRecipeList().size() &&
+   "blocks must have the same number of recipes");
+

fhahn wrote:

Removed, thanks!

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


[Lldb-commits] [clang] [lld] [libc] [flang] [lldb] [libcxx] [clang-tools-extra] [llvm] [compiler-rt] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -982,6 +1037,92 @@ void VPlan::updateDominatorTree(DominatorTree *DT, 
BasicBlock *LoopHeaderBB,
   assert(DT->verify(DominatorTree::VerificationLevel::Fast));
 }
 
+static void remapOperands(VPBlockBase *Entry, VPBlockBase *NewEntry,
+  DenseMap &Old2NewVPValues) {
+  // Update the operands of all cloned recipes starting at NewEntry. This
+  // traverses all reachable blocks. This is done in two steps, to handle 
cycles
+  // in PHI recipes.
+  ReversePostOrderTraversal>
+  OldDeepRPOT(Entry);
+  ReversePostOrderTraversal>
+  NewDeepRPOT(NewEntry);
+  // First, collect all mappings from old to new VPValues defined by cloned
+  // recipes.
+  for (const auto &[OldBB, NewBB] :
+   zip(VPBlockUtils::blocksOnly(OldDeepRPOT),
+   VPBlockUtils::blocksOnly(NewDeepRPOT))) {
+assert(OldBB->getRecipeList().size() == NewBB->getRecipeList().size() &&
+   "blocks must have the same number of recipes");
+
+for (const auto &[OldR, NewR] : zip(*OldBB, *NewBB)) {
+  assert(OldR.getNumOperands() == NewR.getNumOperands() &&
+ "recipes must have the same number of operands");
+  assert(OldR.getNumDefinedValues() == NewR.getNumDefinedValues() &&
+ "recipes must define the same number of operands");
+  for (const auto &[OldV, NewV] :
+   zip(OldR.definedValues(), NewR.definedValues()))
+Old2NewVPValues[OldV] = NewV;
+}
+  }
+
+  // Update all operands to use cloned VPValues.
+  for (VPBasicBlock *NewBB :
+   VPBlockUtils::blocksOnly(NewDeepRPOT)) {
+for (VPRecipeBase &NewR : *NewBB)
+  for (unsigned I = 0, E = NewR.getNumOperands(); I != E; ++I) {
+VPValue *NewOp = Old2NewVPValues.lookup(NewR.getOperand(I));
+NewR.setOperand(I, NewOp);
+  }
+  }
+}
+
+VPlan *VPlan::clone() {
+  DenseMap Old2NewVPValues;
+
+  // Clone blocks.
+  VPBlockBase *NewPreheader = cloneVPB(Preheader);
+  const auto &[NewEntry, __] = cloneSESE(getEntry());
+
+  // Create VPlan, clone live-ins and remap operands in the cloned blocks.
+  auto *NewPlan =
+  new VPlan(cast(NewPreheader), 
cast(NewEntry));
+  for (VPValue *OldLiveIn : VPLiveInsToFree) {
+VPValue *NewLiveIn = new VPValue(OldLiveIn->getLiveInIRValue());
+NewPlan->VPLiveInsToFree.push_back(NewLiveIn);
+Old2NewVPValues[OldLiveIn] = NewLiveIn;
+  }
+  Old2NewVPValues[&VectorTripCount] = &NewPlan->VectorTripCount;
+  Old2NewVPValues[&VFxUF] = &NewPlan->VFxUF;
+  if (BackedgeTakenCount) {
+NewPlan->BackedgeTakenCount = new VPValue();
+Old2NewVPValues[BackedgeTakenCount] = NewPlan->BackedgeTakenCount;
+  }
+  assert(TripCount && "trip count must be set");
+  if (TripCount->isLiveIn())
+Old2NewVPValues[TripCount] = new VPValue(TripCount->getLiveInIRValue());
+  // else NewTripCount will be created and inserted into Old2NewVPValues when
+  // TripCount is cloned. In any case NewPlan->TripCount is updated below.
+
+  remapOperands(Preheader, NewPreheader, Old2NewVPValues);
+  remapOperands(Entry, NewEntry, Old2NewVPValues);
+
+  // Clone live-outs.
+  for (const auto &[_, LO] : LiveOuts)
+NewPlan->addLiveOut(LO->getPhi(), Old2NewVPValues[LO->getOperand(0)]);
+
+  // Initialize remaining fields of cloned VPlan.
+  NewEntry->setPlan(NewPlan);
+  NewPreheader->setPlan(NewPlan);

fhahn wrote:

Removed, thanks!

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


[Lldb-commits] [clang-tools-extra] [libcxx] [flang] [lld] [lldb] [libc] [llvm] [compiler-rt] [clang] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -982,6 +1037,92 @@ void VPlan::updateDominatorTree(DominatorTree *DT, 
BasicBlock *LoopHeaderBB,
   assert(DT->verify(DominatorTree::VerificationLevel::Fast));
 }
 
+static void remapOperands(VPBlockBase *Entry, VPBlockBase *NewEntry,

fhahn wrote:

I left it as is, as keeping it is quite long and having it separate makes it a 
bit easier to read IMO (also reduces one level of indent), but happy to move it 
preferred.

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


[Lldb-commits] [libc] [clang] [flang] [clang-tools-extra] [compiler-rt] [llvm] [libcxx] [lld] [lldb] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -982,6 +1037,92 @@ void VPlan::updateDominatorTree(DominatorTree *DT, 
BasicBlock *LoopHeaderBB,
   assert(DT->verify(DominatorTree::VerificationLevel::Fast));
 }
 
+static void remapOperands(VPBlockBase *Entry, VPBlockBase *NewEntry,
+  DenseMap &Old2NewVPValues) {
+  // Update the operands of all cloned recipes starting at NewEntry. This
+  // traverses all reachable blocks. This is done in two steps, to handle 
cycles
+  // in PHI recipes.
+  ReversePostOrderTraversal>
+  OldDeepRPOT(Entry);
+  ReversePostOrderTraversal>
+  NewDeepRPOT(NewEntry);
+  // First, collect all mappings from old to new VPValues defined by cloned
+  // recipes.
+  for (const auto &[OldBB, NewBB] :
+   zip(VPBlockUtils::blocksOnly(OldDeepRPOT),
+   VPBlockUtils::blocksOnly(NewDeepRPOT))) {
+assert(OldBB->getRecipeList().size() == NewBB->getRecipeList().size() &&
+   "blocks must have the same number of recipes");
+
+for (const auto &[OldR, NewR] : zip(*OldBB, *NewBB)) {
+  assert(OldR.getNumOperands() == NewR.getNumOperands() &&
+ "recipes must have the same number of operands");
+  assert(OldR.getNumDefinedValues() == NewR.getNumDefinedValues() &&
+ "recipes must define the same number of operands");
+  for (const auto &[OldV, NewV] :
+   zip(OldR.definedValues(), NewR.definedValues()))
+Old2NewVPValues[OldV] = NewV;
+}
+  }
+
+  // Update all operands to use cloned VPValues.
+  for (VPBasicBlock *NewBB :
+   VPBlockUtils::blocksOnly(NewDeepRPOT)) {
+for (VPRecipeBase &NewR : *NewBB)
+  for (unsigned I = 0, E = NewR.getNumOperands(); I != E; ++I) {
+VPValue *NewOp = Old2NewVPValues.lookup(NewR.getOperand(I));
+NewR.setOperand(I, NewOp);
+  }
+  }
+}
+
+VPlan *VPlan::clone() {
+  DenseMap Old2NewVPValues;
+
+  // Clone blocks.
+  VPBlockBase *NewPreheader = cloneVPB(Preheader);
+  const auto &[NewEntry, __] = cloneSESE(getEntry());

fhahn wrote:

Updated to use `Entry`, thanks!

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


[Lldb-commits] [llvm] [clang] [flang] [compiler-rt] [clang-tools-extra] [libcxx] [lldb] [libc] [lld] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -982,6 +1037,92 @@ void VPlan::updateDominatorTree(DominatorTree *DT, 
BasicBlock *LoopHeaderBB,
   assert(DT->verify(DominatorTree::VerificationLevel::Fast));
 }
 
+static void remapOperands(VPBlockBase *Entry, VPBlockBase *NewEntry,
+  DenseMap &Old2NewVPValues) {
+  // Update the operands of all cloned recipes starting at NewEntry. This
+  // traverses all reachable blocks. This is done in two steps, to handle 
cycles
+  // in PHI recipes.
+  ReversePostOrderTraversal>
+  OldDeepRPOT(Entry);
+  ReversePostOrderTraversal>
+  NewDeepRPOT(NewEntry);
+  // First, collect all mappings from old to new VPValues defined by cloned
+  // recipes.
+  for (const auto &[OldBB, NewBB] :
+   zip(VPBlockUtils::blocksOnly(OldDeepRPOT),
+   VPBlockUtils::blocksOnly(NewDeepRPOT))) {
+assert(OldBB->getRecipeList().size() == NewBB->getRecipeList().size() &&
+   "blocks must have the same number of recipes");
+
+for (const auto &[OldR, NewR] : zip(*OldBB, *NewBB)) {
+  assert(OldR.getNumOperands() == NewR.getNumOperands() &&
+ "recipes must have the same number of operands");
+  assert(OldR.getNumDefinedValues() == NewR.getNumDefinedValues() &&
+ "recipes must define the same number of operands");
+  for (const auto &[OldV, NewV] :
+   zip(OldR.definedValues(), NewR.definedValues()))
+Old2NewVPValues[OldV] = NewV;
+}
+  }
+
+  // Update all operands to use cloned VPValues.
+  for (VPBasicBlock *NewBB :
+   VPBlockUtils::blocksOnly(NewDeepRPOT)) {
+for (VPRecipeBase &NewR : *NewBB)
+  for (unsigned I = 0, E = NewR.getNumOperands(); I != E; ++I) {
+VPValue *NewOp = Old2NewVPValues.lookup(NewR.getOperand(I));
+NewR.setOperand(I, NewOp);
+  }
+  }
+}
+
+VPlan *VPlan::clone() {
+  DenseMap Old2NewVPValues;

fhahn wrote:

Moved, thanks!

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


[Lldb-commits] [libcxx] [lldb] [clang] [compiler-rt] [libc] [lld] [llvm] [flang] [clang-tools-extra] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -614,6 +614,61 @@ void VPBasicBlock::print(raw_ostream &O, const Twine 
&Indent,
   printSuccessors(O, Indent);
 }
 #endif
+static void cloneCFG(VPBlockBase *Entry,
+ DenseMap &Old2NewVPBlocks);
+
+static VPBlockBase *cloneVPB(VPBlockBase *BB) {

fhahn wrote:

Updated to move block cloning to `::clone()` (in line with recipes) and renamed 
`VPlan::clone` to `VPlan::duplicate`. 

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


[Lldb-commits] [lldb] 5e9f0e3 - [lldb][ObjC][NFC] Fix c++20 gcc compile errors

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

Author: David Spickett
Date: 2024-01-26T11:37:50Z
New Revision: 5e9f0e37494ab42ff8d850527c5517f3006e63e9

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

LOG: [lldb][ObjC][NFC] Fix c++20 gcc compile errors

When compiling with gcc 11+ and -DCMAKE_CXX_STANDARD=20, errors
like the following happened:
```
llvm-project/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp:1063:5: error: 
template-id not allowed for destructor
 1063 | ~GenericNSDictionaryMSyntheticFrontEnd() {
  | ^
```
This appears to be something only gcc enforces and only from 11 and beyond.

This changes fixes all the instances of this pattern by removing the
template arguments.

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/NSArray.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/source/Plugins/Language/ObjC/NSSet.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp 
b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index bd356a61161a537..963983c7ffcae12 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -548,9 +548,8 @@ 
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName
 }
 
 template 
-lldb_private::formatters::
-  GenericNSArrayMSyntheticFrontEnd::
-~GenericNSArrayMSyntheticFrontEnd() {
+lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<
+D32, D64>::~GenericNSArrayMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;
@@ -615,8 +614,8 @@ 
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
 }
 
 template 
-lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
-  ~GenericNSArrayISyntheticFrontEnd() {
+lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<
+D32, D64, Inline>::~GenericNSArrayISyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;

diff  --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 5ae0751cb065f32..18c97dd933b3bf8 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -1059,8 +1059,8 @@ 
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::
   m_data_32(nullptr), m_data_64(nullptr), m_pair_type() {}
 
 template 
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::
-~GenericNSDictionaryMSyntheticFrontEnd() {
+lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
+D32, D64>::~GenericNSDictionaryMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;

diff  --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp 
b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index 44097ee0c42b855..6917f23b10ca690 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -671,8 +671,8 @@ lldb_private::formatters::GenericNSSetMSyntheticFrontEnd<
 }
 
 template 
-lldb_private::formatters::
-  GenericNSSetMSyntheticFrontEnd::~GenericNSSetMSyntheticFrontEnd() {
+lldb_private::formatters::GenericNSSetMSyntheticFrontEnd<
+D32, D64>::~GenericNSSetMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;



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


[Lldb-commits] [clang] [libc] [flang] [libcxx] [clang-tools-extra] [lld] [compiler-rt] [llvm] [lldb] [VPlan] Implement cloning of VPlans. (PR #73158)

2024-01-26 Thread via lldb-commits

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

Looks good to me, ship it!

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


[Lldb-commits] [lldb] 28ee54c - Revert "[lldb][ObjC][NFC] Fix c++20 gcc compile errors"

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

Author: David Spickett
Date: 2024-01-26T12:21:42Z
New Revision: 28ee54c32e6b761e65fd2a7412776f6300ad922b

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

LOG: Revert "[lldb][ObjC][NFC] Fix c++20 gcc compile errors"

This reverts commit 5e9f0e37494ab42ff8d850527c5517f3006e63e9
because it creates a new warning from clang:
```
NSDictionary.cpp:1063:14: warning: ISO C++ requires the name after '::~' to be 
found in the same scope as the name before '::~' [-Wdtor-name]
D32, D64>::~GenericNSDictionaryMSyntheticFrontEnd() {
~^~
 ::GenericNSDictionaryMSyntheticFrontEnd
```

If you remove the template arguments from before the `::`, you
then get:
```
NSDictionary.cpp:1062:27: error: use of class template 
'lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd' requires 
template arguments
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::~GenericNSDictionaryMSyntheticFrontEnd()
 {
  ^
```

And I'm not aware of a way to fix that.

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/NSArray.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/source/Plugins/Language/ObjC/NSSet.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp 
b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 963983c7ffcae12..bd356a61161a537 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -548,8 +548,9 @@ 
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName
 }
 
 template 
-lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<
-D32, D64>::~GenericNSArrayMSyntheticFrontEnd() {
+lldb_private::formatters::
+  GenericNSArrayMSyntheticFrontEnd::
+~GenericNSArrayMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;
@@ -614,8 +615,8 @@ 
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
 }
 
 template 
-lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<
-D32, D64, Inline>::~GenericNSArrayISyntheticFrontEnd() {
+lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
+  ~GenericNSArrayISyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;

diff  --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 18c97dd933b3bf8..5ae0751cb065f32 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -1059,8 +1059,8 @@ 
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::
   m_data_32(nullptr), m_data_64(nullptr), m_pair_type() {}
 
 template 
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
-D32, D64>::~GenericNSDictionaryMSyntheticFrontEnd() {
+lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::
+~GenericNSDictionaryMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;

diff  --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp 
b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index 6917f23b10ca690..44097ee0c42b855 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -671,8 +671,8 @@ lldb_private::formatters::GenericNSSetMSyntheticFrontEnd<
 }
 
 template 
-lldb_private::formatters::GenericNSSetMSyntheticFrontEnd<
-D32, D64>::~GenericNSSetMSyntheticFrontEnd() {
+lldb_private::formatters::
+  GenericNSSetMSyntheticFrontEnd::~GenericNSSetMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;



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


[Lldb-commits] [lldb] bb945fc - Reland "[lldb][ObjC][NFC] Fix c++20 gcc compile errors"

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

Author: David Spickett
Date: 2024-01-26T14:06:49Z
New Revision: bb945fcd4a54c2c8f898e2bdc0d65fae841a1909

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

LOG: Reland "[lldb][ObjC][NFC] Fix c++20 gcc compile errors"

clang's -Wdtor name is correct, but the standard may have not
intended that meaning, according to 
https://bugs.llvm.org/show_bug.cgi?id=46979#c1.
Some of the wording may have changed in 20/23, but we of course
need to support c++17 as well as that's our default.

One workaround would be to explicitly open the namespaces,
then declare the destructor inside that.

Another as shown in the bug report is to repeat the class name, without
the template arguments, before the ::~. For example `Bar::Foo::Foo::~Foo`.
(this extra Foo is the injected class name
https://en.cppreference.com/w/cpp/language/injected-class-name)

I chose to do this because it's the smallest change. It works
with gcc-13 and clang in c++17 and 20 modes (https://godbolt.org/z/fqs4fGE7T).

Added: 


Modified: 
lldb/source/Plugins/Language/ObjC/NSArray.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
lldb/source/Plugins/Language/ObjC/NSSet.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp 
b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index bd356a61161a537..7d0004c572ed6bb 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -548,9 +548,8 @@ 
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName
 }
 
 template 
-lldb_private::formatters::
-  GenericNSArrayMSyntheticFrontEnd::
-~GenericNSArrayMSyntheticFrontEnd() {
+lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd::
+GenericNSArrayMSyntheticFrontEnd::~GenericNSArrayMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;
@@ -616,7 +615,7 @@ 
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
 
 template 
 lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
-  ~GenericNSArrayISyntheticFrontEnd() {
+GenericNSArrayISyntheticFrontEnd::~GenericNSArrayISyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;

diff  --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 5ae0751cb065f32..d377ee74ccc05d1 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -1059,8 +1059,9 @@ 
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::
   m_data_32(nullptr), m_data_64(nullptr), m_pair_type() {}
 
 template 
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd::
-~GenericNSDictionaryMSyntheticFrontEnd() {
+lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
+D32, D64>::GenericNSDictionaryMSyntheticFrontEnd::
+~GenericNSDictionaryMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;

diff  --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp 
b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index 44097ee0c42b855..ed1751cc128ca27 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -671,8 +671,8 @@ lldb_private::formatters::GenericNSSetMSyntheticFrontEnd<
 }
 
 template 
-lldb_private::formatters::
-  GenericNSSetMSyntheticFrontEnd::~GenericNSSetMSyntheticFrontEnd() {
+lldb_private::formatters::GenericNSSetMSyntheticFrontEnd::
+GenericNSSetMSyntheticFrontEnd::~GenericNSSetMSyntheticFrontEnd() {
   delete m_data_32;
   m_data_32 = nullptr;
   delete m_data_64;



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


[Lldb-commits] [clang] [lldb] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

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

erichkeane wrote:

@bolshakov-a : The original bug has a good amount of analysis to it, so if you 
could see if there is a fix for it, else we probably do have to revert for that 
one and miss 18 with this patch.

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


[Lldb-commits] [clang] [lldb] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

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

erichkeane wrote:

I see now that hte problem is probably in the Analyzer, so @steakhal is 
probably the best person to be leading this, but any work you can do 
@bolshakov-a would also likely be appreciated.

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


[Lldb-commits] [lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-26 Thread Andrey Ali Khan Bolshakov via lldb-commits

bolshakov-a wrote:

Prior to this PR, arrays in NTTP were represented as `Declaration`s and now as 
`StructuralValue`s referring to their first element. @steakhal, please note 
[here](https://github.com/llvm/llvm-project/pull/78041/files#diff-2f25fdb80b1a63f2e0a5a7c7a7c061b494b430ee8f5759b48022a86a149030bbR8162)
 how the corresponding `OpaqueValueExpr` is constructed. The is no 
subexpression inside it. Maybe, it will help. I'll probably have a chance to 
look into it deeper after several hours or tomorrow.

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


[Lldb-commits] [llvm] [lldb] [mlir] [openmp] [flang] [mlir][Vector] Add patterns for efficient i4 -> i8 conversion emulation (PR #79494)

2024-01-26 Thread Benjamin Maxwell via lldb-commits

MacDue wrote:

>  It gets difficult to get this working for scalable at this level as we would 
> have to introduce SVE or LLVM intrinsics to model the interleave in an 
> scalable way.

There already are LLVM intrinsics for that, so I don't think it'd be hard to 
extend to support SVE:

I wrote this little test, which seemed to build fine, and generate reasonable 
looking code:
```mlir
func.func @test_sve_i4_extend(%inMem: memref ) -> vector<[8]xi32> {
  %c0 = arith.constant 0 :index
  %c4 = arith.constant 4 : i8
  %in = vector.load %inMem[%c0] :  memref, vector<[8]xi4>
  %shift = vector.splat %c4 : vector<[4]xi8>
  %0 = vector.bitcast %in : vector<[8]xi4> to vector<[4]xi8>
  %1 = arith.shli %0, %shift : vector<[4]xi8>
  %2 = arith.shrsi %1, %shift : vector<[4]xi8>
  %3 = arith.shrsi %0, %shift : vector<[4]xi8>
  %4 = "llvm.intr.experimental.vector.interleave2"(%2, %3) : (vector<[4]xi8>, 
vector<[4]xi8>) -> vector<[8]xi8>
  %5 = arith.extsi %4 : vector<[8]xi8> to vector<[8]xi32>
  return %5 : vector<[8]xi32>
}
```
->
```
test_sve_i4_extend: 
ptrue   p0.s
ld1sb   { z0.s }, p0/z, [x1]
lsl z1.s, z0.s, #28
asr z0.s, z0.s, #4
asr z1.s, z1.s, #28
zip2z2.s, z1.s, z0.s
zip1z0.s, z1.s, z0.s
movprfx z1, z2
sxtbz1.s, p0/m, z2.s
sxtbz0.s, p0/m, z0.s
ret
```

I think in the vector dialect: `"llvm.intr.experimental.vector.interleave2` 
could nicely become `vector.scalable.interleave` :slightly_smiling_face: 




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


[Lldb-commits] [lld] [llvm] [clang] [libcxx] [lldb] [libc] [flang] [compiler-rt] [clang-tools-extra] [Clang][C++23] Implement P2448R2: Relaxing some constexpr restrictions (PR #77753)

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

Fznamznon wrote:

> Oh gosh, I'm an idiot, i meant true

That makes it a little bit challenging to preserve old warnings for older 
versions of the language, without additional flags and options, in some cases 
like:
```
  struct A {
~A();
  };
  struct B : A {  };
  struct C {
B a;
constexpr ~C() {}
  };
```

So, when considering `~C`, it can be checked in 
`CheckConstexprDestructorSubobjects` that `B` has constexpr destructor and by 
the new rules it will, but there is no recursion there so `A` won't be checked 
and warning is lost. I'm not sure I want to add recursion to 
`CheckConstexprDestructorSubobjects`. Not sure about flags to CXXRecordDecl too.

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


[Lldb-commits] [lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-26 Thread via lldb-commits

bgra8 wrote:

Heads up: we've stumbled upon this exact crash 
(https://github.com/llvm/llvm-project/issues/79575) while testing clang inside 
google too.

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


[Lldb-commits] [lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-26 Thread via lldb-commits


@@ -8129,29 +8067,133 @@ 
Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
 else
   Kind = CharacterLiteralKind::Ascii;
 
-E = new (Context) CharacterLiteral(Arg.getAsIntegral().getZExtValue(),
-   Kind, T, Loc);
+E = new (S.Context) CharacterLiteral(Int.getZExtValue(), Kind, T, Loc);
   } else if (T->isBooleanType()) {
-E = CXXBoolLiteralExpr::Create(Context, Arg.getAsIntegral().getBoolValue(),
-   T, Loc);
-  } else if (T->isNullPtrType()) {
-E = new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc);
+E = CXXBoolLiteralExpr::Create(S.Context, Int.getBoolValue(), T, Loc);
   } else {
-E = IntegerLiteral::Create(Context, Arg.getAsIntegral(), T, Loc);
+E = IntegerLiteral::Create(S.Context, Int, T, Loc);
   }
 
   if (OrigT->isEnumeralType()) {
 // FIXME: This is a hack. We need a better way to handle substituted
 // non-type template parameters.
-E = CStyleCastExpr::Create(Context, OrigT, VK_PRValue, CK_IntegralCast, E,
-   nullptr, CurFPFeatureOverrides(),
-   Context.getTrivialTypeSourceInfo(OrigT, Loc),
+E = CStyleCastExpr::Create(S.Context, OrigT, VK_PRValue, CK_IntegralCast, 
E,
+   nullptr, S.CurFPFeatureOverrides(),
+   S.Context.getTrivialTypeSourceInfo(OrigT, Loc),
Loc, Loc);
   }
 
   return E;
 }
 
+static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
+Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
+  auto MakeInitList = [&](ArrayRef Elts) -> Expr * {
+auto *ILE = new (S.Context) InitListExpr(S.Context, Loc, Elts, Loc);
+ILE->setType(T);
+return ILE;
+  };
+
+  switch (Val.getKind()) {
+  case APValue::AddrLabelDiff:
+// This cannot occur in a template argument at all.
+  case APValue::Array:
+  case APValue::Struct:
+  case APValue::Union:
+// These can only occur within a template parameter object, which is
+// represented as a TemplateArgument::Declaration.
+llvm_unreachable("unexpected template argument value");
+
+  case APValue::Int:
+return BuildExpressionFromIntegralTemplateArgumentValue(S, T, Val.getInt(),
+Loc);
+
+  case APValue::Float:
+return FloatingLiteral::Create(S.Context, Val.getFloat(), /*IsExact=*/true,
+   T, Loc);
+
+  case APValue::FixedPoint:
+return FixedPointLiteral::CreateFromRawInt(
+S.Context, Val.getFixedPoint().getValue(), T, Loc,
+Val.getFixedPoint().getScale());
+
+  case APValue::ComplexInt: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList({BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntReal(), Loc),
+ BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntImag(), Loc)});
+  }
+
+  case APValue::ComplexFloat: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList(
+{FloatingLiteral::Create(S.Context, Val.getComplexFloatReal(), true,
+ ElemT, Loc),
+ FloatingLiteral::Create(S.Context, Val.getComplexFloatImag(), true,
+ ElemT, Loc)});
+  }
+
+  case APValue::Vector: {
+QualType ElemT = T->castAs()->getElementType();
+llvm::SmallVector Elts;
+for (unsigned I = 0, N = Val.getVectorLength(); I != N; ++I)
+  Elts.push_back(BuildExpressionFromNonTypeTemplateArgumentValue(
+  S, ElemT, Val.getVectorElt(I), Loc));
+return MakeInitList(Elts);
+  }
+
+  case APValue::None:
+  case APValue::Indeterminate:
+llvm_unreachable("Unexpected APValue kind.");
+  case APValue::LValue:
+  case APValue::MemberPointer:
+// There isn't necessarily a valid equivalent source-level syntax for
+// these; in particular, a naive lowering might violate access control.
+// So for now we lower to a ConstantExpr holding the value, wrapped around
+// an OpaqueValueExpr.
+// FIXME: We should have a better representation for this.
+ExprValueKind VK = VK_PRValue;
+if (T->isReferenceType()) {
+  T = T->getPointeeType();
+  VK = VK_LValue;
+}
+auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);

cor3ntin wrote:

Here we create an OpaqueValueExpr without a source expression and the static 
analyser assume `cast(E)->getSourceExpr()` is not null in 
`ignoreTransparentExprs` 

@steakhal 


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


[Lldb-commits] [lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-26 Thread via lldb-commits

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


[Lldb-commits] [lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

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


@@ -8129,29 +8067,133 @@ 
Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
 else
   Kind = CharacterLiteralKind::Ascii;
 
-E = new (Context) CharacterLiteral(Arg.getAsIntegral().getZExtValue(),
-   Kind, T, Loc);
+E = new (S.Context) CharacterLiteral(Int.getZExtValue(), Kind, T, Loc);
   } else if (T->isBooleanType()) {
-E = CXXBoolLiteralExpr::Create(Context, Arg.getAsIntegral().getBoolValue(),
-   T, Loc);
-  } else if (T->isNullPtrType()) {
-E = new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc);
+E = CXXBoolLiteralExpr::Create(S.Context, Int.getBoolValue(), T, Loc);
   } else {
-E = IntegerLiteral::Create(Context, Arg.getAsIntegral(), T, Loc);
+E = IntegerLiteral::Create(S.Context, Int, T, Loc);
   }
 
   if (OrigT->isEnumeralType()) {
 // FIXME: This is a hack. We need a better way to handle substituted
 // non-type template parameters.
-E = CStyleCastExpr::Create(Context, OrigT, VK_PRValue, CK_IntegralCast, E,
-   nullptr, CurFPFeatureOverrides(),
-   Context.getTrivialTypeSourceInfo(OrigT, Loc),
+E = CStyleCastExpr::Create(S.Context, OrigT, VK_PRValue, CK_IntegralCast, 
E,
+   nullptr, S.CurFPFeatureOverrides(),
+   S.Context.getTrivialTypeSourceInfo(OrigT, Loc),
Loc, Loc);
   }
 
   return E;
 }
 
+static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
+Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
+  auto MakeInitList = [&](ArrayRef Elts) -> Expr * {
+auto *ILE = new (S.Context) InitListExpr(S.Context, Loc, Elts, Loc);
+ILE->setType(T);
+return ILE;
+  };
+
+  switch (Val.getKind()) {
+  case APValue::AddrLabelDiff:
+// This cannot occur in a template argument at all.
+  case APValue::Array:
+  case APValue::Struct:
+  case APValue::Union:
+// These can only occur within a template parameter object, which is
+// represented as a TemplateArgument::Declaration.
+llvm_unreachable("unexpected template argument value");
+
+  case APValue::Int:
+return BuildExpressionFromIntegralTemplateArgumentValue(S, T, Val.getInt(),
+Loc);
+
+  case APValue::Float:
+return FloatingLiteral::Create(S.Context, Val.getFloat(), /*IsExact=*/true,
+   T, Loc);
+
+  case APValue::FixedPoint:
+return FixedPointLiteral::CreateFromRawInt(
+S.Context, Val.getFixedPoint().getValue(), T, Loc,
+Val.getFixedPoint().getScale());
+
+  case APValue::ComplexInt: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList({BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntReal(), Loc),
+ BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntImag(), Loc)});
+  }
+
+  case APValue::ComplexFloat: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList(
+{FloatingLiteral::Create(S.Context, Val.getComplexFloatReal(), true,
+ ElemT, Loc),
+ FloatingLiteral::Create(S.Context, Val.getComplexFloatImag(), true,
+ ElemT, Loc)});
+  }
+
+  case APValue::Vector: {
+QualType ElemT = T->castAs()->getElementType();
+llvm::SmallVector Elts;
+for (unsigned I = 0, N = Val.getVectorLength(); I != N; ++I)
+  Elts.push_back(BuildExpressionFromNonTypeTemplateArgumentValue(
+  S, ElemT, Val.getVectorElt(I), Loc));
+return MakeInitList(Elts);
+  }
+
+  case APValue::None:
+  case APValue::Indeterminate:
+llvm_unreachable("Unexpected APValue kind.");
+  case APValue::LValue:
+  case APValue::MemberPointer:
+// There isn't necessarily a valid equivalent source-level syntax for
+// these; in particular, a naive lowering might violate access control.
+// So for now we lower to a ConstantExpr holding the value, wrapped around
+// an OpaqueValueExpr.
+// FIXME: We should have a better representation for this.
+ExprValueKind VK = VK_PRValue;
+if (T->isReferenceType()) {
+  T = T->getPointeeType();
+  VK = VK_LValue;
+}
+auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);

erichkeane wrote:

Is there a SourceExpr we could put in there?  Or is the assumption that the 
analyzer makes just not a valid one to make?

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


[Lldb-commits] [lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

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


@@ -8129,29 +8067,133 @@ 
Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
 else
   Kind = CharacterLiteralKind::Ascii;
 
-E = new (Context) CharacterLiteral(Arg.getAsIntegral().getZExtValue(),
-   Kind, T, Loc);
+E = new (S.Context) CharacterLiteral(Int.getZExtValue(), Kind, T, Loc);
   } else if (T->isBooleanType()) {
-E = CXXBoolLiteralExpr::Create(Context, Arg.getAsIntegral().getBoolValue(),
-   T, Loc);
-  } else if (T->isNullPtrType()) {
-E = new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc);
+E = CXXBoolLiteralExpr::Create(S.Context, Int.getBoolValue(), T, Loc);
   } else {
-E = IntegerLiteral::Create(Context, Arg.getAsIntegral(), T, Loc);
+E = IntegerLiteral::Create(S.Context, Int, T, Loc);
   }
 
   if (OrigT->isEnumeralType()) {
 // FIXME: This is a hack. We need a better way to handle substituted
 // non-type template parameters.
-E = CStyleCastExpr::Create(Context, OrigT, VK_PRValue, CK_IntegralCast, E,
-   nullptr, CurFPFeatureOverrides(),
-   Context.getTrivialTypeSourceInfo(OrigT, Loc),
+E = CStyleCastExpr::Create(S.Context, OrigT, VK_PRValue, CK_IntegralCast, 
E,
+   nullptr, S.CurFPFeatureOverrides(),
+   S.Context.getTrivialTypeSourceInfo(OrigT, Loc),
Loc, Loc);
   }
 
   return E;
 }
 
+static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
+Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
+  auto MakeInitList = [&](ArrayRef Elts) -> Expr * {
+auto *ILE = new (S.Context) InitListExpr(S.Context, Loc, Elts, Loc);
+ILE->setType(T);
+return ILE;
+  };
+
+  switch (Val.getKind()) {
+  case APValue::AddrLabelDiff:
+// This cannot occur in a template argument at all.
+  case APValue::Array:
+  case APValue::Struct:
+  case APValue::Union:
+// These can only occur within a template parameter object, which is
+// represented as a TemplateArgument::Declaration.
+llvm_unreachable("unexpected template argument value");
+
+  case APValue::Int:
+return BuildExpressionFromIntegralTemplateArgumentValue(S, T, Val.getInt(),
+Loc);
+
+  case APValue::Float:
+return FloatingLiteral::Create(S.Context, Val.getFloat(), /*IsExact=*/true,
+   T, Loc);
+
+  case APValue::FixedPoint:
+return FixedPointLiteral::CreateFromRawInt(
+S.Context, Val.getFixedPoint().getValue(), T, Loc,
+Val.getFixedPoint().getScale());
+
+  case APValue::ComplexInt: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList({BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntReal(), Loc),
+ BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntImag(), Loc)});
+  }
+
+  case APValue::ComplexFloat: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList(
+{FloatingLiteral::Create(S.Context, Val.getComplexFloatReal(), true,
+ ElemT, Loc),
+ FloatingLiteral::Create(S.Context, Val.getComplexFloatImag(), true,
+ ElemT, Loc)});
+  }
+
+  case APValue::Vector: {
+QualType ElemT = T->castAs()->getElementType();
+llvm::SmallVector Elts;
+for (unsigned I = 0, N = Val.getVectorLength(); I != N; ++I)
+  Elts.push_back(BuildExpressionFromNonTypeTemplateArgumentValue(
+  S, ElemT, Val.getVectorElt(I), Loc));
+return MakeInitList(Elts);
+  }
+
+  case APValue::None:
+  case APValue::Indeterminate:
+llvm_unreachable("Unexpected APValue kind.");
+  case APValue::LValue:
+  case APValue::MemberPointer:
+// There isn't necessarily a valid equivalent source-level syntax for
+// these; in particular, a naive lowering might violate access control.
+// So for now we lower to a ConstantExpr holding the value, wrapped around
+// an OpaqueValueExpr.
+// FIXME: We should have a better representation for this.
+ExprValueKind VK = VK_PRValue;
+if (T->isReferenceType()) {
+  T = T->getPointeeType();
+  VK = VK_LValue;
+}
+auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);

erichkeane wrote:

> Is there a SourceExpr we could put in there? Or is the assumption that the 
> analyzer makes just not a valid one to make?

Answered my own question, I don't see anythign we could use.  The existance of 
the constructor used here, IMO, shows that the assumption in the analyzer is 
wrong, so I believe it needs to be fixed there.

https://github.com/llvm/llvm-project/pull/78041
___
lldb-commits mailing 

[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {

JDevlieghere wrote:

Nit: missing newline

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }

JDevlieghere wrote:

There's a utility that simplifies this called `SubsystemRAII`. Here's how you 
use that:

```
#include "TestingSupport/SubsystemRAII.h"

class ProgressReportTest : public ::testing::Test {
SubsystemRAII subsystems;
}
```

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster &broadcaster = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(&broadcaster,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");
+
+std::this_thread::sleep_for(timeout);
+  }
+
+  // Progress report objects should be destroyed at this point so
+  // get each report from the queue and check that they've been
+  // destroyed in reverse order
+  std::this_thread::sleep_for(timeout);

JDevlieghere wrote:

This shouldn't be necessary: you've done the progress reporting from the same 
thread that you're getting the event from so since this is linear code, all 
events should be queued up in the broadcaster. 

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


[Lldb-commits] [lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-26 Thread Andrey Ali Khan Bolshakov via lldb-commits


@@ -8129,29 +8067,133 @@ 
Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
 else
   Kind = CharacterLiteralKind::Ascii;
 
-E = new (Context) CharacterLiteral(Arg.getAsIntegral().getZExtValue(),
-   Kind, T, Loc);
+E = new (S.Context) CharacterLiteral(Int.getZExtValue(), Kind, T, Loc);
   } else if (T->isBooleanType()) {
-E = CXXBoolLiteralExpr::Create(Context, Arg.getAsIntegral().getBoolValue(),
-   T, Loc);
-  } else if (T->isNullPtrType()) {
-E = new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc);
+E = CXXBoolLiteralExpr::Create(S.Context, Int.getBoolValue(), T, Loc);
   } else {
-E = IntegerLiteral::Create(Context, Arg.getAsIntegral(), T, Loc);
+E = IntegerLiteral::Create(S.Context, Int, T, Loc);
   }
 
   if (OrigT->isEnumeralType()) {
 // FIXME: This is a hack. We need a better way to handle substituted
 // non-type template parameters.
-E = CStyleCastExpr::Create(Context, OrigT, VK_PRValue, CK_IntegralCast, E,
-   nullptr, CurFPFeatureOverrides(),
-   Context.getTrivialTypeSourceInfo(OrigT, Loc),
+E = CStyleCastExpr::Create(S.Context, OrigT, VK_PRValue, CK_IntegralCast, 
E,
+   nullptr, S.CurFPFeatureOverrides(),
+   S.Context.getTrivialTypeSourceInfo(OrigT, Loc),
Loc, Loc);
   }
 
   return E;
 }
 
+static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
+Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
+  auto MakeInitList = [&](ArrayRef Elts) -> Expr * {
+auto *ILE = new (S.Context) InitListExpr(S.Context, Loc, Elts, Loc);
+ILE->setType(T);
+return ILE;
+  };
+
+  switch (Val.getKind()) {
+  case APValue::AddrLabelDiff:
+// This cannot occur in a template argument at all.
+  case APValue::Array:
+  case APValue::Struct:
+  case APValue::Union:
+// These can only occur within a template parameter object, which is
+// represented as a TemplateArgument::Declaration.
+llvm_unreachable("unexpected template argument value");
+
+  case APValue::Int:
+return BuildExpressionFromIntegralTemplateArgumentValue(S, T, Val.getInt(),
+Loc);
+
+  case APValue::Float:
+return FloatingLiteral::Create(S.Context, Val.getFloat(), /*IsExact=*/true,
+   T, Loc);
+
+  case APValue::FixedPoint:
+return FixedPointLiteral::CreateFromRawInt(
+S.Context, Val.getFixedPoint().getValue(), T, Loc,
+Val.getFixedPoint().getScale());
+
+  case APValue::ComplexInt: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList({BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntReal(), Loc),
+ BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntImag(), Loc)});
+  }
+
+  case APValue::ComplexFloat: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList(
+{FloatingLiteral::Create(S.Context, Val.getComplexFloatReal(), true,
+ ElemT, Loc),
+ FloatingLiteral::Create(S.Context, Val.getComplexFloatImag(), true,
+ ElemT, Loc)});
+  }
+
+  case APValue::Vector: {
+QualType ElemT = T->castAs()->getElementType();
+llvm::SmallVector Elts;
+for (unsigned I = 0, N = Val.getVectorLength(); I != N; ++I)
+  Elts.push_back(BuildExpressionFromNonTypeTemplateArgumentValue(
+  S, ElemT, Val.getVectorElt(I), Loc));
+return MakeInitList(Elts);
+  }
+
+  case APValue::None:
+  case APValue::Indeterminate:
+llvm_unreachable("Unexpected APValue kind.");
+  case APValue::LValue:
+  case APValue::MemberPointer:
+// There isn't necessarily a valid equivalent source-level syntax for
+// these; in particular, a naive lowering might violate access control.
+// So for now we lower to a ConstantExpr holding the value, wrapped around
+// an OpaqueValueExpr.
+// FIXME: We should have a better representation for this.
+ExprValueKind VK = VK_PRValue;
+if (T->isReferenceType()) {
+  T = T->getPointeeType();
+  VK = VK_LValue;
+}
+auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);

bolshakov-a wrote:

I agree. (It _becomes_ wrong after this PR)

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


[Lldb-commits] [lldb] [lldb][NFCI] Constrain EventDataBytes creation (PR #79508)

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

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


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


[Lldb-commits] [compiler-rt] [flang] [clang] [libc] [lldb] [clang-tools-extra] [llvm] LLDB Debuginfod usage tests (with fixes) (PR #79181)

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


@@ -0,0 +1,65 @@
+# Tests for basic Debuginfod functionality
+
+Because the Debuginfod protocol is a simple HTTP path-based system, one can
+mimic a Debuginfod server by setting up a directory structure to reflect the
+protocol properly. That's how all these tests operate. We override the default
+`DEBUGINFOD_URLS` property with a `file://` URL and populate it with the symbol
+files we need for testing.
+
+## What's being tested
+
+- For assumption validation, the `*-no-locator` tests verify that lldb works as
+  the test expects when files that Debuginfod should provide (`.dwp` files,
+  `.gnu.debuglink`'ed files, etc...) are _already_ there.
+- The `*-negative` tests validate that symbols _aren't_ found without
+  Debuginfod, to ensure they haven't been cached from previous runs (in the
+  hopes of preventing false positive testing).
+- The `*-positive*` tests check that the Debuginfod symbol locator is providing
+  the expected symbols when the debugger doesn't already have them available.
+
+### Symbol file variations tested
+
+There are 5 variations of symbol data where Debuginfod provides value:
+
+1. The `strip` build variation is a binary built with debug information (`-g`),
+   but stripped for deployment. The Debuginfod service can then host the
+   unstripped binary (as either `executable` or `debuginfo`).
+2. The `okdstrip` build variation is a binary build with `-g`, stripped for
+   deployment, where the Debuginfod service is hosting the output of
+   `objcopy --only-keep-debug` (which should also be linked to the stripped 
file
+   using `--add-gnu-debuglink`). Again, the file could be hosted as either
+   `executable` or `debuginfo`.
+3. The `split` build variation is a binary built with `-gsplit-dwarf` that
+   produces `.dwo` which are subsequently linked together (using `llvm-dwp`)
+   into a single `.dwp` file. The Debuginfod service hosts the `.dwp` file as
+   `debuginfo`.
+4. The `split-strip` build variation is a binary built with `-gsplit-dwarf`,
+   then stripped in the same manner as variation #1. For this variation,
+   Debuginfod hosts the unstripped binary as `executable` and the `.dwp` file 
as
+   `debuginfo`.
+5. The `split-okdstrip` build variation is the combination of variations 2 and
+   3, where Debuginfod hosts the `.gnu.debuglink`'ed file as `executable` and
+   the `.dwp` as `debuginfo`.
+
+### Lack of clarity/messy capabilities from Debuginfod
+
+The [debuginfod protocol](https://sourceware.org/elfutils/Debuginfod.html) is
+underspecified for some variations of symbol file deployment. The protocol
+itself is quite simple: query an HTTP server with the path
+`buildid/{.note.gnu.build-id hash}/debuginfo` or
+`buildid/{.note.gnu.build-id hash}/executable` to acquire "symbol data" or "the
+executable". Where there is lack of clarity, I prefer requesting `debuginfo`
+first, then falling back to `executable` (Scenarios #1 & #2). For Scenario #5,
+I've chosen to expect the stripped (i.e. not full) executable, which contains a
+number of sections necessary to correctly symbolicate will be hosted from the
+`executable` API. Depending upon how Debuginfod hosting services choose to
+support `.dwp` paired with stripped files, these assumptions may need to be
+revisited.
+
+I've also chosen to simply treat the `.dwp` file as `debuginfo` and the
+"only-keep-debug" stripped binary as `executable`. This scenario doesn't appear
+to work at all in GDB. Supporting it how I did seems more straight forward than
+trying to extend the protocol. The protocol _does_ support querying for section
+contents by name for a given build ID, but adding support for that in LLDB
+looks...well beyond my current capability (and LLVM's Debuginfod library 
doesn't
+support it at this writing, anyway).

JDevlieghere wrote:

Most of this document is written in a passive voice. Let's do the same for this 
section or use "we" (i.e. the developers) instead of "I". 

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


[Lldb-commits] [lldb] [clang] [flang] [libc] [llvm] [clang-tools-extra] [compiler-rt] LLDB Debuginfod usage tests (with fixes) (PR #79181)

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

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


[Lldb-commits] [lldb] [clang-tools-extra] [compiler-rt] [llvm] [clang] [flang] [libc] LLDB Debuginfod usage tests (with fixes) (PR #79181)

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

https://github.com/JDevlieghere commented:

I'm wondering if shell test are really the best way to test this. For more 
complex scenarios like are being tested here, we generally prefer [1] API tests 
because they're more expressive and allow you to build more complicated test 
binaries with our Makefile system. Things like stripping a binary and 
generating split DWARF all seems like things that could be done that way, to 
avoid checking in a (yaml-ized) binary. 

Did you consider/evaluate writing API tests for this? 

[1] https://lldb.llvm.org/resources/test.html



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


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

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


@@ -4281,25 +4281,31 @@ void 
Process::CalculateExecutionContext(ExecutionContext &exe_ctx) {
 //return Host::GetArchSpecForExistingProcess (process_name);
 //}
 
+EventSP Process::CreateEventFromProcessState(uint32_t event_type) {
+  auto event_data_sp =
+  std::make_shared(shared_from_this(), GetState());
+  return std::make_shared(event_type, event_data_sp);
+}
+
 void Process::AppendSTDOUT(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stdout_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDOUT,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDOUT);
+  BroadcastEventIfUnique(event_sp);

JDevlieghere wrote:

Why not 
`BroadcastEventIfUnique(CreateEventFromProcessState(eBroadcastBitSTDOUT))`? Too 
long? 

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


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

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

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


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


[Lldb-commits] [lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

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


@@ -8129,29 +8067,133 @@ 
Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
 else
   Kind = CharacterLiteralKind::Ascii;
 
-E = new (Context) CharacterLiteral(Arg.getAsIntegral().getZExtValue(),
-   Kind, T, Loc);
+E = new (S.Context) CharacterLiteral(Int.getZExtValue(), Kind, T, Loc);
   } else if (T->isBooleanType()) {
-E = CXXBoolLiteralExpr::Create(Context, Arg.getAsIntegral().getBoolValue(),
-   T, Loc);
-  } else if (T->isNullPtrType()) {
-E = new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc);
+E = CXXBoolLiteralExpr::Create(S.Context, Int.getBoolValue(), T, Loc);
   } else {
-E = IntegerLiteral::Create(Context, Arg.getAsIntegral(), T, Loc);
+E = IntegerLiteral::Create(S.Context, Int, T, Loc);
   }
 
   if (OrigT->isEnumeralType()) {
 // FIXME: This is a hack. We need a better way to handle substituted
 // non-type template parameters.
-E = CStyleCastExpr::Create(Context, OrigT, VK_PRValue, CK_IntegralCast, E,
-   nullptr, CurFPFeatureOverrides(),
-   Context.getTrivialTypeSourceInfo(OrigT, Loc),
+E = CStyleCastExpr::Create(S.Context, OrigT, VK_PRValue, CK_IntegralCast, 
E,
+   nullptr, S.CurFPFeatureOverrides(),
+   S.Context.getTrivialTypeSourceInfo(OrigT, Loc),
Loc, Loc);
   }
 
   return E;
 }
 
+static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
+Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
+  auto MakeInitList = [&](ArrayRef Elts) -> Expr * {
+auto *ILE = new (S.Context) InitListExpr(S.Context, Loc, Elts, Loc);
+ILE->setType(T);
+return ILE;
+  };
+
+  switch (Val.getKind()) {
+  case APValue::AddrLabelDiff:
+// This cannot occur in a template argument at all.
+  case APValue::Array:
+  case APValue::Struct:
+  case APValue::Union:
+// These can only occur within a template parameter object, which is
+// represented as a TemplateArgument::Declaration.
+llvm_unreachable("unexpected template argument value");
+
+  case APValue::Int:
+return BuildExpressionFromIntegralTemplateArgumentValue(S, T, Val.getInt(),
+Loc);
+
+  case APValue::Float:
+return FloatingLiteral::Create(S.Context, Val.getFloat(), /*IsExact=*/true,
+   T, Loc);
+
+  case APValue::FixedPoint:
+return FixedPointLiteral::CreateFromRawInt(
+S.Context, Val.getFixedPoint().getValue(), T, Loc,
+Val.getFixedPoint().getScale());
+
+  case APValue::ComplexInt: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList({BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntReal(), Loc),
+ BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntImag(), Loc)});
+  }
+
+  case APValue::ComplexFloat: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList(
+{FloatingLiteral::Create(S.Context, Val.getComplexFloatReal(), true,
+ ElemT, Loc),
+ FloatingLiteral::Create(S.Context, Val.getComplexFloatImag(), true,
+ ElemT, Loc)});
+  }
+
+  case APValue::Vector: {
+QualType ElemT = T->castAs()->getElementType();
+llvm::SmallVector Elts;
+for (unsigned I = 0, N = Val.getVectorLength(); I != N; ++I)
+  Elts.push_back(BuildExpressionFromNonTypeTemplateArgumentValue(
+  S, ElemT, Val.getVectorElt(I), Loc));
+return MakeInitList(Elts);
+  }
+
+  case APValue::None:
+  case APValue::Indeterminate:
+llvm_unreachable("Unexpected APValue kind.");
+  case APValue::LValue:
+  case APValue::MemberPointer:
+// There isn't necessarily a valid equivalent source-level syntax for
+// these; in particular, a naive lowering might violate access control.
+// So for now we lower to a ConstantExpr holding the value, wrapped around
+// an OpaqueValueExpr.
+// FIXME: We should have a better representation for this.
+ExprValueKind VK = VK_PRValue;
+if (T->isReferenceType()) {
+  T = T->getPointeeType();
+  VK = VK_LValue;
+}
+auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);

erichkeane wrote:

You didn't add the constructor, right?  so it was already an invalid 
assumption, just one that hadn't bubbled out.

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


[Lldb-commits] [clang] [lldb] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-26 Thread Andrey Ali Khan Bolshakov via lldb-commits


@@ -8129,29 +8067,133 @@ 
Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
 else
   Kind = CharacterLiteralKind::Ascii;
 
-E = new (Context) CharacterLiteral(Arg.getAsIntegral().getZExtValue(),
-   Kind, T, Loc);
+E = new (S.Context) CharacterLiteral(Int.getZExtValue(), Kind, T, Loc);
   } else if (T->isBooleanType()) {
-E = CXXBoolLiteralExpr::Create(Context, Arg.getAsIntegral().getBoolValue(),
-   T, Loc);
-  } else if (T->isNullPtrType()) {
-E = new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc);
+E = CXXBoolLiteralExpr::Create(S.Context, Int.getBoolValue(), T, Loc);
   } else {
-E = IntegerLiteral::Create(Context, Arg.getAsIntegral(), T, Loc);
+E = IntegerLiteral::Create(S.Context, Int, T, Loc);
   }
 
   if (OrigT->isEnumeralType()) {
 // FIXME: This is a hack. We need a better way to handle substituted
 // non-type template parameters.
-E = CStyleCastExpr::Create(Context, OrigT, VK_PRValue, CK_IntegralCast, E,
-   nullptr, CurFPFeatureOverrides(),
-   Context.getTrivialTypeSourceInfo(OrigT, Loc),
+E = CStyleCastExpr::Create(S.Context, OrigT, VK_PRValue, CK_IntegralCast, 
E,
+   nullptr, S.CurFPFeatureOverrides(),
+   S.Context.getTrivialTypeSourceInfo(OrigT, Loc),
Loc, Loc);
   }
 
   return E;
 }
 
+static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
+Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
+  auto MakeInitList = [&](ArrayRef Elts) -> Expr * {
+auto *ILE = new (S.Context) InitListExpr(S.Context, Loc, Elts, Loc);
+ILE->setType(T);
+return ILE;
+  };
+
+  switch (Val.getKind()) {
+  case APValue::AddrLabelDiff:
+// This cannot occur in a template argument at all.
+  case APValue::Array:
+  case APValue::Struct:
+  case APValue::Union:
+// These can only occur within a template parameter object, which is
+// represented as a TemplateArgument::Declaration.
+llvm_unreachable("unexpected template argument value");
+
+  case APValue::Int:
+return BuildExpressionFromIntegralTemplateArgumentValue(S, T, Val.getInt(),
+Loc);
+
+  case APValue::Float:
+return FloatingLiteral::Create(S.Context, Val.getFloat(), /*IsExact=*/true,
+   T, Loc);
+
+  case APValue::FixedPoint:
+return FixedPointLiteral::CreateFromRawInt(
+S.Context, Val.getFixedPoint().getValue(), T, Loc,
+Val.getFixedPoint().getScale());
+
+  case APValue::ComplexInt: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList({BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntReal(), Loc),
+ BuildExpressionFromIntegralTemplateArgumentValue(
+ S, ElemT, Val.getComplexIntImag(), Loc)});
+  }
+
+  case APValue::ComplexFloat: {
+QualType ElemT = T->castAs()->getElementType();
+return MakeInitList(
+{FloatingLiteral::Create(S.Context, Val.getComplexFloatReal(), true,
+ ElemT, Loc),
+ FloatingLiteral::Create(S.Context, Val.getComplexFloatImag(), true,
+ ElemT, Loc)});
+  }
+
+  case APValue::Vector: {
+QualType ElemT = T->castAs()->getElementType();
+llvm::SmallVector Elts;
+for (unsigned I = 0, N = Val.getVectorLength(); I != N; ++I)
+  Elts.push_back(BuildExpressionFromNonTypeTemplateArgumentValue(
+  S, ElemT, Val.getVectorElt(I), Loc));
+return MakeInitList(Elts);
+  }
+
+  case APValue::None:
+  case APValue::Indeterminate:
+llvm_unreachable("Unexpected APValue kind.");
+  case APValue::LValue:
+  case APValue::MemberPointer:
+// There isn't necessarily a valid equivalent source-level syntax for
+// these; in particular, a naive lowering might violate access control.
+// So for now we lower to a ConstantExpr holding the value, wrapped around
+// an OpaqueValueExpr.
+// FIXME: We should have a better representation for this.
+ExprValueKind VK = VK_PRValue;
+if (T->isReferenceType()) {
+  T = T->getPointeeType();
+  VK = VK_LValue;
+}
+auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);

bolshakov-a wrote:

Right, I didn't. But the clang codebase is pretty well designed if every class 
can be considered as fully initialized after calling its constructor!

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


[Lldb-commits] [clang] [mlir] [compiler-rt] [libunwind] [flang] [lldb] [llvm] [clang-tools-extra] [openmp] [lld] [BranchFolding] Fix missing predecessors of landing-pad (PR #77608)

2024-01-26 Thread Evgenii Kudriashov via lldb-commits


@@ -0,0 +1,80 @@
+; RUN: llc -mtriple=x86_64-pc-windows-msvc %s

e-kud wrote:

It seems we still have this file on `avx512-intel64` worker:
https://lab.llvm.org/buildbot/#/builders/258/builds/12970
https://lab.llvm.org/buildbot/#/builders/258/builds/12971

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


[Lldb-commits] [lldb] [lldb][NFCI] Constrain EventDataBytes creation (PR #79508)

2024-01-26 Thread via lldb-commits

jimingham wrote:

LGTM  This code was originally written before we used StringRef's, so making 
that conversion complete is good.

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


[Lldb-commits] [compiler-rt] [clang] [lldb] [clang-tools-extra] [libc] [flang] [llvm] LLDB Debuginfod usage tests (with fixes) (PR #79181)

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

kevinfrei wrote:

> I'm wondering if shell test are really the best way to test this. For more 
> complex scenarios like are being tested here, we generally prefer [1] API 
> tests because they're more expressive and allow you to build more complicated 
> test binaries with our Makefile system. Things like stripping a binary and 
> generating split DWARF all seems like things that could be done that way, to 
> avoid checking in a (yaml-ized) binary.
> 
> Did you consider/evaluate writing API tests for this?
> 
> [1] https://lldb.llvm.org/resources/test.html

The next addition (async support) *requires* API tests, so I figured getting 
some shell tests in place to do a more "user experience" kind of testing was 
reasonable, since there will be API-based tests coming. If you feel like moving 
this stuff to API tests wholesale is the right thing to do, I'm happy to go 
figure that out next week.

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


[Lldb-commits] [compiler-rt] [lldb] [clang] [mlir] [libcxx] [clang-tools-extra] [libc] [lld] [libunwind] [flang] [llvm] [Driver, CodeGen] Support -mtls-dialect= (PR #79256)

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

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

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

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/79624

This fixes two issues related to the DebugSymbols symbol locator:

  1. Only the default symbol locator plugin reports progress. On Darwin, which 
uses the DebugSymbols framework we need to report the same progress form the 
corresponding SymbolLocator plugin.

  2. Forceful dSYM lookups, for example when using `add-dsym`, use a different 
code path that currently does not report progress, which is confusing. Here the 
progress event can be more specific and specify its downloading a symbol file 
rather than just locating it as we'll always shell out to dsymForUUID or its 
equivalent.

rdar://121629777

>From 7979269a57fc553a7b010a36b9c75bf570adf674 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Fri, 26 Jan 2024 09:34:11 -0800
Subject: [PATCH] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols

This fixes two issues related to the DebugSymbols symbol locator:

  1. Only the default symbol locator plugin reports progress. On Darwin,
 which uses the DebugSymbols framework we need to report the same
 progress form the corresponding SymbolLocator plugin.

  2. Forceful dSYM lookups, for example when using `add-dsym`, use a
 different code path that currently does not report progress, which
 is confusing. Here the progress event can be more specific and
 specify its downloading a symbol file rather than just locating it
 as we'll always shell out to dsymForUUID or its equivalent.

rdar://121629777
---
 .../SymbolLocatorDebugSymbols.cpp | 39 ++-
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
index 9f32d252b22f5bd..24e563d6ee0f353 100644
--- 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
+++ 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",
+  module_spec.GetFileSpec().GetFilename().AsCString(""));
+
   FileSpec symbol_fspec;
   ModuleSpec dsym_module_spec;
   // First try and find the dSYM in the same directory as the executable or in
@@ -1050,28 +1054,25 @@ bool 
SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(
   const std::string file_path_str =
   file_spec_ptr ? file_spec_ptr->GetPath() : "";
 
-  Log *log = GetLog(LLDBLog::Host);
+  if (uuid_str.empty() && file_path_str.empty())
+return false;
 
   // Create the dsymForUUID command.
-  StreamString command;
+  const char *lookup_arg =
+  !uuid_str.empty() ? uuid_str.c_str() : file_path_str.c_str();
   const char *copy_executable_arg = copy_executable ? "--copyExecutable " : "";
-  if (!uuid_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   uuid_str.c_str());
-LLDB_LOGF(log, "Calling %s with UUID %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), uuid_str.c_str(),
-  command.GetString().data());
-  } else if (!file_path_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   file_path_str.c_str());
-LLDB_LOGF(log, "Calling %s with file %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), file_path_str.c_str(),
-  command.GetString().data());
-  } else {
-return false;
-  }
+
+  StreamString command;
+  command.Printf("%s --ignoreNegativeCache %s%s", dsymForUUID_exe_path.c_str(),
+ copy_executable_arg, lookup_arg);
+
+  // Log and report progress.
+  Log *log = GetLog(LLDBLog::Host);
+  LLDB_LOGF(log, "Calling %s with %s to find dSYM: %s",
+dsymForUUID_exe_path.c_str(), lookup_arg,
+command.GetString().data());
+
+  Progress progress("Downloading symbol file", lookup_arg);
 
   // Invoke dsymForUUID.
   int exit_status = -1;

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

This fixes two issues related to the DebugSymbols symbol locator:

  1. Only the default symbol locator plugin reports progress. On Darwin, which 
uses the DebugSymbols framework we need to report the same progress form the 
corresponding SymbolLocator plugin.

  2. Forceful dSYM lookups, for example when using `add-dsym`, use a different 
code path that currently does not report progress, which is confusing. Here the 
progress event can be more specific and specify its downloading a symbol file 
rather than just locating it as we'll always shell out to dsymForUUID or its 
equivalent.

rdar://121629777

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


1 Files Affected:

- (modified) 
lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp 
(+20-19) 


``diff
diff --git 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
index 9f32d252b22f5bd..24e563d6ee0f353 100644
--- 
a/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
+++ 
b/lldb/source/Plugins/SymbolLocator/DebugSymbols/SymbolLocatorDebugSymbols.cpp
@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",
+  module_spec.GetFileSpec().GetFilename().AsCString(""));
+
   FileSpec symbol_fspec;
   ModuleSpec dsym_module_spec;
   // First try and find the dSYM in the same directory as the executable or in
@@ -1050,28 +1054,25 @@ bool 
SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(
   const std::string file_path_str =
   file_spec_ptr ? file_spec_ptr->GetPath() : "";
 
-  Log *log = GetLog(LLDBLog::Host);
+  if (uuid_str.empty() && file_path_str.empty())
+return false;
 
   // Create the dsymForUUID command.
-  StreamString command;
+  const char *lookup_arg =
+  !uuid_str.empty() ? uuid_str.c_str() : file_path_str.c_str();
   const char *copy_executable_arg = copy_executable ? "--copyExecutable " : "";
-  if (!uuid_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   uuid_str.c_str());
-LLDB_LOGF(log, "Calling %s with UUID %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), uuid_str.c_str(),
-  command.GetString().data());
-  } else if (!file_path_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   file_path_str.c_str());
-LLDB_LOGF(log, "Calling %s with file %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), file_path_str.c_str(),
-  command.GetString().data());
-  } else {
-return false;
-  }
+
+  StreamString command;
+  command.Printf("%s --ignoreNegativeCache %s%s", dsymForUUID_exe_path.c_str(),
+ copy_executable_arg, lookup_arg);
+
+  // Log and report progress.
+  Log *log = GetLog(LLDBLog::Host);
+  LLDB_LOGF(log, "Calling %s with %s to find dSYM: %s",
+dsymForUUID_exe_path.c_str(), lookup_arg,
+command.GetString().data());
+
+  Progress progress("Downloading symbol file", lookup_arg);
 
   // Invoke dsymForUUID.
   int exit_status = -1;

``




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


[Lldb-commits] [libc] [compiler-rt] [clang-tools-extra] [llvm] [lldb] [flang] [clang] LLDB Debuginfod usage tests (with fixes) (PR #79181)

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


@@ -0,0 +1,65 @@
+# Tests for basic Debuginfod functionality
+
+Because the Debuginfod protocol is a simple HTTP path-based system, one can
+mimic a Debuginfod server by setting up a directory structure to reflect the
+protocol properly. That's how all these tests operate. We override the default
+`DEBUGINFOD_URLS` property with a `file://` URL and populate it with the symbol
+files we need for testing.
+
+## What's being tested
+
+- For assumption validation, the `*-no-locator` tests verify that lldb works as
+  the test expects when files that Debuginfod should provide (`.dwp` files,
+  `.gnu.debuglink`'ed files, etc...) are _already_ there.
+- The `*-negative` tests validate that symbols _aren't_ found without
+  Debuginfod, to ensure they haven't been cached from previous runs (in the
+  hopes of preventing false positive testing).
+- The `*-positive*` tests check that the Debuginfod symbol locator is providing
+  the expected symbols when the debugger doesn't already have them available.
+
+### Symbol file variations tested
+
+There are 5 variations of symbol data where Debuginfod provides value:
+
+1. The `strip` build variation is a binary built with debug information (`-g`),
+   but stripped for deployment. The Debuginfod service can then host the
+   unstripped binary (as either `executable` or `debuginfo`).
+2. The `okdstrip` build variation is a binary build with `-g`, stripped for
+   deployment, where the Debuginfod service is hosting the output of
+   `objcopy --only-keep-debug` (which should also be linked to the stripped 
file
+   using `--add-gnu-debuglink`). Again, the file could be hosted as either
+   `executable` or `debuginfo`.
+3. The `split` build variation is a binary built with `-gsplit-dwarf` that
+   produces `.dwo` which are subsequently linked together (using `llvm-dwp`)
+   into a single `.dwp` file. The Debuginfod service hosts the `.dwp` file as
+   `debuginfo`.
+4. The `split-strip` build variation is a binary built with `-gsplit-dwarf`,
+   then stripped in the same manner as variation #1. For this variation,
+   Debuginfod hosts the unstripped binary as `executable` and the `.dwp` file 
as
+   `debuginfo`.
+5. The `split-okdstrip` build variation is the combination of variations 2 and
+   3, where Debuginfod hosts the `.gnu.debuglink`'ed file as `executable` and
+   the `.dwp` as `debuginfo`.
+
+### Lack of clarity/messy capabilities from Debuginfod
+
+The [debuginfod protocol](https://sourceware.org/elfutils/Debuginfod.html) is
+underspecified for some variations of symbol file deployment. The protocol
+itself is quite simple: query an HTTP server with the path
+`buildid/{.note.gnu.build-id hash}/debuginfo` or
+`buildid/{.note.gnu.build-id hash}/executable` to acquire "symbol data" or "the
+executable". Where there is lack of clarity, I prefer requesting `debuginfo`
+first, then falling back to `executable` (Scenarios #1 & #2). For Scenario #5,
+I've chosen to expect the stripped (i.e. not full) executable, which contains a
+number of sections necessary to correctly symbolicate will be hosted from the
+`executable` API. Depending upon how Debuginfod hosting services choose to
+support `.dwp` paired with stripped files, these assumptions may need to be
+revisited.
+
+I've also chosen to simply treat the `.dwp` file as `debuginfo` and the
+"only-keep-debug" stripped binary as `executable`. This scenario doesn't appear
+to work at all in GDB. Supporting it how I did seems more straight forward than
+trying to extend the protocol. The protocol _does_ support querying for section
+contents by name for a given build ID, but adding support for that in LLDB
+looks...well beyond my current capability (and LLVM's Debuginfod library 
doesn't
+support it at this writing, anyway).

kevinfrei wrote:

Changed voicing

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }

chelcassanova wrote:

Lovely, I'll add this in here

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster &broadcaster = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(&broadcaster,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");
+
+std::this_thread::sleep_for(timeout);
+  }
+
+  // Progress report objects should be destroyed at this point so
+  // get each report from the queue and check that they've been
+  // destroyed in reverse order
+  std::this_thread::sleep_for(timeout);

chelcassanova wrote:

Ah, I thought I had to give a tiny bit of time for the objects to be destroyed, 
I'll remove the timeouts here then.

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

LGTM, thanks for adding new reports!

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


[Lldb-commits] [lldb] 5f22d33 - [lldb][NFCI] Change BreakpointIDList::FindBreakpointID to BreakpointIDList::Contains (#79517)

2024-01-26 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-26T10:19:03-08:00
New Revision: 5f22d3356cda0a9b1521c839c006f61b5cc504fc

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

LOG: [lldb][NFCI] Change BreakpointIDList::FindBreakpointID to 
BreakpointIDList::Contains (#79517)

`FindBreakpointID` take a BreakpointID and a pointer to a size_t (so you
can get position information). It returns a bool to indicate whether the
id was found in the list or not.

There are 2 callers of this currently and neither one actually uses the
position information, so I removed it. After that, I renamed it to
Contains to more accurately reflect the intent. Additionally, I changed
the argument type from a reference to a value (because BreakpointID is
just a wrapper around 2 integers, copies are cheap).

Added: 


Modified: 
lldb/include/lldb/Breakpoint/BreakpointID.h
lldb/include/lldb/Breakpoint/BreakpointIDList.h
lldb/source/Breakpoint/BreakpointIDList.cpp
lldb/source/Commands/CommandObjectBreakpoint.cpp
lldb/source/Commands/CommandObjectProcess.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/BreakpointID.h 
b/lldb/include/lldb/Breakpoint/BreakpointID.h
index a62323061b75823..093966d0cf5db30 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointID.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointID.h
@@ -26,6 +26,10 @@ class BreakpointID {
 
   virtual ~BreakpointID();
 
+  bool operator==(BreakpointID rhs) const {
+return m_break_id == rhs.m_break_id && m_location_id == rhs.m_location_id;
+  }
+
   lldb::break_id_t GetBreakpointID() const { return m_break_id; }
 
   lldb::break_id_t GetLocationID() const { return m_location_id; }

diff  --git a/lldb/include/lldb/Breakpoint/BreakpointIDList.h 
b/lldb/include/lldb/Breakpoint/BreakpointIDList.h
index ddf85dd78cf2e0c..f2eaa60d954136f 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointIDList.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointIDList.h
@@ -42,8 +42,7 @@ class BreakpointIDList {
 
   bool AddBreakpointID(BreakpointID bp_id);
 
-  // TODO: This should take a const BreakpointID.
-  bool FindBreakpointID(BreakpointID &bp_id, size_t *position) const;
+  bool Contains(BreakpointID bp_id) const;
 
   // Returns a pair consisting of the beginning and end of a breakpoint
   // ID range expression.  If the input string is not a valid specification,

diff  --git a/lldb/source/Breakpoint/BreakpointIDList.cpp 
b/lldb/source/Breakpoint/BreakpointIDList.cpp
index 5904647314bc0c7..851d074e7535880 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -15,6 +15,8 @@
 #include "lldb/Utility/Args.h"
 #include "lldb/Utility/StreamString.h"
 
+#include "llvm/ADT/STLExtras.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -48,18 +50,8 @@ bool BreakpointIDList::AddBreakpointID(BreakpointID bp_id) {
// return true.
 }
 
-bool BreakpointIDList::FindBreakpointID(BreakpointID &bp_id,
-size_t *position) const {
-  for (size_t i = 0; i < m_breakpoint_ids.size(); ++i) {
-BreakpointID tmp_id = m_breakpoint_ids[i];
-if (tmp_id.GetBreakpointID() == bp_id.GetBreakpointID() &&
-tmp_id.GetLocationID() == bp_id.GetLocationID()) {
-  *position = i;
-  return true;
-}
-  }
-
-  return false;
+bool BreakpointIDList::Contains(BreakpointID bp_id) const {
+  return llvm::is_contained(m_breakpoint_ids, bp_id);
 }
 
 //  This function takes OLD_ARGS, which is usually the result of breaking the

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 1661d5d9b743e27..3fdf5cd3cd43d2d 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1485,9 +1485,8 @@ class CommandObjectBreakpointDelete : public 
CommandObjectParsed {
   for (auto breakpoint_sp : breakpoints.Breakpoints()) {
 if (!breakpoint_sp->IsEnabled() && breakpoint_sp->AllowDelete()) {
   BreakpointID bp_id(breakpoint_sp->GetID());
-  size_t pos = 0;
-  if (!excluded_bp_ids.FindBreakpointID(bp_id, &pos))
-valid_bp_ids.AddBreakpointID(breakpoint_sp->GetID());
+  if (!excluded_bp_ids.Contains(bp_id))
+valid_bp_ids.AddBreakpointID(bp_id);
 }
   }
   if (valid_bp_ids.GetSize() == 0) {

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 6dc7648f872df8f..c7b874d19793770 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -646,9 +646,7 @@ class CommandObjectProcessContinue : public 
CommandObjectParsed {
   for (size_t loc_idx =

[Lldb-commits] [lldb] [lldb][NFCI] Change BreakpointIDList::FindBreakpointID to BreakpointIDList::Contains (PR #79517)

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

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


[Lldb-commits] [lldb] 176d07d - [lldb][NFCI] Constrain EventDataBytes creation (#79508)

2024-01-26 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-26T10:20:52-08:00
New Revision: 176d07d360094b366b25cc009846ec64ac7d8040

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

LOG: [lldb][NFCI] Constrain EventDataBytes creation (#79508)

There are 3 ways to create an EventDataBytes object: (const char *),
(llvm::StringRef), and (const void *, size_t len). All of these cases
can be handled under `llvm::StringRef`. Additionally, this allows us to
remove the otherwise unused `SetBytes`, `SwapBytes`, and
`SetBytesFromCString` methods.

Added: 


Modified: 
lldb/include/lldb/Utility/Event.h
lldb/source/API/SBEvent.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Utility/Event.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/Event.h 
b/lldb/include/lldb/Utility/Event.h
index 3de0401191caa7..461d711b8c3f2c 100644
--- a/lldb/include/lldb/Utility/Event.h
+++ b/lldb/include/lldb/Utility/Event.h
@@ -60,12 +60,8 @@ class EventDataBytes : public EventData {
   // Constructors
   EventDataBytes();
 
-  EventDataBytes(const char *cstr);
-
   EventDataBytes(llvm::StringRef str);
 
-  EventDataBytes(const void *src, size_t src_len);
-
   ~EventDataBytes() override;
 
   // Member functions
@@ -77,12 +73,6 @@ class EventDataBytes : public EventData {
 
   size_t GetByteSize() const;
 
-  void SetBytes(const void *src, size_t src_len);
-
-  void SwapBytes(std::string &new_bytes);
-
-  void SetBytesFromCString(const char *cstr);
-
   // Static functions
   static const EventDataBytes *GetEventDataFromEvent(const Event *event_ptr);
 

diff  --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp
index f12df2939420d6..cc611449e25099 100644
--- a/lldb/source/API/SBEvent.cpp
+++ b/lldb/source/API/SBEvent.cpp
@@ -24,7 +24,8 @@ using namespace lldb_private;
 SBEvent::SBEvent() { LLDB_INSTRUMENT_VA(this); }
 
 SBEvent::SBEvent(uint32_t event_type, const char *cstr, uint32_t cstr_len)
-: m_event_sp(new Event(event_type, new EventDataBytes(cstr, cstr_len))),
+: m_event_sp(new Event(
+  event_type, new EventDataBytes(llvm::StringRef(cstr, cstr_len,
   m_opaque_ptr(m_event_sp.get()) {
   LLDB_INSTRUMENT_VA(this, event_type, cstr, cstr_len);
 }

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index eb42b9eb6cb6a5..4a06027501a898 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1089,7 +1089,8 @@ Status ProcessGDBRemote::DoAttachToProcessWithID(
   const int packet_len =
   ::snprintf(packet, sizeof(packet), "vAttach;%" PRIx64, attach_pid);
   SetID(attach_pid);
-  auto data_sp = std::make_shared(packet, packet_len);
+  auto data_sp =
+  std::make_shared(llvm::StringRef(packet, 
packet_len));
   m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp);
 } else
   SetExitStatus(-1, error.AsCString());
@@ -1127,8 +1128,7 @@ Status ProcessGDBRemote::DoAttachToProcessWithName(
endian::InlHostByteOrder(),
endian::InlHostByteOrder());
 
-  auto data_sp = 
std::make_shared(packet.GetString().data(),
-  packet.GetSize());
+  auto data_sp = std::make_shared(packet.GetString());
   m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp);
 
 } else
@@ -1374,8 +1374,8 @@ Status ProcessGDBRemote::DoResume() {
 return error;
   }
 
-  auto data_sp = std::make_shared(
-  continue_packet.GetString().data(), continue_packet.GetSize());
+  auto data_sp =
+  std::make_shared(continue_packet.GetString());
   m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue, data_sp);
 
   if (!listener_sp->GetEvent(event_sp, std::chrono::seconds(5))) {

diff  --git a/lldb/source/Utility/Event.cpp b/lldb/source/Utility/Event.cpp
index cac118182c75da..863167e56bce6f 100644
--- a/lldb/source/Utility/Event.cpp
+++ b/lldb/source/Utility/Event.cpp
@@ -111,17 +111,7 @@ void EventData::Dump(Stream *s) const { 
s->PutCString("Generic Event Data"); }
 
 EventDataBytes::EventDataBytes() : m_bytes() {}
 
-EventDataBytes::EventDataBytes(const char *cstr) : m_bytes() {
-  SetBytesFromCString(cstr);
-}
-
-EventDataBytes::EventDataBytes(llvm::StringRef str) : m_bytes() {
-  SetBytes(str.data(), str.size());
-}
-
-EventDataBytes::EventDataBytes(const void *src, size_t src_len) : m_bytes() {
-  SetBytes(src, src_len);
-}
+EventDataBytes::EventDataBytes(llvm::StringRef str) : m_bytes(str.str()) {}
 
 EventDataBytes::~EventDataBytes() = default;
 
@@ -147,20 +137,

[Lldb-commits] [lldb] [lldb][NFCI] Constrain EventDataBytes creation (PR #79508)

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

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

This is only testing the `Progress` class constructor behavior. Could you check 
that the `Progress::Increment` method works as expected ?

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


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

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


@@ -4281,25 +4281,31 @@ void 
Process::CalculateExecutionContext(ExecutionContext &exe_ctx) {
 //return Host::GetArchSpecForExistingProcess (process_name);
 //}
 
+EventSP Process::CreateEventFromProcessState(uint32_t event_type) {
+  auto event_data_sp =
+  std::make_shared(shared_from_this(), GetState());
+  return std::make_shared(event_type, event_data_sp);
+}
+
 void Process::AppendSTDOUT(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stdout_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDOUT,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDOUT);
+  BroadcastEventIfUnique(event_sp);

bulbazord wrote:

I didn't really think about it tbh, but I like the inlining so I'll update this 
before landing.

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


[Lldb-commits] [lld] [llvm] [lldb] [libunwind] [compiler-rt] [clang] [flang] [clang-tools-extra] [mlir] [openmp] [BranchFolding] Fix missing predecessors of landing-pad (PR #77608)

2024-01-26 Thread Evgenii Kudriashov via lldb-commits

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


[Lldb-commits] [lld] [llvm] [lldb] [libunwind] [compiler-rt] [clang] [flang] [clang-tools-extra] [mlir] [openmp] [BranchFolding] Fix missing predecessors of landing-pad (PR #77608)

2024-01-26 Thread Evgenii Kudriashov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix a crash when using .dwp files and make type lookup reliable with the index cache (PR #79544)

2024-01-26 Thread David Blaikie via lldb-commits

dwblaikie wrote:

I'm not following all of this, but it appears to be based on the premise that 
it's OK that sometimes split units inside a DWP file are parsed before their 
skeleton unit? Why is that OK/when/why/where is that happening?

I'd think any case where that happens would be a performance (& possibly 
correctness bug) & it'd be better to maintain the invariant that the only way 
you ever parse a split unit is starting from the skeleton - rather than adding 
maps/etc to be able to backtrack to parsing the skeleton when you already have 
the split unit.

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


[Lldb-commits] [lld] [llvm] [lldb] [libunwind] [compiler-rt] [clang] [flang] [clang-tools-extra] [mlir] [openmp] [BranchFolding] Fix missing predecessors of landing-pad (PR #77608)

2024-01-26 Thread Evgenii Kudriashov via lldb-commits

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"

bulbazord wrote:

Don't forget to include the license header in this file

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


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

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


@@ -4281,25 +4281,31 @@ void 
Process::CalculateExecutionContext(ExecutionContext &exe_ctx) {
 //return Host::GetArchSpecForExistingProcess (process_name);
 //}
 
+EventSP Process::CreateEventFromProcessState(uint32_t event_type) {
+  auto event_data_sp =
+  std::make_shared(shared_from_this(), GetState());
+  return std::make_shared(event_type, event_data_sp);
+}
+
 void Process::AppendSTDOUT(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stdout_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDOUT,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDOUT);
+  BroadcastEventIfUnique(event_sp);

bulbazord wrote:

Oh, I remember why I didn't do this now! `BroadcastEventIfUnique` expects an 
lvalue argument but inlining the call would make it an rvalue. I don't think 
this matters tremendously so I'll land as-is and we can revisit as needed later.

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


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

2024-01-26 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-26T10:40:33-08:00
New Revision: 02d3a799e7eb2997950d6a288a08a5e51ff0ff59

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

LOG: [lldb][NFCI] Remove EventData* parameter from BroadcastEventIfUnique 
(#79045)

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

Added: 


Modified: 
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Utility/Broadcaster.h
lldb/source/Target/Process.cpp
lldb/source/Utility/Broadcaster.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 24c599e044c78fa..4599a0dc8821966 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -3216,6 +3216,8 @@ void PruneThreadPlans();
   Status LaunchPrivate(ProcessLaunchInfo &launch_info, lldb::StateType &state,
lldb::EventSP &event_sp);
 
+  lldb::EventSP CreateEventFromProcessState(uint32_t event_type);
+
   Process(const Process &) = delete;
   const Process &operator=(const Process &) = delete;
 };

diff  --git a/lldb/include/lldb/Utility/Broadcaster.h 
b/lldb/include/lldb/Utility/Broadcaster.h
index c8127f0a921d882..f39e677fe9ee041 100644
--- a/lldb/include/lldb/Utility/Broadcaster.h
+++ b/lldb/include/lldb/Utility/Broadcaster.h
@@ -181,9 +181,8 @@ class Broadcaster {
 m_broadcaster_sp->BroadcastEvent(event_type);
   }
 
-  void BroadcastEventIfUnique(uint32_t event_type,
-  EventData *event_data = nullptr) {
-m_broadcaster_sp->BroadcastEventIfUnique(event_type, event_data);
+  void BroadcastEventIfUnique(uint32_t event_type) {
+m_broadcaster_sp->BroadcastEventIfUnique(event_type);
   }
 
   void Clear() { m_broadcaster_sp->Clear(); }
@@ -351,8 +350,7 @@ class Broadcaster {
 void BroadcastEvent(uint32_t event_type,
 const lldb::EventDataSP &event_data_sp);
 
-void BroadcastEventIfUnique(uint32_t event_type,
-EventData *event_data = nullptr);
+void BroadcastEventIfUnique(uint32_t event_type);
 
 void Clear();
 

diff  --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index e1c16ca21643227..23a8a66645c02d6 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4281,25 +4281,31 @@ void 
Process::CalculateExecutionContext(ExecutionContext &exe_ctx) {
 //return Host::GetArchSpecForExistingProcess (process_name);
 //}
 
+EventSP Process::CreateEventFromProcessState(uint32_t event_type) {
+  auto event_data_sp =
+  std::make_shared(shared_from_this(), GetState());
+  return std::make_shared(event_type, event_data_sp);
+}
+
 void Process::AppendSTDOUT(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stdout_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDOUT,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDOUT);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::AppendSTDERR(const char *s, size_t len) {
   std::lock_guard guard(m_stdio_communication_mutex);
   m_stderr_data.append(s, len);
-  BroadcastEventIfUnique(eBroadcastBitSTDERR,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitSTDERR);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::BroadcastAsyncProfileData(const std::string &one_profile_data) {
   std::lock_guard guard(m_profile_data_comm_mutex);
   m_profile_data.push_back(one_profile_data);
-  BroadcastEventIfUnique(eBroadcastBitProfileData,
- new ProcessEventData(shared_from_this(), GetState()));
+  auto event_sp = CreateEventFromProcessState(eBroadcastBitProfileData);
+  BroadcastEventIfUnique(event_sp);
 }
 
 void Process::BroadcastStructuredData(const StructuredData::ObjectSP 
&object_sp,

diff  --git a/lldb/source/Utility/Broadcaster.cpp 
b/lldb/source/Utility/Broadcaster.cpp
index 33cd49963e7c74c..12903edc36b1b98 100644
--- a/lldb/source/Utility/Broadcaster.cpp
+++ b/lldb/source/Utility/Broadcaster.cpp
@@ -311,9 +311,8 @@ void Broadcaster::BroadcasterImpl::BroadcastEvent(
   PrivateBroadcastEvent(event_sp, false);
 }
 
-void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(
-uint32_t event_type, EventData *event_data) {
-  auto event_sp = std::make_shared(event_type, event_data);
+void Broadcaster::BroadcasterImpl::BroadcastEventIfUnique(uint32_t event_type) 
{
+  auto event_sp = std::make_shared(event_type, /*data = */ nullptr);
   PrivateBroadcastEvent(event_sp, true);
 }
 



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

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

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"

chelcassanova wrote:

Will do! I told myself I'd add it at the end then I fully forgot to do that 🙃 

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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

JDevlieghere wrote:

> This is only testing the `Progress` class constructor behavior. Could you 
> check that the `Progress::Increment` method works as expected ?

While it would be nice to have full test coverage, the goal was to cover the 
existing behavior which we'll modify/extend to coalesce events as discussed in 
the 
[RFC](https://discourse.llvm.org/t/rfc-improve-lldb-progress-reporting/75717/). 
Increments are orthogonal to that so I think it's fine to keep that for a 
separate PR. 

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

2024-01-26 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/79533

>From 9274bcd897cd3ecdb3a842bc72ee660ba335aa57 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 25 Jan 2024 16:40:42 -0800
Subject: [PATCH 1/2] [lldb][progress][NFC] Add unit test for progress reports

This test is being added as a way to check the behaviour of how progress
events are broadcasted when reports are started and ended with the
current implementation of progress reports. Here we're mainly checking
and ensuring that the current behaviour is that progress events are
broadcasted individually and placed in the event queue in order of
their creation.
---
 lldb/unittests/Core/CMakeLists.txt |   1 +
 lldb/unittests/Core/ProgressReportTest.cpp | 105 +
 2 files changed, 106 insertions(+)
 create mode 100644 lldb/unittests/Core/ProgressReportTest.cpp

diff --git a/lldb/unittests/Core/CMakeLists.txt 
b/lldb/unittests/Core/CMakeLists.txt
index b3cddd150635b1..d40c357e3f463b 100644
--- a/lldb/unittests/Core/CMakeLists.txt
+++ b/lldb/unittests/Core/CMakeLists.txt
@@ -7,6 +7,7 @@ add_lldb_unittest(LLDBCoreTests
   FormatEntityTest.cpp
   MangledTest.cpp
   ModuleSpecTest.cpp
+  ProgressReportTest.cpp
   RichManglingContextTest.cpp
   SourceLocationSpecTest.cpp
   SourceManagerTest.cpp
diff --git a/lldb/unittests/Core/ProgressReportTest.cpp 
b/lldb/unittests/Core/ProgressReportTest.cpp
new file mode 100644
index 00..bdc168c9e077dd
--- /dev/null
+++ b/lldb/unittests/Core/ProgressReportTest.cpp
@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster &broadcaster = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(&broadcaster,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");
+
+std::this_thread::sleep_for(timeout);
+  }
+
+  // Progress report objects should be destroyed at this point so
+  // get each report from the queue and check that they've been
+  // destroyed in reverse order
+  std::this_thread::sleep_for(timeout);
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  ASSERT_EQ(data->GetTitle(), "Progress report 3");
+  ASSERT_TRUE(data->GetCompleted());
+
+  std::this_thread::sleep_for(timeout);
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  ASSERT_EQ(data->GetTitle(), "Progress report 2");
+  ASSERT_TRUE(data->GetComplete

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -831,6 +831,37 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   return true;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
+PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl &args_impl,

jimingham wrote:

It's spelled incorrectly in the whole rest of this file except for the thread 
plan instances.  We should either get rid of all of these by using 
ScriptedPythonInterface, or fix all the spellings to be consistent, but that 
seems better as a separate commit.

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster &broadcaster = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(&broadcaster,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");

clayborg wrote:

It would be good to verify a few more things here for each start event:
```
ASSERT_FALSE(data->IsFinite());
ASSERT_FALSE(data->GetCompleted());
ASSERT_EQ(data->GetTotal(), 1);
ASSERT_EQ(data->GetMessage(), "Progress report 1: Starting report 1");
```

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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

https://github.com/clayborg commented:

It is great to have unit tests for this. I remember with your previous patch we 
caught an issue where the completed event might not be delivered, or it would 
be delivered without the values being set correctly, so this will be great to 
be able to catch this kind of stuff when we make changes.

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster &broadcaster = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(&broadcaster,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");
+
+std::this_thread::sleep_for(timeout);
+  }
+
+  // Progress report objects should be destroyed at this point so
+  // get each report from the queue and check that they've been
+  // destroyed in reverse order
+  std::this_thread::sleep_for(timeout);
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+  data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+
+  ASSERT_EQ(data->GetTitle(), "Progress report 3");
+  ASSERT_TRUE(data->GetCompleted());

clayborg wrote:

Add a few more tests for each complete event
```
ASSERT_FALSE(data->IsFinite());
ASSERT_EQ(data->GetMessage(), "...");
```

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


[Lldb-commits] [lldb] [lldb][progress][NFC] Add unit test for progress reports (PR #79533)

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


@@ -0,0 +1,105 @@
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Progress.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/Listener.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+class ProgressReportTest : public ::testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+PlatformMacOSX::Initialize();
+Debugger::Initialize(nullptr);
+  }
+  void TearDown() override {
+Debugger::Terminate();
+PlatformMacOSX::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+TEST_F(ProgressReportTest, TestReportCreation) {
+  std::chrono::milliseconds timeout(100);
+
+  // Set up the debugger, make sure that was done properly
+  ArchSpec arch("x86_64-apple-macosx-");
+  Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  // Get the debugger's broadcaster
+  Broadcaster &broadcaster = debugger_sp->GetBroadcaster();
+
+  // Create a listener, make sure it can receive events and that it's
+  // listening to the correct broadcast bit
+  ListenerSP listener_sp = Listener::MakeListener("progress-listener");
+
+  listener_sp->StartListeningForEvents(&broadcaster,
+   Debugger::eBroadcastBitProgress);
+  EXPECT_TRUE(
+  broadcaster.EventTypeHasListeners(Debugger::eBroadcastBitProgress));
+
+  EventSP event_sp;
+  const ProgressEventData *data;
+
+  // Scope this for RAII on the progress objects
+  // Create progress reports and check that their respective events for having
+  // started are broadcasted
+  {
+Progress progress1("Progress report 1", "Starting report 1");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 1");
+
+Progress progress2("Progress report 2", "Starting report 2");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 2");
+
+Progress progress3("Progress report 3", "Starting report 3");
+EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
+ASSERT_TRUE(event_sp);
+
+data = ProgressEventData::GetEventDataFromEvent(event_sp.get());
+ASSERT_EQ(data->GetDetails(), "Starting report 3");

clayborg wrote:

If we are looking to verify things are delivered in the order that they were 
supplied, do you want to do all of the event checking outside of this loop? 
Otherwise the only thing on the event queue here is the data we are looking for 
so this doesn't help us to verify that we got things in the order that they 
were pushed onto the queue. We should be able to do:
```
{
  Progress progress1("Progress report 1", "Starting report 1");
  Progress progress2("Progress report 2", "Starting report 2");
  Progress progress3("Progress report 3", "Starting report 3");
}
// Now check that we got all events in the right order for both the start and 
completed
// check progress started for "Progress report 1"
// check progress started for "Progress report 2"
// check progress started for "Progress report 3"
// check progress completed for "Progress report 1"
// check progress completed for "Progress report 2"
// check progress completed for "Progress report 3"
```
This will help us verify the order of things. 

Might be a good idea to do a check for progress reports with a valid total as 
well, and test that if we increment too many times that we don't deliver 
multiple completed events
```
{
  Progress progress1("Progress report 1", "Starting report 1");
  Progress progress2("Progress report 2", "Starting report 2");
  Progress progress3("Progress report 3", "Starting report 3");
  Progress progress4("Progress report 4", "Starting report 4", 2);
  progress4.Increment(1, "progress detail 1");
  // This should cause the progress to complete
  progress4.Increment(1, "progress detail 2"); 
  // The progress is already completed, I would expect to not see any more 
events for this progress
  progress4.Increment(1, "too many, we shouldn't see this!");
}
```
And when verifying the events for `progress4`:
```
ASSERT_TRUE(data->IsFinite());
ASSERT_FALSE|ASSERT_TRUE(data->GetCompleted()); // Make sure this is correct 
for each event
ASSERT_EQ(data->GetTotal(), 2);
ASSERT_EQ(data->GetMessage(), "..."); // Make sure this is correct for each 
increment
```

https://github.com/llvm/llvm-project/pull/79533
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.

[Lldb-commits] [clang-tools-extra] [libcxx] [clang] [lld] [lldb] [llvm] [mlir] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/79626

>From ab475c9ffb7c3562bad4772389e97b82e9f110c0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Fri, 26 Jan 2024 11:55:06 -0600
Subject: [PATCH] Add elementwise criteria to match.structured.body

---
 .../Linalg/TransformOps/LinalgMatchOps.td |  4 +++
 .../Linalg/TransformOps/LinalgMatchOps.cpp|  9 -
 .../Dialect/Linalg/match-ops-interpreter.mlir | 34 +++
 .../Dialect/Linalg/match-ops-invalid.mlir |  2 +-
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f..dfeb8ae5d5ddbc 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063a..fb18886c16b16d 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block &body = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e..0efe70a7b9ae1e 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,40 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.test_print_remark_at_operand %arg0, "elementwise" : 
!transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+@match_structured_body_elementwise -> @print_elementwise
+: (!transform.any_op) -> !transform.any_op
+transform.yield
+  }
+
+  func.func @payload(%in1: tensor<2xf32>, %in2: tensor<2xf32>, %out: 
tensor<2xf32>) -> tensor<2xf32> attributes { transform.target_tag = 
"start_he

[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -831,6 +831,37 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   return true;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
+PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl &args_impl,
+lldb_private::CommandReturnObject &cmd_retobj,
+lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  PythonObject self(PyRefType::Borrowed, implementor);
+  auto pfunc = self.ResolveName("__call__");

jimingham wrote:

We don't do any checking for arguments in any of the `pfunc` lookups in the 
python wrapper, except in one or two cases where we support overloaded 
implementation functions.  I don't think doing this piecemeal is a great idea.  
It would be better to have some kind of `check_pfunc` feature that does the 
lookup and takes some specification about what to expect of the found function. 
 Then we can insert this in all the current lookups.
But this patch is long enough already, it would be better to do that as a 
separate patch.

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


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

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

petrhosek wrote:

I tried this branch on our Windows builders although I'm not sure if it's 
related or not to this patch:
```
# COMPILED WITH
C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp
 --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
-nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
C:/b/s/w/ir/x/w/github-H-G-Hristov-llvm-project/libcxx/test/support 
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall 
-Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings  -llibc++experimental -nostdlib -L 
C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\libcxx\fuzzing\Output\random.pass.cpp.dir\t.tmp.exe
# executed command: C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
'C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp'
 --driver-mode=g++ --target=x86_64-pc-windows-msvc -fms-runtime-lib=static 
-nostdinc++ -I C:/b/s/w/ir/x/w/llvm_build/include/c++/v1 -I 
C:/b/s/w/ir/x/w/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 -I 
C:/b/s/w/ir/x/w/github-H-G-Hristov-llvm-project/libcxx/test/support 
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -std=c++26 -Werror -Wall 
-Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier 
-Wdeprecated-copy -Wdeprecated-copy-dtor -Wno-user-defined-literals 
-Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter 
-Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args 
-Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed 
-Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move 
-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings -llibc++experimental -nostdlib -L 
C:/b/s/w/ir/x/w/llvm_build/./lib/x86_64-pc-windows-msvc -llibc++ -llibcpmt -o 
'C:\b\s\w\ir\x\w\llvm_build\runtimes\runtimes-x86_64-pc-windows-msvc-bins\test\libcxx\fuzzing\Output\random.pass.cpp.dir\t.tmp.exe'
# .---command stderr
# | In file included from 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:16:
# | In file included from C:/b/s/w/ir/x/w/llvm_build/include/c++/v1\cmath:319:
# | In file included from C:/b/s/w/ir/x/w/llvm_build/include/c++/v1\math.h:301:
# | In file included from C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\math.h:11:
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:413:16: error: call to 
'fpclassify' is ambiguous
# |   413 | return fpclassify(_X) == FP_NAN;
# |   |^~
# | 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:166:12:
 note: in instantiation of function template specialization 'isnan' 
requested here
# |   166 |   if (std::isnan(res)) {
# |   |^
# | 
C:\b\s\w\ir\x\w\github-H-G-Hristov-llvm-project\libcxx\test\libcxx\fuzzing\random.pass.cpp:178:10:
 note: in instantiation of function template specialization 
'helper>' requested here
# |   178 |   return helper>(data, 
size)   ||
# |   |  ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:288:31: note: candidate 
function
# |   288 | _Check_return_ inline int fpclassify(_In_ float _X) throw()
# |   |   ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:293:31: note: candidate 
function
# |   293 | _Check_return_ inline int fpclassify(_In_ double _X) throw()
# |   |   ^
# | C:\b\s\w\ir\cache\windows_sdk\Windows 
Kits\10\Include\10.0.19041.0\ucrt\corecrt_math.h:298:31: note: candidate 
function
# |   298 | 

[Lldb-commits] [lldb] [lldb] Fix a crash when using .dwp files and make type lookup reliable with the index cache (PR #79544)

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

clayborg wrote:

> I'm not following all of this, but it appears to be based on the premise that 
> it's OK that sometimes split units inside a DWP file are parsed before their 
> skeleton unit? Why is that OK/when/why/where is that happening?

When we have accelerator tables from lldb index cache being loaded from disk, 
we have a DIERef object for each matching name. This DIERef objects has a magic 
file index that specifies that this is from the .dwp file. When we do a type 
lookup and get these kinds of entries, we go straight to the `.dwp` file and 
load `.dwo` in the `.dwp` and this causes the issue. 

> I'd think any case where that happens would be a performance (& possibly 
> correctness bug) & it'd be better to maintain the invariant that the only way 
> you ever parse a split unit is starting from the skeleton - rather than 
> adding maps/etc to be able to backtrack to parsing the skeleton when you 
> already have the split unit.

That might mean that anytime we use _any_ DWARFDie, we will need to add 
functionality that checks with the DWARFUnit to verify if it is a .dwo unit, 
and if so, make sure its skeleton unit has been parsed. The current solution 
allows anyone to just work with the existing APIs and they will do the right 
thing and will only grab the backlink if it isn't already set. With DWARF5 it 
is cheap as the info is in the unit headers. 

Without this solution we will have to always parse the skeleton unit headers 
for the main executable and need to parse at least the first DIE in order to 
fill in the .dwo file's skeleton backlink pointer. So this can cause us to pull 
in more DWARF during type lookups.

If you are really against this approach I can search for a solution that avoids 
the maps, but I fear more hidden bugs will arise in the future without an 
approach similar to what this PR does. The current bugs either crashed the 
debug session or stopped type lookups from working. 


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


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

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

Zingam wrote:

@petrhosek It is not related. It was supposedly fixed by this: 
https://github.com/llvm/llvm-project/pull/79619
I've been observing the chromium Windows CI failing for a while. Let's see if 
the above patch fixes it. I'll rebase now this one now.

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


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

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

https://github.com/Zingam updated 
https://github.com/llvm/llvm-project/pull/79032

>From e03452fda84a5284420bba1913299b68caabb6cd Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Mon, 22 Jan 2024 20:35:00 +0200
Subject: [PATCH 1/6] Revert "Revert "[libc++][format] P2637R3: Member `visit`
 (`std::basic_format_arg`) (#76449)""

This reverts commit 02f95b77515fe18ed1076b94cbb850ea0cf3c77e.
---
 libcxx/docs/ReleaseNotes/18.rst   |   1 +
 libcxx/docs/Status/Cxx2cPapers.csv|   2 +-
 libcxx/docs/Status/FormatIssues.csv   |   2 +-
 libcxx/include/__config   |   6 +
 libcxx/include/__format/format_arg.h  | 109 +-
 libcxx/include/__format/format_context.h  |  33 +-
 libcxx/include/format |   2 +-
 .../format.arg/visit.pass.cpp | 333 
 .../format.arg/visit.return_type.pass.cpp | 369 ++
 .../visit_format_arg.deprecated.verify.cpp|  38 ++
 .../format.arg/visit_format_arg.pass.cpp  |   6 +-
 .../format.arguments/format.args/get.pass.cpp |  48 ++-
 libcxx/test/support/test_basic_format_arg.h   |  20 +-
 libcxx/test/support/test_macros.h |   5 +
 .../generate_feature_test_macro_components.py |   1 +
 15 files changed, 927 insertions(+), 48 deletions(-)
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp
 create mode 100644 
libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp

diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fd882bafe19a51..237a63022d55ff 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -79,6 +79,7 @@ Implemented Papers
 - P1759R6 - Native handles and file streams
 - P2868R3 - Remove Deprecated ``std::allocator`` Typedef From C++26
 - P2517R1 - Add a conditional ``noexcept`` specification to ``std::apply``
+- P2637R3 - Member ``visit``
 - P2447R6 - ``span`` over initializer list
 
 
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index f80b1f6b663f04..c45aa3c510072e 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -17,7 +17,7 @@
 "`P0792R14 `__","LWG","``function_ref``: a 
type-erased callable reference","Varna June 2023","","",""
 "`P2874R2 `__","LWG","Mandating Annex D Require No 
More","Varna June 2023","","",""
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
-"`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","|Partial|","18.0",""
+"`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","|Complete|","18.0",""
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
 "`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
diff --git a/libcxx/docs/Status/FormatIssues.csv 
b/libcxx/docs/Status/FormatIssues.csv
index 513988d08036ca..6e58e752191ea5 100644
--- a/libcxx/docs/Status/FormatIssues.csv
+++ b/libcxx/docs/Status/FormatIssues.csv
@@ -16,7 +16,7 @@ Number,Name,Standard,Assignee,Status,First released version
 "`P2693R1 `__","Formatting ``thread::id`` and 
``stacktrace``","C++23","Mark de Wever","|In Progress|"
 "`P2510R3 `__","Formatting pointers","C++26","Mark 
de Wever","|Complete|",17.0
 "`P2757R3 `__","Type-checking format 
args","C++26","","",
-"`P2637R3 `__","Member ``visit``","C++26","","",
+"`P2637R3 `__","Member ``visit``","C++26","Hristo 
Hristov","|Complete|",18.0
 "`P2905R2 `__","Runtime format strings","C++26 
DR","Mark de Wever","|Complete|",18.0
 "`P2918R2 `__","Runtime format strings 
II","C++26","Mark de Wever","|Complete|",18.0
 "`P2909R4 `__","Fix formatting of code units as 
integers (Dude, where’s my ``char``?)","C++26 DR","Mark de 
Wever","|Complete|",18.0
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 9a64cdb489119d..00489d971c296c 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -995,6 +995,12 @@ typedef __char32_t char32_t;
 #define _LIBCPP_DEPRECATED_IN_CXX23
 #  endif
 
+#  if _LIBCPP_STD_VER >= 26
+#define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
+#  else
+#define _LIBCPP_DEPRECATED_IN_CXX26
+#  endif
+
 #  if !defined(_LIBCPP_HAS_NO_CHAR8_

[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

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


@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",

clayborg wrote:

Are we looking for an executable here, or the dSYM file? Should be title be 
"Locating executable file"?

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -831,6 +831,37 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   return true;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
+PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl &args_impl,
+lldb_private::CommandReturnObject &cmd_retobj,
+lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  PythonObject self(PyRefType::Borrowed, implementor);
+  auto pfunc = self.ResolveName("__call__");
+
+  if (!pfunc.IsAllocated())
+return false;

jimingham wrote:

I added this here, but we really need a more general mechanism for informing 
the user when the python code we've been handed is lacking some affordance.  
Most of these wrappers don't have a CommandReturnObject to complain through.

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

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


@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",

JDevlieghere wrote:

We're looking for the symbol file (although dsymForUUID can also get you the 
symbol rich binary). This is the same message already emitted by 
`SymbolLocatorDefault::LocateExecutableSymbolFile`. 

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


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

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

Zingam wrote:

@petrhosek According to the log, the tests in this patch pass. Could you please 
try again. I'll wait a while and if there is not negative feedback I'll reland 
the patch.

> https://logs.chromium.org/logs/fuchsia/led/phosek_google.com/62644843c966785c9dedf065a79d80df8734b4df5ff7703ea3c2a2b5643cec05/+/u/clang/test/stdout
>  is the full log.

```
 PASS: llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit.pass.cpp (8505 of 9639)
 PASS: llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp 
(8506 of 9639)
 PASS: llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp 
(8537 of 9639)
 PASS: llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp
 (8439 of 9639)
```



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


[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread Dave Lee via lldb-commits

https://github.com/kastiglione created 
https://github.com/llvm/llvm-project/pull/79644

The `(( )?&)?` appears to match types which are references. However lldb can 
load the
correct data formatters without having to pattern match against a `&` suffix.

The suffix may have been needed at one point, but it's no longer needed.


>From a5e72e90edb907c287df219eb2abeee67f4eb115 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Thu, 25 Jan 2024 15:55:51 -0800
Subject: [PATCH] [lldb] Remove unnecessary suffix from libc++ type name
 patterns (NFC)

The `(( )?&)?` appears to match types which are references. However lldb can 
load the
correct data formatters without having to pattern match against a `&` suffix.

The suffix may have been needed at one point, but it's no longer needed.
---
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 166 +-
 1 file changed, 79 insertions(+), 87 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index f0fe6c9e06d9d47..e0de80880376acb 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -744,46 +744,46 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxBitsetSyntheticFrontEndCreator,
   "libc++ std::bitset synthetic children",
-  "^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::bitset<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
   "libc++ std::vector synthetic children",
-  "^std::__[[:alnum:]]+::vector<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::vector<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdForwardListSyntheticFrontEndCreator,
   "libc++ std::forward_list synthetic children",
-  "^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$", stl_synth_flags, 
true);
+  "^std::__[[:alnum:]]+::forward_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
   "libc++ std::list synthetic children",
-  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( 
)?&)?$"
-  // so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
+  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>$"
+  // so that it does not clash with: "^std::(__cxx11::)?list<.+>$"
   "^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
-  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$",
+  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>$",
   stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::map synthetic children",
-  "^std::__[[:alnum:]]+::map<.+> >(( )?&)?$", stl_synth_flags, true);
+  "libc++ std::map synthetic children", "^std::__[[:alnum:]]+::map<.+> >$",
+  stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::set synthetic children",
-  "^std::__[[:alnum:]]+::set<.+> >(( )?&)?$", stl_deref_flags, true);
+  "libc++ std::set synthetic children", "^std::__[[:alnum:]]+::set<.+> >$",
+  stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multiset synthetic children",
-  "^std::__[[:alnum:]]+::multiset<.+> >(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::multiset<.+> >$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multimap synthetic children",
-  "^std::__[[:alnum:]]+::multimap<.+> >(( )?&)?$", stl_synth_flags, true);
+  "^std::__[[:alnum:]]+::multimap<.+> >$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
@@ -794,23 +794,19 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator,
   "libc++ std::initializer_list synthetic children",
-  "^std::initializer_list<.+>(( )?&)?$", stl_synth_flags, true);
+  "^std::initializer_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(cpp_category_sp, LibcxxQueueFrontEndCreator,
   "libc++ std::queue synthetic children",
-  "^std::__[[:alnum:]]+::queue<.+>(( )?&)?$", stl_synth_flags,
-   

[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Adrian Prantl via lldb-commits


@@ -1050,28 +1054,25 @@ bool 
SymbolLocatorDebugSymbols::DownloadObjectAndSymbolFile(
   const std::string file_path_str =
   file_spec_ptr ? file_spec_ptr->GetPath() : "";
 
-  Log *log = GetLog(LLDBLog::Host);
+  if (uuid_str.empty() && file_path_str.empty())
+return false;
 
   // Create the dsymForUUID command.
-  StreamString command;
+  const char *lookup_arg =
+  !uuid_str.empty() ? uuid_str.c_str() : file_path_str.c_str();
   const char *copy_executable_arg = copy_executable ? "--copyExecutable " : "";
-  if (!uuid_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   uuid_str.c_str());
-LLDB_LOGF(log, "Calling %s with UUID %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), uuid_str.c_str(),
-  command.GetString().data());
-  } else if (!file_path_str.empty()) {
-command.Printf("%s --ignoreNegativeCache %s%s",
-   dsymForUUID_exe_path.c_str(), copy_executable_arg,
-   file_path_str.c_str());
-LLDB_LOGF(log, "Calling %s with file %s to find dSYM: %s",
-  dsymForUUID_exe_path.c_str(), file_path_str.c_str(),
-  command.GetString().data());
-  } else {
-return false;
-  }
+
+  StreamString command;

adrian-prantl wrote:

more unnecessary comments about unnecessary c string conversions :-)
```
llvm::SmallString<64> buf;
llvm::raw_svector_ostream(buf) << ...;
```

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


[Lldb-commits] [lldb] [lldb] Fix progress reporting for SymbolLocatorDebugSymbols (PR #79624)

2024-01-26 Thread Adrian Prantl via lldb-commits


@@ -776,6 +776,10 @@ std::optional 
SymbolLocatorDebugSymbols::LocateExecutableSymbolFile(
   exec_fspec ? exec_fspec->GetFilename().AsCString("") : "",
   arch ? arch->GetArchitectureName() : "", (const void *)uuid);
 
+  Progress progress(
+  "Locating external symbol file",
+  module_spec.GetFileSpec().GetFilename().AsCString(""));

adrian-prantl wrote:

Aside: Looks like we're missing a AsString() method in ConstString so we can 
avoid the roundtrip through `char *`

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


[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)


Changes

The `(( )?&)?` appears to match types which are references. However lldb 
can load the
correct data formatters without having to pattern match against a `&` 
suffix.

The suffix may have been needed at one point, but it's no longer needed.


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


1 Files Affected:

- (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
(+79-87) 


``diff
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index f0fe6c9e06d9d4..e0de80880376ac 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -744,46 +744,46 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxBitsetSyntheticFrontEndCreator,
   "libc++ std::bitset synthetic children",
-  "^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::bitset<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
   "libc++ std::vector synthetic children",
-  "^std::__[[:alnum:]]+::vector<.+>(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::vector<.+>$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdForwardListSyntheticFrontEndCreator,
   "libc++ std::forward_list synthetic children",
-  "^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$", stl_synth_flags, 
true);
+  "^std::__[[:alnum:]]+::forward_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
   "libc++ std::list synthetic children",
-  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>(( 
)?&)?$"
-  // so that it does not clash with: "^std::(__cxx11::)?list<.+>(( )?&)?$"
+  // A POSIX variant of: "^std::__(?!cxx11:)[[:alnum:]]+::list<.+>$"
+  // so that it does not clash with: "^std::(__cxx11::)?list<.+>$"
   "^std::__([A-Zabd-z0-9]|cx?[A-Za-wyz0-9]|cxx1?[A-Za-z02-9]|"
-  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>(( )?&)?$",
+  "cxx11[[:alnum:]])[[:alnum:]]*::list<.+>$",
   stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::map synthetic children",
-  "^std::__[[:alnum:]]+::map<.+> >(( )?&)?$", stl_synth_flags, true);
+  "libc++ std::map synthetic children", "^std::__[[:alnum:]]+::map<.+> >$",
+  stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
-  "libc++ std::set synthetic children",
-  "^std::__[[:alnum:]]+::set<.+> >(( )?&)?$", stl_deref_flags, true);
+  "libc++ std::set synthetic children", "^std::__[[:alnum:]]+::set<.+> >$",
+  stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multiset synthetic children",
-  "^std::__[[:alnum:]]+::multiset<.+> >(( )?&)?$", stl_deref_flags, true);
+  "^std::__[[:alnum:]]+::multiset<.+> >$", stl_deref_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
   "libc++ std::multimap synthetic children",
-  "^std::__[[:alnum:]]+::multimap<.+> >(( )?&)?$", stl_synth_flags, true);
+  "^std::__[[:alnum:]]+::multimap<.+> >$", stl_synth_flags, true);
   AddCXXSynthetic(
   cpp_category_sp,
   lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
@@ -794,23 +794,19 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP 
cpp_category_sp) {
   cpp_category_sp,
   lldb_private::formatters::LibcxxInitializerListSyntheticFrontEndCreator,
   "libc++ std::initializer_list synthetic children",
-  "^std::initializer_list<.+>(( )?&)?$", stl_synth_flags, true);
+  "^std::initializer_list<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(cpp_category_sp, LibcxxQueueFrontEndCreator,
   "libc++ std::queue synthetic children",
-  "^std::__[[:alnum:]]+::queue<.+>(( )?&)?$", stl_synth_flags,
-  true);
+  "^std::__[[:alnum:]]+::queue<.+>$", stl_synth_flags, true);
   AddCXXSynthetic(cpp_category_sp, LibcxxTupleFrontEndCreator,
   "libc++ std::tuple synthetic children",
-  "^std::__[[:alnum:]]+::tuple<.*>(( )?&)?$", stl_synth_flags,
-  true);
+  "^std::__[[:alnum:]]+::tuple<.*>$", stl_synth_fl

[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

2024-01-26 Thread Dave Lee via lldb-commits

kastiglione wrote:

Because of clang-format, the diff obscures the fact that this change only 
deletes `(( )?&)?` from these strings. There are no other changes.

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


[Lldb-commits] [lldb] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-26 Thread via lldb-commits


@@ -831,6 +831,37 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   return true;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallParsedCommandObject(
+PyObject *implementor, lldb::DebuggerSP debugger, 
lldb_private::StructuredDataImpl &args_impl,
+lldb_private::CommandReturnObject &cmd_retobj,
+lldb::ExecutionContextRefSP exe_ctx_ref_sp) {
+
+  PyErr_Cleaner py_err_cleaner(true);
+
+  PythonObject self(PyRefType::Borrowed, implementor);
+  auto pfunc = self.ResolveName("__call__");
+
+  if (!pfunc.IsAllocated())
+return false;
+
+  auto cmd_retobj_arg = SWIGBridge::ToSWIGWrapper(cmd_retobj);

jimingham wrote:

That must have been problematic in development.  This sort of compressed style 
is less good when you are debugging...

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


[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread lorenzo chelini via lldb-commits

chelini wrote:

Is it ready for review? Is marked as "draft".

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


[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/79626

>From ab475c9ffb7c3562bad4772389e97b82e9f110c0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Fri, 26 Jan 2024 11:55:06 -0600
Subject: [PATCH] Add elementwise criteria to match.structured.body

---
 .../Linalg/TransformOps/LinalgMatchOps.td |  4 +++
 .../Linalg/TransformOps/LinalgMatchOps.cpp|  9 -
 .../Dialect/Linalg/match-ops-interpreter.mlir | 34 +++
 .../Dialect/Linalg/match-ops-invalid.mlir |  2 +-
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f2..dfeb8ae5d5ddbcb 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063ac..fb18886c16b16d5 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block &body = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e4..0efe70a7b9ae1eb 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,40 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.test_print_remark_at_operand %arg0, "elementwise" : 
!transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+@match_structured_body_elementwise -> @print_elementwise
+: (!transform.any_op) -> !transform.any_op
+transform.yield
+  }
+
+  func.func @payload(%in1: tensor<2xf32>, %in2: tensor<2xf32>, %out: 
tensor<2xf32>) -> tensor<2xf32> attributes { transform.target_tag = 
"st

[Lldb-commits] [lldb] [lldb] Remove unnecessary suffix from libc++ type name patterns (NFC) (PR #79644)

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

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

LGTM

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


[Lldb-commits] [mlir] [clang] [llvm] [libcxx] [lld] [clang-tools-extra] [lldb] [mlir][transform] Add elementwise criteria to `match.structured.body` (PR #79626)

2024-01-26 Thread via lldb-commits

https://github.com/srcarroll updated 
https://github.com/llvm/llvm-project/pull/79626

>From ab475c9ffb7c3562bad4772389e97b82e9f110c0 Mon Sep 17 00:00:00 2001
From: Sam 
Date: Fri, 26 Jan 2024 11:55:06 -0600
Subject: [PATCH 1/2] Add elementwise criteria to match.structured.body

---
 .../Linalg/TransformOps/LinalgMatchOps.td |  4 +++
 .../Linalg/TransformOps/LinalgMatchOps.cpp|  9 -
 .../Dialect/Linalg/match-ops-interpreter.mlir | 34 +++
 .../Dialect/Linalg/match-ops-invalid.mlir |  2 +-
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td 
b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
index 162dd05f93030f2..dfeb8ae5d5ddbcb 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgMatchOps.td
@@ -106,6 +106,9 @@ def MatchStructuredBodyOp : Op((bbarg0, bbarg1), bbarg2)` where `` and
 `` are binary operations whose names are specified in the 
attribute
@@ -123,6 +126,7 @@ def MatchStructuredBodyOp : Op:$reduction_position,
UnitAttr:$passthrough,
+   UnitAttr:$elementwise,
OptionalAttr:$contraction);
   let assemblyFormat = "$operand_handle attr-dict `:` type($operand_handle)";
   let extraClassDeclaration = SingleOpMatcher.extraDeclaration;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
index 115da4b90e063ac..fb18886c16b16d5 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgMatchOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Dialect/Linalg/IR/Linalg.h"
 #include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h"
 #include "mlir/Dialect/Linalg/TransformOps/Syntax.h"
+#include "mlir/Dialect/Linalg/Utils/Utils.h"
 #include "mlir/Dialect/Transform/IR/MatchInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Interfaces/FunctionImplementation.h"
@@ -187,6 +188,11 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 }
 return DiagnosedSilenceableFailure::success();
   }
+  if (getElementwise()) {
+if (!isElementwise(linalgOp))
+  return emitSilenceableError() << "not elementwise";
+return DiagnosedSilenceableFailure::success();
+  }
   if (std::optional contractionOps = getContraction()) {
 Block &body = linalgOp->getRegion(0).front();
 std::string message;
@@ -209,13 +215,14 @@ DiagnosedSilenceableFailure 
transform::MatchStructuredBodyOp::matchOperation(
 
 LogicalResult transform::MatchStructuredBodyOp::verify() {
   int64_t numOptions = getReductionPosition().has_value() + getPassthrough() +
-   getContraction().has_value();
+   getElementwise() + getContraction().has_value();
 
   if (numOptions > 1) {
 std::string attributeNames;
 llvm::raw_string_ostream os(attributeNames);
 llvm::interleaveComma(ArrayRef{getReductionPositionAttrName(),
getPassthroughAttrName(),
+   getElementwiseAttrName(),
getContractionAttrName()},
   os);
 return emitOpError() << "only one of {" << os.str() << "} is allowed";
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir 
b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index a7353a4c38881e4..0efe70a7b9ae1eb 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -180,6 +180,40 @@ module attributes { transform.with_named_sequence } {
 
 // -
 
+module attributes { transform.with_named_sequence } {
+  transform.named_sequence @print_elementwise(%arg0: !transform.any_op 
{transform.readonly}) {
+transform.test_print_remark_at_operand %arg0, "elementwise" : 
!transform.any_op
+transform.yield
+  }
+
+  transform.named_sequence @match_structured_body_elementwise(%arg0: 
!transform.any_op {transform.readonly}) -> !transform.any_op {
+%0 = transform.match.structured failures(propagate) %arg0 : 
(!transform.any_op) -> !transform.any_op {
+^bb0(%arg1: !transform.any_op):
+  transform.match.structured.body %arg1 { elementwise } : !transform.any_op
+  transform.match.structured.yield %arg1 : !transform.any_op
+}
+transform.yield %0 : !transform.any_op
+  }
+
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op 
{transform.consumed}) {
+transform.foreach_match in %arg0
+@match_structured_body_elementwise -> @print_elementwise
+: (!transform.any_op) -> !transform.any_op
+transform.yield
+  }
+
+  func.func @payload(%in1: tensor<2xf32>, %in2: tensor<2xf32>, %out: 
tensor<2xf32>) -> tensor<2xf32> attributes { transform.target_tag = 

  1   2   >