[Lldb-commits] [lldb] [clang] [libcxx] [lld] [compiler-rt] [libc] [clang-tools-extra] [llvm] [flang] [Legalizer] Expand fmaximum and fminimum (PR #67301)

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


@@ -8262,6 +8262,64 @@ SDValue TargetLowering::expandFMINNUM_FMAXNUM(SDNode 
*Node,
   return SDValue();
 }
 
+SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
+SelectionDAG &DAG) const {
+  SDLoc DL(N);
+  SDValue LHS = N->getOperand(0);
+  SDValue RHS = N->getOperand(1);
+  unsigned Opc = N->getOpcode();
+  EVT VT = N->getValueType(0);
+  EVT CCVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
+  bool IsMax = Opc == ISD::FMAXIMUM;
+
+  if (VT.isVector() &&
+  isOperationLegalOrCustomOrPromote(Opc, VT.getScalarType()))
+return SDValue();
+
+  // First, implement comparison not propagating NaN. If no native fmin or fmax
+  // available, use plain select with setcc instead.
+  SDValue MinMax;
+  if (isOperationLegalOrCustom(IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE,
+   VT)) {
+MinMax = DAG.getNode(IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE, DL, VT,
+ LHS, RHS);
+  } else if (isOperationLegalOrCustom(IsMax ? ISD::FMAXNUM : ISD::FMINNUM,
+  VT)) {
+MinMax = DAG.getNode(IsMax ? ISD::FMAXNUM : ISD::FMINNUM, DL, VT, LHS, 
RHS);
+  } else {
+SDValue Compare =
+DAG.getSetCC(DL, CCVT, LHS, RHS, IsMax ? ISD::SETGT : ISD::SETLT);
+MinMax = DAG.getSelect(DL, VT, Compare, LHS, RHS);
+  }
+
+  // Propagate any NaN of both operands
+  if (!N->getFlags().hasNoNaNs() &&
+  (!DAG.isKnownNeverNaN(LHS) || !DAG.isKnownNeverNaN(RHS))) {
+ConstantFP *FPNaN = ConstantFP::get(
+*DAG.getContext(), APFloat::getNaN(DAG.EVTToAPFloatSemantics(VT)));
+MinMax = DAG.getSelect(DL, VT, DAG.getSetCC(DL, CCVT, LHS, RHS, 
ISD::SETUO),
+   DAG.getConstantFP(*FPNaN, DL, VT), MinMax);
+  }
+
+  // fminimum/fmaximum requires -0.0 less than +0.0
+  if (!N->getFlags().hasNoSignedZeros() && !DAG.isKnownNeverZeroFloat(LHS) &&
+  !DAG.isKnownNeverZeroFloat(RHS)) {
+SDValue IsZero = DAG.getSetCC(DL, CCVT, MinMax,
+  DAG.getConstantFP(0.0, DL, VT), ISD::SETEQ);
+SDValue TestZero =
+DAG.getTargetConstant(IsMax ? fcPosZero : fcNegZero, DL, MVT::i32);
+SDValue LCmp = DAG.getSelect(
+DL, VT, DAG.getNode(ISD::IS_FPCLASS, DL, CCVT, LHS, TestZero), LHS,
+MinMax);
+SDValue RCmp = DAG.getSelect(
+DL, VT, DAG.getNode(ISD::IS_FPCLASS, DL, CCVT, RHS, TestZero), RHS,
+LCmp);
+MinMax = DAG.getSelect(DL, VT, IsZero, RCmp, MinMax);

arsenm wrote:

I think we should try to avoid using is_fpclass here. Additionally, I think we 
have under-defined the internally used IEEE nodes. As currently defined, 
minnum_ieee/maxnum_ieee have unspecified signed 0 order. However for AMDGPU at 
least, the actual hardware instructions have always appropriately ordered 0s. 
We could either refine the _IEEE node definitions to be IEEE -2019 and require 
ordered 0 behavior which doesn't require this fixup. 

https://github.com/llvm/llvm-project/pull/67301
___
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] [clang] [libcxx] [libc] [lldb] [compiler-rt] [flang] [lld] [Legalizer] Expand fmaximum and fminimum (PR #67301)

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


@@ -8310,6 +8310,64 @@ SDValue TargetLowering::expandFMINNUM_FMAXNUM(SDNode 
*Node,
   return SDValue();
 }
 
+SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
+SelectionDAG &DAG) const {
+  SDLoc DL(N);
+  SDValue LHS = N->getOperand(0);
+  SDValue RHS = N->getOperand(1);
+  unsigned Opc = N->getOpcode();
+  EVT VT = N->getValueType(0);
+  EVT CCVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
+  bool IsMax = Opc == ISD::FMAXIMUM;
+
+  if (VT.isVector() &&
+  isOperationLegalOrCustomOrPromote(Opc, VT.getScalarType()))
+return SDValue();
+
+  // First, implement comparison not propagating NaN. If no native fmin or fmax
+  // available, use plain select with setcc instead.
+  SDValue MinMax;
+  unsigned CompOpcIeee = IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE;
+  unsigned CompOpc = IsMax ? ISD::FMAXNUM : ISD::FMINNUM;
+  if (isOperationLegalOrCustom(CompOpcIeee, VT)) {
+MinMax = DAG.getNode(CompOpcIeee, DL, VT, LHS, RHS);
+  } else if (isOperationLegalOrCustom(CompOpc, VT)) {
+MinMax = DAG.getNode(CompOpc, DL, VT, LHS, RHS);
+  } else {
+// NaN (if exists) will be propagated later, so orderness doesn't matter.
+SDValue Compare =
+DAG.getSetCC(DL, CCVT, LHS, RHS, IsMax ? ISD::SETGT : ISD::SETLT);
+MinMax = DAG.getSelect(DL, VT, Compare, LHS, RHS);
+  }
+
+  // Propagate any NaN of both operands
+  if (!N->getFlags().hasNoNaNs() &&
+  (!DAG.isKnownNeverNaN(LHS) || !DAG.isKnownNeverNaN(RHS))) {
+ConstantFP *FPNaN = ConstantFP::get(
+*DAG.getContext(), APFloat::getNaN(DAG.EVTToAPFloatSemantics(VT)));
+MinMax = DAG.getSelect(DL, VT, DAG.getSetCC(DL, CCVT, LHS, RHS, 
ISD::SETUO),
+   DAG.getConstantFP(*FPNaN, DL, VT), MinMax);
+  }
+
+  // fminimum/fmaximum requires -0.0 less than +0.0
+  if (!N->getFlags().hasNoSignedZeros() && !DAG.isKnownNeverZeroFloat(LHS) &&
+  !DAG.isKnownNeverZeroFloat(RHS)) {

arsenm wrote:

Ditto, check RHS first 

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


[Lldb-commits] [libcxx] [llvm] [clang-tools-extra] [flang] [lld] [compiler-rt] [lldb] [libc] [clang] [Legalizer] Expand fmaximum and fminimum (PR #67301)

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


@@ -8310,6 +8310,64 @@ SDValue TargetLowering::expandFMINNUM_FMAXNUM(SDNode 
*Node,
   return SDValue();
 }
 
+SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
+SelectionDAG &DAG) const {
+  SDLoc DL(N);
+  SDValue LHS = N->getOperand(0);
+  SDValue RHS = N->getOperand(1);
+  unsigned Opc = N->getOpcode();
+  EVT VT = N->getValueType(0);
+  EVT CCVT = getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT);
+  bool IsMax = Opc == ISD::FMAXIMUM;
+
+  if (VT.isVector() &&
+  isOperationLegalOrCustomOrPromote(Opc, VT.getScalarType()))
+return SDValue();
+
+  // First, implement comparison not propagating NaN. If no native fmin or fmax
+  // available, use plain select with setcc instead.
+  SDValue MinMax;
+  unsigned CompOpcIeee = IsMax ? ISD::FMAXNUM_IEEE : ISD::FMINNUM_IEEE;
+  unsigned CompOpc = IsMax ? ISD::FMAXNUM : ISD::FMINNUM;
+  if (isOperationLegalOrCustom(CompOpcIeee, VT)) {
+MinMax = DAG.getNode(CompOpcIeee, DL, VT, LHS, RHS);
+  } else if (isOperationLegalOrCustom(CompOpc, VT)) {
+MinMax = DAG.getNode(CompOpc, DL, VT, LHS, RHS);
+  } else {
+// NaN (if exists) will be propagated later, so orderness doesn't matter.
+SDValue Compare =
+DAG.getSetCC(DL, CCVT, LHS, RHS, IsMax ? ISD::SETGT : ISD::SETLT);
+MinMax = DAG.getSelect(DL, VT, Compare, LHS, RHS);
+  }
+
+  // Propagate any NaN of both operands
+  if (!N->getFlags().hasNoNaNs() &&
+  (!DAG.isKnownNeverNaN(LHS) || !DAG.isKnownNeverNaN(RHS))) {

arsenm wrote:

Should invert the order of these checks. RHS is canonically simpler / cheaper 
to inspect 

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


[Lldb-commits] [lldb] [compiler-rt] [clang-tools-extra] [libcxxabi] [flang] [libc] [lld] [llvm] [libcxx] [clang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

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


@@ -71,6 +71,18 @@ enum Fixups {
   // Used to generate an R_RISCV_ALIGN relocation, which indicates the linker
   // should fixup the alignment after linker relaxation.
   fixup_riscv_align,
+  // 20-bit fixup corresponding to %tlsdesc_hi(foo) for instructions like
+  // auipc
+  fixup_riscv_tlsdesc_hi20,

MaskRay wrote:

I wonder whether we can just use `MCFixupKind(FirstLiteralRelocationKind + 
ELF::R_RISCV_TLSDESC_CALL)`

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


[Lldb-commits] [libc] [libcxxabi] [lldb] [compiler-rt] [clang-tools-extra] [clang] [llvm] [flang] [lld] [libcxx] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

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

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


[Lldb-commits] [lldb] [compiler-rt] [clang-tools-extra] [libcxxabi] [flang] [libc] [lld] [llvm] [libcxx] [clang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

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


@@ -188,3 +188,8 @@ addi a2, ft0, 24 # CHECK: :[[@LINE]]:10: error: invalid 
operand for instruction
 
 # fence.tso accepts no operands
 fence.tso rw, rw # CHECK: :[[@LINE]]:11: error: invalid operand for instruction
+
+.Ltlsdesc_hi0:
+jalr   x5, 0(a1), %tlsdesc_hi(.Ltlsdesc_hi0) # CHECK: :[[@LINE]]:17: error: 
operand must be a symbol with %tlsdesc_call modifier
+jalr   x1, 0(a1), %tlsdesc_call(.Ltlsdesc_hi0) # CHECK: :[[@LINE]]:12: error: 
the output operand must be t0/x5 when using %tlsdesc_call modifier

MaskRay wrote:

I think it's clearer to place these negative tests in a test named `tlsdesc*.s`

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


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

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

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


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

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


@@ -959,8 +959,12 @@ void CodeGenPGO::emitCounterIncrement(CGBuilderTy 
&Builder, const Stmt *S,
 
   unsigned Counter = (*RegionCounterMap)[S];
 
-  llvm::Value *Args[] = {FuncNameVar,
- Builder.getInt64(FunctionHash),
+  // Make sure that pointer to global is passed in with zero addrspace
+  // This is relevant during GPU profiling
+  auto *NormalizedPtr = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+  FuncNameVar, llvm::PointerType::getUnqual(CGM.getLLVMContext()));

arsenm wrote:

Avoid using getUnqual. I'm sure there's a proper address space to query 
somewhere here 

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


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

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


@@ -448,8 +456,12 @@ GlobalVariable *createPGOFuncNameVar(Module &M,
   new GlobalVariable(M, Value->getType(), true, Linkage, Value,
  getPGOFuncNameVarName(PGOFuncName, Linkage));
 
+  // If the target is a GPU, make the symbol protected so it can
+  // be read from the host device
+  if (isGPUProfTarget(M))
+FuncNameVar->setVisibility(GlobalValue::ProtectedVisibility);
   // Hide the symbol so that we correctly get a copy for each executable.
-  if (!GlobalValue::isLocalLinkage(FuncNameVar->getLinkage()))
+  else if (!GlobalValue::isLocalLinkage(FuncNameVar->getLinkage()))
 FuncNameVar->setVisibility(GlobalValue::HiddenVisibility);

arsenm wrote:

Can you spot this into some kind of function-to-visibility to use function? 
This doesn't feel like the right way to control it, so might as well cleanly 
separate it out 

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


[Lldb-commits] [flang] [libcxxabi] [lldb] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc] [llvm] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

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

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


[Lldb-commits] [flang] [libcxxabi] [lldb] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc] [llvm] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

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


@@ -71,6 +71,18 @@ enum Fixups {
   // Used to generate an R_RISCV_ALIGN relocation, which indicates the linker
   // should fixup the alignment after linker relaxation.
   fixup_riscv_align,
+  // 20-bit fixup corresponding to %tlsdesc_hi(foo) for instructions like
+  // auipc
+  fixup_riscv_tlsdesc_hi20,

MaskRay wrote:

> instructions like auipc

It seems that tlsdesc is auipc-style only, instead of lui-style. You can say 
that this is for auipc.

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


[Lldb-commits] [lldb] [compiler-rt] [clang-tools-extra] [libcxxabi] [flang] [libc] [lld] [llvm] [libcxx] [clang] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

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

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


[Lldb-commits] [polly] [lldb] [compiler-rt] [clang-tools-extra] [libcxxabi] [flang] [libc] [openmp] [llvm] [mlir] [libcxx] [clang] [OpenMP] Patch for Support to loop bind clause : Checking Parent Regi

2024-01-08 Thread Sandeep Kosuri via lldb-commits

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


[Lldb-commits] [lld] [lldb] [llvm] [polly] [libcxxabi] [openmp] [libcxx] [libc] [mlir] [flang] [compiler-rt] [libunwind] [clang] [clang-tools-extra] Make clang report invalid target versions. (PR #753

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK closed 
https://github.com/llvm/llvm-project/pull/75373
___
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] [libcxx] [lld] [compiler-rt] [lldb] [clang] [llvm] [libc] [openmp] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)

2024-01-08 Thread Joseph Huber via lldb-commits


@@ -58,6 +60,22 @@ class GlobalTy {
   void setPtr(void *P) { Ptr = P; }
 };
 
+typedef void *IntPtrT;
+struct __llvm_profile_data {
+#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) Type Name;
+#include "llvm/ProfileData/InstrProfData.inc"
+};
+
+/// PGO profiling data extracted from a GPU device
+struct GPUProfGlobals {
+  std::string names;
+  std::vector> counts;
+  std::vector<__llvm_profile_data> data;
+  Triple targetTriple;
+

jhuber6 wrote:

That's confusing, how would using a `std::vector` not have that problem as 
well? I'll need to look into that.

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


[Lldb-commits] [clang-tools-extra] [libc] [libcxxabi] [mlir] [lldb] [libcxx] [llvm] [flang] [lld] [compiler-rt] [clang] [Mips] Fix unable to handle inline assembly ends with compat-branch o… (PR #7729

2024-01-08 Thread via lldb-commits

https://github.com/yingopq updated 
https://github.com/llvm/llvm-project/pull/77291

>From 7689da7ccdfc9ce255339d8ee1e2ab3d41c9f3ee Mon Sep 17 00:00:00 2001
From: Ying Huang 
Date: Mon, 8 Jan 2024 17:50:15 +0800
Subject: [PATCH] [Mips] Fix unable to handle inline assembly ends with
 compat-branch on MIPS

Modify:
Add a global variable 'CurForbiddenSlotAttr' to save current
instruction`s forbidden slot and whether set reorder.
This is the judgment condition for whether to add nop.
We would add a couple of '.set noreorder' and '.set reorder' to wrap
the current instruction and the next instruction.
Then we can get previous instruction`s forbidden slot attribute and
whether set reorder by 'CurForbiddenSlotAttr'.
If previous instruction has forbidden slot and .set reorder is active
and current instruction is CTI. Then emit a NOP after it.

Fix https://github.com/llvm/llvm-project/issues/61045.

Because https://reviews.llvm.org/D158589 was 'Needs Review' state, not
ending, so we commit pull request again.
---
 lld/test/ELF/mips-pc-relocs.s | 18 +++--
 .../Target/Mips/AsmParser/MipsAsmParser.cpp   | 79 ++-
 .../CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll | 46 +++
 llvm/test/MC/Mips/forbidden-slot.s| 16 
 llvm/test/MC/Mips/mips32r6/relocations.s  | 22 +++---
 llvm/test/MC/Mips/mips64r6/relocations.s  | 26 +++---
 llvm/test/MC/Mips/relocation.s|  4 +-
 7 files changed, 176 insertions(+), 35 deletions(-)
 create mode 100644 llvm/test/CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll
 create mode 100644 llvm/test/MC/Mips/forbidden-slot.s

diff --git a/lld/test/ELF/mips-pc-relocs.s b/lld/test/ELF/mips-pc-relocs.s
index 5e7dbed94ca7c4..7d23f9d7469a48 100644
--- a/lld/test/ELF/mips-pc-relocs.s
+++ b/lld/test/ELF/mips-pc-relocs.s
@@ -40,11 +40,13 @@ __start:
 # ^-- (0x20020-0x2)>>2
 # CHECK-NEXT:20004:   beqc$5, $6, 0x20020
 # ^-- (0x20020-4-0x20004)>>2
-# CHECK-NEXT:20008:   beqzc   $9, 0x20020
-# ^-- (0x20020-4-0x20008)>>2
-# CHECK-NEXT:2000c:   bc  0x20020
-# ^-- (0x20020-4-0x2000c)>>2
-# CHECK-NEXT:20010:   aluipc  $2, 0
-# ^-- %hi(0x20020-0x20010)
-# CHECK-NEXT:20014:   addiu   $2, $2, 12
-# ^-- %lo(0x20020-0x20014)
+# CHECK-NEXT:20008:   nop
+# CHECK-NEXT:2000c:   beqzc   $9, 0x20020
+# ^-- (0x20020-4-0x2000c)>>2
+# CHECK-NEXT:20010:   nop
+# CHECK-NEXT:20014:   bc  0x20020
+# ^-- (0x20020-4-0x200014)>>2
+# CHECK-NEXT:20018:   aluipc  $2, 0
+# ^-- %hi(0x20020-0x20018)
+# CHECK-NEXT:2001c:   addiu   $2, $2, 4
+# ^-- %lo(0x20020-0x2001c)
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp 
b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 3c673ae938fdec..9725c6f9f6183a 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -150,6 +150,7 @@ class MipsAsmParser : public MCTargetAsmParser {
   bool IsLittleEndian;
   bool IsPicEnabled;
   bool IsCpRestoreSet;
+  bool CurForbiddenSlotAttr;
   int CpRestoreOffset;
   unsigned GPReg;
   unsigned CpSaveLocation;
@@ -552,6 +553,7 @@ class MipsAsmParser : public MCTargetAsmParser {
 
 CurrentFn = nullptr;
 
+CurForbiddenSlotAttr = false;
 IsPicEnabled = getContext().getObjectFileInfo()->isPositionIndependent();
 
 IsCpRestoreSet = false;
@@ -723,6 +725,16 @@ class MipsAsmParser : public MCTargetAsmParser {
 return getSTI().hasFeature(Mips::FeatureGINV);
   }
 
+  bool hasForbiddenSlot(const MCInstrDesc &MCID) const {
+return !inMicroMipsMode() && (MCID.TSFlags & MipsII::HasForbiddenSlot);
+  }
+
+  bool SafeInForbiddenSlot(const MCInstrDesc &MCID) const {
+return !(MCID.TSFlags & MipsII::IsCTI);
+  }
+
+  void onEndOfFile() override;
+
   /// Warn if RegIndex is the same as the current AT.
   void warnIfRegIndexIsAT(unsigned RegIndex, SMLoc Loc);
 
@@ -2307,7 +2319,42 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, 
SMLoc IDLoc,
 
   bool FillDelaySlot =
   MCID.hasDelaySlot() && AssemblerOptions.back()->isReorder();
-  if (FillDelaySlot)
+
+  // Get previous instruction`s forbidden slot attribute and
+  // whether set reorder.
+  // This 'CurForbiddenSlotAttr' is a global variable.
+  bool PrevForbiddenSlotAttr = CurForbiddenSlotAttr;
+
+  // Flag represents we set reorder after nop.
+  bool SetReorderAfterNop = false;
+
+  // If previous instruction has forbidden slot and .set reorder
+  // is active and current instruction is CTI.
+  // Then emit a NOP after it.
+  if (PrevForbiddenSl

[Lldb-commits] [compiler-rt] [libcxx] [mlir] [openmp] [lldb] [lld] [clang-tools-extra] [llvm] [clang] [flang] [clang] Add `intrin0.h` header to mimic `intrin0.h` used by MSVC STL for clang-cl (PR #757

2024-01-08 Thread Max Winkler via lldb-commits

MaxEW707 wrote:

> I would like some measurements so we can compare build times on Windows.

I took some benchmarks with `-ftime-trace` on the parse times with and without 
this change.
Pretty much all the big hitters, string/vector/map/algorithm, includes 
`` which includes `` which includes ``.
The test file used looked as follows to simulate some common stl includes.
```
#include 
#include 
#include 
```

clang-cl 16 frontend took ~190ms to parse those 3 headers. `intrin.h` took 
~32ms to parse.

clang-cl built with this PR frontend took ~1368ms to parse. `intrin.h` took 
~969ms to parse. Most of that time is from `` as expected. 
`intrin0.h` took ~2ms to parse.

It is known that `immintrin.h` and `x86intrin.h` being the everything header 
definitely makes it an **expensive** include.
I don't need to compile any project to know that include time difference will 
be felt by any code that uses STL.

MSVC STL ships with each compiler upgrade. VS has a separate dir for each 
installed msvc, `VC\Tools\MSVC\14.38.33130` for MSVC 1938, and each installed 
compiler has a specific version of msvc stl shipped with it under, 
`VC\Tools\MSVC\[version]\include`.
Only one version of clang-cl is shipped with VS at a time and it will always 
point to the latest `VCToolsDir` via the clang driver unless clang is passed an 
explicit dir on the command line by the user.
For example VS2022 17.7 upgraded from clang-cl 15 to clang-cl 16. From that 
point on-wards only clang-cl 16 exists on disk in your VS install.
That seems to correspond to what was said here, 
https://github.com/microsoft/STL/pull/4282#discussion_r1441191186, every 
shipped version of MSVC STL supports only the latest compilers provided by VS.

We have some options. I am fine with whatever the consensus is as long as I can 
move this over the finish line.
1. Users who upgrade clang-cl before MSVC STL officially supports the new 
version of clang-cl will suffer slower builds.
I would classify this as an unsupported config since once VS ships with 
support for the new clang-cl, intentionally building against an older 
`VCToolsDir` will also incur the include overhead. Up to you guys if view this 
as an unsupported config.
2. Add a config define that users can define to enable the old behaviour in the 
interim. Once MSVC STL supports the new version of clang-cl we can remove this 
config define in the next release.
3.  Release clang with `intrin0.h`. Get a change into MSVC STL. Wait for MSVC 
STL release. Release another clang with `intrin.h` changes. I am not well 
versed on what changes clang allows in patch or minor releases but this feels 
like it would have a long lag time before clang-cl can become usable for us.

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


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

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/66963

>From 647f5fe641b30c874bab770fced9fcec9b601161 Mon Sep 17 00:00:00 2001
From: Zijun Zhao 
Date: Wed, 13 Sep 2023 14:26:01 -0700
Subject: [PATCH 1/9] [libc++] Implement ranges::contains_subrange

---
 libcxx/include/CMakeLists.txt |   1 +
 .../__algorithm/ranges_contains_subrange.h| 145 +
 libcxx/include/algorithm  |  14 +
 ...obust_against_copying_projections.pass.cpp |   2 +
 .../ranges.contains_subrange.pass.cpp | 293 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 456 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 0fe3ab44d2466e..dd3ff541fbc7ba 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -110,6 +110,7 @@ set(files
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
   __algorithm/ranges_contains.h
+  __algorithm/ranges_contains_subrange.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h 
b/libcxx/include/__algorithm/ranges_contains_subrange.h
new file mode 100644
index 00..16de6c29cb2a1a
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains_subrange.h
@@ -0,0 +1,145 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+
+#include <__algorithm/ranges_starts_with.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains_subrange {
+struct __fn {
+  template  _Sent1,
+input_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred,
+class _Proj1,
+class _Proj2,
+class _Offset>
+  static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred& __pred,
+  _Proj1& __proj1,
+  _Proj2& __proj2,
+  _Offset __offset) {
+if (__offset < 0)
+  return false;
+else {
+  for (; __offset >= 0; __offset--, __first1++) {
+auto result = ranges::starts_with(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+std::ref(__pred),
+std::ref(__proj1),
+std::ref(__proj2));
+if (result)
+  return true;
+  }
+  return false;
+}
+  }
+
+  template  _Sent1,
+input_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred  = ranges::equal_to,
+class _Proj1 = identity,
+class _Proj2 = identity>
+requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred __pred   = {},
+  _Proj1 __proj1 = {},
+  _Proj2 __proj2 = {}) const {
+auto __n1 = ranges::distance(__first1, __last1);
+auto __n2 = ranges::distance(__first2, __last2);
+auto __offset = __n1 - __n2;
+
+return __contains_subrange_fn_impl(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+__pred,
+__proj1,
+__proj2,
+std::move(__offset));
+  }
+
+  template 
+requires indirectly_comparable, iterator_t<_Range2>, 
_Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 
__proj1 = {}, _Proj2 __proj2 = {}) const {
+auto __n1 = 0;
+auto __n2 = 0;
+
+if conste

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

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/66963

>From 647f5fe641b30c874bab770fced9fcec9b601161 Mon Sep 17 00:00:00 2001
From: Zijun Zhao 
Date: Wed, 13 Sep 2023 14:26:01 -0700
Subject: [PATCH 1/8] [libc++] Implement ranges::contains_subrange

---
 libcxx/include/CMakeLists.txt |   1 +
 .../__algorithm/ranges_contains_subrange.h| 145 +
 libcxx/include/algorithm  |  14 +
 ...obust_against_copying_projections.pass.cpp |   2 +
 .../ranges.contains_subrange.pass.cpp | 293 ++
 .../niebloid.compile.pass.cpp |   1 +
 6 files changed, 456 insertions(+)
 create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h
 create mode 100644 
libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 0fe3ab44d2466e..dd3ff541fbc7ba 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -110,6 +110,7 @@ set(files
   __algorithm/ranges_binary_search.h
   __algorithm/ranges_clamp.h
   __algorithm/ranges_contains.h
+  __algorithm/ranges_contains_subrange.h
   __algorithm/ranges_copy.h
   __algorithm/ranges_copy_backward.h
   __algorithm/ranges_copy_if.h
diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h 
b/libcxx/include/__algorithm/ranges_contains_subrange.h
new file mode 100644
index 00..16de6c29cb2a1a
--- /dev/null
+++ b/libcxx/include/__algorithm/ranges_contains_subrange.h
@@ -0,0 +1,145 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
+
+#include <__algorithm/ranges_starts_with.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __contains_subrange {
+struct __fn {
+  template  _Sent1,
+input_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred,
+class _Proj1,
+class _Proj2,
+class _Offset>
+  static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred& __pred,
+  _Proj1& __proj1,
+  _Proj2& __proj2,
+  _Offset __offset) {
+if (__offset < 0)
+  return false;
+else {
+  for (; __offset >= 0; __offset--, __first1++) {
+auto result = ranges::starts_with(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+std::ref(__pred),
+std::ref(__proj1),
+std::ref(__proj2));
+if (result)
+  return true;
+  }
+  return false;
+}
+  }
+
+  template  _Sent1,
+input_iterator _Iter2,
+sentinel_for<_Iter2> _Sent2,
+class _Pred  = ranges::equal_to,
+class _Proj1 = identity,
+class _Proj2 = identity>
+requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Iter1 __first1,
+  _Sent1 __last1,
+  _Iter2 __first2,
+  _Sent2 __last2,
+  _Pred __pred   = {},
+  _Proj1 __proj1 = {},
+  _Proj2 __proj2 = {}) const {
+auto __n1 = ranges::distance(__first1, __last1);
+auto __n2 = ranges::distance(__first2, __last2);
+auto __offset = __n1 - __n2;
+
+return __contains_subrange_fn_impl(
+std::move(__first1),
+std::move(__last1),
+std::move(__first2),
+std::move(__last2),
+__pred,
+__proj1,
+__proj2,
+std::move(__offset));
+  }
+
+  template 
+requires indirectly_comparable, iterator_t<_Range2>, 
_Pred, _Proj1, _Proj2>
+  _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+  _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 
__proj1 = {}, _Proj2 __proj2 = {}) const {
+auto __n1 = 0;
+auto __n2 = 0;
+
+if conste

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

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


@@ -58,6 +60,22 @@ class GlobalTy {
   void setPtr(void *P) { Ptr = P; }
 };
 
+typedef void *IntPtrT;
+struct __llvm_profile_data {
+#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) Type Name;
+#include "llvm/ProfileData/InstrProfData.inc"
+};
+
+/// PGO profiling data extracted from a GPU device
+struct GPUProfGlobals {
+  std::string names;
+  std::vector> counts;
+  std::vector<__llvm_profile_data> data;
+  Triple targetTriple;
+

EthanLuisMcDonough wrote:

I can't seem to use `SmallVector` for `__llvm_profile_data` because many of its 
defined fields are const qualified and it needs an assignment operator 
definition. I'm able to use `std::remove_const`, but that feels kind of hack-y. 
Not sure if the best solution is to use `std::vector`, `std::remove_const`, or 
remove the const qualifiers in 
[InstrProfData.inc](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ProfileData/InstrProfData.inc).

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


[Lldb-commits] [flang] [libcxxabi] [llvm] [clang-tools-extra] [clang] [lld] [libcxx] [polly] [lldb] [compiler-rt] [libunwind] [mlir] [libc] [openmp] Make clang report invalid target versions. (PR #753

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/75373

>From 74f256d8a77ee2ba8e0d5bbb6519aa2729cf94d5 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 01/16] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 llvm/lib/TargetParser/Triple.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index c5e9ad43d22588..335253194d1cf8 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/ARMTargetParser.h"
@@ -1199,7 +1200,11 @@ StringRef Triple::getOSAndEnvironmentName() const {
 
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
-  Version.tryParse(Name);
+  if (Version.tryParse(Name)) {
+errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
+"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+exit(1);
+  }
   return Version.withoutBuild();
 }
 

>From 0d159b2a9b76e233e020ac0aef15b49b03f4d86c Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:23:54 +
Subject: [PATCH 02/16] rephrase

---
 llvm/lib/TargetParser/Triple.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 335253194d1cf8..713ca447403d50 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1201,8 +1201,7 @@ StringRef Triple::getOSAndEnvironmentName() const {
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
   if (Version.tryParse(Name)) {
-errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
-"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+errs() << "version "<< Name << " is invalid\n";
 exit(1);
   }
   return Version.withoutBuild();

>From b2dda9ce95804783c59aa1ca4e81a7941aae805d Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 03/16] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 clang/lib/Basic/Targets/OSTargets.h | 5 +
 llvm/include/llvm/TargetParser/Triple.h | 4 
 llvm/lib/TargetParser/Triple.cpp| 8 
 3 files changed, 17 insertions(+)

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..bc28066019971c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -323,6 +323,11 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
 // This historical but ambiguous name for the minSdkVersion macro. Keep
 // defined for compatibility.
 Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  } else {
+llvm::errs() << "version "<< Triple.getVersionName() <<
+" in triple " << Triple.getArchName() << "-" << Triple.getVendorName()
+<< "-" << Triple.getOSAndEnvironmentName() << " is invalid\n";
+exit(1);
   }
 } else {
 Builder.defineMacro("__gnu_linux__");
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index 47904621c0967f..05df1c489ad06e 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -434,6 +434,10 @@ class Triple {
   /// string (separated by a '-' if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// Get the version component of the environment component as a single
+  /// string (the version after the environment).
+  StringRef getVersionName() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 49bc24ffbfae6c..db4ba7100781bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1199,6 +1199,14 @@ StringRef Triple::getOSAndEnvironmentName() const {
   return Tmp.split('-').second;  // Strip second component
 }
 
+StringRef Triple::getVersionName() const {
+  StringRef VersionName = getEnvironmentName();
+  StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
+  if (VersionName.startswith(EnvironmentTypeName))
+return VersionName.substr(EnvironmentTypeName.size());
+  return VersionName;
+}
+
 static 

[Lldb-commits] [polly] [libunwind] [flang] [compiler-rt] [clang] [libc] [mlir] [libcxx] [libcxxabi] [openmp] [lld] [llvm] [lldb] [clang-tools-extra] Make clang report invalid target versions. (PR #753

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/75373

>From 74f256d8a77ee2ba8e0d5bbb6519aa2729cf94d5 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 01/15] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 llvm/lib/TargetParser/Triple.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index c5e9ad43d22588..335253194d1cf8 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/ARMTargetParser.h"
@@ -1199,7 +1200,11 @@ StringRef Triple::getOSAndEnvironmentName() const {
 
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
-  Version.tryParse(Name);
+  if (Version.tryParse(Name)) {
+errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
+"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+exit(1);
+  }
   return Version.withoutBuild();
 }
 

>From 0d159b2a9b76e233e020ac0aef15b49b03f4d86c Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:23:54 +
Subject: [PATCH 02/15] rephrase

---
 llvm/lib/TargetParser/Triple.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 335253194d1cf8..713ca447403d50 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1201,8 +1201,7 @@ StringRef Triple::getOSAndEnvironmentName() const {
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
   if (Version.tryParse(Name)) {
-errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
-"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+errs() << "version "<< Name << " is invalid\n";
 exit(1);
   }
   return Version.withoutBuild();

>From b2dda9ce95804783c59aa1ca4e81a7941aae805d Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 03/15] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 clang/lib/Basic/Targets/OSTargets.h | 5 +
 llvm/include/llvm/TargetParser/Triple.h | 4 
 llvm/lib/TargetParser/Triple.cpp| 8 
 3 files changed, 17 insertions(+)

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..bc28066019971c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -323,6 +323,11 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
 // This historical but ambiguous name for the minSdkVersion macro. Keep
 // defined for compatibility.
 Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  } else {
+llvm::errs() << "version "<< Triple.getVersionName() <<
+" in triple " << Triple.getArchName() << "-" << Triple.getVendorName()
+<< "-" << Triple.getOSAndEnvironmentName() << " is invalid\n";
+exit(1);
   }
 } else {
 Builder.defineMacro("__gnu_linux__");
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index 47904621c0967f..05df1c489ad06e 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -434,6 +434,10 @@ class Triple {
   /// string (separated by a '-' if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// Get the version component of the environment component as a single
+  /// string (the version after the environment).
+  StringRef getVersionName() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 49bc24ffbfae6c..db4ba7100781bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1199,6 +1199,14 @@ StringRef Triple::getOSAndEnvironmentName() const {
   return Tmp.split('-').second;  // Strip second component
 }
 
+StringRef Triple::getVersionName() const {
+  StringRef VersionName = getEnvironmentName();
+  StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
+  if (VersionName.startswith(EnvironmentTypeName))
+return VersionName.substr(EnvironmentTypeName.size());
+  return VersionName;
+}
+
 static 

[Lldb-commits] [lldb] [lldb][[DWARFDeclContext] Add function to extract qualified names as vector (PR #77349)

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


@@ -68,6 +68,11 @@ class DWARFDeclContext {
 
   const char *GetQualifiedName() const;
 
+  /// Returns a vector of string, one string per entry in the fully qualified
+  /// name. For example, for the DeclContext `A::B::C`, this methods returns
+  /// `{"C", "B", "A"}`
+  llvm::SmallVector GetQualifiedNameAsVector() const;

felipepiovezan wrote:

I'm not sure what the relationship between a CompilerContext and a 
DWARFDeclContext (which is what we have here) is. Let me try to figure out if 
there is some way to connect the two

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


[Lldb-commits] [compiler-rt] [libcxx] [mlir] [clang] [clang-tools-extra] [lld] [libcxxabi] [lldb] [libc] [openmp] [llvm] [msan] Unwind stack before fatal reports (PR #77168)

2024-01-08 Thread Vitaly Buka via lldb-commits

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


[Lldb-commits] [compiler-rt] [libcxx] [mlir] [clang] [clang-tools-extra] [lld] [libcxxabi] [lldb] [libc] [openmp] [llvm] [msan] Unwind stack before fatal reports (PR #77168)

2024-01-08 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/77168

>From a127373cf1ac1676ce17ce8dca909d0c3bce9d18 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Mon, 8 Jan 2024 11:45:37 -0800
Subject: [PATCH 1/2] [NFC][msan] Switch allocator interface to use
 BufferedStackTrace

We will need it to unwind for fatal errors.

Pull Request: https://github.com/llvm/llvm-project/pull/77363
---
 compiler-rt/lib/msan/msan.h | 23 ++--
 compiler-rt/lib/msan/msan_allocator.cpp | 29 +
 2 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h
index 25fa2212bdadd3..753e6b260734f9 100644
--- a/compiler-rt/lib/msan/msan.h
+++ b/compiler-rt/lib/msan/msan.h
@@ -255,18 +255,19 @@ char *GetProcSelfMaps();
 void InitializeInterceptors();
 
 void MsanAllocatorInit();
-void MsanDeallocate(StackTrace *stack, void *ptr);
-
-void *msan_malloc(uptr size, StackTrace *stack);
-void *msan_calloc(uptr nmemb, uptr size, StackTrace *stack);
-void *msan_realloc(void *ptr, uptr size, StackTrace *stack);
-void *msan_reallocarray(void *ptr, uptr nmemb, uptr size, StackTrace *stack);
-void *msan_valloc(uptr size, StackTrace *stack);
-void *msan_pvalloc(uptr size, StackTrace *stack);
-void *msan_aligned_alloc(uptr alignment, uptr size, StackTrace *stack);
-void *msan_memalign(uptr alignment, uptr size, StackTrace *stack);
+void MsanDeallocate(BufferedStackTrace *stack, void *ptr);
+
+void *msan_malloc(uptr size, BufferedStackTrace *stack);
+void *msan_calloc(uptr nmemb, uptr size, BufferedStackTrace *stack);
+void *msan_realloc(void *ptr, uptr size, BufferedStackTrace *stack);
+void *msan_reallocarray(void *ptr, uptr nmemb, uptr size,
+BufferedStackTrace *stack);
+void *msan_valloc(uptr size, BufferedStackTrace *stack);
+void *msan_pvalloc(uptr size, BufferedStackTrace *stack);
+void *msan_aligned_alloc(uptr alignment, uptr size, BufferedStackTrace *stack);
+void *msan_memalign(uptr alignment, uptr size, BufferedStackTrace *stack);
 int msan_posix_memalign(void **memptr, uptr alignment, uptr size,
-StackTrace *stack);
+BufferedStackTrace *stack);
 
 void InstallTrapHandler();
 void InstallAtExitHandler();
diff --git a/compiler-rt/lib/msan/msan_allocator.cpp 
b/compiler-rt/lib/msan/msan_allocator.cpp
index 72a7f980d39fb0..987c894c79d45e 100644
--- a/compiler-rt/lib/msan/msan_allocator.cpp
+++ b/compiler-rt/lib/msan/msan_allocator.cpp
@@ -178,7 +178,7 @@ void MsanThreadLocalMallocStorage::CommitBack() {
   allocator.DestroyCache(GetAllocatorCache(this));
 }
 
-static void *MsanAllocate(StackTrace *stack, uptr size, uptr alignment,
+static void *MsanAllocate(BufferedStackTrace *stack, uptr size, uptr alignment,
   bool zeroise) {
   if (size > max_malloc_size) {
 if (AllocatorMayReturnNull()) {
@@ -229,7 +229,7 @@ static void *MsanAllocate(StackTrace *stack, uptr size, 
uptr alignment,
   return allocated;
 }
 
-void MsanDeallocate(StackTrace *stack, void *p) {
+void MsanDeallocate(BufferedStackTrace *stack, void *p) {
   CHECK(p);
   UnpoisonParam(1);
   RunFreeHooks(p);
@@ -259,8 +259,8 @@ void MsanDeallocate(StackTrace *stack, void *p) {
   }
 }
 
-static void *MsanReallocate(StackTrace *stack, void *old_p, uptr new_size,
-uptr alignment) {
+static void *MsanReallocate(BufferedStackTrace *stack, void *old_p,
+uptr new_size, uptr alignment) {
   Metadata *meta = reinterpret_cast(allocator.GetMetaData(old_p));
   uptr old_size = meta->requested_size;
   uptr actually_allocated_size = allocator.GetActuallyAllocatedSize(old_p);
@@ -284,7 +284,7 @@ static void *MsanReallocate(StackTrace *stack, void *old_p, 
uptr new_size,
   return new_p;
 }
 
-static void *MsanCalloc(StackTrace *stack, uptr nmemb, uptr size) {
+static void *MsanCalloc(BufferedStackTrace *stack, uptr nmemb, uptr size) {
   if (UNLIKELY(CheckForCallocOverflow(size, nmemb))) {
 if (AllocatorMayReturnNull())
   return nullptr;
@@ -320,15 +320,15 @@ static uptr AllocationSizeFast(const void *p) {
   return reinterpret_cast(allocator.GetMetaData(p))->requested_size;
 }
 
-void *msan_malloc(uptr size, StackTrace *stack) {
+void *msan_malloc(uptr size, BufferedStackTrace *stack) {
   return SetErrnoOnNull(MsanAllocate(stack, size, sizeof(u64), false));
 }
 
-void *msan_calloc(uptr nmemb, uptr size, StackTrace *stack) {
+void *msan_calloc(uptr nmemb, uptr size, BufferedStackTrace *stack) {
   return SetErrnoOnNull(MsanCalloc(stack, nmemb, size));
 }
 
-void *msan_realloc(void *ptr, uptr size, StackTrace *stack) {
+void *msan_realloc(void *ptr, uptr size, BufferedStackTrace *stack) {
   if (!ptr)
 return SetErrnoOnNull(MsanAllocate(stack, size, sizeof(u64), false));
   if (size == 0) {
@@ -338,7 +338,8 @@ void *msan_realloc(void *ptr, uptr size, StackTrace *stack) 
{
   return SetErrno

[Lldb-commits] [lldb] [libunwind] [libcxx] [compiler-rt] [lld] [llvm] [clang-tools-extra] [libc] [clang] [flang] [libc++][test] try to directly create socket file in /tmp when filepath is too long (PR

2024-01-08 Thread Wu Yingcong via lldb-commits

yingcong-wu wrote:

Great, thank you. I don't have commit access, could you please help land this 
patch for me?

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


[Lldb-commits] [lldb] [lldb][[DWARFDeclContext] Add function to extract qualified names as vector (PR #77349)

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

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


[Lldb-commits] [lldb] [lldb][[DWARFDeclContext] Add function to extract qualified names as vector (PR #77349)

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


@@ -68,6 +68,11 @@ class DWARFDeclContext {
 
   const char *GetQualifiedName() const;
 
+  /// Returns a vector of string, one string per entry in the fully qualified
+  /// name. For example, for the DeclContext `A::B::C`, this methods returns
+  /// `{"C", "B", "A"}`
+  llvm::SmallVector GetQualifiedNameAsVector() const;

adrian-prantl wrote:

Would it make sense to use CompilerContext (which is a vector of 
`pair`) instead?

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


[Lldb-commits] [lldb] [lldb][[DWARFDeclContext] Add function to extract qualified names as vector (PR #77349)

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


@@ -55,6 +55,12 @@ const char *DWARFDeclContext::GetQualifiedName() const {
   return m_qualified_name.c_str();
 }
 
+llvm::SmallVector
+DWARFDeclContext::GetQualifiedNameAsVector() const {
+  return llvm::to_vector_of(
+  llvm::map_range(m_entries, GetName));

adrian-prantl wrote:

TIL!

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


[Lldb-commits] [lldb] [lldb][[DWARFDeclContext] Add function to extract qualified names as vector (PR #77349)

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

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


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


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

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

adrian-prantl wrote:

I'll probably need some help from someone with a windows machine to debug this. 
Your hunch about path separators sounds plausible.

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


[Lldb-commits] [lld] [libcxxabi] [openmp] [flang] [clang-tools-extra] [mlir] [libc] [libcxx] [llvm] [clang] [lldb] [libunwind] [polly] [compiler-rt] Make clang report invalid target versions. (PR #753

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


@@ -786,4 +786,7 @@ def warn_android_unversioned_fallback : Warning<
   " directories will not be used in Clang 19. Provide a versioned directory"
   " for the target version or lower instead.">,
   InGroup>;
+
+def err_android_version_invalid : Error<
+  "Version %0 in triple %1 is invalid.">;

MaskRay wrote:

Perhaps `version '%0' in target triple '%1' is invalid`

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


[Lldb-commits] [lld] [libcxxabi] [flang] [clang-tools-extra] [libc] [libcxx] [lldb] [llvm] [clang] [compiler-rt] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

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


@@ -0,0 +1,44 @@
+# RUN: llvm-mc -filetype=obj -triple riscv32 < %s --defsym RV32=1  | 
llvm-objdump -d -M no-aliases - | FileCheck %s --check-prefixes=INST,RV32
+# RUN: llvm-mc -filetype=obj -triple riscv64 < %s | llvm-objdump -d -M 
no-aliases - | FileCheck %s --check-prefixes=INST,RV64
+
+# RUN: not llvm-mc -triple riscv32 < %s --defsym RV32=1 --defsym ERR=1 2>&1 | 
FileCheck %s --check-prefixes=ERR
+# RUN: not llvm-mc -triple riscv64 < %s --defsym ERR=1 2>&1 | FileCheck %s 
--check-prefixes=ERR
+
+start:  # @start
+# %bb.0:# %entry
+.Ltlsdesc_hi0:
+   auipc a0, %tlsdesc_hi(a-4)
+   # INST: auipc a0, 0x0
+   auipc   a0, %tlsdesc_hi(unspecified)
+   # INST: auipc a0, 0x0
+.ifdef RV32
+   lw  a1, %tlsdesc_load_lo(.Ltlsdesc_hi0)(a0)
+   # RV32: lw a1, 0x0(a0)
+.else
+   ld  a1, %tlsdesc_load_lo(.Ltlsdesc_hi0)(a0)
+   #RV64: ld a1, 0x0(a0)
+.endif
+   addia0, a0, %tlsdesc_add_lo(.Ltlsdesc_hi0)
+   # INST: addi a0, a0, 0x0
+   jalrt0, 0(a1), %tlsdesc_call(.Ltlsdesc_hi0)
+   # INST: jalr t0, 0x0(a1)
+   add a0, a0, tp
+   # INST: add a0, a0, tp
+   ret
+
+## Check invalid usage
+.ifdef ERR
+   auipc x1, %tlsdesc_call(foo) # ERR: :[[@LINE]]:12: error: operand must 
be a symbol with a 
%pcrel_hi/%got_pcrel_hi/%tls_ie_pcrel_hi/%tls_gd_pcrel_hi/%tlsdesc_hi modifier 
or an integer in the range

MaskRay wrote:

Note: `[[@LINE]]` is deprecated. Use `[[#@LINE]]`

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


[Lldb-commits] [lld] [libcxxabi] [flang] [clang-tools-extra] [libc] [libcxx] [lldb] [llvm] [clang] [compiler-rt] [RISCV] Support Global Dynamic TLSDESC in the RISC-V backend (PR #66915)

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


@@ -3,8 +3,8 @@
 
 # Out of range immediates
 ## simm12
-flh ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol 
with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
-fsh ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with 
%lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
+flh ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol 
with %lo/%pcrel_lo/%tprel_lo/%tlsdesc_load_lo modifier or an integer in the 
range [-2048, 2047]

MaskRay wrote:

`%tlsdesc_load_lo` only makes sense for `ld`. Changing the diagnostic will 
require updates to lots of files and is misleading to a lot of instructions. 
Perhaps the initial patch can drop this message update.

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


[Lldb-commits] [lld] [libcxxabi] [flang] [clang-tools-extra] [libc] [libcxx] [lldb] [llvm] [clang] [compiler-rt] [RISC-V][LLD] Add Support for RISC-V TLSDESC Relocations (PR #66916)

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

MaskRay wrote:

The base branch can be edited if you click "Edit" near the title, which will 
help reveal the lld side changes...

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


[Lldb-commits] [mlir] [polly] [clang] [libunwind] [flang] [lld] [lldb] [compiler-rt] [clang-tools-extra] [libcxxabi] [libcxx] [openmp] [libc] [llvm] Make clang report invalid target versions. (PR #753

2024-01-08 Thread Jessica Clarke via lldb-commits


@@ -786,4 +786,7 @@ def warn_android_unversioned_fallback : Warning<
   " directories will not be used in Clang 19. Provide a versioned directory"
   " for the target version or lower instead.">,
   InGroup>;
+
+def err_android_version_invalid : Error<
+  "Version %0 in triple %1 is invalid.">;

jrtc27 wrote:

* Elsewhere we say "target triple"
* Repeating the version seems a bit ugly?

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


[Lldb-commits] [mlir] [polly] [clang] [libunwind] [flang] [lld] [lldb] [compiler-rt] [clang-tools-extra] [libcxxabi] [libcxx] [openmp] [libc] [llvm] Make clang report invalid target versions. (PR #753

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

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


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


[Lldb-commits] [lld] [libcxxabi] [openmp] [flang] [clang-tools-extra] [mlir] [libc] [libcxx] [llvm] [clang] [lldb] [libunwind] [polly] [compiler-rt] Make clang report invalid target versions. (PR #753

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

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


[Lldb-commits] [lld] [libcxxabi] [openmp] [flang] [clang-tools-extra] [mlir] [libc] [libcxx] [llvm] [clang] [lldb] [libunwind] [polly] [compiler-rt] Make clang report invalid target versions. (PR #753

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


@@ -786,4 +786,7 @@ def warn_android_unversioned_fallback : Warning<
   " directories will not be used in Clang 19. Provide a versioned directory"
   " for the target version or lower instead.">,
   InGroup>;
+
+def err_android_version_invalid : Error<

MaskRay wrote:

You can name it `err_triple_version_invalid` in case other OSes want to do the 
same checking.

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


[Lldb-commits] [lld] [libcxxabi] [openmp] [flang] [clang-tools-extra] [mlir] [libc] [libcxx] [llvm] [clang] [lldb] [libunwind] [polly] [compiler-rt] Make clang report invalid target versions. (PR #753

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


@@ -786,4 +786,7 @@ def warn_android_unversioned_fallback : Warning<
   " directories will not be used in Clang 19. Provide a versioned directory"
   " for the target version or lower instead.">,
   InGroup>;
+
+def err_android_version_invalid : Error<
+  "Version %0 in triple %1 is invalid.">;

MaskRay wrote:

No capitalization and drop the full stop to be consistent with other 
messages/convention.

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


[Lldb-commits] [flang] [libunwind] [libcxxabi] [openmp] [compiler-rt] [clang-tools-extra] [libcxx] [polly] [llvm] [lldb] [libc] [lld] [mlir] [clang] Make clang report invalid target versions. (PR #753

2024-01-08 Thread via lldb-commits

https://github.com/pirama-arumuga-nainar approved this pull request.

Please also wait for @MaskRay's LGTM before merging.

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


[Lldb-commits] [mlir] [polly] [clang-tools-extra] [llvm] [libcxx] [flang] [libunwind] [openmp] [lldb] [compiler-rt] [libcxxabi] [lld] [libc] [clang] Make clang report invalid target versions. (PR #753

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/75373

>From 74f256d8a77ee2ba8e0d5bbb6519aa2729cf94d5 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 01/15] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 llvm/lib/TargetParser/Triple.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index c5e9ad43d22588..335253194d1cf8 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/ARMTargetParser.h"
@@ -1199,7 +1200,11 @@ StringRef Triple::getOSAndEnvironmentName() const {
 
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
-  Version.tryParse(Name);
+  if (Version.tryParse(Name)) {
+errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
+"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+exit(1);
+  }
   return Version.withoutBuild();
 }
 

>From 0d159b2a9b76e233e020ac0aef15b49b03f4d86c Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:23:54 +
Subject: [PATCH 02/15] rephrase

---
 llvm/lib/TargetParser/Triple.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 335253194d1cf8..713ca447403d50 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1201,8 +1201,7 @@ StringRef Triple::getOSAndEnvironmentName() const {
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
   if (Version.tryParse(Name)) {
-errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
-"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+errs() << "version "<< Name << " is invalid\n";
 exit(1);
   }
   return Version.withoutBuild();

>From b2dda9ce95804783c59aa1ca4e81a7941aae805d Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 03/15] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 clang/lib/Basic/Targets/OSTargets.h | 5 +
 llvm/include/llvm/TargetParser/Triple.h | 4 
 llvm/lib/TargetParser/Triple.cpp| 8 
 3 files changed, 17 insertions(+)

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..bc28066019971c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -323,6 +323,11 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
 // This historical but ambiguous name for the minSdkVersion macro. Keep
 // defined for compatibility.
 Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  } else {
+llvm::errs() << "version "<< Triple.getVersionName() <<
+" in triple " << Triple.getArchName() << "-" << Triple.getVendorName()
+<< "-" << Triple.getOSAndEnvironmentName() << " is invalid\n";
+exit(1);
   }
 } else {
 Builder.defineMacro("__gnu_linux__");
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index 47904621c0967f..05df1c489ad06e 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -434,6 +434,10 @@ class Triple {
   /// string (separated by a '-' if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// Get the version component of the environment component as a single
+  /// string (the version after the environment).
+  StringRef getVersionName() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 49bc24ffbfae6c..db4ba7100781bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1199,6 +1199,14 @@ StringRef Triple::getOSAndEnvironmentName() const {
   return Tmp.split('-').second;  // Strip second component
 }
 
+StringRef Triple::getVersionName() const {
+  StringRef VersionName = getEnvironmentName();
+  StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
+  if (VersionName.startswith(EnvironmentTypeName))
+return VersionName.substr(EnvironmentTypeName.size());
+  return VersionName;
+}
+
 static 

[Lldb-commits] [clang] [libcxx] [lld] [llvm] [compiler-rt] [flang] [libcxxabi] [openmp] [polly] [clang-tools-extra] [lldb] [libunwind] [mlir] [libc] Make clang report invalid target versions. (PR #753

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/75373

>From 74f256d8a77ee2ba8e0d5bbb6519aa2729cf94d5 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 01/14] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 llvm/lib/TargetParser/Triple.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index c5e9ad43d22588..335253194d1cf8 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/ARMTargetParser.h"
@@ -1199,7 +1200,11 @@ StringRef Triple::getOSAndEnvironmentName() const {
 
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
-  Version.tryParse(Name);
+  if (Version.tryParse(Name)) {
+errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
+"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+exit(1);
+  }
   return Version.withoutBuild();
 }
 

>From 0d159b2a9b76e233e020ac0aef15b49b03f4d86c Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:23:54 +
Subject: [PATCH 02/14] rephrase

---
 llvm/lib/TargetParser/Triple.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 335253194d1cf8..713ca447403d50 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1201,8 +1201,7 @@ StringRef Triple::getOSAndEnvironmentName() const {
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
   if (Version.tryParse(Name)) {
-errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
-"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+errs() << "version "<< Name << " is invalid\n";
 exit(1);
   }
   return Version.withoutBuild();

>From b2dda9ce95804783c59aa1ca4e81a7941aae805d Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 03/14] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 clang/lib/Basic/Targets/OSTargets.h | 5 +
 llvm/include/llvm/TargetParser/Triple.h | 4 
 llvm/lib/TargetParser/Triple.cpp| 8 
 3 files changed, 17 insertions(+)

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..bc28066019971c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -323,6 +323,11 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
 // This historical but ambiguous name for the minSdkVersion macro. Keep
 // defined for compatibility.
 Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  } else {
+llvm::errs() << "version "<< Triple.getVersionName() <<
+" in triple " << Triple.getArchName() << "-" << Triple.getVendorName()
+<< "-" << Triple.getOSAndEnvironmentName() << " is invalid\n";
+exit(1);
   }
 } else {
 Builder.defineMacro("__gnu_linux__");
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index 47904621c0967f..05df1c489ad06e 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -434,6 +434,10 @@ class Triple {
   /// string (separated by a '-' if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// Get the version component of the environment component as a single
+  /// string (the version after the environment).
+  StringRef getVersionName() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 49bc24ffbfae6c..db4ba7100781bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1199,6 +1199,14 @@ StringRef Triple::getOSAndEnvironmentName() const {
   return Tmp.split('-').second;  // Strip second component
 }
 
+StringRef Triple::getVersionName() const {
+  StringRef VersionName = getEnvironmentName();
+  StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
+  if (VersionName.startswith(EnvironmentTypeName))
+return VersionName.substr(EnvironmentTypeName.size());
+  return VersionName;
+}
+
 static 

[Lldb-commits] [llvm] [lldb] [lld] [flang] [clang] [mlir] [libc] [openmp] [polly] [compiler-rt] [libcxx] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)

2024-01-08 Thread Juneyoung Lee via lldb-commits


@@ -0,0 +1,125 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -O0 | FileCheck %s

aqjune wrote:

I added the -fast-isel=false case to check the case when the regular DAG ISel 
path is taken.

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


[Lldb-commits] [lld] [openmp] [libcxx] [flang] [mlir] [libc] [lldb] [llvm] [clang] [polly] [compiler-rt] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)

2024-01-08 Thread Juneyoung Lee via lldb-commits

https://github.com/aqjune updated 
https://github.com/llvm/llvm-project/pull/77281

>From 1bbfe05bc50e1fbdb207f21a178b6fc7ab24e8cf Mon Sep 17 00:00:00 2001
From: Juneyoung Lee 
Date: Mon, 8 Jan 2024 02:01:41 -0600
Subject: [PATCH 1/2] [WebAssembly] Correctly consider signext/zext arg flags
 at function declaration

---
 .../WebAssembly/WebAssemblyFastISel.cpp   |   6 +-
 .../WebAssembly/signext-zeroext-callsite.ll   | 125 ++
 2 files changed, 129 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/WebAssembly/signext-zeroext-callsite.ll

diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
index 15dc44a0439573..80159974ecd691 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
@@ -839,9 +839,11 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) 
{
 
 unsigned Reg;
 
-if (Attrs.hasParamAttr(I, Attribute::SExt))
+if (Attrs.hasParamAttr(I, Attribute::SExt) ||
+(IsDirect && Func->hasParamAttribute(I, Attribute::SExt)))
   Reg = getRegForSignedValue(V);
-else if (Attrs.hasParamAttr(I, Attribute::ZExt))
+else if (Attrs.hasParamAttr(I, Attribute::ZExt) ||
+ (IsDirect && Func->hasParamAttribute(I, Attribute::ZExt)))
   Reg = getRegForUnsignedValue(V);
 else
   Reg = getRegForValue(V);
diff --git a/llvm/test/CodeGen/WebAssembly/signext-zeroext-callsite.ll 
b/llvm/test/CodeGen/WebAssembly/signext-zeroext-callsite.ll
new file mode 100644
index 00..02ca578716dc98
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/signext-zeroext-callsite.ll
@@ -0,0 +1,125 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -O0 | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+
+declare i32 @foo(i1 signext noundef, i32 noundef)
+
+; callsite_signext and callsite_nosignext must emit equivalent codes
+
+define i32 @callsite_nosignext() {
+; CHECK-LABEL: callsite_nosignext:
+; CHECK: .functype callsite_nosignext () -> (i32)
+; CHECK-NEXT:.local i32, i32, i32, i32, i32, i32
+; CHECK-NEXT:  # %bb.0: # %start
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 0
+; CHECK-NEXT:i32.const 0
+; CHECK-NEXT:local.set 1
+; CHECK-NEXT:i32.const 31
+; CHECK-NEXT:local.set 2
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.shl
+; CHECK-NEXT:local.set 3
+; CHECK-NEXT:local.get 3
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.shr_s
+; CHECK-NEXT:local.set 4
+; CHECK-NEXT:local.get 4
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:call foo
+; CHECK-NEXT:local.set 5
+; CHECK-NEXT:local.get 5
+; CHECK-NEXT:return
+start:
+  %0 = call i32 @foo(i1 1, i32 0)
+  ret i32 %0
+}
+
+define i32 @callsite_signext() {
+; CHECK-LABEL: callsite_signext:
+; CHECK: .functype callsite_signext () -> (i32)
+; CHECK-NEXT:.local i32, i32, i32, i32, i32, i32
+; CHECK-NEXT:  # %bb.0: # %start
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 0
+; CHECK-NEXT:i32.const 0
+; CHECK-NEXT:local.set 1
+; CHECK-NEXT:i32.const 31
+; CHECK-NEXT:local.set 2
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.shl
+; CHECK-NEXT:local.set 3
+; CHECK-NEXT:local.get 3
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.shr_s
+; CHECK-NEXT:local.set 4
+; CHECK-NEXT:local.get 4
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:call foo
+; CHECK-NEXT:local.set 5
+; CHECK-NEXT:local.get 5
+; CHECK-NEXT:return
+start:
+  %0 = call i32 @foo(i1 signext 1, i32 0)
+  ret i32 %0
+}
+
+declare i32 @foo2(i1 zeroext noundef, i32 noundef)
+
+; callsite_zeroext and callsite_nozeroext must emit equivalent codes
+
+define i32 @callsite_nozeroext() {
+; CHECK-LABEL: callsite_nozeroext:
+; CHECK: .functype callsite_nozeroext () -> (i32)
+; CHECK-NEXT:.local i32, i32, i32, i32, i32
+; CHECK-NEXT:  # %bb.0: # %start
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 0
+; CHECK-NEXT:i32.const 0
+; CHECK-NEXT:local.set 1
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 2
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.and
+; CHECK-NEXT:local.set 3
+; CHECK-NEXT:local.get 3
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:call foo2
+; CHECK-NEXT:local.set 4
+; CHECK-NEXT:local.get 4
+; CHECK-NEXT:return
+start:
+  %0 = call i32 @foo2(i1 1, i32 0)
+  ret i32 %0
+}
+
+define i32 @callsite_zeroext() {
+; CHECK-LABEL: callsite_zeroext:
+; CHECK: .functype callsite_zeroext () -> (i32)
+; CHECK-NEXT:.local i32, i32, i32, i32, i32
+; CHECK-NEXT:  # %bb.0: # %start
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 0
+; CHECK-NEXT:i32.const 0
+; CHECK-NEXT:local.set 1
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:l

[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits

nmosier wrote:

I went ahead and turned `TraceItemStorage` into a variant. I also deleted the 
memory usage / bytes from the tests. Also, I noticed some error messages were 
different for some tests — I'm guessing they may have changed in newer versions 
of libipt.

Right now, only 1 test fails:
```
==  

  
FAIL: testStartPerCpuSession 
(TestTraceStartStopMultipleThreads.TestTraceStartStopMultipleThreads)   
 
--  

  
Traceback (most recent call last):  

  
  File "/llvm/lldb/packages/Python/lldbsuite/test/decorators.py", line 162, in 
wrapper 
   
return func(*args, **kwargs)

  
  File 
"/llvm/lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py", 
line 14, in wrapper 

func(*args, **kwargs)   

  
  File 
"/llvm/lldb/test/API/commands/trace/multiple-threads/TestTraceStartStopMultipleThreads.py",
 line 260, in testStartPerCpuSession

self.expect("thread trace dump instructions")   

  
  File "/llvm/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2353, in 
expect  

self.runCmd(

  
  File "/llvm/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2031, in 
runCmd  

self.assertTrue(self.res.Succeeded(), msg if (msg) else CMD_MSG(cmd))   

  
AssertionError: False is not True : Command 'thread trace dump instructions 

  
Error output:   

  
error: Malformed perf context switch trace for cpu 14 at offset 64. A context 
switch record doesn't happen after the previous record. Previous TSC= 
2215501248, current TSC = 22155012
48. 

  
' did not return successfully   

  
Config=x86_64-/llvm-build/bin/clang 

  
```

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits

https://github.com/nmosier updated 
https://github.com/llvm/llvm-project/pull/77252

>From 7b184bbc1ae24d548d8574d2620b642e3304423a Mon Sep 17 00:00:00 2001
From: Nicholas Mosier 
Date: Sun, 7 Jan 2024 20:06:55 +
Subject: [PATCH] [lldb] Fix Intel PT plugin compile errors

Fix #77251.
---
 .../CommandObjectTraceStartIntelPT.cpp|  4 +--
 .../Plugins/Trace/intel-pt/DecodedThread.cpp  | 32 +++
 .../Plugins/Trace/intel-pt/DecodedThread.h| 26 +--
 .../Plugins/Trace/intel-pt/LibiptDecoder.cpp  |  4 +--
 .../Trace/intel-pt/TraceCursorIntelPT.cpp |  4 +--
 .../intel-pt/TraceIntelPTBundleLoader.cpp | 13 
 lldb/source/Target/ProcessTrace.cpp   |  2 ++
 .../API/commands/trace/TestTraceDumpInfo.py   | 15 ++---
 lldb/test/API/commands/trace/TestTraceLoad.py | 20 
 9 files changed, 49 insertions(+), 71 deletions(-)

diff --git 
a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
index d4f7dc354e9fed..44224229e625bf 100644
--- a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
@@ -158,7 +158,7 @@ 
CommandObjectProcessTraceStartIntelPT::CommandOptions::GetDefinitions() {
   return llvm::ArrayRef(g_process_trace_start_intel_pt_options);
 }
 
-bool CommandObjectProcessTraceStartIntelPT::DoExecute(
+void CommandObjectProcessTraceStartIntelPT::DoExecute(
 Args &command, CommandReturnObject &result) {
   if (Error err = m_trace.Start(
   m_options.m_ipt_trace_size, m_options.m_process_buffer_size_limit,
@@ -167,8 +167,6 @@ bool CommandObjectProcessTraceStartIntelPT::DoExecute(
 result.SetError(Status(std::move(err)));
   else
 result.SetStatus(eReturnStatusSuccessFinishResult);
-
-  return result.Succeeded();
 }
 
 std::optional
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
index 17f8f51bdf0e0d..9c075398d54703 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -85,11 +85,11 @@ double DecodedThread::NanosecondsRange::GetInterpolatedTime(
   return interpolate(next_range->nanos);
 }
 
-uint64_t DecodedThread::GetItemsCount() const { return m_item_kinds.size(); }
+uint64_t DecodedThread::GetItemsCount() const { return m_item_data.size(); }
 
 lldb::addr_t
 DecodedThread::GetInstructionLoadAddress(uint64_t item_index) const {
-  return m_item_data[item_index].load_address;
+  return std::get(m_item_data[item_index]);
 }
 
 lldb::addr_t
@@ -99,14 +99,16 @@ DecodedThread::GetSyncPointOffsetByIndex(uint64_t 
item_index) const {
 
 ThreadSP DecodedThread::GetThread() { return m_thread_sp; }
 
+template 
 DecodedThread::TraceItemStorage &
-DecodedThread::CreateNewTraceItem(lldb::TraceItemKind kind) {
-  m_item_kinds.push_back(kind);
-  m_item_data.emplace_back();
+DecodedThread::CreateNewTraceItem(lldb::TraceItemKind kind, Data &&data) {
+  m_item_data.emplace_back(data);
+
   if (m_last_tsc)
 (*m_last_tsc)->second.items_count++;
   if (m_last_nanoseconds)
 (*m_last_nanoseconds)->second.items_count++;
+
   return m_item_data.back();
 }
 
@@ -176,27 +178,27 @@ uint64_t DecodedThread::GetTotalInstructionCount() const {
 }
 
 void DecodedThread::AppendEvent(lldb::TraceEvent event) {
-  CreateNewTraceItem(lldb::eTraceItemKindEvent).event = event;
+  CreateNewTraceItem(lldb::eTraceItemKindEvent, event);
   m_events_stats.RecordEvent(event);
 }
 
 void DecodedThread::AppendInstruction(const pt_insn &insn) {
-  CreateNewTraceItem(lldb::eTraceItemKindInstruction).load_address = insn.ip;
+  CreateNewTraceItem(lldb::eTraceItemKindInstruction, insn.ip);
   m_insn_count++;
 }
 
 void DecodedThread::AppendError(const IntelPTError &error) {
-  CreateNewTraceItem(lldb::eTraceItemKindError).error = error.message();
+  CreateNewTraceItem(lldb::eTraceItemKindError, error.message());
   m_error_stats.RecordError(/*fatal=*/false);
 }
 
 void DecodedThread::AppendCustomError(StringRef err, bool fatal) {
-  CreateNewTraceItem(lldb::eTraceItemKindError).error = err.str();
+  CreateNewTraceItem(lldb::eTraceItemKindError, err.str());
   m_error_stats.RecordError(fatal);
 }
 
 lldb::TraceEvent DecodedThread::GetEventByIndex(int item_index) const {
-  return m_item_data[item_index].event;
+  return std::get(m_item_data[item_index]);
 }
 
 const DecodedThread::EventsStats &DecodedThread::GetEventsStats() const {
@@ -233,13 +235,18 @@ const DecodedThread::ErrorStats 
&DecodedThread::GetErrorStats() const {
 
 lldb::TraceItemKind
 DecodedThread::GetItemKindByIndex(uint64_t item_index) const {
-  return static_cast(m_item_kinds[item_index]);
+  return std::visit(
+  llvm::makeVisitor(
+  [](const std::string &) { return lldb::eTraceItemKindError; },
+  [](lldb::TraceEvent) { return lldb::eTraceItemKi

[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 036e48e2f5f890e1f9574cdb610e2336f12038a2 
77aa29a286cbf06a9959790ec26eb025ab5e3a16 -- 
lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp 
lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp 
lldb/source/Plugins/Trace/intel-pt/DecodedThread.h 
lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp 
lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp 
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp 
lldb/source/Target/ProcessTrace.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
index cd9ede789b..9c075398d5 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -103,7 +103,7 @@ template 
 DecodedThread::TraceItemStorage &
 DecodedThread::CreateNewTraceItem(lldb::TraceItemKind kind, Data &&data) {
   m_item_data.emplace_back(data);
-  
+
   if (m_last_tsc)
 (*m_last_tsc)->second.items_count++;
   if (m_last_nanoseconds)
@@ -235,10 +235,12 @@ const DecodedThread::ErrorStats 
&DecodedThread::GetErrorStats() const {
 
 lldb::TraceItemKind
 DecodedThread::GetItemKindByIndex(uint64_t item_index) const {
-  return std::visit(llvm::makeVisitor([] (const std::string &) { return 
lldb::eTraceItemKindError; },
-  [] (lldb::TraceEvent) { return 
lldb::eTraceItemKindEvent; },
-  [] (lldb::addr_t) { return 
lldb::eTraceItemKindInstruction; }),
-m_item_data[item_index]);
+  return std::visit(
+  llvm::makeVisitor(
+  [](const std::string &) { return lldb::eTraceItemKindError; },
+  [](lldb::TraceEvent) { return lldb::eTraceItemKindEvent; },
+  [](lldb::addr_t) { return lldb::eTraceItemKindInstruction; }),
+  m_item_data[item_index]);
 }
 
 llvm::StringRef DecodedThread::GetErrorByIndex(uint64_t item_index) const {
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
index 6b5dd20909..a48c55cc76 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -266,14 +266,16 @@ private:
   /// to update \a CalculateApproximateMemoryUsage() accordingly.
   lldb::ThreadSP m_thread_sp;
 
-  using TraceItemStorage = std::variant;
+  using TraceItemStorage =
+  std::variant;
 
   /// Create a new trace item.
   ///
   /// \return
   ///   The index of the new item.
   template 
-  DecodedThread::TraceItemStorage &CreateNewTraceItem(lldb::TraceItemKind 
kind, Data &&data);
+  DecodedThread::TraceItemStorage &CreateNewTraceItem(lldb::TraceItemKind kind,
+  Data &&data);
 
   /// Most of the trace data is stored here.
   std::deque m_item_data;

``




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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits

https://github.com/nmosier updated 
https://github.com/llvm/llvm-project/pull/77252

>From 77aa29a286cbf06a9959790ec26eb025ab5e3a16 Mon Sep 17 00:00:00 2001
From: Nicholas Mosier 
Date: Sun, 7 Jan 2024 20:06:55 +
Subject: [PATCH] [lldb] Fix Intel PT plugin compile errors

Fix #77251.
---
 .../CommandObjectTraceStartIntelPT.cpp|  4 +--
 .../Plugins/Trace/intel-pt/DecodedThread.cpp  | 30 +++
 .../Plugins/Trace/intel-pt/DecodedThread.h| 24 ---
 .../Plugins/Trace/intel-pt/LibiptDecoder.cpp  |  4 +--
 .../Trace/intel-pt/TraceCursorIntelPT.cpp |  4 +--
 .../intel-pt/TraceIntelPTBundleLoader.cpp | 13 
 lldb/source/Target/ProcessTrace.cpp   |  2 ++
 .../API/commands/trace/TestTraceDumpInfo.py   | 15 ++
 lldb/test/API/commands/trace/TestTraceLoad.py | 20 -
 9 files changed, 45 insertions(+), 71 deletions(-)

diff --git 
a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
index d4f7dc354e9fed..44224229e625bf 100644
--- a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
@@ -158,7 +158,7 @@ 
CommandObjectProcessTraceStartIntelPT::CommandOptions::GetDefinitions() {
   return llvm::ArrayRef(g_process_trace_start_intel_pt_options);
 }
 
-bool CommandObjectProcessTraceStartIntelPT::DoExecute(
+void CommandObjectProcessTraceStartIntelPT::DoExecute(
 Args &command, CommandReturnObject &result) {
   if (Error err = m_trace.Start(
   m_options.m_ipt_trace_size, m_options.m_process_buffer_size_limit,
@@ -167,8 +167,6 @@ bool CommandObjectProcessTraceStartIntelPT::DoExecute(
 result.SetError(Status(std::move(err)));
   else
 result.SetStatus(eReturnStatusSuccessFinishResult);
-
-  return result.Succeeded();
 }
 
 std::optional
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
index 17f8f51bdf0e0d..cd9ede789b11c5 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -85,11 +85,11 @@ double DecodedThread::NanosecondsRange::GetInterpolatedTime(
   return interpolate(next_range->nanos);
 }
 
-uint64_t DecodedThread::GetItemsCount() const { return m_item_kinds.size(); }
+uint64_t DecodedThread::GetItemsCount() const { return m_item_data.size(); }
 
 lldb::addr_t
 DecodedThread::GetInstructionLoadAddress(uint64_t item_index) const {
-  return m_item_data[item_index].load_address;
+  return std::get(m_item_data[item_index]);
 }
 
 lldb::addr_t
@@ -99,14 +99,16 @@ DecodedThread::GetSyncPointOffsetByIndex(uint64_t 
item_index) const {
 
 ThreadSP DecodedThread::GetThread() { return m_thread_sp; }
 
+template 
 DecodedThread::TraceItemStorage &
-DecodedThread::CreateNewTraceItem(lldb::TraceItemKind kind) {
-  m_item_kinds.push_back(kind);
-  m_item_data.emplace_back();
+DecodedThread::CreateNewTraceItem(lldb::TraceItemKind kind, Data &&data) {
+  m_item_data.emplace_back(data);
+  
   if (m_last_tsc)
 (*m_last_tsc)->second.items_count++;
   if (m_last_nanoseconds)
 (*m_last_nanoseconds)->second.items_count++;
+
   return m_item_data.back();
 }
 
@@ -176,27 +178,27 @@ uint64_t DecodedThread::GetTotalInstructionCount() const {
 }
 
 void DecodedThread::AppendEvent(lldb::TraceEvent event) {
-  CreateNewTraceItem(lldb::eTraceItemKindEvent).event = event;
+  CreateNewTraceItem(lldb::eTraceItemKindEvent, event);
   m_events_stats.RecordEvent(event);
 }
 
 void DecodedThread::AppendInstruction(const pt_insn &insn) {
-  CreateNewTraceItem(lldb::eTraceItemKindInstruction).load_address = insn.ip;
+  CreateNewTraceItem(lldb::eTraceItemKindInstruction, insn.ip);
   m_insn_count++;
 }
 
 void DecodedThread::AppendError(const IntelPTError &error) {
-  CreateNewTraceItem(lldb::eTraceItemKindError).error = error.message();
+  CreateNewTraceItem(lldb::eTraceItemKindError, error.message());
   m_error_stats.RecordError(/*fatal=*/false);
 }
 
 void DecodedThread::AppendCustomError(StringRef err, bool fatal) {
-  CreateNewTraceItem(lldb::eTraceItemKindError).error = err.str();
+  CreateNewTraceItem(lldb::eTraceItemKindError, err.str());
   m_error_stats.RecordError(fatal);
 }
 
 lldb::TraceEvent DecodedThread::GetEventByIndex(int item_index) const {
-  return m_item_data[item_index].event;
+  return std::get(m_item_data[item_index]);
 }
 
 const DecodedThread::EventsStats &DecodedThread::GetEventsStats() const {
@@ -233,13 +235,16 @@ const DecodedThread::ErrorStats 
&DecodedThread::GetErrorStats() const {
 
 lldb::TraceItemKind
 DecodedThread::GetItemKindByIndex(uint64_t item_index) const {
-  return static_cast(m_item_kinds[item_index]);
+  return std::visit(llvm::makeVisitor([] (const std::string &) { return 
lldb::eTraceItemKindError; },
+  [] (lldb::TraceEvent) { return 
ll

[Lldb-commits] [lldb] [lldb] DWARFDIE: Follow DW_AT_specification when computing CompilerCo… (PR #77157)

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


@@ -375,16 +375,21 @@ std::vector DWARFDIE::GetDeclContextDIEs() 
const {
 
 std::vector DWARFDIE::GetDeclContext() const {
   std::vector context;
-  const dw_tag_t tag = Tag();
-  if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
-return context;
   DWARFDIE parent = GetParent();
-  if (parent)
+  if (parent) {
+const dw_tag_t parent_tag = parent.Tag();
+if (parent_tag == DW_TAG_compile_unit || parent_tag == DW_TAG_partial_unit)

adrian-prantl wrote:

Updated!

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


[Lldb-commits] [lldb] [lldb] DWARFDIE: Follow DW_AT_specification when computing CompilerCo… (PR #77157)

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

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/77157

>From 5f34a103d0b06220bb93b55525865e23694854b4 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Fri, 5 Jan 2024 15:11:24 -0800
Subject: [PATCH] [lldb] DWARFDIE: Follow DW_AT_specification when computing
 CompilerContext

Following the specification chain seems to be clearly the expected
behavior of GetDeclContext(). Otherwise C++ methods have an empty
CompilerContext instead of being nested in their struct/class.

Theprimary motivation for this functionality is the Swift plugin. In
order to test the change I added a proof-of-concept implementation of
a Module::FindFunction() variant that takes a CompilerContext, expesed
via lldb-test.

rdar://120553412
---
 lldb/include/lldb/Core/Module.h   |  6 +++
 lldb/source/Core/Module.cpp   | 17 +++
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 44 ---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 11 ++---
 .../DWARF/x86/find-basic-function.cpp |  6 +++
 lldb/tools/lldb-test/lldb-test.cpp|  4 ++
 6 files changed, 67 insertions(+), 21 deletions(-)

diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index f4973cdda1efcc..0188057247a68b 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -337,6 +337,12 @@ class Module : public std::enable_shared_from_this,
  const ModuleFunctionSearchOptions &options,
  SymbolContextList &sc_list);
 
+  /// Find functions by compiler context.
+  void FindFunctions(llvm::ArrayRef compiler_ctx,
+ lldb::FunctionNameType name_type_mask,
+ const ModuleFunctionSearchOptions &options,
+ SymbolContextList &sc_list);
+
   /// Find functions by name.
   ///
   /// If the function is an inlined function, it will have a block,
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index c0574b724ace7b..331cf324664114 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -855,6 +855,23 @@ void Module::FindFunctions(ConstString name,
   }
 }
 
+void Module::FindFunctions(llvm::ArrayRef compiler_ctx,
+   FunctionNameType name_type_mask,
+   const ModuleFunctionSearchOptions &options,
+   SymbolContextList &sc_list) {
+  if (compiler_ctx.empty() ||
+  compiler_ctx.back().kind != CompilerContextKind::Function)
+return;
+  ConstString name = compiler_ctx.back().name;
+  SymbolContextList unfiltered;
+  FindFunctions(name, CompilerDeclContext(), name_type_mask, options,
+unfiltered);
+  // Filter by context.
+  for (auto &sc : unfiltered)
+if (sc.function && compiler_ctx.equals(sc.function->GetCompilerContext()))
+  sc_list.Append(sc);
+}
+
 void Module::FindFunctions(const RegularExpression ®ex,
const ModuleFunctionSearchOptions &options,
SymbolContextList &sc_list) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index bed68f45426f67..d4446befd83b05 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -373,44 +373,51 @@ std::vector DWARFDIE::GetDeclContextDIEs() 
const {
   return result;
 }
 
-std::vector DWARFDIE::GetDeclContext() const {
+static std::vector
+GetDeclContextImpl(llvm::SmallSet &seen, DWARFDIE die) {
   std::vector context;
-  const dw_tag_t tag = Tag();
-  if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
+  // Stop if we hit a cycle.
+  if (!die || !seen.insert(die.GetID()).second)
 return context;
-  DWARFDIE parent = GetParent();
-  if (parent)
-context = parent.GetDeclContext();
+
+  // Handle outline member function DIEs by following the specification.
+  if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification))
+return GetDeclContextImpl(seen, spec);
+
+  // Get the parent context chain.
+  context = GetDeclContextImpl(seen, die.GetParent());
+
+  // Add this DIE's contribution at the end of the chain.
   auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
 context.push_back({kind, ConstString(name)});
   };
-  switch (tag) {
+  switch (die.Tag()) {
   case DW_TAG_module:
-push_ctx(CompilerContextKind::Module, GetName());
+push_ctx(CompilerContextKind::Module, die.GetName());
 break;
   case DW_TAG_namespace:
-push_ctx(CompilerContextKind::Namespace, GetName());
+push_ctx(CompilerContextKind::Namespace, die.GetName());
 break;
   case DW_TAG_structure_type:
-push_ctx(CompilerContextKind::Struct, GetName());
+push_ctx(CompilerContextKind::Struct, die.GetName());
 break;
   case DW_TAG_union_type:
-push_ctx(CompilerContextKind::Union, GetName());
+push_ctx(CompilerContextKind::Union,

[Lldb-commits] [llvm] [compiler-rt] [lldb] [mlir] [libc] [libcxx] [openmp] [clang] [flang] [lld] [polly] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)

2024-01-08 Thread Derek Schuff via lldb-commits


@@ -0,0 +1,125 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -O0 | FileCheck %s

dschuff wrote:

Is there a test that covers this behavior for DAG ISel? Maybe it would make 
sense to add test expectations for both here?

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

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


@@ -107,7 +107,15 @@ DecodedThread::CreateNewTraceItem(lldb::TraceItemKind 
kind) {
 (*m_last_tsc)->second.items_count++;
   if (m_last_nanoseconds)
 (*m_last_nanoseconds)->second.items_count++;
-  return m_item_data.back();
+
+  TraceItemStorage &data = m_item_data.back();
+
+  // If creating an error item, then properly initialize TraceItemStorage's
+  // non-trivially-constructible union member `error`.
+  if (kind == lldb::eTraceItemKindError)
+new (&data.error) std::string();

walter-erquinigo wrote:

I see. Then I'm fine with `new (&data.error) std::string();`

But, if you want to make a more complex change that will also be very clean, 
you could use `std::variant` instead of `union` for `TraceItemStorage`. 
`std::variant` handles constructors and destructors nicely. Then we could also 
get rid of `m_item_kinds`. 

I'm fine with either option.

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits

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


[Lldb-commits] [lldb] [lldb] DWARFDIE: Follow DW_AT_specification when computing CompilerCo… (PR #77157)

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


@@ -375,16 +375,21 @@ std::vector DWARFDIE::GetDeclContextDIEs() 
const {
 
 std::vector DWARFDIE::GetDeclContext() const {
   std::vector context;
-  const dw_tag_t tag = Tag();
-  if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
-return context;
   DWARFDIE parent = GetParent();
-  if (parent)
+  if (parent) {
+const dw_tag_t parent_tag = parent.Tag();
+if (parent_tag == DW_TAG_compile_unit || parent_tag == DW_TAG_partial_unit)

adrian-prantl wrote:

In theory a DWARF producer could produce any structure. Clang and Swift only 
produce this form. I was trying to come up with a very simple cycle detection 
here. My thinking was that if the parent is the CU and the specification isn't 
the current DIE this is not a cycle, but thinking about it again, there still 
could be a larger cycle. I'll rework this to use a visited set.

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits


@@ -107,7 +107,15 @@ DecodedThread::CreateNewTraceItem(lldb::TraceItemKind 
kind) {
 (*m_last_tsc)->second.items_count++;
   if (m_last_nanoseconds)
 (*m_last_nanoseconds)->second.items_count++;
-  return m_item_data.back();
+
+  TraceItemStorage &data = m_item_data.back();
+
+  // If creating an error item, then properly initialize TraceItemStorage's
+  // non-trivially-constructible union member `error`.
+  if (kind == lldb::eTraceItemKindError)
+new (&data.error) std::string();

nmosier wrote:

I don't think so (I tried it, and the crash came back). The problem is that 
before line 116, `data.error` is uninitialized. Thus `data.error = {}` 
implicitly invokes the destructor of `data.error` on uninitialized memory 
before constructing a new std::string, causing a crash. 

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


[Lldb-commits] [lldb] [lldb] DWARFDIE: Follow DW_AT_specification when computing CompilerCo… (PR #77157)

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


@@ -404,7 +409,7 @@ std::vector 
DWARFDIE::GetDeclContext() const {
 push_ctx(CompilerContextKind::Enum, GetName());
 break;
   case DW_TAG_subprogram:
-push_ctx(CompilerContextKind::Function, GetPubname());
+push_ctx(CompilerContextKind::Function, GetName());

adrian-prantl wrote:

I noticed that Pubname returns the linkage name, which is not useful here, and 
apparently changing this had no effect on the testsuite.

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

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

walter-erquinigo wrote:

Nice! Could you just delete all the tests that check for number of bytes? I 
think it's better to delete them because they might change in different systems.

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

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


@@ -276,6 +276,9 @@ class DecodedThread : public 
std::enable_shared_from_this {
 
 /// The string message of this item if it's an error
 std::string error;
+
+TraceItemStorage() {}
+~TraceItemStorage() {}

walter-erquinigo wrote:

do you still need these?

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

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


@@ -107,7 +107,15 @@ DecodedThread::CreateNewTraceItem(lldb::TraceItemKind 
kind) {
 (*m_last_tsc)->second.items_count++;
   if (m_last_nanoseconds)
 (*m_last_nanoseconds)->second.items_count++;
-  return m_item_data.back();
+
+  TraceItemStorage &data = m_item_data.back();
+
+  // If creating an error item, then properly initialize TraceItemStorage's
+  // non-trivially-constructible union member `error`.
+  if (kind == lldb::eTraceItemKindError)
+new (&data.error) std::string();

walter-erquinigo wrote:

could you just do `data.error = {}`?

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits

nmosier wrote:

Thanks! That test passes now. Another test was crashing as well, but I fixed 
that (it was due to `TraceItemStorage.error` not being initialized properly in 
`DecodedThread::CreateNewTraceItem` when creating an error item.

49 out of 56 tests now pass, with the remaining tests being soft failures 
(e.g., unexpected output but no crashes, generally due to small differences 
like 
```
"memoryUsage": { 
  "totalInBytes": "924", 
  "avgPerItemInBytes": 33
},   
```
vs. expected
```
"memoryUsage": {
  "totalInBytes": "252",
  "avgPerItemInBytes": 9
}, 
```

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits

https://github.com/nmosier updated 
https://github.com/llvm/llvm-project/pull/77252

>From eece351a68e014d7a46bd1e3512298dd5dda Mon Sep 17 00:00:00 2001
From: Nicholas Mosier 
Date: Sun, 7 Jan 2024 20:06:55 +
Subject: [PATCH] [lldb] Fix Intel PT plugin compile errors

Fix #77251.
---
 lldb/include/lldb/Target/ProcessTrace.h |  2 +-
 .../intel-pt/CommandObjectTraceStartIntelPT.cpp |  4 +---
 .../source/Plugins/Trace/intel-pt/DecodedThread.cpp | 10 +-
 lldb/source/Plugins/Trace/intel-pt/DecodedThread.h  |  9 ++---
 .../source/Plugins/Trace/intel-pt/LibiptDecoder.cpp |  4 ++--
 .../Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp   |  4 ++--
 .../Trace/intel-pt/TraceIntelPTBundleLoader.cpp | 13 +++--
 lldb/source/Target/ProcessTrace.cpp |  2 ++
 8 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/lldb/include/lldb/Target/ProcessTrace.h 
b/lldb/include/lldb/Target/ProcessTrace.h
index 037dea232cc024..201754e975e4fb 100644
--- a/lldb/include/lldb/Target/ProcessTrace.h
+++ b/lldb/include/lldb/Target/ProcessTrace.h
@@ -71,7 +71,7 @@ class ProcessTrace : public PostMortemProcess {
   bool DoUpdateThreadList(ThreadList &old_thread_list,
   ThreadList &new_thread_list) override;
 
-private:
+public:
   static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
 lldb::ListenerSP listener_sp,
 const FileSpec *crash_file_path,
diff --git 
a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
index d4f7dc354e9fed..44224229e625bf 100644
--- a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
@@ -158,7 +158,7 @@ 
CommandObjectProcessTraceStartIntelPT::CommandOptions::GetDefinitions() {
   return llvm::ArrayRef(g_process_trace_start_intel_pt_options);
 }
 
-bool CommandObjectProcessTraceStartIntelPT::DoExecute(
+void CommandObjectProcessTraceStartIntelPT::DoExecute(
 Args &command, CommandReturnObject &result) {
   if (Error err = m_trace.Start(
   m_options.m_ipt_trace_size, m_options.m_process_buffer_size_limit,
@@ -167,8 +167,6 @@ bool CommandObjectProcessTraceStartIntelPT::DoExecute(
 result.SetError(Status(std::move(err)));
   else
 result.SetStatus(eReturnStatusSuccessFinishResult);
-
-  return result.Succeeded();
 }
 
 std::optional
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
index 17f8f51bdf0e0d..7497bdd3316e9e 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -107,7 +107,15 @@ DecodedThread::CreateNewTraceItem(lldb::TraceItemKind 
kind) {
 (*m_last_tsc)->second.items_count++;
   if (m_last_nanoseconds)
 (*m_last_nanoseconds)->second.items_count++;
-  return m_item_data.back();
+
+  TraceItemStorage &data = m_item_data.back();
+
+  // If creating an error item, then properly initialize TraceItemStorage's
+  // non-trivially-constructible union member `error`.
+  if (kind == lldb::eTraceItemKindError)
+new (&data.error) std::string();
+
+  return data;
 }
 
 void DecodedThread::NotifySyncPoint(lldb::addr_t psb_offset) {
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
index 5745cdb67ab68f..0f2c6e56bd541e 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -14,9 +14,9 @@
 #include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
+#include 
 #include 
 #include 
-#include 
 
 namespace lldb_private {
 namespace trace_intel_pt {
@@ -276,6 +276,9 @@ class DecodedThread : public 
std::enable_shared_from_this {
 
 /// The string message of this item if it's an error
 std::string error;
+
+TraceItemStorage() {}
+~TraceItemStorage() {}
   };
 
   /// Create a new trace item.
@@ -285,10 +288,10 @@ class DecodedThread : public 
std::enable_shared_from_this {
   DecodedThread::TraceItemStorage &CreateNewTraceItem(lldb::TraceItemKind 
kind);
 
   /// Most of the trace data is stored here.
-  std::vector m_item_data;
+  std::deque m_item_data;
   /// The TraceItemKind for each trace item encoded as uint8_t. We don't 
include
   /// it in TraceItemStorage to avoid padding.
-  std::vector m_item_kinds;
+  std::deque m_item_kinds;
 
   /// This map contains the TSCs of the decoded trace items. It maps
   /// `item index -> TSC`, where `item index` is the first index
diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp 
b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
index cdf81954eee902..f8241ef6a79329 100644
--- a/lldb/source/Plugins/Trace/intel-pt

[Lldb-commits] [lldb] [libcxxabi] [libunwind] [flang] [lld] [clang] [compiler-rt] [libc] [libcxx] [mlir] [polly] [llvm] [clang-tools-extra] Make clang report invalid target versions. (PR #75373)

2024-01-08 Thread via lldb-commits


@@ -1430,6 +1430,18 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   const ToolChain &TC = getToolChain(
   *UArgs, computeTargetTriple(*this, TargetTriple, *UArgs));
 
+  if (TC.getTriple().isAndroid()) {
+llvm::Triple Triple = TC.getTriple();
+unsigned TripleVersion = Triple.getEnvironmentVersion().getMajor();
+StringRef TripleVersionName = Triple.getEnvironmentVersionString();
+
+if (TripleVersion == 0 && TripleVersionName != "") {

pirama-arumuga-nainar wrote:

Check for `Triple.getEnvironmentVersion().empty()` instead of `.getMajor() == 
0`.  In non-Android contexts, a major version of `0` may be valid.

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


[Lldb-commits] [llvm] [compiler-rt] [mlir] [libcxx] [clang] [lldb] [libunwind] [clang-tools-extra] [polly] [libc] [flang] [lld] [libcxxabi] Make clang report invalid target versions. (PR #75373)

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/75373

>From 74f256d8a77ee2ba8e0d5bbb6519aa2729cf94d5 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 01/14] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 llvm/lib/TargetParser/Triple.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index c5e9ad43d22588..335253194d1cf8 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/ARMTargetParser.h"
@@ -1199,7 +1200,11 @@ StringRef Triple::getOSAndEnvironmentName() const {
 
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
-  Version.tryParse(Name);
+  if (Version.tryParse(Name)) {
+errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
+"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+exit(1);
+  }
   return Version.withoutBuild();
 }
 

>From 0d159b2a9b76e233e020ac0aef15b49b03f4d86c Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:23:54 +
Subject: [PATCH 02/14] rephrase

---
 llvm/lib/TargetParser/Triple.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 335253194d1cf8..713ca447403d50 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1201,8 +1201,7 @@ StringRef Triple::getOSAndEnvironmentName() const {
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
   if (Version.tryParse(Name)) {
-errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
-"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+errs() << "version "<< Name << " is invalid\n";
 exit(1);
   }
   return Version.withoutBuild();

>From b2dda9ce95804783c59aa1ca4e81a7941aae805d Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 03/14] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 clang/lib/Basic/Targets/OSTargets.h | 5 +
 llvm/include/llvm/TargetParser/Triple.h | 4 
 llvm/lib/TargetParser/Triple.cpp| 8 
 3 files changed, 17 insertions(+)

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..bc28066019971c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -323,6 +323,11 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
 // This historical but ambiguous name for the minSdkVersion macro. Keep
 // defined for compatibility.
 Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  } else {
+llvm::errs() << "version "<< Triple.getVersionName() <<
+" in triple " << Triple.getArchName() << "-" << Triple.getVendorName()
+<< "-" << Triple.getOSAndEnvironmentName() << " is invalid\n";
+exit(1);
   }
 } else {
 Builder.defineMacro("__gnu_linux__");
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index 47904621c0967f..05df1c489ad06e 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -434,6 +434,10 @@ class Triple {
   /// string (separated by a '-' if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// Get the version component of the environment component as a single
+  /// string (the version after the environment).
+  StringRef getVersionName() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 49bc24ffbfae6c..db4ba7100781bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1199,6 +1199,14 @@ StringRef Triple::getOSAndEnvironmentName() const {
   return Tmp.split('-').second;  // Strip second component
 }
 
+StringRef Triple::getVersionName() const {
+  StringRef VersionName = getEnvironmentName();
+  StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
+  if (VersionName.startswith(EnvironmentTypeName))
+return VersionName.substr(EnvironmentTypeName.size());
+  return VersionName;
+}
+
 static 

[Lldb-commits] [lldb] [libcxxabi] [libunwind] [flang] [lld] [clang] [compiler-rt] [libc] [libcxx] [mlir] [polly] [llvm] [clang-tools-extra] Make clang report invalid target versions. (PR #75373)

2024-01-08 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/75373

>From 74f256d8a77ee2ba8e0d5bbb6519aa2729cf94d5 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 01/13] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 llvm/lib/TargetParser/Triple.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index c5e9ad43d22588..335253194d1cf8 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/TargetParser/ARMTargetParser.h"
@@ -1199,7 +1200,11 @@ StringRef Triple::getOSAndEnvironmentName() const {
 
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
-  Version.tryParse(Name);
+  if (Version.tryParse(Name)) {
+errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
+"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+exit(1);
+  }
   return Version.withoutBuild();
 }
 

>From 0d159b2a9b76e233e020ac0aef15b49b03f4d86c Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:23:54 +
Subject: [PATCH 02/13] rephrase

---
 llvm/lib/TargetParser/Triple.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 335253194d1cf8..713ca447403d50 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1201,8 +1201,7 @@ StringRef Triple::getOSAndEnvironmentName() const {
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
   if (Version.tryParse(Name)) {
-errs() << "The input is "<< Name << " and it is invalid. Should pass an "<<
-"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n";
+errs() << "version "<< Name << " is invalid\n";
 exit(1);
   }
   return Version.withoutBuild();

>From b2dda9ce95804783c59aa1ca4e81a7941aae805d Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Wed, 13 Dec 2023 20:07:45 +
Subject: [PATCH 03/13] Make clang report garbage target versions.

Clang always silently ignores garbage target versions and this makes
debug harder. So clang will report when target versions are invalid.
---
 clang/lib/Basic/Targets/OSTargets.h | 5 +
 llvm/include/llvm/TargetParser/Triple.h | 4 
 llvm/lib/TargetParser/Triple.cpp| 8 
 3 files changed, 17 insertions(+)

diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 342af4bbc42b7b..bc28066019971c 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -323,6 +323,11 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public 
OSTargetInfo {
 // This historical but ambiguous name for the minSdkVersion macro. Keep
 // defined for compatibility.
 Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  } else {
+llvm::errs() << "version "<< Triple.getVersionName() <<
+" in triple " << Triple.getArchName() << "-" << Triple.getVendorName()
+<< "-" << Triple.getOSAndEnvironmentName() << " is invalid\n";
+exit(1);
   }
 } else {
 Builder.defineMacro("__gnu_linux__");
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetParser/Triple.h
index 47904621c0967f..05df1c489ad06e 100644
--- a/llvm/include/llvm/TargetParser/Triple.h
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -434,6 +434,10 @@ class Triple {
   /// string (separated by a '-' if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// Get the version component of the environment component as a single
+  /// string (the version after the environment).
+  StringRef getVersionName() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 49bc24ffbfae6c..db4ba7100781bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1199,6 +1199,14 @@ StringRef Triple::getOSAndEnvironmentName() const {
   return Tmp.split('-').second;  // Strip second component
 }
 
+StringRef Triple::getVersionName() const {
+  StringRef VersionName = getEnvironmentName();
+  StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
+  if (VersionName.startswith(EnvironmentTypeName))
+return VersionName.substr(EnvironmentTypeName.size());
+  return VersionName;
+}
+
 static 

[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

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

walter-erquinigo wrote:

> because the prior call to `CreateProcess` on line 107 returned null.

If that call returned null, that means that CreateProcess wasn't able to find 
the "trace" process plugin. Another thing to add, which should definitely work, 
is to invoke

```
ProcessTrace::Initialize();
```
right before `CreateProcess`. That should definitely work

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


[Lldb-commits] [lldb] [lldb] Add color support to StreamString (PR #77380)

2024-01-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pete Lawrence (PortalPete)


Changes

This change just adds a `bool colors` parameter to the `StreamString` class's 
constructor, which it passes up to its superclass’s constructor.

rdar://120671168

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


2 Files Affected:

- (modified) lldb/include/lldb/Utility/StreamString.h (+1-1) 
- (modified) lldb/source/Utility/StreamString.cpp (+1-1) 


``diff
diff --git a/lldb/include/lldb/Utility/StreamString.h 
b/lldb/include/lldb/Utility/StreamString.h
index 4c568acdcc6f60..3d675caf8f3f43 100644
--- a/lldb/include/lldb/Utility/StreamString.h
+++ b/lldb/include/lldb/Utility/StreamString.h
@@ -22,7 +22,7 @@ namespace lldb_private {
 
 class StreamString : public Stream {
 public:
-  StreamString();
+  StreamString(bool colors = false);
 
   StreamString(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
 
diff --git a/lldb/source/Utility/StreamString.cpp 
b/lldb/source/Utility/StreamString.cpp
index 745a85b7576520..0d35ccbdbbd0f5 100644
--- a/lldb/source/Utility/StreamString.cpp
+++ b/lldb/source/Utility/StreamString.cpp
@@ -11,7 +11,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-StreamString::StreamString() : Stream(0, 4, eByteOrderBig) {}
+StreamString::StreamString(bool colors) : Stream(0, 4, eByteOrderBig, colors) 
{}
 
 StreamString::StreamString(uint32_t flags, uint32_t addr_size,
ByteOrder byte_order)

``




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


[Lldb-commits] [lldb] [lldb] Add color support to StreamString (PR #77380)

2024-01-08 Thread Pete Lawrence via lldb-commits

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

This change just adds a `bool colors` parameter to the `StreamString` class's 
constructor, which it passes up to its superclass’s constructor.

rdar://120671168

>From 6ee5afb1a5f0f5e2070bfb0fb70f4a51bcd6ef9f Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Fri, 5 Jan 2024 20:02:46 -1000
Subject: [PATCH] [lldb] Add color support to StreamString
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This change just adds a `bool colors` parameter to the `StreamString` class's 
constructor, which it passes up to its superclass’s constructor.

rdar://120671168
---
 lldb/include/lldb/Utility/StreamString.h | 2 +-
 lldb/source/Utility/StreamString.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/include/lldb/Utility/StreamString.h 
b/lldb/include/lldb/Utility/StreamString.h
index 4c568acdcc6f60..3d675caf8f3f43 100644
--- a/lldb/include/lldb/Utility/StreamString.h
+++ b/lldb/include/lldb/Utility/StreamString.h
@@ -22,7 +22,7 @@ namespace lldb_private {
 
 class StreamString : public Stream {
 public:
-  StreamString();
+  StreamString(bool colors = false);
 
   StreamString(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
 
diff --git a/lldb/source/Utility/StreamString.cpp 
b/lldb/source/Utility/StreamString.cpp
index 745a85b7576520..0d35ccbdbbd0f5 100644
--- a/lldb/source/Utility/StreamString.cpp
+++ b/lldb/source/Utility/StreamString.cpp
@@ -11,7 +11,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-StreamString::StreamString() : Stream(0, 4, eByteOrderBig) {}
+StreamString::StreamString(bool colors) : Stream(0, 4, eByteOrderBig, colors) 
{}
 
 StreamString::StreamString(uint32_t flags, uint32_t addr_size,
ByteOrder byte_order)

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits

nmosier wrote:

Thanks for the suggestions. Unfortunately, it's still crashing, now on the line
```c
process_sp->SetID(static_cast(pid));
```
because the prior call to `CreateProcess` on line 107 returned null.

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


[Lldb-commits] [lldb] [lldb] Change interface of StructuredData::Array::GetItemAtIndexAsInteger (PR #71993)

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

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


[Lldb-commits] [lldb] 16b8a0d - [lldb] Change interface of StructuredData::Array::GetItemAtIndexAsInteger (#71993)

2024-01-08 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-08T13:31:03-08:00
New Revision: 16b8a0dc6885dea0882887a6e642a504fd1e193c

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

LOG: [lldb] Change interface of StructuredData::Array::GetItemAtIndexAsInteger 
(#71993)

This is a follow-up to (#71613) and (#71961).

Added: 


Modified: 
lldb/include/lldb/Utility/StructuredData.h
lldb/source/Breakpoint/BreakpointResolverName.cpp

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
lldb/source/Target/DynamicRegisterInfo.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/StructuredData.h 
b/lldb/include/lldb/Utility/StructuredData.h
index e7ee12868512f4..5e63ef92fac3ec 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -221,31 +221,17 @@ class StructuredData {
 }
 
 template 
-bool GetItemAtIndexAsInteger(size_t idx, IntType &result) const {
-  ObjectSP value_sp = GetItemAtIndex(idx);
-  if (value_sp.get()) {
+std::optional GetItemAtIndexAsInteger(size_t idx) const {
+  if (auto item_sp = GetItemAtIndex(idx)) {
 if constexpr (std::numeric_limits::is_signed) {
-  if (auto signed_value = value_sp->GetAsSignedInteger()) {
-result = static_cast(signed_value->GetValue());
-return true;
-  }
+  if (auto *signed_value = item_sp->GetAsSignedInteger())
+return static_cast(signed_value->GetValue());
 } else {
-  if (auto unsigned_value = value_sp->GetAsUnsignedInteger()) {
-result = static_cast(unsigned_value->GetValue());
-return true;
-  }
+  if (auto *unsigned_value = item_sp->GetAsUnsignedInteger())
+return static_cast(unsigned_value->GetValue());
 }
   }
-  return false;
-}
-
-template 
-bool GetItemAtIndexAsInteger(size_t idx, IntType &result,
- IntType default_val) const {
-  bool success = GetItemAtIndexAsInteger(idx, result);
-  if (!success)
-result = default_val;
-  return success;
+  return {};
 }
 
 std::optional GetItemAtIndexAsString(size_t idx) const {

diff  --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp 
b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 82eef43ad6cfd2..aa86d2a26d1100 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -161,14 +161,14 @@ BreakpointResolverSP 
BreakpointResolverName::CreateFromStructuredData(
 error.SetErrorString("BRN::CFSD: name entry is not a string.");
 return nullptr;
   }
-  std::underlying_type::type fnt;
-  success = names_mask_array->GetItemAtIndexAsInteger(i, fnt);
-  if (!success) {
+  auto maybe_fnt = names_mask_array->GetItemAtIndexAsInteger<
+  std::underlying_type::type>(i);
+  if (!maybe_fnt) {
 error.SetErrorString("BRN::CFSD: name mask entry is not an integer.");
 return nullptr;
   }
   names.push_back(std::string(*maybe_name));
-  name_masks.push_back(static_cast(fnt));
+  name_masks.push_back(static_cast(*maybe_fnt));
 }
 
 std::shared_ptr resolver_sp =

diff  --git 
a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
index 2a35256a6fb0bf..72293c5331f40d 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
@@ -592,9 +592,10 @@ addr_t 
InstrumentationRuntimeTSan::GetFirstNonInternalFramePc(
 if (skip_one_frame && i == 0)
   continue;
 
-addr_t addr;
-if (!trace_array->GetItemAtIndexAsInteger(i, addr))
+auto maybe_addr = trace_array->GetItemAtIndexAsInteger(i);
+if (!maybe_addr)
   continue;
+addr_t addr = *maybe_addr;
 
 lldb_private::Address so_addr;
 if (!process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(

diff  --git a/lldb/source/Target/DynamicRegisterInfo.cpp 
b/lldb/source/Target/DynamicRegisterInfo.cpp
index 7469c1d4259afc..1a817449fa9589 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -349,10 +349,8 @@ DynamicRegisterInfo::SetRegisterInfo(const 
StructuredData::Dictionary &dict,
   const size_t num_regs = invalidate_reg_list->GetSize();
   if (num_regs > 0) {
 for (uint32_t idx = 0; idx < num_regs; ++idx) {
-  uint64_t invalidate_reg_num;
-  std::optional maybe_invalidate_reg_name =
-  invalidate_reg_list->GetItemAtIndex

[Lldb-commits] [lldb] [lldb] Deprecate SBBreakpoint::AddName in favor of AddNameWithErrorHandling (PR #71228)

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

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


[Lldb-commits] [lldb] 09e32ab - [lldb] Deprecate SBBreakpoint::AddName in favor of AddNameWithErrorHandling (#71228)

2024-01-08 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-08T13:30:24-08:00
New Revision: 09e32ab75076a1f2270d37343922c86c12bdd047

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

LOG: [lldb] Deprecate SBBreakpoint::AddName in favor of 
AddNameWithErrorHandling (#71228)

AddName gives no feedback other than if it succeeded whereas
AddNameWithErrorHandling gives you back an SBError object. I would like
to mark AddName as deprecated and direct folks to use
AddNameWithErorrHandling instead.

-

Co-authored-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/API/SBBreakpoint.h

Removed: 




diff  --git a/lldb/include/lldb/API/SBBreakpoint.h 
b/lldb/include/lldb/API/SBBreakpoint.h
index 0bb7c31d74f21f..e08df3b6d5ab07 100644
--- a/lldb/include/lldb/API/SBBreakpoint.h
+++ b/lldb/include/lldb/API/SBBreakpoint.h
@@ -112,6 +112,8 @@ class LLDB_API SBBreakpoint {
 
   SBError SetScriptCallbackBody(const char *script_body_text);
 
+  LLDB_DEPRECATED_FIXME("Doesn't provide error handling",
+"AddNameWithErrorHandling")
   bool AddName(const char *new_name);
 
   SBError AddNameWithErrorHandling(const char *new_name);



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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

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

walter-erquinigo wrote:

> At least one test fails: `./bin/lldb -o 'trace load -v 
> /llvm/lldb/test/API/commands/trace/intelpt-trace/trace_2threads.json'` 
> crashes with an assertion failure on TraceIntelPTBundleLoader.cpp:127 
> (`*process_sp` is a null pointer dereference).
> 
> Do you know why `process_sp` would be null in this case? I added some extra 
> assertions and it looks like `target_sp->m_process_sp` is null after the call 
> to `ProcessTrace::CreateInstance` on line 111.

It seems that the issue is that we still need to make `Target::m_process_sp` 
point to the newly created process...

So, let's give something else a try:

Return that code to its original form

```
ProcessSP process_sp = target_sp->CreateProcess(
/*listener*/ nullptr, "trace",
/*crash_file*/ nullptr,
/*can_connect*/ false);
```

If that passes the test, then there's nothing else to do and we are good to go.
If that doesn't work, then we need to additional add the line 
`LLDB_PLUGIN_DEFINE(ProcessTrace)` before any function declaration in the 
ProcessTrace.cpp file. That `LLDB_PLUGIN_DEFINE` define will register the 
ProcessTrace process plugin with that "trace", which will be searchable by 
`target_sp->CreateProcess`, who is looking for a trace process called "trace".

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


[Lldb-commits] [lldb] [lldb] All ValueObjectSP instances are now valid (non-null) but have an error state (In-progress | Take 2) (PR #77375)

2024-01-08 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 07d6fbf8d80083470b4371f2ddabd656a9c317e6 
c416cad26ed3e84918f639cc5a408682afff451f -- 
lldb/include/lldb/Breakpoint/Watchpoint.h lldb/include/lldb/Core/ValueObject.h 
lldb/include/lldb/Core/ValueObjectConstResult.h 
lldb/include/lldb/Core/ValueObjectConstResultCast.h 
lldb/include/lldb/Core/ValueObjectConstResultChild.h 
lldb/include/lldb/Core/ValueObjectConstResultImpl.h 
lldb/include/lldb/Core/ValueObjectList.h 
lldb/include/lldb/Core/ValueObjectRegister.h 
lldb/include/lldb/Core/ValueObjectSyntheticFilter.h 
lldb/include/lldb/Core/ValueObjectUpdater.h 
lldb/include/lldb/DataFormatters/TypeSynthetic.h 
lldb/include/lldb/DataFormatters/ValueObjectPrinter.h 
lldb/include/lldb/DataFormatters/VectorIterator.h 
lldb/include/lldb/Expression/ExpressionVariable.h 
lldb/include/lldb/Expression/UserExpression.h 
lldb/include/lldb/Interpreter/ScriptInterpreter.h 
lldb/include/lldb/Target/LanguageRuntime.h 
lldb/include/lldb/Target/StackFrame.h 
lldb/include/lldb/Target/StackFrameRecognizer.h 
lldb/include/lldb/Target/Target.h lldb/include/lldb/Target/Thread.h 
lldb/include/lldb/Target/ThreadPlan.h 
lldb/include/lldb/Target/ThreadPlanCallFunction.h 
lldb/include/lldb/lldb-forward.h lldb/source/Breakpoint/BreakpointLocation.cpp 
lldb/source/Breakpoint/Watchpoint.cpp 
lldb/source/Commands/CommandObjectDWIMPrint.cpp 
lldb/source/Commands/CommandObjectExpression.cpp 
lldb/source/Commands/CommandObjectFrame.cpp 
lldb/source/Commands/CommandObjectMemory.cpp 
lldb/source/Commands/CommandObjectTarget.cpp 
lldb/source/Commands/CommandObjectThread.cpp 
lldb/source/Commands/CommandObjectType.cpp 
lldb/source/Commands/CommandObjectWatchpoint.cpp 
lldb/source/Core/FormatEntity.cpp lldb/source/Core/IOHandlerCursesGUI.cpp 
lldb/source/Core/ValueObject.cpp lldb/source/Core/ValueObjectConstResult.cpp 
lldb/source/Core/ValueObjectConstResultCast.cpp 
lldb/source/Core/ValueObjectConstResultChild.cpp 
lldb/source/Core/ValueObjectConstResultImpl.cpp 
lldb/source/Core/ValueObjectList.cpp lldb/source/Core/ValueObjectRegister.cpp 
lldb/source/Core/ValueObjectSyntheticFilter.cpp 
lldb/source/Core/ValueObjectUpdater.cpp 
lldb/source/DataFormatters/FormatManager.cpp 
lldb/source/DataFormatters/TypeSynthetic.cpp 
lldb/source/DataFormatters/ValueObjectPrinter.cpp 
lldb/source/DataFormatters/VectorType.cpp 
lldb/source/Expression/ExpressionVariable.cpp lldb/source/Target/StackFrame.cpp 
lldb/source/Target/Target.cpp lldb/source/Target/Thread.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index 0f1b8c98ae..cd80f8e428 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -468,7 +468,6 @@ public:
   virtual std::optional
   GetChildAtIndex(size_t idx, bool can_create = true);
 
-
   virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
  bool can_create = true);
   /// The method always creates missing children in the path, if necessary.

``




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


[Lldb-commits] [lldb] [lldb] All ValueObjectSP instances are now valid (non-null) but have an error state (In-progress | Take 2) (PR #77375)

2024-01-08 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pete Lawrence (PortalPete)


Changes

> **Note**
> I originally proposed this change with [PR 
74912](https://github.com/llvm/llvm-project/pull/74912) before renaming the 
branch.

### Purpose
For now, we'd like to get people's thought's on the goal, design, and scope of 
this PR by reviewing these preliminary changes.

I recommend focussing (or starting) on these files:
* `ValueObject.h`
* `ValueObject.cpp`


### Goal
Every `ValueObjectSP` will have an actual value and will never be equal to 
`nullptr`.


### Design
To force each `ValueObjectSP` to contain _something_, we're considering 
changing the type from a typedef…
```cpp
typedef std::shared_ptr ValueObjectSP;

```

to this subclass:
```cpp
class ValueObjectSP : public std::shared_ptr {
  ValueObjectSP() = delete;
  operator bool() = delete;

public:
  ValueObjectSP(std::shared_ptr 
&&pointer)
  : std::shared_ptr(std::move(pointer)) {
assert(pointer);
  }
};
```

This class removes the default constructor to force each `ValueObjectSP` to 
point to a real `ValueObject` instance. It also removes `operator bool()` 
because no instance will ever equal `nullptr`. 


### Change Patterns
The bulk of the changes into one of these two camps:
1. For methods that have a `Status &error` parameter **and** return an 
`ValueObjectSP`, the return value *becomes* the container for the error state, 
which eliminate the need for a parameter.
* This means that callers of these methods need to check the return value's 
error state.
  * `return_value->GetError.Success()`
  * `return_value->GetError.Fail()`

2. For all other methods that return a `ValueObjectSP` but don't have a `Status 
&` parameter, they now return `std::optional`.
* This changes a fair amount of code in these ways:
  * Code which had been using the `std::shared_ptr` Boolean operator now uses 
the `std::optional` Boolean operator.
  * Nearby code has to call the optional's `value()` method to get the shared 
pointer inside.
  * Methods with lines that return `ValueObjectSP()` now return `{}`, which 
creates an optional with nothing in it.

Again, I recommend focussing (or starting) on these files:
* `ValueObject.h`
* `ValueObject.cpp`


### Remaining work
This is very much a work-in-progress for a proof of concept, which means:
* It doesn't compile (yet)
* So far I've modified 53 files
* I estimate another 100-250 more files need to change based on the ninja build 
progress indicator.

The remaining changes will just be more of the same but now's a good time to 
take a look at this sample to get a sense of the magnitude and trajectory of 
the remaining changes.

---

Patch is 203.61 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/77375.diff


53 Files Affected:

- (modified) lldb/include/lldb/Breakpoint/Watchpoint.h (+2-2) 
- (modified) lldb/include/lldb/Core/ValueObject.h (+38-28) 
- (modified) lldb/include/lldb/Core/ValueObjectConstResult.h (+4-4) 
- (modified) lldb/include/lldb/Core/ValueObjectConstResultCast.h (+3-3) 
- (modified) lldb/include/lldb/Core/ValueObjectConstResultChild.h (+3-3) 
- (modified) lldb/include/lldb/Core/ValueObjectConstResultImpl.h (+4-4) 
- (modified) lldb/include/lldb/Core/ValueObjectList.h (+10-7) 
- (modified) lldb/include/lldb/Core/ValueObjectRegister.h (+2-2) 
- (modified) lldb/include/lldb/Core/ValueObjectSyntheticFilter.h (+5-5) 
- (modified) lldb/include/lldb/Core/ValueObjectUpdater.h (+3-3) 
- (modified) lldb/include/lldb/DataFormatters/TypeSynthetic.h (+12-10) 
- (modified) lldb/include/lldb/DataFormatters/ValueObjectPrinter.h (+2-1) 
- (modified) lldb/include/lldb/DataFormatters/VectorIterator.h (+1-1) 
- (modified) lldb/include/lldb/Expression/ExpressionVariable.h (+37-16) 
- (modified) lldb/include/lldb/Expression/UserExpression.h (+1-1) 
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+4-4) 
- (modified) lldb/include/lldb/Target/LanguageRuntime.h (+3-3) 
- (modified) lldb/include/lldb/Target/StackFrame.h (+6-6) 
- (modified) lldb/include/lldb/Target/StackFrameRecognizer.h (+1-3) 
- (modified) lldb/include/lldb/Target/Target.h (+1-1) 
- (modified) lldb/include/lldb/Target/Thread.h (+2-2) 
- (modified) lldb/include/lldb/Target/ThreadPlan.h (+2-2) 
- (modified) lldb/include/lldb/Target/ThreadPlanCallFunction.h (+1-1) 
- (modified) lldb/include/lldb/lldb-forward.h (+12-1) 
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+2-4) 
- (modified) lldb/source/Breakpoint/Watchpoint.cpp (+13-9) 
- (modified) lldb/source/Commands/CommandObjectDWIMPrint.cpp (+12-11) 
- (modified) lldb/source/Commands/CommandObjectExpression.cpp (+14-11) 
- (modified) lldb/source/Commands/CommandObjectFrame.cpp (+19-17) 
- (modified) lldb/source/Commands/CommandObjectMemory.cpp (+9-16) 
- (modified) lldb/source/Commands/CommandObjectTarget.cp

[Lldb-commits] [lldb] [lldb] Remove redundant severity substring within a diagnostic message. (PR #76111)

2024-01-08 Thread Pete Lawrence via lldb-commits


@@ -48,8 +48,17 @@ std::string DiagnosticManager::GetString(char separator) {
   std::string ret;
 
   for (const auto &diagnostic : Diagnostics()) {
-ret.append(StringForSeverity(diagnostic->GetSeverity()));
-ret.append(std::string(diagnostic->GetMessage()));
+std::string message(diagnostic->GetMessage());
+std::string searchable_message(diagnostic->GetMessage().lower());
+std::string severity(StringForSeverity(diagnostic->GetSeverity()));
+
+// Erase the (first) redundant severity string in the message.
+size_t position = searchable_message.find(severity);
+if (position != std::string::npos)
+  message.erase(position, severity.length());
+
+ret.append(severity);
+ret.append(message);

PortalPete wrote:

 Ok, you're suggestion is up @felipepiovezan.
Thanks again! 🙂

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


[Lldb-commits] [lldb] [lldb] Remove redundant severity substring within a diagnostic message. (PR #76111)

2024-01-08 Thread Pete Lawrence via lldb-commits

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

>From d10ce06475f52ec918aab96f7b1f85ee414d2d2f Mon Sep 17 00:00:00 2001
From: Pete Lawrence 
Date: Tue, 19 Dec 2023 19:25:36 -1000
Subject: [PATCH] [lldb] Remove redundant severity substring within a
 diagnostic message.

For example, the following message has the severity string "error: " twice.
> "error: :3:1: error: cannot find 'bogus' in scope

This method already appends the severity string in the beginning, but with this 
fix, it also removes a secondary instance, if applicable.

Note that this change only removes the *first* redundant substring. I 
considered putting the removal logic in a loop, but I decided that if something 
is generating more than one redundant severity substring, then that's a problem 
the message's source should probably fix.

rdar://114203423
---
 lldb/source/Expression/DiagnosticManager.cpp  | 15 ---
 .../TestModulesCompileError.py|  2 +-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Expression/DiagnosticManager.cpp 
b/lldb/source/Expression/DiagnosticManager.cpp
index 08977066e3330a..9a1100df78db2b 100644
--- a/lldb/source/Expression/DiagnosticManager.cpp
+++ b/lldb/source/Expression/DiagnosticManager.cpp
@@ -46,11 +46,20 @@ static const char *StringForSeverity(DiagnosticSeverity 
severity) {
 
 std::string DiagnosticManager::GetString(char separator) {
   std::string ret;
+  llvm::raw_string_ostream stream(ret);
 
   for (const auto &diagnostic : Diagnostics()) {
-ret.append(StringForSeverity(diagnostic->GetSeverity()));
-ret.append(std::string(diagnostic->GetMessage()));
-ret.push_back(separator);
+llvm::StringRef severity = StringForSeverity(diagnostic->GetSeverity());
+stream << severity;
+
+llvm::StringRef message = diagnostic->GetMessage();
+std::string searchable_message = message.lower();
+auto severity_pos = message.find(severity);
+stream << message.take_front(severity_pos);
+
+if (severity_pos != llvm::StringRef::npos)
+  stream << message.drop_front(severity_pos + severity.size());
+stream << separator;
   }
 
   return ret;
diff --git 
a/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py 
b/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
index 36e302be2525b5..620b6e44fc852a 100644
--- a/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
+++ b/lldb/test/API/lang/objc/modules-compile-error/TestModulesCompileError.py
@@ -21,7 +21,7 @@ def test(self):
 "expr @import LLDBTestModule",
 error=True,
 substrs=[
-"module.h:4:1: error: use of undeclared identifier 
'syntax_error_for_lldb_to_find'",
+"module.h:4:1: use of undeclared identifier 
'syntax_error_for_lldb_to_find'",
 "syntax_error_for_lldb_to_find // comment that tests source 
printing",
 "could not build module 'LLDBTestModule'",
 ],

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


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-08 Thread Nicholas Mosier via lldb-commits

nmosier wrote:

At least one test fails: `./bin/lldb -o 'trace load -v 
/llvm/lldb/test/API/commands/trace/intelpt-trace/trace_2threads.json'` crashes 
with an assertion failure on TraceIntelPTBundleLoader.cpp:127 (`*process_sp` is 
a null pointer dereference).

Do you know why `process_sp` would be null in this case? I added some extra 
assertions and it looks like `target_sp->m_process_sp` is null after the call 
to `ProcessTrace::CreateInstance` on line 111.



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


[Lldb-commits] [lld] [mlir] [lldb] [openmp] [clang] [flang] [compiler-rt] [libc] [libcxx] [polly] [llvm] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)

2024-01-08 Thread Juneyoung Lee via lldb-commits

https://github.com/aqjune updated 
https://github.com/llvm/llvm-project/pull/77281

>From 1bbfe05bc50e1fbdb207f21a178b6fc7ab24e8cf Mon Sep 17 00:00:00 2001
From: Juneyoung Lee 
Date: Mon, 8 Jan 2024 02:01:41 -0600
Subject: [PATCH] [WebAssembly] Correctly consider signext/zext arg flags at
 function declaration

---
 .../WebAssembly/WebAssemblyFastISel.cpp   |   6 +-
 .../WebAssembly/signext-zeroext-callsite.ll   | 125 ++
 2 files changed, 129 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/WebAssembly/signext-zeroext-callsite.ll

diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
index 15dc44a0439573..80159974ecd691 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
@@ -839,9 +839,11 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) 
{
 
 unsigned Reg;
 
-if (Attrs.hasParamAttr(I, Attribute::SExt))
+if (Attrs.hasParamAttr(I, Attribute::SExt) ||
+(IsDirect && Func->hasParamAttribute(I, Attribute::SExt)))
   Reg = getRegForSignedValue(V);
-else if (Attrs.hasParamAttr(I, Attribute::ZExt))
+else if (Attrs.hasParamAttr(I, Attribute::ZExt) ||
+ (IsDirect && Func->hasParamAttribute(I, Attribute::ZExt)))
   Reg = getRegForUnsignedValue(V);
 else
   Reg = getRegForValue(V);
diff --git a/llvm/test/CodeGen/WebAssembly/signext-zeroext-callsite.ll 
b/llvm/test/CodeGen/WebAssembly/signext-zeroext-callsite.ll
new file mode 100644
index 00..02ca578716dc98
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/signext-zeroext-callsite.ll
@@ -0,0 +1,125 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -O0 | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+
+declare i32 @foo(i1 signext noundef, i32 noundef)
+
+; callsite_signext and callsite_nosignext must emit equivalent codes
+
+define i32 @callsite_nosignext() {
+; CHECK-LABEL: callsite_nosignext:
+; CHECK: .functype callsite_nosignext () -> (i32)
+; CHECK-NEXT:.local i32, i32, i32, i32, i32, i32
+; CHECK-NEXT:  # %bb.0: # %start
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 0
+; CHECK-NEXT:i32.const 0
+; CHECK-NEXT:local.set 1
+; CHECK-NEXT:i32.const 31
+; CHECK-NEXT:local.set 2
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.shl
+; CHECK-NEXT:local.set 3
+; CHECK-NEXT:local.get 3
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.shr_s
+; CHECK-NEXT:local.set 4
+; CHECK-NEXT:local.get 4
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:call foo
+; CHECK-NEXT:local.set 5
+; CHECK-NEXT:local.get 5
+; CHECK-NEXT:return
+start:
+  %0 = call i32 @foo(i1 1, i32 0)
+  ret i32 %0
+}
+
+define i32 @callsite_signext() {
+; CHECK-LABEL: callsite_signext:
+; CHECK: .functype callsite_signext () -> (i32)
+; CHECK-NEXT:.local i32, i32, i32, i32, i32, i32
+; CHECK-NEXT:  # %bb.0: # %start
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 0
+; CHECK-NEXT:i32.const 0
+; CHECK-NEXT:local.set 1
+; CHECK-NEXT:i32.const 31
+; CHECK-NEXT:local.set 2
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.shl
+; CHECK-NEXT:local.set 3
+; CHECK-NEXT:local.get 3
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.shr_s
+; CHECK-NEXT:local.set 4
+; CHECK-NEXT:local.get 4
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:call foo
+; CHECK-NEXT:local.set 5
+; CHECK-NEXT:local.get 5
+; CHECK-NEXT:return
+start:
+  %0 = call i32 @foo(i1 signext 1, i32 0)
+  ret i32 %0
+}
+
+declare i32 @foo2(i1 zeroext noundef, i32 noundef)
+
+; callsite_zeroext and callsite_nozeroext must emit equivalent codes
+
+define i32 @callsite_nozeroext() {
+; CHECK-LABEL: callsite_nozeroext:
+; CHECK: .functype callsite_nozeroext () -> (i32)
+; CHECK-NEXT:.local i32, i32, i32, i32, i32
+; CHECK-NEXT:  # %bb.0: # %start
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 0
+; CHECK-NEXT:i32.const 0
+; CHECK-NEXT:local.set 1
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 2
+; CHECK-NEXT:local.get 0
+; CHECK-NEXT:local.get 2
+; CHECK-NEXT:i32.and
+; CHECK-NEXT:local.set 3
+; CHECK-NEXT:local.get 3
+; CHECK-NEXT:local.get 1
+; CHECK-NEXT:call foo2
+; CHECK-NEXT:local.set 4
+; CHECK-NEXT:local.get 4
+; CHECK-NEXT:return
+start:
+  %0 = call i32 @foo2(i1 1, i32 0)
+  ret i32 %0
+}
+
+define i32 @callsite_zeroext() {
+; CHECK-LABEL: callsite_zeroext:
+; CHECK: .functype callsite_zeroext () -> (i32)
+; CHECK-NEXT:.local i32, i32, i32, i32, i32
+; CHECK-NEXT:  # %bb.0: # %start
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local.set 0
+; CHECK-NEXT:i32.const 0
+; CHECK-NEXT:local.set 1
+; CHECK-NEXT:i32.const 1
+; CHECK-NEXT:local

[Lldb-commits] [lldb] [lldb] Deprecate SBBreakpoint::AddName in favor of AddNameWithErrorHandling (PR #71228)

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

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


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


[Lldb-commits] [lldb] [lldb] Change interface of StructuredData::Array::GetItemAtIndexAsInteger (PR #71993)

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

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

LGTM

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


[Lldb-commits] [llvm] [clang-tools-extra] [lldb] [clang] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)

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

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


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


[Lldb-commits] [libcxx] [flang] [lldb] [lld] [clang] [libc] [clang-tools-extra] [compiler-rt] [llvm] [msan] Unwind stack before fatal reports (PR #77168)

2024-01-08 Thread Vitaly Buka via lldb-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/77168

>From d4953b7a14dfb1d351b543e2546d710ae30173ed Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Fri, 5 Jan 2024 18:42:43 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 compiler-rt/lib/msan/msan.h   |  3 ++
 compiler-rt/lib/msan/msan_allocator.cpp   | 29 ---
 compiler-rt/lib/msan/msan_new_delete.cpp  | 26 ++---
 .../TestCases/max_allocation_size.cpp | 10 ++-
 4 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h
index 25fa2212bdadd3..b717161577a1db 100644
--- a/compiler-rt/lib/msan/msan.h
+++ b/compiler-rt/lib/msan/msan.h
@@ -321,6 +321,9 @@ const int STACK_TRACE_TAG_VPTR = STACK_TRACE_TAG_FIELDS + 1;
 stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal); \
   }
 
+#define GET_FATAL_STACK_TRACE \
+  GET_FATAL_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME())
+
 class ScopedThreadLocalStateBackup {
  public:
   ScopedThreadLocalStateBackup() { Backup(); }
diff --git a/compiler-rt/lib/msan/msan_allocator.cpp 
b/compiler-rt/lib/msan/msan_allocator.cpp
index 72a7f980d39fb0..f71f59cedf820e 100644
--- a/compiler-rt/lib/msan/msan_allocator.cpp
+++ b/compiler-rt/lib/msan/msan_allocator.cpp
@@ -180,17 +180,19 @@ void MsanThreadLocalMallocStorage::CommitBack() {
 
 static void *MsanAllocate(StackTrace *stack, uptr size, uptr alignment,
   bool zeroise) {
-  if (size > max_malloc_size) {
+  if (UNLIKELY(size > max_malloc_size)) {
 if (AllocatorMayReturnNull()) {
   Report("WARNING: MemorySanitizer failed to allocate 0x%zx bytes\n", 
size);
   return nullptr;
 }
-ReportAllocationSizeTooBig(size, max_malloc_size, stack);
+GET_FATAL_STACK_TRACE;
+ReportAllocationSizeTooBig(size, max_malloc_size, &stack);
   }
   if (UNLIKELY(IsRssLimitExceeded())) {
 if (AllocatorMayReturnNull())
   return nullptr;
-ReportRssLimitExceeded(stack);
+GET_FATAL_STACK_TRACE;
+ReportRssLimitExceeded(&stack);
   }
   MsanThread *t = GetCurrentThread();
   void *allocated;
@@ -206,7 +208,8 @@ static void *MsanAllocate(StackTrace *stack, uptr size, 
uptr alignment,
 SetAllocatorOutOfMemory();
 if (AllocatorMayReturnNull())
   return nullptr;
-ReportOutOfMemory(size, stack);
+GET_FATAL_STACK_TRACE;
+ReportOutOfMemory(size, &stack);
   }
   Metadata *meta =
   reinterpret_cast(allocator.GetMetaData(allocated));
@@ -288,7 +291,8 @@ static void *MsanCalloc(StackTrace *stack, uptr nmemb, uptr 
size) {
   if (UNLIKELY(CheckForCallocOverflow(size, nmemb))) {
 if (AllocatorMayReturnNull())
   return nullptr;
-ReportCallocOverflow(nmemb, size, stack);
+GET_FATAL_STACK_TRACE;
+ReportCallocOverflow(nmemb, size, &stack);
   }
   return MsanAllocate(stack, nmemb * size, sizeof(u64), true);
 }
@@ -343,7 +347,8 @@ void *msan_reallocarray(void *ptr, uptr nmemb, uptr size, 
StackTrace *stack) {
 errno = errno_ENOMEM;
 if (AllocatorMayReturnNull())
   return nullptr;
-ReportReallocArrayOverflow(nmemb, size, stack);
+GET_FATAL_STACK_TRACE;
+ReportReallocArrayOverflow(nmemb, size, &stack);
   }
   return msan_realloc(ptr, nmemb * size, stack);
 }
@@ -358,7 +363,8 @@ void *msan_pvalloc(uptr size, StackTrace *stack) {
 errno = errno_ENOMEM;
 if (AllocatorMayReturnNull())
   return nullptr;
-ReportPvallocOverflow(size, stack);
+GET_FATAL_STACK_TRACE;
+ReportPvallocOverflow(size, &stack);
   }
   // pvalloc(0) should allocate one page.
   size = size ? RoundUpTo(size, PageSize) : PageSize;
@@ -370,7 +376,8 @@ void *msan_aligned_alloc(uptr alignment, uptr size, 
StackTrace *stack) {
 errno = errno_EINVAL;
 if (AllocatorMayReturnNull())
   return nullptr;
-ReportInvalidAlignedAllocAlignment(size, alignment, stack);
+GET_FATAL_STACK_TRACE;
+ReportInvalidAlignedAllocAlignment(size, alignment, &stack);
   }
   return SetErrnoOnNull(MsanAllocate(stack, size, alignment, false));
 }
@@ -380,7 +387,8 @@ void *msan_memalign(uptr alignment, uptr size, StackTrace 
*stack) {
 errno = errno_EINVAL;
 if (AllocatorMayReturnNull())
   return nullptr;
-ReportInvalidAllocationAlignment(alignment, stack);
+GET_FATAL_STACK_TRACE;
+ReportInvalidAllocationAlignment(alignment, &stack);
   }
   return SetErrnoOnNull(MsanAllocate(stack, size, alignment, false));
 }
@@ -390,7 +398,8 @@ int msan_posix_memalign(void **memptr, uptr alignment, uptr 
size,
   if (UNLIKELY(!CheckPosixMemalignAlignment(alignment))) {
 if (AllocatorMayReturnNull())
   return errno_EINVAL;
-ReportInvalidPosixMemalignAlignment(alignment, stack);
+GET_FATAL_STA

[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)

2024-01-08 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)

2024-01-08 Thread Michael Buch via lldb-commits


@@ -1084,3 +1084,43 @@ bool 
lldb_private::formatters::LibcxxWStringViewSummaryProvider(
   return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
 dataobj, size);
 }
+
+bool lldb_private::formatters::LibcxxChronoMonthSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  // These are the names used in the C++20 ostream operator. Since LLVM uses
+  // C++17 it's not possible to use the ostream operator directly.
+  static const std::array months = {
+  "January", "February", "March", "April",   "May",  "June",
+  "July","August",   "September", "October", "November", "December"};
+
+  unsigned month = 
valobj.GetChildMemberWithName("__m_")->GetValueAsUnsigned(0);
+  if (month >= 1 && month <= 12)
+stream << "month=" << months[month - 1];
+  else
+stream.Printf("month=%u", month);
+
+  return true;
+}
+
+bool lldb_private::formatters::LibcxxChronoYearMonthDaySummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+
+  stream << "date=";
+  int year = valobj.GetChildMemberWithName("__y_")
+ ->GetChildMemberWithName("__y_")
+ ->GetValueAsSigned(0);
+  if (year < 0) {
+stream << '-';
+year = -year;
+  }
+
+  unsigned month = valobj.GetChildMemberWithName("__m_")

Michael137 wrote:

```suggestion
  const unsigned month = valobj.GetChildMemberWithName("__m_")
```

nullptr check question from above also applies here

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


[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)

2024-01-08 Thread Michael Buch via lldb-commits


@@ -1084,3 +1084,43 @@ bool 
lldb_private::formatters::LibcxxWStringViewSummaryProvider(
   return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
 dataobj, size);
 }
+
+bool lldb_private::formatters::LibcxxChronoMonthSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  // These are the names used in the C++20 ostream operator. Since LLVM uses
+  // C++17 it's not possible to use the ostream operator directly.

Michael137 wrote:

Should we FIXME this?

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


[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)

2024-01-08 Thread Michael Buch via lldb-commits

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

(sorry had the review comments pending but didn't click the `Submit review` 
button)

LGTM

Just left some minor comments



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


[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)

2024-01-08 Thread Michael Buch via lldb-commits


@@ -1084,3 +1084,43 @@ bool 
lldb_private::formatters::LibcxxWStringViewSummaryProvider(
   return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
 dataobj, size);
 }
+
+bool lldb_private::formatters::LibcxxChronoMonthSummaryProvider(
+ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+  // These are the names used in the C++20 ostream operator. Since LLVM uses
+  // C++17 it's not possible to use the ostream operator directly.
+  static const std::array months = {
+  "January", "February", "March", "April",   "May",  "June",
+  "July","August",   "September", "October", "November", "December"};
+
+  unsigned month = 
valobj.GetChildMemberWithName("__m_")->GetValueAsUnsigned(0);

Michael137 wrote:

```suggestion
  const unsigned month = 
valobj.GetChildMemberWithName("__m_")->GetValueAsUnsigned(0);
```

Also we should probably check that `GetChildMemberWithName` returns a valid 
pointer

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


[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)

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

https://github.com/bulbazord commented:

I don't have a lot of knowledge about the C++20 calendar types, but the LLDB 
implementation looks ok to me.

What do you think @Michael137?

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


[Lldb-commits] [libc] [clang-tools-extra] [openmp] [flang] [compiler-rt] [polly] [llvm] [libcxxabi] [mlir] [clang] [lldb] [libcxx] [OpenMP] Patch for Support to loop bind clause : Checking Parent Regi

2024-01-08 Thread Alexey Bataev via lldb-commits

https://github.com/alexey-bataev approved this pull request.

LG

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


[Lldb-commits] [clang] [compiler-rt] [libcxx] [polly] [llvm] [flang] [libcxxabi] [mlir] [lldb] [openmp] [libc] [clang-tools-extra] [OpenMP] Patch for Support to loop bind clause : Checking Parent Regi

2024-01-08 Thread via lldb-commits

https://github.com/SunilKuravinakop updated 
https://github.com/llvm/llvm-project/pull/76938

>From 1dcd4703002acdde370a285089008e409043717b Mon Sep 17 00:00:00 2001
From: Sunil Kuravinakop 
Date: Thu, 4 Jan 2024 04:08:28 -0600
Subject: [PATCH 1/4] Changes uploaded to the phabricator on Dec 16th are lost
 because the phabricator is down. Hence re-uploading it to the github.com.

  Changes to be committed:
modified:   clang/include/clang/Sema/Sema.h
modified:   clang/lib/Sema/SemaOpenMP.cpp
modified:   clang/test/OpenMP/generic_loop_ast_print.cpp
modified:   clang/test/OpenMP/loop_bind_messages.cpp
modified:   clang/test/PCH/pragma-loop.cpp
---
 clang/include/clang/Sema/Sema.h  |   8 +-
 clang/lib/Sema/SemaOpenMP.cpp|  62 ---
 clang/test/OpenMP/generic_loop_ast_print.cpp |   4 +-
 clang/test/OpenMP/loop_bind_messages.cpp | 180 +--
 clang/test/PCH/pragma-loop.cpp   |   8 +-
 5 files changed, 226 insertions(+), 36 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 5e3b57ea33220b..3d8d94d200ac58 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11335,6 +11335,7 @@ class Sema final {
   /// on the parameter of the bind clause. In the methods for the
   /// mapped directives, check the parameters of the lastprivate clause.
   bool checkLastPrivateForMappedDirectives(ArrayRef Clauses);
+
   /// Depending on the bind clause of OMPD_loop map the directive to new
   /// directives.
   ///1) loop bind(parallel) --> OMPD_for
@@ -11344,9 +11345,12 @@ class Sema final {
   /// rigorous semantic checking in the new mapped directives.
   bool mapLoopConstruct(llvm::SmallVector &ClausesWithoutBind,
 ArrayRef Clauses,
-OpenMPBindClauseKind BindKind,
+OpenMPBindClauseKind &BindKind,
 OpenMPDirectiveKind &Kind,
-OpenMPDirectiveKind &PrevMappedDirective);
+OpenMPDirectiveKind &PrevMappedDirective,
+SourceLocation StartLoc, SourceLocation EndLoc,
+const DeclarationNameInfo &DirName,
+OpenMPDirectiveKind CancelRegion);
 
 public:
   /// The declarator \p D defines a function in the scope \p S which is nested
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index f34d2959dc6191..6e060e5b8ee268 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -5072,6 +5072,18 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 CurrentRegion != OMPD_cancellation_point &&
 CurrentRegion != OMPD_cancel && CurrentRegion != OMPD_scan)
   return false;
+// Checks needed for mapping "loop" construct. Please check 
mapLoopConstruct
+// for a detailed explanation
+if (SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion == OMPD_loop &&
+((BindKind == OMPC_BIND_parallel) || (BindKind == OMPC_BIND_teams)) &&
+(isOpenMPWorksharingDirective(ParentRegion) ||
+ ParentRegion == OMPD_loop)) {
+  int ErrorMsgNumber = (BindKind == OMPC_BIND_parallel) ? 1 : 4;
+  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
+  << true << getOpenMPDirectiveName(ParentRegion) << ErrorMsgNumber
+  << getOpenMPDirectiveName(CurrentRegion);
+  return true;
+}
 if (CurrentRegion == OMPD_cancellation_point ||
 CurrentRegion == OMPD_cancel) {
   // OpenMP [2.16, Nesting of Regions]
@@ -6124,35 +6136,36 @@ processImplicitMapsWithDefaultMappers(Sema &S, 
DSAStackTy *Stack,
 
 bool Sema::mapLoopConstruct(llvm::SmallVector &ClausesWithoutBind,
 ArrayRef Clauses,
-OpenMPBindClauseKind BindKind,
+OpenMPBindClauseKind &BindKind,
 OpenMPDirectiveKind &Kind,
-OpenMPDirectiveKind &PrevMappedDirective) {
+OpenMPDirectiveKind &PrevMappedDirective,
+SourceLocation StartLoc, SourceLocation EndLoc,
+const DeclarationNameInfo &DirName,
+OpenMPDirectiveKind CancelRegion) {
 
   bool UseClausesWithoutBind = false;
 
   // Restricting to "#pragma omp loop bind"
   if (getLangOpts().OpenMP >= 50 && Kind == OMPD_loop) {
+
+const OpenMPDirectiveKind ParentDirective = DSAStack->getParentDirective();
+
 if (BindKind == OMPC_BIND_unknown) {
   // Setting the enclosing teams or parallel construct for the loop
   // directive without bind clause.
   BindKind = OMPC_BIND_thread; // Default bind(thread) if binding is 
unknown
 
-  const OpenMPDirectiveKind ParentDirective =
-  DSAStack->getParentDirective();
   if (ParentDirective == OMPD_unkno

[Lldb-commits] [lldb] [lldb][NFCI] Change return type of BreakpointIDList::GetBreakpointIDAtIndex (PR #77166)

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

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


[Lldb-commits] [lldb] 5cbf74b - [lldb][NFCI] Change return type of BreakpointIDList::GetBreakpointIDAtIndex (#77166)

2024-01-08 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-08T10:52:00-08:00
New Revision: 5cbf74b012c10e9cc841a27cd5d7335e556f47dd

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

LOG: [lldb][NFCI] Change return type of 
BreakpointIDList::GetBreakpointIDAtIndex (#77166)

There are 2 motivations here:
1.) There is no need to hand out constant references to BreakpointIDs,
they are only 8 bytes big. In addition, every use of this method already
  makes a copy anyway.
2.) Each BreakpointIDList held onto an invalid BreakpointID specifically
to
  prevent lifetime issues. Returning a value means you can return an
  invalid BreakpointID instead of needing to allocate storage for an
  invalid BreakpointID.

Added: 


Modified: 
lldb/include/lldb/Breakpoint/BreakpointIDList.h
lldb/source/Breakpoint/BreakpointIDList.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/BreakpointIDList.h 
b/lldb/include/lldb/Breakpoint/BreakpointIDList.h
index 161d1a2d314ead..6910024695d898 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointIDList.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointIDList.h
@@ -33,7 +33,7 @@ class BreakpointIDList {
 
   size_t GetSize() const;
 
-  const BreakpointID &GetBreakpointIDAtIndex(size_t index) const;
+  BreakpointID GetBreakpointIDAtIndex(size_t index) const;
 
   bool RemoveBreakpointIDAtIndex(size_t index);
 
@@ -63,7 +63,6 @@ class BreakpointIDList {
 
 private:
   BreakpointIDArray m_breakpoint_ids;
-  BreakpointID m_invalid_id;
 
   BreakpointIDList(const BreakpointIDList &) = delete;
   const BreakpointIDList &operator=(const BreakpointIDList &) = delete;

diff  --git a/lldb/source/Breakpoint/BreakpointIDList.cpp 
b/lldb/source/Breakpoint/BreakpointIDList.cpp
index c4fdbc370b223d..05c461827cadd8 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -20,17 +20,15 @@ using namespace lldb_private;
 
 // class BreakpointIDList
 
-BreakpointIDList::BreakpointIDList()
-: m_invalid_id(LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID) {}
+BreakpointIDList::BreakpointIDList() : m_breakpoint_ids() {}
 
 BreakpointIDList::~BreakpointIDList() = default;
 
 size_t BreakpointIDList::GetSize() const { return m_breakpoint_ids.size(); }
 
-const BreakpointID &
-BreakpointIDList::GetBreakpointIDAtIndex(size_t index) const {
+BreakpointID BreakpointIDList::GetBreakpointIDAtIndex(size_t index) const {
   return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index]
-: m_invalid_id);
+: BreakpointID());
 }
 
 bool BreakpointIDList::RemoveBreakpointIDAtIndex(size_t index) {



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


[Lldb-commits] [lldb] [lldb][NFCI] Remove BreakpointIDList::InsertStringArray (PR #77161)

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

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


[Lldb-commits] [lldb] 07d6fbf - [lldb][NFCI] Remove BreakpointIDList::InsertStringArray (#77161)

2024-01-08 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-08T10:51:00-08:00
New Revision: 07d6fbf8d80083470b4371f2ddabd656a9c317e6

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

LOG: [lldb][NFCI] Remove BreakpointIDList::InsertStringArray (#77161)

This abstraction is leaky and BreakpointIDList does not need to know
about CommandReturnObject.
Additionally, setting the CommandReturnObject inout param to a success
state does very little. The function returns immediately if the input
ArrayRef is empty, and reading
CommandObjectMultiwordBreakpoint::VerifyIDs more closely, the input is
always empty if the previous call to
BreakpointIDList::FindAndReplaceIDRanges failed. If the call was
successful, then the CommandReturnObject is already in a success state.

I have opted to remove the function altogether and inline the
functionality where it was used.

Added: 


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

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/BreakpointIDList.h 
b/lldb/include/lldb/Breakpoint/BreakpointIDList.h
index 924cb1f26b8b8a..161d1a2d314ead 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointIDList.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointIDList.h
@@ -48,9 +48,6 @@ class BreakpointIDList {
 
   bool FindBreakpointID(const char *bp_id, size_t *position) const;
 
-  void InsertStringArray(llvm::ArrayRef string_array,
- CommandReturnObject &result);
-
   // Returns a pair consisting of the beginning and end of a breakpoint
   // ID range expression.  If the input string is not a valid specification,
   // returns an empty pair.

diff  --git a/lldb/source/Breakpoint/BreakpointIDList.cpp 
b/lldb/source/Breakpoint/BreakpointIDList.cpp
index dd16d3b6388c46..c4fdbc370b223d 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -82,19 +82,6 @@ bool BreakpointIDList::FindBreakpointID(const char 
*bp_id_str,
   return FindBreakpointID(*bp_id, position);
 }
 
-void BreakpointIDList::InsertStringArray(
-llvm::ArrayRef string_array, CommandReturnObject &result) {
-  if(string_array.empty())
-return;
-
-  for (const char *str : string_array) {
-auto bp_id = BreakpointID::ParseCanonicalReference(str);
-if (bp_id)
-  m_breakpoint_ids.push_back(*bp_id);
-  }
-  result.SetStatus(eReturnStatusSuccessFinishNoResult);
-}
-
 //  This function takes OLD_ARGS, which is usually the result of breaking the
 //  command string arguments into
 //  an array of space-separated strings, and searches through the arguments for

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp 
b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 63492590d32d66..f9ba68eda3ff1f 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -2494,7 +2494,9 @@ void CommandObjectMultiwordBreakpoint::VerifyIDs(
   // NOW, convert the list of breakpoint id strings in TEMP_ARGS into an actual
   // BreakpointIDList:
 
-  valid_ids->InsertStringArray(temp_args.GetArgumentArrayRef(), result);
+  for (llvm::StringRef temp_arg : temp_args.GetArgumentArrayRef())
+if (auto bp_id = BreakpointID::ParseCanonicalReference(temp_arg))
+  valid_ids->AddBreakpointID(*bp_id);
 
   // At this point,  all of the breakpoint ids that the user passed in have
   // been converted to breakpoint IDs and put into valid_ids.



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


[Lldb-commits] [lldb] [lldb][NFCI] Change return type of BreakpointIDList::GetBreakpointIDAtIndex (PR #77166)

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


@@ -20,17 +20,15 @@ using namespace lldb_private;
 
 // class BreakpointIDList
 
-BreakpointIDList::BreakpointIDList()
-: m_invalid_id(LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID) {}
+BreakpointIDList::BreakpointIDList() : m_breakpoint_ids() {}
 
 BreakpointIDList::~BreakpointIDList() = default;
 
 size_t BreakpointIDList::GetSize() const { return m_breakpoint_ids.size(); }
 
-const BreakpointID &
-BreakpointIDList::GetBreakpointIDAtIndex(size_t index) const {
+BreakpointID BreakpointIDList::GetBreakpointIDAtIndex(size_t index) const {
   return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index]
-: m_invalid_id);
+: BreakpointID());

bulbazord wrote:

The default constructor for `BreakpointID` sets the breakpoint id and location 
id to invalid values.

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


[Lldb-commits] [lldb] [lldb][NFCI] Remove BreakpointIDList::InsertStringArray (PR #77161)

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

bulbazord wrote:

> LGTM!
> 
> I see that we still have `FindAndReplaceIDRanges` referencing 
> CommandReturnObject; out of curiosity, have you had a chance to look into 
> removing that one (if it makes sense)? I see that `CommandReturnObject` is 
> neither `#include`ed nor forward declared in the header, so the code is very 
> much relying on others files to do either of those.

Yes, I planned on doing that in a follow-up. :)

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


[Lldb-commits] [lldb] [lldb][[DWARFDeclContext] Add function to extract qualified names as vector (PR #77349)

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

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

>From 1b444a334fdfd5c88e263e9804cffbd7574a670b Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan 
Date: Mon, 11 Dec 2023 12:42:40 -0300
Subject: [PATCH 1/2] [lldb][[DWARFDeclContext] Add function to extract
 qualified names as vector

This functionality will support the efforts to implement the IDX_Parent
attribute of accelerator table entries, and it will allow us to more easily
compare each of the names in a DIE parent chain hierarchy.
---
 .../SymbolFile/DWARF/DWARFDeclContext.cpp |   6 +
 .../SymbolFile/DWARF/DWARFDeclContext.h   |   5 +
 .../SymbolFile/DWARF/DWARFDIETest.cpp | 109 ++
 3 files changed, 120 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
index 44421c0eda3eec..3cdb47d50bbfc0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
@@ -55,6 +55,12 @@ const char *DWARFDeclContext::GetQualifiedName() const {
   return m_qualified_name.c_str();
 }
 
+llvm::SmallVector
+DWARFDeclContext::GetQualifiedNameAsVector() const {
+  return llvm::to_vector_of(
+  llvm::map_range(m_entries, GetName));
+}
+
 bool DWARFDeclContext::operator==(const DWARFDeclContext &rhs) const {
   if (m_entries.size() != rhs.m_entries.size())
 return false;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
index a20a862d340296..40ebb72c91d8f0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
@@ -68,6 +68,11 @@ class DWARFDeclContext {
 
   const char *GetQualifiedName() const;
 
+  /// Returns a vector of string, one string per entry in the fully qualified
+  /// name. For example, for the name `A::B::C`, this methods returns `{"A",
+  /// "B", "C"}`
+  llvm::SmallVector GetQualifiedNameAsVector() const;
+
   // Same as GetQualifiedName, but the life time of the returned string will
   // be that of the LLDB session.
   ConstString GetQualifiedNameAsConstString() const {
diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
index 8497855b2f3db5..5672270ee31f89 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -7,8 +7,10 @@
 
//===--===//
 
 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h"
 #include "TestingSupport/Symbol/YAMLModuleTester.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -104,3 +106,110 @@ TEST(DWARFDIETest, ChildIteration) {
   DWARFDIE no_children_die(unit, die_child0);
   EXPECT_TRUE(no_children_die.children().empty());
 }
+
+TEST(DWARFDIETest, DeclContext) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'mynamespace'
+- 'mystruct'
+- 'mytype'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_language
+  Form:DW_FORM_data2
+- Code:0x0002
+  Tag: DW_TAG_structure_type
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x0003
+  Tag: DW_TAG_base_type
+  Children:DW_CHILDREN_no
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+- Code:0x0004
+  Tag: DW_TAG_namespace
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_name
+  Form:DW_FORM_strp
+  debug_info:
+- Version: 4
+  AddrSize:8
+  Entries:
+- AbbrCode:0x0001 # compile_unit
+  Values:
+- Value:   0x000C
+- AbbrCode:0x0004 # namespace
+  Values:
+- Value:   0x # DW_ATE_strp
+- AbbrCode:0x0002 # structure_type
+  Values:
+- Value:   0x000c # DW_ATE_strp
+- AbbrCode:0x0003 # base_type
+  Values:
+- Value:   0x0015 # DW_ATE_strp
+- AbbrCode:0x
+)";
+
+  YAMLModu

[Lldb-commits] [lldb] [lldb][[DWARFDeclContext] Add function to extract qualified names as vector (PR #77349)

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


@@ -68,6 +68,11 @@ class DWARFDeclContext {
 
   const char *GetQualifiedName() const;
 
+  /// Returns a vector of string, one string per entry in the fully qualified
+  /// name. For example, for the name `A::B::C`, this methods returns `{"A",
+  /// "B", "C"}`
+  llvm::SmallVector GetQualifiedNameAsVector() const;

felipepiovezan wrote:

Oops, this comment is wrong: the order of the strings is reversed here.

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


  1   2   >