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

2024-01-21 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] [clang-tools-extra] [clang] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-21 Thread via lldb-commits

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

Afaik @AaronBallman's questions have been answered.
LGTM. Thanks!
I think we should land this sooner rather than later if we want it to land in 
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] [clang-tools-extra] [clang] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-01-21 Thread via lldb-commits


@@ -183,6 +183,8 @@ C++ Language Changes
 
 C++20 Feature Support
 ^
+- Implemented `P1907R1 ` which extends allowed 
non-type template argument
+  kinds with e.g. floating point values and pointers and references to 
subobjects.

cor3ntin wrote:

```suggestion
  kinds with e.g. floating point values and pointers and references to 
subobjects.
  This feature is still experimental. Accordingly, 
`__cpp_nontype_template_args` was not updated.
```

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-21 Thread via lldb-commits


@@ -5401,6 +5409,8 @@ std::string CGDebugInfo::GetName(const Decl *D, bool 
Qualified) const {
 // feasible some day.
 return TA.getAsIntegral().getBitWidth() <= 64 &&
IsReconstitutableType(TA.getIntegralType());
+  case TemplateArgument::StructuralValue:
+return false;

cor3ntin wrote:

I don't think this is blocking either way, at worse we have suboptimal 
debugging experience for a new feature

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] [compiler-rt] [lldb] [mlir] [flang] [lld] [libcxx] [llvm] [openmp] [clang-tools-extra] [libc] [clang] [libc++][format] P2637R3: Member `visit` (`std::basic_format_arg`) (PR #76449)

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

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


[Lldb-commits] [lldb] [lld] [llvm] [libcxx] [openmp] [flang] [libunwind] [libcxxabi] [compiler-rt] [clang-tools-extra] [polly] [libc] [clang] [mlir] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

H-G-Hristov wrote:

I did some re-imagining of the tests, there is a some redundancy but it is 
cleared that nothing was missed.
I also used the Clang 18's "Placeholder variables with no name" to make the 
test a bit cleaner, so I disabled the unsupported compilers.
The tests are formatted in tabular form manually to make them easier to read.

If the above is unacceptable, it can be fixed easily. For now it makes it 
easier to read and review. 

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


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

2024-01-21 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/2] [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] [libunwind] [openmp] [libc] [flang] [mlir] [libcxxabi] [polly] [libcxx] [lldb] [lld] [clang] [compiler-rt] [clang-tools-extra] [llvm] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

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


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

2024-01-21 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/2] [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] [llvm] [libcxx] [compiler-rt] [lldb] [clang] [libc] [lld] [clang-tools-extra] [flang] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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)

fhahn wrote:

IsFull is gone now

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] [lld] [llvm] [libcxx] [flang] [compiler-rt] [clang-tools-extra] [libc] [clang] [VPlan] Implement cloning of VPlans. (PR #73158)

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

https://github.com/fhahn edited 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] [clang-tools-extra] [lld] [clang] [flang] [libc] [compiler-rt] [llvm] [lldb] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -1200,6 +1271,59 @@ void VPUser::printOperands(raw_ostream &O, VPSlotTracker 
&SlotTracker) const {
 }
 #endif
 
+VPBlockBase *VPBlockUtils::cloneCFG(
+VPBlockBase *Entry, DenseMap &Old2New,
+DenseMap &Old2NewVPValues, bool FullRemapping) {
+  ReversePostOrderTraversal> 
RPOT(
+  Entry);
+  VPBlockBase *NewEntry = nullptr;
+  for (VPBlockBase *BB : RPOT) {
+VPBlockBase *NewBB = BB->clone();
+if (!NewEntry)
+  NewEntry = NewBB;

fhahn wrote:

updated, 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] [lld] [flang] [llvm] [lldb] [clang-tools-extra] [clang] [libc] [compiler-rt] [libcxx] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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),

fhahn wrote:

Replace with `remapOperands`, no casts allowed, adjusted ordering as well

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] [lldb] [llvm] [libcxx] [lld] [flang] [libc] [compiler-rt] [clang-tools-extra] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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) {

fhahn wrote:

Remove now, 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] [compiler-rt] [clang] [libc] [flang] [clang-tools-extra] [llvm] [lld] [lldb] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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 =

fhahn wrote:

Updated, 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] [lld] [clang-tools-extra] [libc] [compiler-rt] [llvm] [lldb] [flang] [clang] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -1200,6 +1271,59 @@ void VPUser::printOperands(raw_ostream &O, VPSlotTracker 
&SlotTracker) const {
 }
 #endif
 
+VPBlockBase *VPBlockUtils::cloneCFG(
+VPBlockBase *Entry, DenseMap &Old2New,
+DenseMap &Old2NewVPValues, bool FullRemapping) {
+  ReversePostOrderTraversal> 
RPOT(
+  Entry);
+  VPBlockBase *NewEntry = nullptr;
+  for (VPBlockBase *BB : RPOT) {
+VPBlockBase *NewBB = BB->clone();
+if (!NewEntry)
+  NewEntry = NewBB;
+
+for (VPBlockBase *Pred : BB->getPredecessors())
+  connectBlocks(Old2New[Pred], NewBB);

fhahn wrote:

Added asserts checking successors/predecessors after cloning the CFG, 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] [lldb] [compiler-rt] [lld] [libc] [libcxx] [clang] [flang] [clang-tools-extra] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -1594,6 +1657,13 @@ class VPWidenPHIRecipe : public VPHeaderPHIRecipe {
   addOperand(Start);
   }
 
+  VPRecipeBase *clone() override {
+auto *Res = new VPWidenPHIRecipe(cast(getUnderlyingInstr()),

fhahn wrote:

Yep

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] [flang] [llvm] [libc] [lld] [clang-tools-extra] [compiler-rt] [lldb] [clang] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -1200,6 +1271,59 @@ void VPUser::printOperands(raw_ostream &O, VPSlotTracker 
&SlotTracker) const {
 }
 #endif
 
+VPBlockBase *VPBlockUtils::cloneCFG(
+VPBlockBase *Entry, DenseMap &Old2New,
+DenseMap &Old2NewVPValues, bool FullRemapping) {
+  ReversePostOrderTraversal> 
RPOT(
+  Entry);
+  VPBlockBase *NewEntry = nullptr;
+  for (VPBlockBase *BB : RPOT) {
+VPBlockBase *NewBB = BB->clone();
+if (!NewEntry)
+  NewEntry = NewBB;
+
+for (VPBlockBase *Pred : BB->getPredecessors())
+  connectBlocks(Old2New[Pred], NewBB);
+
+Old2New[BB] = NewBB;
+
+if (!isa(BB))
+  continue;
+  }
+
+  // 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))) {
+for (const auto &[OldR, NewR] : zip(*OldBB, *NewBB))
+  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));
+if (!FullRemapping)

fhahn wrote:

FullRemapping is gone

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] [lld] [compiler-rt] [libc] [clang-tools-extra] [llvm] [flang] [clang] [lldb] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -2262,9 +2400,22 @@ class VPDerivedIVRecipe : public VPRecipeBase, public 
VPValue {
 VPValue(this), TruncResultTy(TruncResultTy), Kind(IndDesc.getKind()),
 FPBinOp(dyn_cast_or_null(IndDesc.getInductionBinOp())) 
{
   }

fhahn wrote:

Updated, 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] [flang] [lld] [lldb] [llvm] [libcxx] [compiler-rt] [clang-tools-extra] [libc] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -615,6 +615,18 @@ void VPBasicBlock::print(raw_ostream &O, const Twine 
&Indent,
 }
 #endif
 
+VPBlockBase *VPRegionBlock::clone() {

fhahn wrote:

Updated, thanks! Also removed `VPBlockBase::clone` and moved to static 
functions, as without remapping it is not really useful (also, generally full 
remapping isn't possible without mappings for defs outside the block/region)

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] [lldb] [flang] [libc] [lld] [llvm] [libcxx] [clang] [compiler-rt] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -2262,9 +2400,22 @@ class VPDerivedIVRecipe : public VPRecipeBase, public 
VPValue {
 VPValue(this), TruncResultTy(TruncResultTy), Kind(IndDesc.getKind()),
 FPBinOp(dyn_cast_or_null(IndDesc.getInductionBinOp())) 
{
   }
+  VPDerivedIVRecipe(InductionDescriptor::InductionKind Kind,
+const FPMathOperator *FPBinOp, VPValue *Start,
+VPCanonicalIVPHIRecipe *CanonicalIV, VPValue *Step,
+Type *TruncResultTy)
+  : VPRecipeBase(VPDef::VPDerivedIVSC, {Start, CanonicalIV, Step}),
+VPValue(this), TruncResultTy(TruncResultTy), Kind(Kind),
+FPBinOp(FPBinOp) {}
 
   ~VPDerivedIVRecipe() override = default;
 
+  VPRecipeBase *clone() override {
+return new VPDerivedIVRecipe(Kind, FPBinOp, getOperand(0),
+ cast(getOperand(1)),
+ getOperand(2), TruncResultTy);

fhahn wrote:

adjusted, 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] [flang] [libc] [libcxx] [lldb] [compiler-rt] [llvm] [clang] [lld] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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];

fhahn wrote:

adjusted, 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] [flang] [llvm] [compiler-rt] [clang] [clang-tools-extra] [libc] [lld] [lldb] [libcxx] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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;
+  }

fhahn wrote:

Renamed, 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] [libc] [llvm] [compiler-rt] [clang] [lld] [clang-tools-extra] [flang] [lldb] [libcxx] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -615,6 +615,18 @@ void VPBasicBlock::print(raw_ostream &O, const Twine 
&Indent,
 }
 #endif
 
+VPBlockBase *VPRegionBlock::clone() {
+  DenseMap Old2New;

fhahn wrote:

Renamed, 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] [lld] [clang-tools-extra] [compiler-rt] [llvm] [libc] [clang] [lldb] [flang] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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;

fhahn wrote:

Updated, 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] [lld] [llvm] [clang-tools-extra] [lldb] [libcxx] [flang] [clang] [libc] [compiler-rt] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -2807,6 +2976,8 @@ class VPlan {
   VPBasicBlock *getPreheader() { return Preheader; }
   const VPBasicBlock *getPreheader() const { return Preheader; }
 

fhahn wrote:

Done, 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] [lld] [llvm] [compiler-rt] [libc] [clang] [lldb] [clang-tools-extra] [libcxx] [flang] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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());

fhahn wrote:

Renamed, 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] [libc] [clang-tools-extra] [llvm] [lldb] [lld] [compiler-rt] [libcxx] [flang] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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)]);

fhahn wrote:

Documented stages and 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] [libc] [libcxx] [lld] [compiler-rt] [clang-tools-extra] [llvm] [clang] [lldb] [flang] [VPlan] Implement cloning of VPlans. (PR #73158)

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


@@ -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();

fhahn wrote:

Yes exactly!

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] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

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

https://github.com/bolshakov-a updated 
https://github.com/llvm/llvm-project/pull/78041

>From e2fa0ec1fbb77a521b92f2a17f45879ca01cd304 Mon Sep 17 00:00:00 2001
From: Andrey Ali Khan Bolshakov 
Date: Sun, 6 Aug 2023 19:38:23 +0300
Subject: [PATCH] [c++20] P1907R1: Support for generalized non-type template
 arguments of scalar type.

Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and
reverted because a dependency commit was reverted, then committed again
as 4b574008aef5a7235c1f894ab065fe300d26e786 and reverted again because
"dependency commit" 5a391d38ac6c561ba908334d427f26124ed9132e was
reverted. But it doesn't seem that 5a391d38ac6c was a real dependency
for this.

This commit incorporates 4b574008aef5a7235c1f894ab065fe300d26e786 and
18e093faf726d15f210ab4917142beec51848258 by Richard Smith, with some
minor fixes, most notably:

- `UncommonValue` renamed to `StructuralValue`

- `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and
member pointer handling branch
in `BuildExpressionFromNonTypeTemplateArgumentValue`;

- handling of `StructuralValue` in `IsTypeDeclaredInsideVisitor`;

- filling in `SugaredConverted` along with `CanonicalConverted`
parameter in `Sema::CheckTemplateArgument`;

- minor cleanup
in `TemplateInstantiator::transformNonTypeTemplateParmRef`;

- `TemplateArgument` constructors refactored;

- `ODRHash` calculation for `UncommonValue`;

- USR generation for `UncommonValue`;

- more correct MS compatibility mangling algorithm (tested on MSVC
ver. 19.35; toolset ver. 143);

- IR emitting fixed on using a subobject as a template argument when
the corresponding template parameter is used in an lvalue context;

- `noundef` attribute and opaque pointers in `template-arguments` test;

- analysis for C++17 mode is turned off for templates
in `warn-bool-conversion` test;
in C++17 and C++20 mode, array reference used as a template argument
of pointer type produces template argument of UncommonValue type, and
`BuildExpressionFromNonTypeTemplateArgumentValue` makes
`OpaqueValueExpr` for it, and `DiagnoseAlwaysNonNullPointer` cannot see
through it; despite of "These cases should not warn" comment, I'm not
sure about correct behavior; I'd expect a suggestion to replace `if` by
`if constexpr`;

- `temp.arg.nontype/p1.cpp` and `dr18xx.cpp` tests fixed.
---
 clang-tools-extra/clangd/DumpAST.cpp  |   1 +
 clang-tools-extra/clangd/FindTarget.cpp   |   1 +
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/include/clang/AST/ODRHash.h |   3 +
 clang/include/clang/AST/PropertiesBase.td |  14 ++
 clang/include/clang/AST/RecursiveASTVisitor.h |   2 +
 .../clang/AST/TemplateArgumentVisitor.h   |   2 +
 clang/include/clang/AST/TemplateBase.h|  86 ---
 .../clang/Basic/DiagnosticSemaKinds.td|   5 -
 clang/include/clang/Sema/Sema.h   |   4 +-
 clang/lib/AST/ASTContext.cpp  |   5 +
 clang/lib/AST/ASTImporter.cpp |  13 ++
 clang/lib/AST/ASTStructuralEquivalence.cpp|   3 +
 clang/lib/AST/Decl.cpp|   4 +
 clang/lib/AST/ItaniumMangle.cpp   |  36 ++-
 clang/lib/AST/MicrosoftMangle.cpp |  78 +--
 clang/lib/AST/ODRHash.cpp |  67 ++
 clang/lib/AST/StmtProfile.cpp |   6 +
 clang/lib/AST/TemplateBase.cpp| 113 -
 clang/lib/AST/TypeLoc.cpp |   1 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  10 +
 clang/lib/CodeGen/CGExpr.cpp  |  12 +-
 clang/lib/Index/USRGeneration.cpp |  10 +
 clang/lib/Sema/SemaLookup.cpp |   1 +
 clang/lib/Sema/SemaOverload.cpp   |  10 +-
 clang/lib/Sema/SemaTemplate.cpp   | 218 +++---
 clang/lib/Sema/SemaTemplateDeduction.cpp  |  64 +++--
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  14 +-
 clang/lib/Sema/SemaTemplateVariadic.cpp   |   2 +
 clang/lib/Sema/TreeTransform.h|  12 +-
 clang/lib/Serialization/ASTReader.cpp |   1 +
 clang/lib/Serialization/ASTWriter.cpp |   1 +
 clang/test/CXX/drs/dr18xx.cpp |   4 +-
 .../CXX/temp/temp.arg/temp.arg.nontype/p1.cpp |   4 +-
 clang/test/CodeGenCXX/mangle-ms-templates.cpp |  48 
 clang/test/CodeGenCXX/mangle-template.cpp |  40 +++-
 clang/test/CodeGenCXX/template-arguments.cpp  | 113 +
 .../Index/USR/structural-value-tpl-arg.cpp|  23 ++
 clang/test/Modules/odr_hash.cpp   | 193 +++-
 clang/test/SemaCXX/warn-bool-conversion.cpp   |   2 +
 .../SemaTemplate/temp_arg_nontype_cxx1z.cpp   |  40 ++--
 .../SemaTemplate/temp_arg_nontype_cxx20.cpp   |  40 ++--
 clang/tools/libclang/CIndex.cpp   |   5 +
 clang/tools/libclang/CXCursor.cpp |   3 +
 clang/www/cxx_status.html |  18 +-
 lldb/include/lldb/lldb-enumerations.h |   1 +
 .../TypeSystem/Clang/TypeSystemClang.cpp  

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

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

https://github.com/bolshakov-a updated 
https://github.com/llvm/llvm-project/pull/78041

>From 6cc472d5a1214e847b7f3a5dce28d6bed86121ed Mon Sep 17 00:00:00 2001
From: Bolshakov 
Date: Sun, 21 Jan 2024 16:19:51 +0300
Subject: [PATCH] [c++20] P1907R1: Support for generalized non-type template
 arguments of scalar type.

Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and
reverted because a dependency commit was reverted, then committed again
as 4b574008aef5a7235c1f894ab065fe300d26e786 and reverted again because
"dependency commit" 5a391d38ac6c561ba908334d427f26124ed9132e was
reverted. But it doesn't seem that 5a391d38ac6c was a real dependency
for this.

This commit incorporates 4b574008aef5a7235c1f894ab065fe300d26e786 and
18e093faf726d15f210ab4917142beec51848258 by Richard Smith, with some
minor fixes, most notably:

- `UncommonValue` renamed to `StructuralValue`

- `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and
member pointer handling branch
in `BuildExpressionFromNonTypeTemplateArgumentValue`;

- handling of `StructuralValue` in `IsTypeDeclaredInsideVisitor`;

- filling in `SugaredConverted` along with `CanonicalConverted`
parameter in `Sema::CheckTemplateArgument`;

- minor cleanup
in `TemplateInstantiator::transformNonTypeTemplateParmRef`;

- `TemplateArgument` constructors refactored;

- `ODRHash` calculation for `UncommonValue`;

- USR generation for `UncommonValue`;

- more correct MS compatibility mangling algorithm (tested on MSVC
ver. 19.35; toolset ver. 143);

- IR emitting fixed on using a subobject as a template argument when
the corresponding template parameter is used in an lvalue context;

- `noundef` attribute and opaque pointers in `template-arguments` test;

- analysis for C++17 mode is turned off for templates
in `warn-bool-conversion` test;
in C++17 and C++20 mode, array reference used as a template argument
of pointer type produces template argument of UncommonValue type, and
`BuildExpressionFromNonTypeTemplateArgumentValue` makes
`OpaqueValueExpr` for it, and `DiagnoseAlwaysNonNullPointer` cannot see
through it; despite of "These cases should not warn" comment, I'm not
sure about correct behavior; I'd expect a suggestion to replace `if` by
`if constexpr`;

- `temp.arg.nontype/p1.cpp` and `dr18xx.cpp` tests fixed.
---
 clang-tools-extra/clangd/DumpAST.cpp  |   1 +
 clang-tools-extra/clangd/FindTarget.cpp   |   1 +
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/include/clang/AST/ODRHash.h |   3 +
 clang/include/clang/AST/PropertiesBase.td |  14 ++
 clang/include/clang/AST/RecursiveASTVisitor.h |   2 +
 .../clang/AST/TemplateArgumentVisitor.h   |   2 +
 clang/include/clang/AST/TemplateBase.h|  86 ---
 .../clang/Basic/DiagnosticSemaKinds.td|   5 -
 clang/include/clang/Sema/Sema.h   |   4 +-
 clang/lib/AST/ASTContext.cpp  |   5 +
 clang/lib/AST/ASTImporter.cpp |  13 ++
 clang/lib/AST/ASTStructuralEquivalence.cpp|   3 +
 clang/lib/AST/Decl.cpp|   4 +
 clang/lib/AST/ItaniumMangle.cpp   |  36 ++-
 clang/lib/AST/MicrosoftMangle.cpp |  78 +--
 clang/lib/AST/ODRHash.cpp |  67 ++
 clang/lib/AST/StmtProfile.cpp |   6 +
 clang/lib/AST/TemplateBase.cpp| 113 -
 clang/lib/AST/TypeLoc.cpp |   1 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  10 +
 clang/lib/CodeGen/CGExpr.cpp  |  12 +-
 clang/lib/Index/USRGeneration.cpp |  10 +
 clang/lib/Sema/SemaLookup.cpp |   1 +
 clang/lib/Sema/SemaOverload.cpp   |  10 +-
 clang/lib/Sema/SemaTemplate.cpp   | 218 +++---
 clang/lib/Sema/SemaTemplateDeduction.cpp  |  64 +++--
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  14 +-
 clang/lib/Sema/SemaTemplateVariadic.cpp   |   2 +
 clang/lib/Sema/TreeTransform.h|  12 +-
 clang/lib/Serialization/ASTReader.cpp |   1 +
 clang/lib/Serialization/ASTWriter.cpp |   1 +
 clang/test/CXX/drs/dr18xx.cpp |   4 +-
 .../CXX/temp/temp.arg/temp.arg.nontype/p1.cpp |   4 +-
 clang/test/CodeGenCXX/mangle-ms-templates.cpp |  48 
 clang/test/CodeGenCXX/mangle-template.cpp |  40 +++-
 clang/test/CodeGenCXX/template-arguments.cpp  | 113 +
 .../Index/USR/structural-value-tpl-arg.cpp|  23 ++
 clang/test/Modules/odr_hash.cpp   | 193 +++-
 clang/test/SemaCXX/warn-bool-conversion.cpp   |   2 +
 .../SemaTemplate/temp_arg_nontype_cxx1z.cpp   |  40 ++--
 .../SemaTemplate/temp_arg_nontype_cxx20.cpp   |  40 ++--
 clang/tools/libclang/CIndex.cpp   |   5 +
 clang/tools/libclang/CXCursor.cpp |   3 +
 clang/www/cxx_status.html |  18 +-
 lldb/include/lldb/lldb-enumerations.h |   1 +
 .../TypeSystem/Clang/TypeSystemClang.cpp  |   3 +
 47

[Lldb-commits] [lldb] [polly] [libunwind] [libc] [llvm] [clang-tools-extra] [libcxx] [libcxxabi] [compiler-rt] [openmp] [lld] [flang] [mlir] [clang] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

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


[Lldb-commits] [openmp] [flang] [compiler-rt] [lld] [clang] [polly] [mlir] [libcxx] [clang-tools-extra] [libcxxabi] [lldb] [llvm] [libunwind] [libc] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

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

> I did some re-imagining of the tests, there is a some redundancy but it is 
> cleared that nothing was missed.  The tests are formatted in tabular form 
> manually to make them easier to read.

Redundant code in tests when if improves readability is not too bad. I really 
like how the new testing code looks. It was a lot easier to follow. Thanks a 
lot!

>  I also used the Clang 18's "Placeholder variables with no name" to make the 
> test a bit cleaner, so I disabled the unsupported compilers.
> If the above is unacceptable, it can be fixed easily. For now it makes it 
> easier to read and review.

IMO we should not disable tests for compilers, only for the reason to be able 
to use newer language features in the test. Note if the header requires 
language features I'm fine to disable that for a compiler. In this case we can 
easily allow clang-17 with a minor change as pointed out in the review.

The patch is getting close to be ready.



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


[Lldb-commits] [clang] [mlir] [libunwind] [llvm] [libcxx] [lldb] [openmp] [polly] [lld] [libc] [compiler-rt] [clang-tools-extra] [flang] [libcxxabi] [libc++][numeric] P0543R3: Saturation arithmetic (P

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


@@ -0,0 +1,172 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+// The test uses "Placeholder variables with no name"

mordante wrote:

I'm strongly against disabling tests without good reasons. Basically we don't 
know whether the code works with clang-17. Instead we should do this 
```
// TODO(LLVM-20) remove [[maybe_unused]]  since all supported compilers support 
"Placeholder variables with no name"
[[maybe_unused]] std::same_as decltype(auto) _ = std::add_sat(minVal, 
maxVal);
```
I tested this solution here https://godbolt.org/z/Y57obWo7s




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


[Lldb-commits] [flang] [clang-tools-extra] [compiler-rt] [libunwind] [openmp] [lldb] [llvm] [libc] [libcxx] [mlir] [clang] [polly] [libcxxabi] [lld] [libc++][numeric] P0543R3: Saturation arithmetic (P

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


@@ -0,0 +1,458 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+// The test uses "Placeholder variables with no name"
+// UNSUPPORTED: clang-17
+// XFAIL: apple-clang
+
+// 
+
+// template
+//   constexpr R saturate_cast(T x) noexcept; // 
freestanding
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// Smaller to larger
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Same type
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Larger to smaller
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+template 
+constexpr auto zero() {
+  return IntegerT{0};
+}
+
+constexpr bool test() {
+  // clang-format off
+
+#ifndef TEST_HAS_NO_INT128
+  using SIntT = __int128_t;
+  using UIntT = __uint128_t;
+#else
+  using SIntT = long long int;
+  using UIntT = unsigned long long int;
+#endif
+
+  // Constants: biggest numbers
+
+  constexpr auto big_sintMin  = std::numeric_limits::min();
+  constexpr auto big_sintZero =zero();
+  constexpr auto big_sintMax  = std::numeric_limits::max();
+
+  constexpr auto big_uintMin  = std::numeric_limits::min();
+  constexpr auto big_uintZero =zero();
+  constexpr auto big_uintMax  = std::numeric_limits::max();
+
+  // Constants: numeric limits
+
+  constexpr auto std_scharMin  = std::numeric_limits::min();
+  constexpr auto std_scharZero =zero();
+  constexpr auto std_scharMax  = std::numeric_limits::max();
+
+  constexpr auto std_ucharMin  = std::numeric_limits::min();
+  constexpr auto std_ucharZero =zero();
+  constexpr auto std_ucharMax  = std::numeric_limits::max();
+
+  constexpr auto std_ssintMin  = std::numeric_limits::min();
+  constexpr auto std_ssintZero =zero();
+  constexpr auto std_ssintMax  = std::numeric_limits::max();
+
+  constexpr auto std_usintMin  = std::numeric_limits::min();
+  constexpr auto std_usintZero =zero();
+  constexpr auto std_usintMax  = std::numeric_limits::max();
+
+  constexpr auto std_sintMin   = std::numeric_limits::min();
+  constexpr auto std_sintZero  =zero();
+  constexpr auto std_sintMax   = std::numeric_limits::max();
+
+  constexpr auto std_uintMin   = std::numeric_limits::min();
+  constexpr auto std_uintZero  =zero();
+  constexpr auto std_uintMax   = std::numeric_limits::max();
+
+  constexpr auto std_slMin = std::numeric_limits::min();
+  constexpr auto std_slZero=zero();
+  constexpr auto std_slMax = std::numeric_limits::max();
+
+  constexpr auto std_ulMin = std::numeric_limits::min();
+  constexpr auto std_ulZero=zero();
+  constexpr auto std_ulMax = std::numeric_limits::max();
+
+  constexpr auto std_sllMin= std::numeric_limits::min();
+  constexpr auto std_sllZero   =zero();
+  constexpr auto std_sllMax= std::numeric_limits::max();
+
+  constexpr auto std_ullMin= std::numeric_limits::min();
+  constexpr auto std_ullZero   =zero();
+  constexpr auto std_ullMax= std::numeric_limits::max();
+  
+  // signed char
+
+  assert(std::saturate_cast(std_scharMin)  == std_scharMin);
+  assert(std::saturate_cast(std_scharZero) == std_scharZero);
+  assert(std::saturate_cast(std_scharMax)  == std_scharMax);
+
+  assert(std::saturate_cast(std_ucharMin)  == std_scharZero);
+  assert(std::saturate_cast(std_ucharZero) == std_scharZero);
+  assert(std::saturate_cast(std_ucharMax)  == std_scharMax);
+
+  assert(std::saturate_cast(big_sintMin)   == std_scharMin);  // 
saturated
+  assert(std::saturate_cast(big_sintZero)  == std_scharZero);
+  assert(std::saturate_cast(big_sintMax)   == std_scharMax);  // 
saturated
+
+  assert(std::saturate_cast(big_uintMin)   == std_scharZero);
+  assert(std::saturate_cast(big_uintZero)  == std_scharZero);
+  assert(std::saturate_cast(big_uintMax)   == std_scharMax);  // 
saturated
+
+  // short
+
+  std::same_as decltype(auto) _ = std::sat

[Lldb-commits] [mlir] [openmp] [llvm] [clang] [libcxx] [libc] [lldb] [clang-tools-extra] [lld] [libunwind] [flang] [polly] [libcxxabi] [compiler-rt] [libc++][numeric] P0543R3: Saturation arithmetic (P

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


@@ -0,0 +1,172 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+// The test uses "Placeholder variables with no name"
+// UNSUPPORTED: clang-17
+// XFAIL: apple-clang
+
+// 
+
+// template
+// constexpr T add_sat(T x, T y) noexcept; // freestanding
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+template 
+constexpr bool test_signed() {
+  constexpr auto minVal = std::numeric_limits::min();
+  constexpr auto maxVal = std::numeric_limits::max();
+
+  std::same_as decltype(auto) _ = std::add_sat(minVal, maxVal);
+  static_assert(noexcept(std::add_sat(minVal, maxVal)));
+
+  // clang-format off
+
+  // Limit values (-1, 0, 1, min, max)

mordante wrote:

Thanks, this makes validating what the test does a lot easier.

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


[Lldb-commits] [flang] [polly] [clang] [lldb] [libcxx] [clang-tools-extra] [libcxxabi] [libc] [libunwind] [openmp] [lld] [llvm] [mlir] [compiler-rt] [libc++][numeric] P0543R3: Saturation arithmetic (P

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


@@ -0,0 +1,458 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+// The test uses "Placeholder variables with no name"
+// UNSUPPORTED: clang-17
+// XFAIL: apple-clang
+
+// 
+
+// template
+//   constexpr R saturate_cast(T x) noexcept; // 
freestanding
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// Smaller to larger
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Same type
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Larger to smaller
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+template 
+constexpr auto zero() {
+  return IntegerT{0};
+}
+
+constexpr bool test() {
+  // clang-format off
+
+#ifndef TEST_HAS_NO_INT128
+  using SIntT = __int128_t;
+  using UIntT = __uint128_t;
+#else
+  using SIntT = long long int;
+  using UIntT = unsigned long long int;
+#endif
+
+  // Constants: biggest numbers
+
+  constexpr auto big_sintMin  = std::numeric_limits::min();
+  constexpr auto big_sintZero =zero();
+  constexpr auto big_sintMax  = std::numeric_limits::max();

mordante wrote:

This feels a bit odd. The `climits` header has nice macros for these values 
https://en.cppreference.com/w/c/types/limits.

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


[Lldb-commits] [clang] [lldb] [mlir] [clang-tools-extra] [openmp] [lld] [libc] [libcxxabi] [flang] [libunwind] [polly] [compiler-rt] [llvm] [libcxx] [libc++][numeric] P0543R3: Saturation arithmetic (P

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


@@ -0,0 +1,458 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+// The test uses "Placeholder variables with no name"
+// UNSUPPORTED: clang-17
+// XFAIL: apple-clang
+
+// 
+
+// template
+//   constexpr R saturate_cast(T x) noexcept; // 
freestanding
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// Smaller to larger
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Same type
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Larger to smaller
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+template 
+constexpr auto zero() {
+  return IntegerT{0};
+}
+
+constexpr bool test() {
+  // clang-format off
+
+#ifndef TEST_HAS_NO_INT128
+  using SIntT = __int128_t;
+  using UIntT = __uint128_t;
+#else
+  using SIntT = long long int;
+  using UIntT = unsigned long long int;
+#endif
+
+  // Constants: biggest numbers
+
+  constexpr auto big_sintMin  = std::numeric_limits::min();
+  constexpr auto big_sintZero =zero();
+  constexpr auto big_sintMax  = std::numeric_limits::max();

H-G-Hristov wrote:

These are needed specifically as these values can vary but I used the C integer 
constants wherever applicable.

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


[Lldb-commits] [clang] [lldb] [mlir] [clang-tools-extra] [openmp] [lld] [libc] [libcxxabi] [flang] [libunwind] [polly] [compiler-rt] [llvm] [libcxx] [libc++][numeric] P0543R3: Saturation arithmetic (P

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


@@ -0,0 +1,458 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+// The test uses "Placeholder variables with no name"
+// UNSUPPORTED: clang-17
+// XFAIL: apple-clang
+
+// 
+
+// template
+//   constexpr R saturate_cast(T x) noexcept; // 
freestanding
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// Smaller to larger
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Same type
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Larger to smaller
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+template 
+constexpr auto zero() {
+  return IntegerT{0};
+}
+
+constexpr bool test() {
+  // clang-format off
+
+#ifndef TEST_HAS_NO_INT128
+  using SIntT = __int128_t;
+  using UIntT = __uint128_t;
+#else
+  using SIntT = long long int;
+  using UIntT = unsigned long long int;
+#endif
+
+  // Constants: biggest numbers
+
+  constexpr auto big_sintMin  = std::numeric_limits::min();
+  constexpr auto big_sintZero =zero();
+  constexpr auto big_sintMax  = std::numeric_limits::max();
+
+  constexpr auto big_uintMin  = std::numeric_limits::min();
+  constexpr auto big_uintZero =zero();
+  constexpr auto big_uintMax  = std::numeric_limits::max();
+
+  // Constants: numeric limits
+
+  constexpr auto std_scharMin  = std::numeric_limits::min();
+  constexpr auto std_scharZero =zero();
+  constexpr auto std_scharMax  = std::numeric_limits::max();
+
+  constexpr auto std_ucharMin  = std::numeric_limits::min();
+  constexpr auto std_ucharZero =zero();
+  constexpr auto std_ucharMax  = std::numeric_limits::max();
+
+  constexpr auto std_ssintMin  = std::numeric_limits::min();
+  constexpr auto std_ssintZero =zero();
+  constexpr auto std_ssintMax  = std::numeric_limits::max();
+
+  constexpr auto std_usintMin  = std::numeric_limits::min();
+  constexpr auto std_usintZero =zero();
+  constexpr auto std_usintMax  = std::numeric_limits::max();
+
+  constexpr auto std_sintMin   = std::numeric_limits::min();
+  constexpr auto std_sintZero  =zero();
+  constexpr auto std_sintMax   = std::numeric_limits::max();
+
+  constexpr auto std_uintMin   = std::numeric_limits::min();
+  constexpr auto std_uintZero  =zero();
+  constexpr auto std_uintMax   = std::numeric_limits::max();
+
+  constexpr auto std_slMin = std::numeric_limits::min();
+  constexpr auto std_slZero=zero();
+  constexpr auto std_slMax = std::numeric_limits::max();
+
+  constexpr auto std_ulMin = std::numeric_limits::min();
+  constexpr auto std_ulZero=zero();
+  constexpr auto std_ulMax = std::numeric_limits::max();
+
+  constexpr auto std_sllMin= std::numeric_limits::min();
+  constexpr auto std_sllZero   =zero();
+  constexpr auto std_sllMax= std::numeric_limits::max();
+
+  constexpr auto std_ullMin= std::numeric_limits::min();
+  constexpr auto std_ullZero   =zero();
+  constexpr auto std_ullMax= std::numeric_limits::max();
+  
+  // signed char
+
+  assert(std::saturate_cast(std_scharMin)  == std_scharMin);
+  assert(std::saturate_cast(std_scharZero) == std_scharZero);
+  assert(std::saturate_cast(std_scharMax)  == std_scharMax);
+
+  assert(std::saturate_cast(std_ucharMin)  == std_scharZero);
+  assert(std::saturate_cast(std_ucharZero) == std_scharZero);
+  assert(std::saturate_cast(std_ucharMax)  == std_scharMax);
+
+  assert(std::saturate_cast(big_sintMin)   == std_scharMin);  // 
saturated
+  assert(std::saturate_cast(big_sintZero)  == std_scharZero);
+  assert(std::saturate_cast(big_sintMax)   == std_scharMax);  // 
saturated
+
+  assert(std::saturate_cast(big_uintMin)   == std_scharZero);
+  assert(std::saturate_cast(big_uintZero)  == std_scharZero);
+  assert(std::saturate_cast(big_uintMax)   == std_scharMax);  // 
saturated
+
+  // short
+
+  std::same_as decltype(auto) _ = std::sat

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

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


@@ -6472,7 +6494,20 @@ void CXXNameMangler::mangleValueInTemplateArg(QualType 
T, const APValue &V,
   Out << "plcvPcad";
   Kind = Offset;
 } else {
-  if (!V.getLValuePath().empty() || V.isLValueOnePastTheEnd()) {
+  // Clang 11 and before mangled an array subject to array-to-pointer decay
+  // as if it were the declaration itself.
+  bool IsArrayToPointerDecayMangledAsDecl = false;
+  if (TopLevel && Ctx.getLangOpts().getClangABICompat() <=
+  LangOptions::ClangABI::Ver11) {
+QualType BType = B.getType();
+IsArrayToPointerDecayMangledAsDecl =
+BType->isArrayType() && V.getLValuePath().size() == 1 &&
+V.getLValuePath()[0].getAsArrayIndex() == 0 &&
+Ctx.hasSimilarType(T, Ctx.getDecayedType(BType));
+  }
+

AaronBallman wrote:

Thank you for the details!

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-21 Thread Aaron Ballman via lldb-commits

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

LGTM! Thank you for all the hard work on this!

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-21 Thread via lldb-commits

cor3ntin wrote:

Do you need me to merge that for you?

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] Add the ability to define a Python based command that uses CommandObjectParsed (PR #70734)

2024-01-21 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/70734

>From a0c72c07861218fa27420045aecdd5cd072cc60a Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Mon, 30 Oct 2023 14:48:37 -0700
Subject: [PATCH 1/2] Add the ability to define a Python based command that
 uses the CommandObjectParsed way to specify options and arguments so that
 these commands can be "first class citizens" with build-in commands.

---
 lldb/bindings/python/CMakeLists.txt   |   3 +-
 lldb/bindings/python/python-wrapper.swig  |  31 +
 lldb/examples/python/parsed_cmd.py| 315 
 lldb/include/lldb/Interpreter/CommandObject.h |   5 +-
 .../lldb/Interpreter/ScriptInterpreter.h  |  29 +
 .../source/Commands/CommandObjectCommands.cpp | 697 +-
 lldb/source/Commands/Options.td   |  22 +-
 lldb/source/Interpreter/CommandObject.cpp |  16 +
 .../Python/PythonDataObjects.h|   2 +
 .../Python/SWIGPythonBridge.h |   7 +
 .../Python/ScriptInterpreterPython.cpp| 252 ++-
 .../Python/ScriptInterpreterPythonImpl.h  |  21 +
 .../script/add/TestAddParsedCommand.py| 146 
 .../command/script/add/test_commands.py   | 175 +
 .../Python/PythonTestSuite.cpp|   8 +
 15 files changed, 1714 insertions(+), 15 deletions(-)
 create mode 100644 lldb/examples/python/parsed_cmd.py
 create mode 100644 
lldb/test/API/commands/command/script/add/TestAddParsedCommand.py
 create mode 100644 lldb/test/API/commands/command/script/add/test_commands.py

diff --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index c941f764dfc92a..657fdd2c959006 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -96,7 +96,8 @@ function(finish_swig_python swig_target 
lldb_python_bindings_dir lldb_python_tar
 ${lldb_python_target_dir}
 "utils"
 FILES "${LLDB_SOURCE_DIR}/examples/python/in_call_stack.py"
-  "${LLDB_SOURCE_DIR}/examples/python/symbolication.py")
+  "${LLDB_SOURCE_DIR}/examples/python/symbolication.py"
+  "${LLDB_SOURCE_DIR}/examples/python/parsed_cmd.py")
 
   create_python_package(
 ${swig_target}
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 17bc7b1f219870..47887491d0c552 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -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);
+
+  // FIXME:
+  // I wanted to do something like:
+  // size_t num_elem = args.size();
+  // PythonList my_list(num_elem);
+  // for (const char *elem : args)
+  //   my_list.append(PythonString(elem);
+  //
+  // and then pass my_list to the pfunc, but that crashes somewhere
+  // deep in Python for reasons that aren't clear to me.
+  
+  pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), 
SWIGBridge::ToSWIGWrapper(args_impl),
+SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj());
+
+  return true;
+}
+
 PythonObject lldb_private::python::SWIGBridge::LLDBSWIGPythonCreateOSPlugin(
 const char *python_class_name, const char *session_dictionary_name,
 const lldb::ProcessSP &process_sp) {
diff --git a/lldb/examples/python/parsed_cmd.py 
b/lldb/examples/python/parsed_cmd.py
new file mode 100644
index 00..7ee9e077d49ab5
--- /dev/null
+++ b/lldb/examples/python/parsed_cmd.py
@@ -0,0 +1,315 @@
+"""
+This module implements a couple of utility classes to make writing
+lldb parsed commands more Pythonic.
+The way to use it is to make a class for you command that inherits from 
ParsedCommandBase.
+That will make an LLDBOVParser which you will use for your
+option definition, and to fetch option values for the current invocation
+of your command.  Access to the OV parser is through:
+
+ParsedCommandBase.get_parser()
+
+Next, implement setup_command_definition in your new command class, and call:
+
+  self.get_parser().add_option
+
+to add all your options.  The order doesn't matter for options, lldb will sort 
them
+alphabetically for you when it prints help.
+
+Similarly you can define the arguments with:
+
+  self.get_parser.add_argument
+
+at present, lldb doesn't do as much work as it should verifying arguments, it 
pretty
+much only checks that commands that take no arguments don't get

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

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

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/78605

>From bf4fd0e1ce2236d94d15046c344d90c472368c98 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Thu, 18 Jan 2024 09:09:50 -0800
Subject: [PATCH 1/8] Added settings for cache location and timeout

---
 .../Debuginfod/SymbolLocatorDebuginfod.cpp| 82 +++
 .../SymbolLocatorDebuginfodProperties.td  |  8 +-
 llvm/include/llvm/Debuginfod/Debuginfod.h | 13 +++
 llvm/lib/Debuginfod/Debuginfod.cpp| 31 +--
 4 files changed, 108 insertions(+), 26 deletions(-)

diff --git 
a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp 
b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
index 111be6be365240..a20437c256eb43 100644
--- a/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
+++ b/lldb/source/Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
@@ -9,6 +9,7 @@
 #include "SymbolLocatorDebuginfod.h"
 
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/OptionValueString.h"
 #include "lldb/Utility/Args.h"
 
 #include "llvm/Debuginfod/Debuginfod.h"
@@ -54,6 +55,34 @@ class PluginProperties : public Properties {
 return urls;
   }
 
+  llvm::Expected GetCachePath() {
+OptionValueString *s =
+m_collection_sp->GetPropertyAtIndexAsOptionValueString(
+ePropertySymbolCachePath);
+// If we don't have a valid cache location, use the default one.
+if (!s || !s->GetCurrentValueAsRef().size()) {
+  llvm::Expected maybeCachePath =
+  llvm::getDefaultDebuginfodCacheDirectory();
+  if (!maybeCachePath) {
+return maybeCachePath;
+  }
+  m_cache_path = *maybeCachePath;
+  return llvm::StringRef(m_cache_path);
+}
+return s->GetCurrentValueAsRef();
+  }
+
+  std::chrono::milliseconds GetTimeout() const {
+std::optional seconds =
+m_collection_sp->GetPropertyAtIndexAs(ePropertyTimeout);
+if (seconds && *seconds != 0) {
+  return std::chrono::duration_cast(
+  std::chrono::seconds(*seconds));
+} else {
+  return llvm::getDefaultDebuginfodTimeout();
+}
+  }
+
 private:
   void ServerURLsChangedCallback() {
 m_server_urls = GetDebugInfoDURLs();
@@ -65,6 +94,7 @@ class PluginProperties : public Properties {
   }
   // Storage for the StringRef's used within the Debuginfod library.
   Args m_server_urls;
+  std::string m_cache_path;
 };
 
 } // namespace
@@ -112,31 +142,49 @@ SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() {
   return new SymbolLocatorDebuginfod();
 }
 
-static std::optional GetFileForModule(
-const ModuleSpec &module_spec,
-std::function(llvm::object::BuildIDRef)>
-PullFromServer) {
-  if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
-return {};
++ static std::optional +
+GetFileForModule(
+const ModuleSpec &module_spec,
+std::function UrlBuilder) {
   const UUID &module_uuid = module_spec.GetUUID();
-  if (module_uuid.IsValid() && llvm::canUseDebuginfod()) {
-llvm::object::BuildID build_id(module_uuid.GetBytes());
-llvm::Expected result = PullFromServer(build_id);
-if (result)
-  return FileSpec(*result);
-// An error here should be logged as a failure in the Debuginfod library,
-// so just consume it here
-consumeError(result.takeError());
-  }
+  // Don't bother if we don't have a valid UUID, Debuginfod isn't available,
+  // or if the 'symbols.enable-external-lookup' setting is false
+  if (!module_uuid.IsValid() || !llvm::canUseDebuginfod() ||
+  !ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup())
+return {};
+
+  // Grab the settings values we need
+  PluginProperties &plugin_props = GetGlobalPluginProperties();
+  llvm::Expected CacheDirectoryPathOrErr =
+  plugin_props.GetCachePath();
+  // A cache location is *required*
+  if (!CacheDirectoryPathOrErr)
+return {};
+  llvm::StringRef CacheDirectoryPath = *CacheDirectoryPathOrErr;
+  llvm::SmallVector DebuginfodUrls =
+  llvm::getDefaultDebuginfodUrls();
+  std::chrono::milliseconds Timeout = plugin_props.GetTimeout();
+
+  // We're ready to ask the Debuginfod library to find our file
+  llvm::object::BuildID build_id(module_uuid.GetBytes());
+  std::string UrlPath = UrlBuilder(build_id);
+  std::string CacheKey = llvm::getDebuginfodCacheKey(UrlPath);
+  llvm::Expected result = llvm::getCachedOrDownloadArtifact(
+  CacheKey, UrlPath, CacheDirectoryPath, DebuginfodUrls, Timeout);
+  if (result)
+return FileSpec(*result);
+  // An error here should be logged as a failure in the Debuginfod library,
+  // just consume it here
+  consumeError(result.takeError());
   return {};
 }
 
 std::optional SymbolLocatorDebuginfod::LocateExecutableObjectFile(
 const ModuleSpec &module_spec) {
-  return GetFileForModule(module_spec, llvm::getCachedOrDownloadExecutable);
+  return GetFileForModule

[Lldb-commits] [flang] [lld] [mlir] [libcxx] [libunwind] [lldb] [compiler-rt] [clang-tools-extra] [clang] [libcxxabi] [openmp] [llvm] [libc] [polly] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

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


[Lldb-commits] [clang-tools-extra] [lld] [libcxxabi] [llvm] [flang] [libc] [compiler-rt] [libunwind] [openmp] [lldb] [clang] [mlir] [polly] [libcxx] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

H-G-Hristov wrote:

There is a problem with the test. Working on it.

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


[Lldb-commits] [flang] [lld] [clang] [libunwind] [polly] [libc] [llvm] [compiler-rt] [lldb] [clang-tools-extra] [libcxx] [mlir] [libcxxabi] [openmp] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

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


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

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

bolshakov-a wrote:

> Do you need me to merge that for you?

Yes, please. I don't have commit access.

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] [libunwind] [llvm] [flang] [clang-tools-extra] [mlir] [lldb] [libcxxabi] [compiler-rt] [lld] [polly] [libcxx] [clang] [openmp] [libc] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

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


[Lldb-commits] [lldb] [polly] [clang-tools-extra] [libcxxabi] [libcxx] [mlir] [lld] [clang] [compiler-rt] [libc] [flang] [libunwind] [llvm] [openmp] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

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

LGTM modulo one typo.

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


[Lldb-commits] [lld] [openmp] [libcxxabi] [libunwind] [clang-tools-extra] [libc] [libcxx] [compiler-rt] [lldb] [llvm] [clang] [mlir] [polly] [flang] [libc++][numeric] P0543R3: Saturation arithmetic (P

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


@@ -0,0 +1,397 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// template
+//   constexpr R saturate_cast(T x) noexcept; // 
freestanding
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+#include 
+
+// Smaller to larger
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Same type
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Larger to smaller
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+static_assert(noexcept(std::saturate_cast(std::numeric_limits::max(;
+
+// Tests
+
+constexpr bool test() {
+  // clang-format off
+
+#ifndef TEST_HAS_NO_INT128
+  using SIntT = __int128_t;
+  using UIntT = __uint128_t;
+#else
+  using SIntT = long long int;
+  using UIntT = unsigned long long int;
+#endif
+
+  // Constants the values of which depend on the context (platform)
+
+  constexpr auto sBigMin = std::numeric_limits::min();
+  constexpr auto sZero   = SIntT{0};
+  constexpr auto sBigMax = std::numeric_limits::max();
+
+  constexpr auto uZero   = UIntT{0};
+  constexpr auto uBigMax = std::numeric_limits::max();
+
+  // Constants to avoid casting in place
+
+  constexpr auto O_C  = static_cast(0);
+  constexpr auto O_UC = static_cast(0);
+
+  constexpr auto O_S  = static_cast(0);
+  constexpr auto O_US = static_cast(0);
+
+  // signed char
+
+  // TODO(LLVM-20) remove [[maybe_unused]] and `{}` scope since all supported 
compilers support "Placeholder variables with no name",
+  // here and bellow...

mordante wrote:

```suggestion
  // here and below...
```

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


[Lldb-commits] [llvm] [clang-tools-extra] [mlir] [lldb] [compiler-rt] [lld] [clang] [flang] [libcxx] [clang-format] Add ShortReturnTypeColumn option. (PR #78011)

2024-01-21 Thread Björn Schäpers via lldb-commits

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


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


[Lldb-commits] [llvm] [clang-tools-extra] [mlir] [lldb] [compiler-rt] [lld] [clang] [flang] [libcxx] [clang-format] Add ShortReturnTypeColumn option. (PR #78011)

2024-01-21 Thread Björn Schäpers via lldb-commits

HazardyKnusperkeks wrote:

Just ping me in a few days, if there is no other reaction and we merge it.

https://github.com/llvm/llvm-project/pull/78011
___
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-21 Thread via lldb-commits

https://github.com/cor3ntin closed 
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] 5518a9d - [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (#78041)

2024-01-21 Thread via lldb-commits

Author: Andrey Ali Khan Bolshakov
Date: 2024-01-21T21:28:57+01:00
New Revision: 5518a9d7673bfe55b4110bea049140316d032fbf

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

LOG: [c++20] P1907R1: Support for generalized non-type template arguments of 
scalar type. (#78041)

Previously committed as 9e08e51a20d0d2b1c5724bb17e969d036fced4cd, and
reverted because a dependency commit was reverted, then committed again
as 4b574008aef5a7235c1f894ab065fe300d26e786 and reverted again because
"dependency commit" 5a391d38ac6c561ba908334d427f26124ed9132e was
reverted. But it doesn't seem that 5a391d38ac6c was a real dependency
for this.

This commit incorporates 4b574008aef5a7235c1f894ab065fe300d26e786 and
18e093faf726d15f210ab4917142beec51848258 by Richard Smith (@zygoloid),
with some minor fixes, most notably:

- `UncommonValue` renamed to `StructuralValue`

- `VK_PRValue` instead of `VK_RValue` as default kind in lvalue and
member pointer handling branch in
`BuildExpressionFromNonTypeTemplateArgumentValue`;

- handling of `StructuralValue` in `IsTypeDeclaredInsideVisitor`;

- filling in `SugaredConverted` along with `CanonicalConverted`
parameter in `Sema::CheckTemplateArgument`;

- minor cleanup in
`TemplateInstantiator::transformNonTypeTemplateParmRef`;

- `TemplateArgument` constructors refactored;

- `ODRHash` calculation for `UncommonValue`;

- USR generation for `UncommonValue`;

- more correct MS compatibility mangling algorithm (tested on MSVC ver.
19.35; toolset ver. 143);

- IR emitting fixed on using a subobject as a template argument when the
corresponding template parameter is used in an lvalue context;

- `noundef` attribute and opaque pointers in `template-arguments` test;

- analysis for C++17 mode is turned off for templates in
`warn-bool-conversion` test; in C++17 and C++20 mode, array reference
used as a template argument of pointer type produces template argument
of UncommonValue type, and
`BuildExpressionFromNonTypeTemplateArgumentValue` makes
`OpaqueValueExpr` for it, and `DiagnoseAlwaysNonNullPointer` cannot see
through it; despite of "These cases should not warn" comment, I'm not
sure about correct behavior; I'd expect a suggestion to replace `if` by
`if constexpr`;

- `temp.arg.nontype/p1.cpp` and `dr18xx.cpp` tests fixed.

Added: 
clang/test/CodeGenCXX/template-arguments.cpp
clang/test/Index/USR/structural-value-tpl-arg.cpp

Modified: 
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ODRHash.h
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/TemplateArgumentVisitor.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CXX/drs/dr18xx.cpp
clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
clang/test/CodeGenCXX/mangle-ms-templates.cpp
clang/test/CodeGenCXX/mangle-template.cpp
clang/test/Modules/odr_hash.cpp
clang/test/SemaCXX/warn-bool-conversion.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
clang/www/cxx_status.html
lldb/include/lldb/lldb-enumerations.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index b0cec65c39fa31..9a525efb938e8d 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -143,6 +143,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_ARGUMENT_KIND(Declaration);
   TEMPLATE_ARGUMENT_KIND(Template);
   TEMPLATE_ARGUMENT_KIND(TemplateExpansion);
+  TEMPLATE_ARGUMENT_KIND(StructuralValue);
 #undef TEMPLATE_ARGUMENT_KIND
 }
 llv

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

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

bolshakov-a wrote:

Thank you all, especially to @zygoloid for allowing me to steal its thunder!

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] [clang-tools-extra] [mlir] [libc] [libcxx] [llvm] [lldb] [MLGO] Remove absl dependency from scripts (PR #78880)

2024-01-21 Thread Aiden Grossman via lldb-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/78880

>From 80c9507d7f49ddbc5f2554f597950f797355c255 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sun, 21 Jan 2024 03:53:03 +
Subject: [PATCH 1/7] Add make_corpus script test

---
 .../tests/corpus/make_corpus_script.test  | 22 +++
 llvm/utils/mlgo-utils/tests/lit.cfg   |  7 +-
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 llvm/utils/mlgo-utils/tests/corpus/make_corpus_script.test

diff --git a/llvm/utils/mlgo-utils/tests/corpus/make_corpus_script.test 
b/llvm/utils/mlgo-utils/tests/corpus/make_corpus_script.test
new file mode 100644
index 000..f4f97544bce47d3
--- /dev/null
+++ b/llvm/utils/mlgo-utils/tests/corpus/make_corpus_script.test
@@ -0,0 +1,22 @@
+## Testing that the make_corpus script works as expected when invoked.
+
+# RUN: rm -rf %t.dir && mkdir %t.dir
+# RUN: touch %t.dir/test1.bc
+# RUN: touch %t.dir/test2.bc
+# RUN: rm -rf %t.out.dir && mkdir %t.out.dir
+
+# RUN: %python %scripts_dir/corpus/make_corpus.py --input_dir=%t.dir 
--output_dir=%t.out.dir --default_args="-test"
+
+# RUN: cat %t.out.dir/corpus_description.json | FileCheck %s
+
+## Check that we get the expected command in the global command override
+# CHECK: "-test"
+# CHECK: "has_thinlto": false
+## Check that the modules are in the corpus description
+# CHECK: "test1"
+# CHECK: "test2"
+
+# RUN: ls %t.out.dir | FileCheck %s --check-prefix CHECK-DIR
+
+# CHECK-DIR: test1.bc
+# CHECK-DIR: test2.bc
diff --git a/llvm/utils/mlgo-utils/tests/lit.cfg 
b/llvm/utils/mlgo-utils/tests/lit.cfg
index 055f0945942fc1c..9afced53f195c5f 100644
--- a/llvm/utils/mlgo-utils/tests/lit.cfg
+++ b/llvm/utils/mlgo-utils/tests/lit.cfg
@@ -1,3 +1,5 @@
+import os
+
 import lit.formats
 
 from lit.llvm import llvm_config
@@ -5,7 +7,7 @@ from lit.llvm import llvm_config
 config.name = "mlgo-utils"
 config.test_format = lit.formats.ShTest(execute_external=False)
 
-config.suffixes = [".py"]
+config.suffixes = [".py", ".test"]
 
 config.test_source_root = os.path.dirname(__file__)
 config.test_exec_root = config.obj_root
@@ -13,3 +15,6 @@ config.test_exec_root = config.obj_root
 config.environment["PYTHONPATH"] = os.path.join(config.src_root, "utils", 
"mlgo-utils")
 
 llvm_config.use_default_substitutions()
+
+scripts_dir = os.path.join(config.src_root, "utils/mlgo-utils/mlgo")
+config.substitutions.append(("%scripts_dir", scripts_dir))

>From d99f5d4cd2c7c6d9e70125e893dc2ae40c897d36 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sun, 21 Jan 2024 04:58:42 +
Subject: [PATCH 2/7] Add another test

---
 llvm/utils/mlgo-utils/CMakeLists.txt  |  2 +-
 .../combine_training_corpus_script.test   | 29 +++
 llvm/utils/mlgo-utils/tests/lit.cfg   |  1 +
 3 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 
llvm/utils/mlgo-utils/tests/corpus/combine_training_corpus_script.test

diff --git a/llvm/utils/mlgo-utils/CMakeLists.txt 
b/llvm/utils/mlgo-utils/CMakeLists.txt
index 7b303c7639401ae..c263c92c632797e 100644
--- a/llvm/utils/mlgo-utils/CMakeLists.txt
+++ b/llvm/utils/mlgo-utils/CMakeLists.txt
@@ -5,7 +5,7 @@ configure_lit_site_cfg(
 
 add_lit_testsuite(check-mlgo-utils "Running mlgo-utils tests"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS "FileCheck" "not" "count"
+  DEPENDS "FileCheck" "not" "count" "split-file"
 )
 
 set_target_properties(check-mlgo-utils PROPERTIES FOLDER "Tests")
diff --git 
a/llvm/utils/mlgo-utils/tests/corpus/combine_training_corpus_script.test 
b/llvm/utils/mlgo-utils/tests/corpus/combine_training_corpus_script.test
new file mode 100644
index 000..1aa182146a49ee4
--- /dev/null
+++ b/llvm/utils/mlgo-utils/tests/corpus/combine_training_corpus_script.test
@@ -0,0 +1,29 @@
+## Testing that the combine_trainig_corpus script works as expected when
+## invoked.
+
+# RUN: rm -rf %t.dir && mkdir %t.dir
+# RUN: split-file %s %t.dir
+# RUN: %python %scripts_dir/corpus/combine_training_corpus.py --root_dir=%t.dir
+# RUN: cat %t.dir/corpus_description.json | FileCheck %s
+
+## Check that we end up with the same properties as the original corpora
+# CHECK: "has_thinlto": false
+
+## Check that the modules end up in the combined corpus. Order does not matter.
+# CHECK-DAG: "subcorpus1/test1.o"
+# CHECK-DAG: "subcorpus2/test2.o"
+
+#--- subcorpus1/corpus_description.json
+{
+  "has_thinlto": false,
+  "modules": [
+"test1.o"
+  ]
+}
+#--- subcorpus2/corpus_description.json
+{
+  "has_thinlto": false,
+  "modules": [
+"test2.o"
+  ]
+}
diff --git a/llvm/utils/mlgo-utils/tests/lit.cfg 
b/llvm/utils/mlgo-utils/tests/lit.cfg
index 9afced53f195c5f..58c35e69c652c58 100644
--- a/llvm/utils/mlgo-utils/tests/lit.cfg
+++ b/llvm/utils/mlgo-utils/tests/lit.cfg
@@ -15,6 +15,7 @@ config.test_exec_root = config.obj_root
 config.environment["PYTHONPATH"] = os.path.join(config.src_root, "utils", 
"mlgo-utils")
 
 llvm_config.use_defaul

[Lldb-commits] [clang] [clang-tools-extra] [mlir] [libc] [libcxx] [llvm] [lldb] [MLGO] Remove absl dependency from scripts (PR #78880)

2024-01-21 Thread Aiden Grossman via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Skip ObjC timezone tests on macOS >= 14 (NFC) (PR #78817)

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

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


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


[Lldb-commits] [lldb] b7355ee - [lldb] Skip ObjC timezone tests on macOS >= 14 (NFC) (#78817)

2024-01-21 Thread via lldb-commits

Author: Dave Lee
Date: 2024-01-21T15:34:02-08:00
New Revision: b7355ee99ec63f44a6dc4f7dad9bb5a130bcc0eb

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

LOG: [lldb] Skip ObjC timezone tests on macOS >= 14 (NFC) (#78817)

Starting with macOS 14, the `NSTimeZone` and `CFTimeZone` types are backed by 
swift 
implementations. These tests won't pass on mainline lldb, since it doesn't have 
Swift 
support.

Added: 


Modified: 

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
index a1ffe84ad556f0e..c56b887a3f5088e 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py
@@ -19,6 +19,11 @@ def test_nsdate_with_run_command(self):
 """Test formatters for  NSDate."""
 self.appkit_tester_impl(self.nsdate_data_formatter_commands, False)
 
+@skipIf(macos_version=[">=", "14.0"])
+def test_timezone_with_run_command(self):
+"""Test formatters for NSTimeZone and CFTimeZone."""
+self.appkit_tester_impl(self.timezone_data_formatter_commands, False)
+
 def nsdate_data_formatter_commands(self):
 self.expect(
 "frame variable date1 date2",
@@ -51,16 +56,6 @@ def nsdate_data_formatter_commands(self):
 self.expect_expr("date_1970_plus_05", result_summary="1970-01-01 
00:00:00 UTC")
 self.expect_expr("date_1970_plus_04", result_summary="1970-01-01 
00:00:00 UTC")
 
-self.expect(
-"frame variable cupertino home europe",
-substrs=['"America/Los_Angeles"', '"Europe/Rome"', 
'"Europe/Paris"'],
-)
-
-self.expect(
-"frame variable cupertino_ns home_ns europe_ns",
-substrs=['"America/Los_Angeles"', '"Europe/Rome"', 
'"Europe/Paris"'],
-)
-
 self.expect(
 "frame variable mut_bv",
 substrs=[
@@ -71,3 +66,14 @@ def nsdate_data_formatter_commands(self):
 
 self.expect_expr("distant_past", result_summary="0001-01-01 00:00:00 
UTC")
 self.expect_expr("distant_future", result_summary="4001-01-01 00:00:00 
UTC")
+
+def timezone_data_formatter_commands(self):
+self.expect(
+"frame variable cupertino home europe",
+substrs=['"America/Los_Angeles"', '"Europe/Rome"', 
'"Europe/Paris"'],
+)
+
+self.expect(
+"frame variable cupertino_ns home_ns europe_ns",
+substrs=['"America/Los_Angeles"', '"Europe/Rome"', 
'"Europe/Paris"'],
+)



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


[Lldb-commits] [lldb] [lldb] Skip ObjC timezone tests on macOS >= 14 (NFC) (PR #78817)

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

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


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

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

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

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

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

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

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

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

petrhosek wrote:

The `llvm-libc++-static-clangcl.cfg.in :: 
std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp` is 
failing on Windows with the following error:
```
Exit Code: 1

Command Output (stdout):
--
# COMPILED WITH
C:/b/s/w/ir/x/w/llvm_build/./bin/clang-cl.exe 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.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/llvm-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\std\utilities\format\format.arguments\format.arg\Output\visit.return_type.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\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.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/llvm-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\std\utilities\format\format.arguments\format.arg\Output\visit.return_type.pass.cpp.dir\t.tmp.exe'
# .---command stderr
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:134:35:
 error: implicit conversion from 'long long' to 'const long' changes value from 
192812079084 to -461449236 [-Werror,-Wconstant-conversion]
# |   134 |   test(true, 192812079084L);
# |   |   ^
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:363:3:
 note: in instantiation of function template specialization 'test' 
requested here
# |   363 |   test();
# |   |   ^
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:135:36:
 error: implicit conversion from 'long long' to 'const long' changes value from 
192812079084 to -461449236 [-Werror,-Wconstant-conversion]
# |   135 |   test(false, 192812079084L);
# |   |    ^
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:40:12:
 error: implicit conversion from 'long long' to 'long' changes value from 
192812079084 to -461449236 [-Werror,-Wconstant-conversion]
# |40 | return 192812079084L;
# |   | ~~ ^
# | 
C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\test\std\utilities\format\format.arguments\format.arg\visit.return_type.pass.cpp:60:20:
 note: in instantiation of function template speciali

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

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

petrhosek wrote:

Please ignore 04c85587596ab10d885a957a00c8fa22740f15c1 which addresses a 
different issue, this is still broken in tip-of-tree.

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


[Lldb-commits] [libcxx] [lld] [flang] [compiler-rt] [mlir] [libc] [libunwind] [openmp] [polly] [llvm] [libcxxabi] [lldb] [clang] [clang-tools-extra] [libc++][numeric] P0543R3: Saturation arithmetic (P

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

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


[Lldb-commits] [clang] [flang] [lld] [clang-tools-extra] [llvm] [libcxx] [lldb] [mlir] [compiler-rt] [clang-format] Add ShortReturnTypeColumn option. (PR #78011)

2024-01-21 Thread Owen Pan via lldb-commits

owenca wrote:

> @mydeveloperday, do you have an opinion on this pull request? It addresses 
> #78010 with minimal changes, or are you interested in exploring other 
> possibilities?

It's weird to add such a top-level option to fix a bug and keep the current 
behavior. See 
https://github.com/llvm/llvm-project/issues/78010#issuecomment-1903300176.

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


[Lldb-commits] [clang-tools-extra] [libunwind] [libcxx] [llvm] [libc] [mlir] [compiler-rt] [lldb] [clang] [flang] [lld] [IRPGO][ValueProfile] Instrument virtual table address that could be used to do

2024-01-21 Thread Mingming Liu via lldb-commits

minglotus-6 wrote:

I created a 
[branch](https://github.com/minglotus-6/llvm-project/tree/type_profile) and 
submitted the end-to-end implementation there. Besides (a [squashed 
version](https://github.com/llvm/llvm-project/commit/de71eacf04a236031be6f1b53168f8f566244297)
 of) this pull request, the rest of the branch contains [thinlto import of 
vtables](https://github.com/llvm/llvm-project/commit/f6c1fc894717c6e7c2b591868b20e85aaa5b7b6a)
 and actual icp transformations ([commit 
1](https://github.com/llvm/llvm-project/commit/094c8a9aa5b5f2bc30d3db5e1332f0a81a3f0411)
 and 
[2](https://github.com/llvm/llvm-project/commit/84582fef567b1839ca73ab14735b6cbdc8adc073))

> we could first teach profile reader to understand new sections in a forward 
> compatible way without bumping the version and let it soak everywhere (e.g, 
> for a few weeks), and increase the version number as a second change. I'm 
> planning to make some progress on this aspect and might also discuss f2f.

(Overdue public update) Turns out it's not feasible to pursue backward 
compatibility with raw profiles, or forward compatibility with indexed profiles 
without breaking them at least once. For instance, currently, the indexed 
profile reader relies on the C++ struct 
[definition](https://github.com/llvm/llvm-project/blob/a31a60074717fc40887cfe132b77eec93bedd307/llvm/include/llvm/ProfileData/InstrProf.h#L1040-L1063)
 of Header (e.g., the layout of fields) [to know the byte size of the profile 
header](https://github.com/llvm/llvm-project/blob/a31a60074717fc40887cfe132b77eec93bedd307/llvm/lib/ProfileData/InstrProf.cpp#L1549-L1570).
 As a result, older compilers won't be able to tell the byte size of header C++ 
struct if any new field is added in the header C++ struct (i.e., recording byte 
size in Header breaks forward compat once). So the code changes in the branch 
above doesn't make any effort to have additional version compat other than 
what's guaranteed currently (i.e. none for raw profiles, and backward compat 
for indexed profiles).

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