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

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


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

arsenm wrote:

PseudoSourceValue::mayAlias is supposed to report aliasing to possible IR 
values. It looks like it's layered weirdly, and expects you to go through 
MachineInstr::mayAlias. MachineInstr::mayAlias ought to be using the AA tags, 
it shouldn't be a fundamental limitation 

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


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

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


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

arsenm wrote:

It looks to me like it does use it if you pass UseTBAA=true. Not sure why this 
would be a parameter in the first place 

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


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

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


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

arsenm wrote:

The values don't need to be identical, that's the point of the AA query. 
BasicAA will parse through the offsets 

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


[Lldb-commits] [lldb] [lldb][NFC] Fix compilation issue on windows (PR #76453)

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

DavidSpickett wrote:

Our Windows bot actually uses clang-cl, I assume msvc is checking the calling 
convention here.

Going by https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170, it 
should be stdcall and WINAPI is just stdcall 
(https://learn.microsoft.com/en-us/office/client-developer/excel/developing-dlls?redirectedfrom=MSDN#exporting-functions-and-commands).

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


[Lldb-commits] [lldb] [lldb][NFC] Fix compilation issue on windows (PR #76453)

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

DavidSpickett wrote:

Please update `lldb/unittests/Thread/ThreadTest.cpp` as well.

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


[Lldb-commits] [lldb] 54378a7 - [lldb][Windows] Fix -Wmissing-field-initializers warnings after 54981bb75d374 (#76255)

2024-01-03 Thread via lldb-commits

Author: Nico Weber
Date: 2024-01-03T10:12:30Z
New Revision: 54378a7c2fd7f0ed0a3ea7ef08bc24896700e2c5

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

LOG: [lldb][Windows] Fix -Wmissing-field-initializers warnings after 
54981bb75d374 (#76255)

Added: 


Modified: 

lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp 
b/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
index 5c4f80b97009a3..fee485b7599ca0 100644
--- 
a/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ 
b/lldb/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -29,7 +29,7 @@ using namespace lldb_private;
   #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase, 
\
   {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, generic,
\
 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 },
\
-nullptr, nullptr,  
\
+nullptr, nullptr, nullptr, 
\
 }
 
 #define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
@@ -37,14 +37,14 @@ using namespace lldb_private;
   #reg, NULL, 16, 0, eEncodingUint, eFormatVectorOfUInt64, 
\
   {dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM,
\
LLDB_INVALID_REGNUM, lldb_##reg##_x86_64},  
\
-  nullptr, nullptr
+  nullptr, nullptr, nullptr,
 
 #define DEFINE_GPR_PSEUDO_32(reg)  
\
 {  
\
   #reg, nullptr, 4, 0, eEncodingUint, eFormatHexUppercase, 
\
   {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,  
\
 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 },
\
-nullptr, nullptr   
\
+nullptr, nullptr, nullptr, 
\
 }
 
 #define DEFINE_GPR_PSEUDO_16(reg)  
\
@@ -52,7 +52,7 @@ using namespace lldb_private;
   #reg, nullptr, 2, 0, eEncodingUint, eFormatHexUppercase, 
\
   {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,  
\
 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 },
\
-nullptr, nullptr   
\
+nullptr, nullptr, nullptr, 
\
 }
 
 #define DEFINE_GPR_PSEUDO_8(reg)   
\
@@ -60,7 +60,7 @@ using namespace lldb_private;
   #reg, nullptr, 1, 0, eEncodingUint, eFormatHexUppercase, 
\
   {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,  
\
 LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 },
\
-nullptr, nullptr   
\
+nullptr, nullptr, nullptr, 
\
 }
 
 namespace {



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


[Lldb-commits] [lldb] [lldb/win] Fix -Wmissing-field-initializers warnings after 54981bb75d374 (PR #76255)

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

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


[Lldb-commits] [lldb] [lldb/win] Fix -Wmissing-field-initializers warnings after 54981bb75d374 (PR #76255)

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

DavidSpickett wrote:

Thanks for the fix! Ignoring clang-format as it would obscure the intent of the 
change.

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


[Lldb-commits] [lldb] [clang-tools-extra] [flang] [clang] [libc] [llvm] [compiler-rt] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits

yi-wu-arm wrote:

Hi @klausler , any thought of this patch? Thank in advance!

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


[Lldb-commits] [lldb] 43a5c4a - [lldb][test] Skip other Global Module Cache tests on Arm/AArch64 Linux

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

Author: David Spickett
Date: 2024-01-03T11:24:58Z
New Revision: 43a5c4a10d19e7ecca4232966495aabc4e901559

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

LOG: [lldb][test] Skip other Global Module Cache tests on Arm/AArch64 Linux

These are expected to fail but sometimes crash during the test leaving them
as unresolved.

Same failure message and likely same cause as the other test in this file.

Added: 


Modified: 
lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py

Removed: 




diff  --git 
a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py 
b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
index 5b6e9e8a588a39..1264df61f2be47 100644
--- a/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
+++ b/lldb/test/API/python_api/global_module_cache/TestGlobalModuleCache.py
@@ -52,11 +52,13 @@ def test_OneTargetOneDebugger(self):
 # This test tests for the desired behavior as an expected fail.
 @skipIfWindows
 @expectedFailureAll
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
 def test_TwoTargetsOneDebugger(self):
 self.do_test(False, True)
 
 @skipIfWindows
 @expectedFailureAll
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
 def test_OneTargetTwoDebuggers(self):
 self.do_test(True, False)
 



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


[Lldb-commits] [lldb] [polly] [libcxx] [openmp] [libcxxabi] [mlir] [compiler-rt] [clang] [llvm] [clang-tools-extra] [libc] [flang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-03 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph approved this pull request.


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


[Lldb-commits] [lldb] [polly] [compiler-rt] [llvm] [libc] [libcxx] [clang-tools-extra] [openmp] [libcxxabi] [flang] [mlir] [clang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-03 Thread Rik Huijzer via lldb-commits

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


[Lldb-commits] [lldb] [polly] [compiler-rt] [llvm] [libc] [libcxx] [clang-tools-extra] [openmp] [libcxxabi] [flang] [mlir] [clang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-03 Thread Rik Huijzer via lldb-commits

rikhuijzer wrote:

@joker-eph, thanks again for the review!

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


[Lldb-commits] [clang-tools-extra] [lldb] [clang] [llvm] [libc] [compiler-rt] [flang] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-03 Thread Thorsten Schütt via lldb-commits

https://github.com/tschuett updated 
https://github.com/llvm/llvm-project/pull/76763

From e713bb6e2c36ec16c731217f0c3be19b040a03d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Sch=C3=BCtt?= 
Date: Tue, 2 Jan 2024 18:00:45 +0100
Subject: [PATCH] [GlobalIsel] Combine select of binops

---
 .../llvm/CodeGen/GlobalISel/CombinerHelper.h  |   3 +
 .../CodeGen/GlobalISel/GenericMachineInstrs.h | 103 ++
 .../lib/CodeGen/GlobalISel/CombinerHelper.cpp |  91 +++-
 .../AArch64/GlobalISel/combine-select.mir |  74 +
 4 files changed, 243 insertions(+), 28 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h 
b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index dcc1a4580b14a2..f3b68623596c46 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -910,6 +910,9 @@ class CombinerHelper {
 
   bool tryFoldSelectOfConstants(GSelect *Select, BuildFnTy &MatchInfo);
 
+  /// Try to fold select(cc, binop(), binop()) -> binop(select(), X)
+  bool tryFoldSelectOfBinOps(GSelect *Select, BuildFnTy &MatchInfo);
+
   bool isOneOrOneSplat(Register Src, bool AllowUndefs);
   bool isZeroOrZeroSplat(Register Src, bool AllowUndefs);
   bool isConstantSplatVector(Register Src, int64_t SplatValue,
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h 
b/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
index 6ab1d4550c51ca..21d98d30356c93 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
@@ -558,6 +558,109 @@ class GVecReduce : public GenericMachineInstr {
   }
 };
 
+// Represents a binary operation, i.e, x = y op z.
+class GBinOp : public GenericMachineInstr {
+public:
+  Register getLHSReg() const { return getReg(1); }
+  Register getRHSReg() const { return getReg(2); }
+
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+// Integer.
+case TargetOpcode::G_ADD:
+case TargetOpcode::G_SUB:
+case TargetOpcode::G_MUL:
+case TargetOpcode::G_SDIV:
+case TargetOpcode::G_UDIV:
+case TargetOpcode::G_SREM:
+case TargetOpcode::G_UREM:
+case TargetOpcode::G_SMIN:
+case TargetOpcode::G_SMAX:
+case TargetOpcode::G_UMIN:
+case TargetOpcode::G_UMAX:
+// Floating point.
+case TargetOpcode::G_FMINNUM:
+case TargetOpcode::G_FMAXNUM:
+case TargetOpcode::G_FMINNUM_IEEE:
+case TargetOpcode::G_FMAXNUM_IEEE:
+case TargetOpcode::G_FMINIMUM:
+case TargetOpcode::G_FMAXIMUM:
+case TargetOpcode::G_FADD:
+case TargetOpcode::G_FSUB:
+case TargetOpcode::G_FMUL:
+case TargetOpcode::G_FDIV:
+case TargetOpcode::G_FPOW:
+// Logical.
+case TargetOpcode::G_AND:
+case TargetOpcode::G_OR:
+case TargetOpcode::G_XOR:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents an integer binary operation.
+class GIntBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_ADD:
+case TargetOpcode::G_SUB:
+case TargetOpcode::G_MUL:
+case TargetOpcode::G_SDIV:
+case TargetOpcode::G_UDIV:
+case TargetOpcode::G_SREM:
+case TargetOpcode::G_UREM:
+case TargetOpcode::G_SMIN:
+case TargetOpcode::G_SMAX:
+case TargetOpcode::G_UMIN:
+case TargetOpcode::G_UMAX:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents a floating point binary operation.
+class GFBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_FMINNUM:
+case TargetOpcode::G_FMAXNUM:
+case TargetOpcode::G_FMINNUM_IEEE:
+case TargetOpcode::G_FMAXNUM_IEEE:
+case TargetOpcode::G_FMINIMUM:
+case TargetOpcode::G_FMAXIMUM:
+case TargetOpcode::G_FADD:
+case TargetOpcode::G_FSUB:
+case TargetOpcode::G_FMUL:
+case TargetOpcode::G_FDIV:
+case TargetOpcode::G_FPOW:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents a logical binary operation.
+class GLogicalBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_AND:
+case TargetOpcode::G_OR:
+case TargetOpcode::G_XOR:
+  return true;
+default:
+  return false;
+}
+  };
+};
 
 } // namespace llvm
 
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp 
b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 8b15bdb0aca30b..102b49c48460b1 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -6390,8 +6390,7 @@ bool CombinerHelper::tryFoldSelectOfConstants(GSelect 
*Select,
   if (TrueValue.isZero() && FalseValue.isOne()) {
 MatchInfo = [=](MachineIRBuil

[Lldb-commits] [clang-tools-extra] [lldb] [clang] [llvm] [libc] [compiler-rt] [flang] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-03 Thread Thorsten Schütt via lldb-commits

https://github.com/tschuett updated 
https://github.com/llvm/llvm-project/pull/76763

From e713bb6e2c36ec16c731217f0c3be19b040a03d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Sch=C3=BCtt?= 
Date: Tue, 2 Jan 2024 18:00:45 +0100
Subject: [PATCH 1/3] [GlobalIsel] Combine select of binops

---
 .../llvm/CodeGen/GlobalISel/CombinerHelper.h  |   3 +
 .../CodeGen/GlobalISel/GenericMachineInstrs.h | 103 ++
 .../lib/CodeGen/GlobalISel/CombinerHelper.cpp |  91 +++-
 .../AArch64/GlobalISel/combine-select.mir |  74 +
 4 files changed, 243 insertions(+), 28 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h 
b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index dcc1a4580b14a2..f3b68623596c46 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -910,6 +910,9 @@ class CombinerHelper {
 
   bool tryFoldSelectOfConstants(GSelect *Select, BuildFnTy &MatchInfo);
 
+  /// Try to fold select(cc, binop(), binop()) -> binop(select(), X)
+  bool tryFoldSelectOfBinOps(GSelect *Select, BuildFnTy &MatchInfo);
+
   bool isOneOrOneSplat(Register Src, bool AllowUndefs);
   bool isZeroOrZeroSplat(Register Src, bool AllowUndefs);
   bool isConstantSplatVector(Register Src, int64_t SplatValue,
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h 
b/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
index 6ab1d4550c51ca..21d98d30356c93 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
@@ -558,6 +558,109 @@ class GVecReduce : public GenericMachineInstr {
   }
 };
 
+// Represents a binary operation, i.e, x = y op z.
+class GBinOp : public GenericMachineInstr {
+public:
+  Register getLHSReg() const { return getReg(1); }
+  Register getRHSReg() const { return getReg(2); }
+
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+// Integer.
+case TargetOpcode::G_ADD:
+case TargetOpcode::G_SUB:
+case TargetOpcode::G_MUL:
+case TargetOpcode::G_SDIV:
+case TargetOpcode::G_UDIV:
+case TargetOpcode::G_SREM:
+case TargetOpcode::G_UREM:
+case TargetOpcode::G_SMIN:
+case TargetOpcode::G_SMAX:
+case TargetOpcode::G_UMIN:
+case TargetOpcode::G_UMAX:
+// Floating point.
+case TargetOpcode::G_FMINNUM:
+case TargetOpcode::G_FMAXNUM:
+case TargetOpcode::G_FMINNUM_IEEE:
+case TargetOpcode::G_FMAXNUM_IEEE:
+case TargetOpcode::G_FMINIMUM:
+case TargetOpcode::G_FMAXIMUM:
+case TargetOpcode::G_FADD:
+case TargetOpcode::G_FSUB:
+case TargetOpcode::G_FMUL:
+case TargetOpcode::G_FDIV:
+case TargetOpcode::G_FPOW:
+// Logical.
+case TargetOpcode::G_AND:
+case TargetOpcode::G_OR:
+case TargetOpcode::G_XOR:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents an integer binary operation.
+class GIntBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_ADD:
+case TargetOpcode::G_SUB:
+case TargetOpcode::G_MUL:
+case TargetOpcode::G_SDIV:
+case TargetOpcode::G_UDIV:
+case TargetOpcode::G_SREM:
+case TargetOpcode::G_UREM:
+case TargetOpcode::G_SMIN:
+case TargetOpcode::G_SMAX:
+case TargetOpcode::G_UMIN:
+case TargetOpcode::G_UMAX:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents a floating point binary operation.
+class GFBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_FMINNUM:
+case TargetOpcode::G_FMAXNUM:
+case TargetOpcode::G_FMINNUM_IEEE:
+case TargetOpcode::G_FMAXNUM_IEEE:
+case TargetOpcode::G_FMINIMUM:
+case TargetOpcode::G_FMAXIMUM:
+case TargetOpcode::G_FADD:
+case TargetOpcode::G_FSUB:
+case TargetOpcode::G_FMUL:
+case TargetOpcode::G_FDIV:
+case TargetOpcode::G_FPOW:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents a logical binary operation.
+class GLogicalBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_AND:
+case TargetOpcode::G_OR:
+case TargetOpcode::G_XOR:
+  return true;
+default:
+  return false;
+}
+  };
+};
 
 } // namespace llvm
 
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp 
b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 8b15bdb0aca30b..102b49c48460b1 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -6390,8 +6390,7 @@ bool CombinerHelper::tryFoldSelectOfConstants(GSelect 
*Select,
   if (TrueValue.isZero() && FalseValue.isOne()) {
 MatchInfo = [=](MachineIR

[Lldb-commits] [clang-tools-extra] [libc] [lldb] [mlir] [clang] [llvm] [lld] [libcxx] [compiler-rt] [flang] [openmp] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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

H-G-Hristov wrote:

> I did a full review. There are a number of comments, once these are addressed 
> the patch is ready.

Thank you for the detailed review and patience! 

I believe the failing tests are unrelated to this patch.

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


[Lldb-commits] [clang-tools-extra] [lldb] [clang] [llvm] [libc] [compiler-rt] [flang] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-03 Thread Thorsten Schütt via lldb-commits

tschuett wrote:

Please review changes (C++ and mir) regarding flag handling.

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


[Lldb-commits] [clang-tools-extra] [lldb] [clang] [llvm] [libc] [compiler-rt] [flang] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-03 Thread Thorsten Schütt via lldb-commits

https://github.com/tschuett updated 
https://github.com/llvm/llvm-project/pull/76763

From e713bb6e2c36ec16c731217f0c3be19b040a03d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Sch=C3=BCtt?= 
Date: Tue, 2 Jan 2024 18:00:45 +0100
Subject: [PATCH 1/4] [GlobalIsel] Combine select of binops

---
 .../llvm/CodeGen/GlobalISel/CombinerHelper.h  |   3 +
 .../CodeGen/GlobalISel/GenericMachineInstrs.h | 103 ++
 .../lib/CodeGen/GlobalISel/CombinerHelper.cpp |  91 +++-
 .../AArch64/GlobalISel/combine-select.mir |  74 +
 4 files changed, 243 insertions(+), 28 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h 
b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
index dcc1a4580b14a2..f3b68623596c46 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
@@ -910,6 +910,9 @@ class CombinerHelper {
 
   bool tryFoldSelectOfConstants(GSelect *Select, BuildFnTy &MatchInfo);
 
+  /// Try to fold select(cc, binop(), binop()) -> binop(select(), X)
+  bool tryFoldSelectOfBinOps(GSelect *Select, BuildFnTy &MatchInfo);
+
   bool isOneOrOneSplat(Register Src, bool AllowUndefs);
   bool isZeroOrZeroSplat(Register Src, bool AllowUndefs);
   bool isConstantSplatVector(Register Src, int64_t SplatValue,
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h 
b/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
index 6ab1d4550c51ca..21d98d30356c93 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
@@ -558,6 +558,109 @@ class GVecReduce : public GenericMachineInstr {
   }
 };
 
+// Represents a binary operation, i.e, x = y op z.
+class GBinOp : public GenericMachineInstr {
+public:
+  Register getLHSReg() const { return getReg(1); }
+  Register getRHSReg() const { return getReg(2); }
+
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+// Integer.
+case TargetOpcode::G_ADD:
+case TargetOpcode::G_SUB:
+case TargetOpcode::G_MUL:
+case TargetOpcode::G_SDIV:
+case TargetOpcode::G_UDIV:
+case TargetOpcode::G_SREM:
+case TargetOpcode::G_UREM:
+case TargetOpcode::G_SMIN:
+case TargetOpcode::G_SMAX:
+case TargetOpcode::G_UMIN:
+case TargetOpcode::G_UMAX:
+// Floating point.
+case TargetOpcode::G_FMINNUM:
+case TargetOpcode::G_FMAXNUM:
+case TargetOpcode::G_FMINNUM_IEEE:
+case TargetOpcode::G_FMAXNUM_IEEE:
+case TargetOpcode::G_FMINIMUM:
+case TargetOpcode::G_FMAXIMUM:
+case TargetOpcode::G_FADD:
+case TargetOpcode::G_FSUB:
+case TargetOpcode::G_FMUL:
+case TargetOpcode::G_FDIV:
+case TargetOpcode::G_FPOW:
+// Logical.
+case TargetOpcode::G_AND:
+case TargetOpcode::G_OR:
+case TargetOpcode::G_XOR:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents an integer binary operation.
+class GIntBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_ADD:
+case TargetOpcode::G_SUB:
+case TargetOpcode::G_MUL:
+case TargetOpcode::G_SDIV:
+case TargetOpcode::G_UDIV:
+case TargetOpcode::G_SREM:
+case TargetOpcode::G_UREM:
+case TargetOpcode::G_SMIN:
+case TargetOpcode::G_SMAX:
+case TargetOpcode::G_UMIN:
+case TargetOpcode::G_UMAX:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents a floating point binary operation.
+class GFBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_FMINNUM:
+case TargetOpcode::G_FMAXNUM:
+case TargetOpcode::G_FMINNUM_IEEE:
+case TargetOpcode::G_FMAXNUM_IEEE:
+case TargetOpcode::G_FMINIMUM:
+case TargetOpcode::G_FMAXIMUM:
+case TargetOpcode::G_FADD:
+case TargetOpcode::G_FSUB:
+case TargetOpcode::G_FMUL:
+case TargetOpcode::G_FDIV:
+case TargetOpcode::G_FPOW:
+  return true;
+default:
+  return false;
+}
+  };
+};
+
+// Represents a logical binary operation.
+class GLogicalBinOp : public GBinOp {
+public:
+  static bool classof(const MachineInstr *MI) {
+switch (MI->getOpcode()) {
+case TargetOpcode::G_AND:
+case TargetOpcode::G_OR:
+case TargetOpcode::G_XOR:
+  return true;
+default:
+  return false;
+}
+  };
+};
 
 } // namespace llvm
 
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp 
b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index 8b15bdb0aca30b..102b49c48460b1 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -6390,8 +6390,7 @@ bool CombinerHelper::tryFoldSelectOfConstants(GSelect 
*Select,
   if (TrueValue.isZero() && FalseValue.isOne()) {
 MatchInfo = [=](MachineIR

[Lldb-commits] [compiler-rt] [clang] [clang-tools-extra] [llvm] [libc] [flang] [lldb] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-03 Thread Thorsten Schütt via lldb-commits


@@ -6548,6 +6534,54 @@ bool CombinerHelper::tryFoldBoolSelectToLogic(GSelect 
*Select,
   return false;
 }
 
+bool CombinerHelper::tryFoldSelectOfBinOps(GSelect *Select,
+   BuildFnTy &MatchInfo) {
+  Register DstReg = Select->getReg(0);
+  Register Cond = Select->getCondReg();
+  Register False = Select->getFalseReg();
+  Register True = Select->getTrueReg();
+  LLT DstTy = MRI.getType(DstReg);
+
+  GBinOp *LHS = getOpcodeDef(True, MRI);
+  GBinOp *RHS = getOpcodeDef(False, MRI);
+
+  // We need two binops of the same kind on the true/false registers.
+  if (!LHS || !RHS || LHS->getOpcode() != RHS->getOpcode())
+return false;
+
+  // Note that there are no constraints on CondTy.
+  unsigned Flags = (LHS->getFlags() & RHS->getFlags()) | Select->getFlags();

tschuett wrote:

This line differs from the Dag combiner.

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


[Lldb-commits] [compiler-rt] [clang] [clang-tools-extra] [llvm] [libc] [flang] [lldb] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-03 Thread Thorsten Schütt via lldb-commits


@@ -6548,6 +6534,54 @@ bool CombinerHelper::tryFoldBoolSelectToLogic(GSelect 
*Select,
   return false;
 }
 
+bool CombinerHelper::tryFoldSelectOfBinOps(GSelect *Select,
+   BuildFnTy &MatchInfo) {
+  Register DstReg = Select->getReg(0);
+  Register Cond = Select->getCondReg();
+  Register False = Select->getFalseReg();
+  Register True = Select->getTrueReg();
+  LLT DstTy = MRI.getType(DstReg);
+
+  GBinOp *LHS = getOpcodeDef(True, MRI);
+  GBinOp *RHS = getOpcodeDef(False, MRI);
+
+  // We need two binops of the same kind on the true/false registers.
+  if (!LHS || !RHS || LHS->getOpcode() != RHS->getOpcode())
+return false;
+
+  // Note that there are no constraints on CondTy.
+  unsigned Flags = (LHS->getFlags() & RHS->getFlags()) | Select->getFlags();
+  unsigned Opcode = LHS->getOpcode();
+
+  // Fold select(cond, binop(x, y), binop(z, y))
+  //  --> binop(select(cond, x, z), y)
+  if (LHS->getRHSReg() == RHS->getRHSReg()) {
+MatchInfo = [=](MachineIRBuilder &B) {
+  B.setInstrAndDebugLoc(*Select);
+  auto Sel = B.buildSelect(DstTy, Cond, LHS->getLHSReg(), RHS->getLHSReg(),
+   Select->getFlags());

tschuett wrote:

And Flags are added to selects.

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


[Lldb-commits] [compiler-rt] [clang] [clang-tools-extra] [llvm] [libc] [flang] [lldb] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-03 Thread Thorsten Schütt via lldb-commits


@@ -544,3 +544,154 @@ body: |
 %ext:_(s32) = G_ANYEXT %sel
 $w0 = COPY %ext(s32)
 ...
+---
+# select cond, and(x, y), and(z, y) --> and (select cond, x, z), y
+name:select_cond_and_x_y_and_z_y_and_select_x_z_y
+body: |
+  bb.1:
+liveins: $x0, $x1, $x2
+; CHECK-LABEL: name: select_cond_and_x_y_and_z_y_and_select_x_z_y
+; CHECK: liveins: $x0, $x1, $x2
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
+; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
+; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
+; CHECK-NEXT: %a:_(s8) = G_TRUNC [[COPY1]](s64)
+; CHECK-NEXT: %b:_(s8) = G_TRUNC [[COPY2]](s64)
+; CHECK-NEXT: %d:_(s8) = G_TRUNC [[COPY3]](s64)
+; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s8) = G_SELECT %c(s1), %a, %d
+; CHECK-NEXT: %sel:_(s8) = G_AND [[SELECT]], %b
+; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s8)
+; CHECK-NEXT: $w0 = COPY %ext(s32)
+%0:_(s64) = COPY $x0
+%1:_(s64) = COPY $x1
+%2:_(s64) = COPY $x2
+%3:_(s64) = COPY $x3
+%4:_(s64) = COPY $x4
+%c:_(s1) = G_TRUNC %0
+%a:_(s8) = G_TRUNC %1
+%b:_(s8) = G_TRUNC %2
+%d:_(s8) = G_TRUNC %3
+%e:_(s8) = G_TRUNC %4
+%and1:_(s8) = G_AND %a, %b
+%and2:_(s8) = G_AND %d, %b
+%sel:_(s8) = G_SELECT %c, %and1, %and2
+%ext:_(s32) = G_ANYEXT %sel
+$w0 = COPY %ext(s32)
+...
+---
+# select cond, xor(x, y), xor(x, z) --> xor x, select, x, z)
+name:select_cond_xor_x_y_xor_x_z_xor_x__select_x_y
+body: |
+  bb.1:
+liveins: $x0, $x1, $x2
+; CHECK-LABEL: name: select_cond_xor_x_y_xor_x_z_xor_x__select_x_y
+; CHECK: liveins: $x0, $x1, $x2
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x3
+; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x4
+; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
+; CHECK-NEXT: %a:_(s8) = G_TRUNC [[COPY1]](s64)
+; CHECK-NEXT: %d:_(s8) = G_TRUNC [[COPY2]](s64)
+; CHECK-NEXT: %e:_(s8) = G_TRUNC [[COPY3]](s64)
+; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s8) = G_SELECT %c(s1), %e, %d
+; CHECK-NEXT: %sel:_(s8) = G_XOR %a, [[SELECT]]
+; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s8)
+; CHECK-NEXT: $w0 = COPY %ext(s32)
+%0:_(s64) = COPY $x0
+%1:_(s64) = COPY $x1
+%2:_(s64) = COPY $x2
+%3:_(s64) = COPY $x3
+%4:_(s64) = COPY $x4
+%c:_(s1) = G_TRUNC %0
+%a:_(s8) = G_TRUNC %1
+%b:_(s8) = G_TRUNC %2
+%d:_(s8) = G_TRUNC %3
+%e:_(s8) = G_TRUNC %4
+%xor1:_(s8) = G_XOR %a, %e
+%xor2:_(s8) = G_XOR %a, %d
+%sel:_(s8) = G_SELECT %c, %xor1, %xor2
+%ext:_(s32) = G_ANYEXT %sel
+$w0 = COPY %ext(s32)
+...
+---
+# negative test select cond, and(x, y), or(z, a) --> failed
+name:select_cond_and_x_y_or_z_a_failed
+body: |
+  bb.1:
+liveins: $x0, $x1, $x2
+; CHECK-LABEL: name: select_cond_and_x_y_or_z_a_failed
+; CHECK: liveins: $x0, $x1, $x2
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
+; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
+; CHECK-NEXT: [[COPY4:%[0-9]+]]:_(s64) = COPY $x4
+; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
+; CHECK-NEXT: %a:_(s8) = G_TRUNC [[COPY1]](s64)
+; CHECK-NEXT: %b:_(s8) = G_TRUNC [[COPY2]](s64)
+; CHECK-NEXT: %d:_(s8) = G_TRUNC [[COPY3]](s64)
+; CHECK-NEXT: %e:_(s8) = G_TRUNC [[COPY4]](s64)
+; CHECK-NEXT: %and1:_(s8) = G_AND %a, %b
+; CHECK-NEXT: %or2:_(s8) = G_OR %e, %d
+; CHECK-NEXT: %sel:_(s8) = G_SELECT %c(s1), %and1, %or2
+; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s8)
+; CHECK-NEXT: $w0 = COPY %ext(s32)
+%0:_(s64) = COPY $x0
+%1:_(s64) = COPY $x1
+%2:_(s64) = COPY $x2
+%3:_(s64) = COPY $x3
+%4:_(s64) = COPY $x4
+%c:_(s1) = G_TRUNC %0
+%a:_(s8) = G_TRUNC %1
+%b:_(s8) = G_TRUNC %2
+%d:_(s8) = G_TRUNC %3
+%e:_(s8) = G_TRUNC %4
+%and1:_(s8) = G_AND %a, %b
+%or2:_(s8) = G_OR %e, %d
+%sel:_(s8) = G_SELECT %c, %and1, %or2
+%ext:_(s32) = G_ANYEXT %sel
+$w0 = COPY %ext(s32)
+...
+---
+# flags test select cond, xor(x, y), xor(x, z) --> xor x, select, cond, x, z)
+name:flags_select_cond_xor_x_y_xor_x_z_xor_x__select_cond_x_y
+body: |
+  bb.1:
+liveins: $x0, $x1, $x2
+; CHECK-LABEL: name: 
flags_select_cond_xor_x_y_xor_x_z_xor_x__select_cond_x_y
+; CHECK: liveins: $x0, $x1, $x2
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x3
+; CHECK-NEX

[Lldb-commits] [compiler-rt] [clang] [clang-tools-extra] [llvm] [libc] [flang] [lldb] [GlobalIsel] Combine select of binops (PR #76763)

2024-01-03 Thread Thorsten Schütt via lldb-commits


@@ -544,3 +544,154 @@ body: |
 %ext:_(s32) = G_ANYEXT %sel
 $w0 = COPY %ext(s32)
 ...
+---
+# select cond, and(x, y), and(z, y) --> and (select cond, x, z), y
+name:select_cond_and_x_y_and_z_y_and_select_x_z_y
+body: |
+  bb.1:
+liveins: $x0, $x1, $x2
+; CHECK-LABEL: name: select_cond_and_x_y_and_z_y_and_select_x_z_y
+; CHECK: liveins: $x0, $x1, $x2
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
+; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
+; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
+; CHECK-NEXT: %a:_(s8) = G_TRUNC [[COPY1]](s64)
+; CHECK-NEXT: %b:_(s8) = G_TRUNC [[COPY2]](s64)
+; CHECK-NEXT: %d:_(s8) = G_TRUNC [[COPY3]](s64)
+; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s8) = G_SELECT %c(s1), %a, %d
+; CHECK-NEXT: %sel:_(s8) = G_AND [[SELECT]], %b
+; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s8)
+; CHECK-NEXT: $w0 = COPY %ext(s32)
+%0:_(s64) = COPY $x0
+%1:_(s64) = COPY $x1
+%2:_(s64) = COPY $x2
+%3:_(s64) = COPY $x3
+%4:_(s64) = COPY $x4
+%c:_(s1) = G_TRUNC %0
+%a:_(s8) = G_TRUNC %1
+%b:_(s8) = G_TRUNC %2
+%d:_(s8) = G_TRUNC %3
+%e:_(s8) = G_TRUNC %4
+%and1:_(s8) = G_AND %a, %b
+%and2:_(s8) = G_AND %d, %b
+%sel:_(s8) = G_SELECT %c, %and1, %and2
+%ext:_(s32) = G_ANYEXT %sel
+$w0 = COPY %ext(s32)
+...
+---
+# select cond, xor(x, y), xor(x, z) --> xor x, select, x, z)
+name:select_cond_xor_x_y_xor_x_z_xor_x__select_x_y
+body: |
+  bb.1:
+liveins: $x0, $x1, $x2
+; CHECK-LABEL: name: select_cond_xor_x_y_xor_x_z_xor_x__select_x_y
+; CHECK: liveins: $x0, $x1, $x2
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x3
+; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x4
+; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
+; CHECK-NEXT: %a:_(s8) = G_TRUNC [[COPY1]](s64)
+; CHECK-NEXT: %d:_(s8) = G_TRUNC [[COPY2]](s64)
+; CHECK-NEXT: %e:_(s8) = G_TRUNC [[COPY3]](s64)
+; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s8) = G_SELECT %c(s1), %e, %d
+; CHECK-NEXT: %sel:_(s8) = G_XOR %a, [[SELECT]]
+; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s8)
+; CHECK-NEXT: $w0 = COPY %ext(s32)
+%0:_(s64) = COPY $x0
+%1:_(s64) = COPY $x1
+%2:_(s64) = COPY $x2
+%3:_(s64) = COPY $x3
+%4:_(s64) = COPY $x4
+%c:_(s1) = G_TRUNC %0
+%a:_(s8) = G_TRUNC %1
+%b:_(s8) = G_TRUNC %2
+%d:_(s8) = G_TRUNC %3
+%e:_(s8) = G_TRUNC %4
+%xor1:_(s8) = G_XOR %a, %e
+%xor2:_(s8) = G_XOR %a, %d
+%sel:_(s8) = G_SELECT %c, %xor1, %xor2
+%ext:_(s32) = G_ANYEXT %sel
+$w0 = COPY %ext(s32)
+...
+---
+# negative test select cond, and(x, y), or(z, a) --> failed
+name:select_cond_and_x_y_or_z_a_failed
+body: |
+  bb.1:
+liveins: $x0, $x1, $x2
+; CHECK-LABEL: name: select_cond_and_x_y_or_z_a_failed
+; CHECK: liveins: $x0, $x1, $x2
+; CHECK-NEXT: {{  $}}
+; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
+; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
+; CHECK-NEXT: [[COPY4:%[0-9]+]]:_(s64) = COPY $x4
+; CHECK-NEXT: %c:_(s1) = G_TRUNC [[COPY]](s64)
+; CHECK-NEXT: %a:_(s8) = G_TRUNC [[COPY1]](s64)
+; CHECK-NEXT: %b:_(s8) = G_TRUNC [[COPY2]](s64)
+; CHECK-NEXT: %d:_(s8) = G_TRUNC [[COPY3]](s64)
+; CHECK-NEXT: %e:_(s8) = G_TRUNC [[COPY4]](s64)
+; CHECK-NEXT: %and1:_(s8) = G_AND %a, %b
+; CHECK-NEXT: %or2:_(s8) = G_OR %e, %d
+; CHECK-NEXT: %sel:_(s8) = G_SELECT %c(s1), %and1, %or2
+; CHECK-NEXT: %ext:_(s32) = G_ANYEXT %sel(s8)
+; CHECK-NEXT: $w0 = COPY %ext(s32)
+%0:_(s64) = COPY $x0
+%1:_(s64) = COPY $x1
+%2:_(s64) = COPY $x2
+%3:_(s64) = COPY $x3
+%4:_(s64) = COPY $x4
+%c:_(s1) = G_TRUNC %0
+%a:_(s8) = G_TRUNC %1
+%b:_(s8) = G_TRUNC %2
+%d:_(s8) = G_TRUNC %3
+%e:_(s8) = G_TRUNC %4
+%and1:_(s8) = G_AND %a, %b
+%or2:_(s8) = G_OR %e, %d

tschuett wrote:

This failed because and and or.

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


[Lldb-commits] [flang] [clang] [libcxx] [lldb] [clang-tools-extra] [llvm] [compiler-rt] [libc] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Peter Klausler via lldb-commits


@@ -22,6 +22,9 @@ extern "C" {
 // CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
 void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 
+// GNU extension subroutine FDATE
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *string, std::int64_t length);

klausler wrote:

Why `std::byte` here instead of the usual `char`?

https://github.com/llvm/llvm-project/pull/71222
___
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] [llvm] [libc] [compiler-rt] [lldb] [clang] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Peter Klausler via lldb-commits


@@ -43,6 +66,26 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit) {
 }
 } // namespace io
 
+// CALL FDATE(DATE)
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *arg, std::int64_t length) {
+  // Day Mon dd hh:mm:ss \n\0 is 26 characters, e.g.
+  // Tue May 26 21:51:03 2015\n\0
+  char str[26];
+  // Insufficient space, fill with spaces and return.
+  if (length < 24) {
+std::memset(reinterpret_cast(arg), ' ', length);
+return;
+  }
+
+  Terminator terminator{__FILE__, __LINE__};
+  std::time_t current_time;
+  std::time(¤t_time);
+  CtimeBuffer(str, sizeof(str), current_time, terminator);
+
+  // Pad space on \n\0 as well, start at index 24 (included).

klausler wrote:

What does "Pad space on \n\0 as well" mean?

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


[Lldb-commits] [llvm] [flang] [compiler-rt] [clang] [libc] [lldb] [clang-tools-extra] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits


@@ -43,6 +66,26 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit) {
 }
 } // namespace io
 
+// CALL FDATE(DATE)
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *arg, std::int64_t length) {
+  // Day Mon dd hh:mm:ss \n\0 is 26 characters, e.g.
+  // Tue May 26 21:51:03 2015\n\0
+  char str[26];
+  // Insufficient space, fill with spaces and return.
+  if (length < 24) {
+std::memset(reinterpret_cast(arg), ' ', length);
+return;
+  }
+
+  Terminator terminator{__FILE__, __LINE__};
+  std::time_t current_time;
+  std::time(¤t_time);
+  CtimeBuffer(str, sizeof(str), current_time, terminator);
+
+  // Pad space on \n\0 as well, start at index 24 (included).

yi-wu-arm wrote:

`ctime` returns a string that follow the format:
`Day Mon dd hh:mm:ss \n\0`: `Tue May 26 21:51:03 2015\n\0`, 26 characters 
in total, the last two character, new line and null-terminator will be pad with 
space as well

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


[Lldb-commits] [openmp] [clang-tools-extra] [flang] [mlir] [llvm] [lld] [compiler-rt] [libc] [lldb] [clang] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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

mordante wrote:

> > I did a full review. There are a number of comments, once these are 
> > addressed the patch is ready.
> 
> Thank you for the detailed review and patience!
> 
> I believe the failing tests are unrelated to this patch:
> 
> > Failed Tests (2):
> > llvm-libc++-shared-clangcl.cfg.in :: 
> > libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp
> > llvm-libc++-shared-clangcl.cfg.in :: 
> > libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp

The breakage is indeed unrelated. I've reverted the patch that introduced it.

https://github.com/llvm/llvm-project/pull/76632
___
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] [llvm] [libc] [compiler-rt] [lldb] [clang] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Peter Klausler via lldb-commits


@@ -43,6 +66,26 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit) {
 }
 } // namespace io
 
+// CALL FDATE(DATE)
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *arg, std::int64_t length) {
+  // Day Mon dd hh:mm:ss \n\0 is 26 characters, e.g.
+  // Tue May 26 21:51:03 2015\n\0
+  char str[26];
+  // Insufficient space, fill with spaces and return.
+  if (length < 24) {
+std::memset(reinterpret_cast(arg), ' ', length);
+return;
+  }
+
+  Terminator terminator{__FILE__, __LINE__};
+  std::time_t current_time;
+  std::time(¤t_time);
+  CtimeBuffer(str, sizeof(str), current_time, terminator);
+
+  // Pad space on \n\0 as well, start at index 24 (included).

klausler wrote:

Do you mean that the last two bytes will be replaced with spaces?

https://github.com/llvm/llvm-project/pull/71222
___
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] [llvm] [libc] [compiler-rt] [lldb] [clang] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits


@@ -43,6 +66,26 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit) {
 }
 } // namespace io
 
+// CALL FDATE(DATE)
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *arg, std::int64_t length) {
+  // Day Mon dd hh:mm:ss \n\0 is 26 characters, e.g.
+  // Tue May 26 21:51:03 2015\n\0
+  char str[26];
+  // Insufficient space, fill with spaces and return.
+  if (length < 24) {
+std::memset(reinterpret_cast(arg), ' ', length);
+return;
+  }
+
+  Terminator terminator{__FILE__, __LINE__};
+  std::time_t current_time;
+  std::time(¤t_time);
+  CtimeBuffer(str, sizeof(str), current_time, terminator);
+
+  // Pad space on \n\0 as well, start at index 24 (included).

yi-wu-arm wrote:

yeah, let me rephase the comment.

https://github.com/llvm/llvm-project/pull/71222
___
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] [llvm] [libc] [compiler-rt] [lldb] [clang] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits


@@ -22,6 +22,9 @@ extern "C" {
 // CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
 void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 
+// GNU extension subroutine FDATE
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *string, std::int64_t length);

yi-wu-arm wrote:

it was `std::int8_t` but when I was doing for getlog 
https://github.com/llvm/llvm-project/pull/74628#discussion_r1420503257, pointed 
out that it would be better to use std::byte since I have to cast them into 
`char` anyways.

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


[Lldb-commits] [flang] [clang] [openmp] [libcxx] [lld] [lldb] [clang-tools-extra] [llvm] [mlir] [compiler-rt] [libc] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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

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

LGTM modulo some nits. I like to have a quick look at the final version before 
approving.

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


[Lldb-commits] [openmp] [clang-tools-extra] [flang] [mlir] [llvm] [lld] [compiler-rt] [libc] [lldb] [clang] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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

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


[Lldb-commits] [libcxx] [lld] [llvm] [openmp] [libc] [lldb] [mlir] [compiler-rt] [flang] [clang] [clang-tools-extra] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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


@@ -24,6 +24,10 @@
 
 #include "test_macros.h"
 
+#if _LIBCPP_STD_VER >= 26

mordante wrote:

This is the way to test for versions in the test suite.
```suggestion
#if TEST_STD_VER >= 26
```
The same for other places. Also since we can no longer use 
`native_handle_test_helpers` I prefer the use the C++ version guard in that 
header. (I know I asked for it's removal earlier, sorry).

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


[Lldb-commits] [mlir] [openmp] [lldb] [libc] [compiler-rt] [libcxx] [llvm] [lld] [clang-tools-extra] [flang] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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


@@ -0,0 +1,30 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// REQUIRES: has-unix-headers
+// UNSUPPORTED: libcpp-hardening-mode=none
+// XFAIL: availability-verbose_abort-missing
+
+// 
+
+// class basic_filebuf;
+
+// native_handle_type native_handle() const noexcept;
+
+#include 
+
+#include "../native_handle_test_helpers.h"
+
+int main(int, char**) {
+  test_native_handle_assertion>();
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+  test_native_handle_assertion>();
+#endif

mordante wrote:

```suggestion
#endif
  return 0;
```
The same for the other assert tests.

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


[Lldb-commits] [clang-tools-extra] [clang] [llvm] [mlir] [libc] [libcxx] [flang] [openmp] [lldb] [compiler-rt] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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


@@ -0,0 +1,58 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// class basic_filebuf;
+
+// native_handle_type native_handle() const noexcept;
+
+#include 
+#include 
+#include 
+#include 
+
+#include "platform_support.h"
+#include "test_macros.h"
+#include "../native_handle_test_helpers.h"
+
+template 
+void test() {
+  std::basic_filebuf f;
+  std::filesystem::path p = get_temp_file_name();
+
+  // non-const
+  {

mordante wrote:

Thanks I find this a lot more readable.

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


[Lldb-commits] [libcxx] [clang-tools-extra] [flang] [lldb] [clang] [libc] [compiler-rt] [llvm] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits


@@ -22,6 +22,9 @@ extern "C" {
 // CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
 void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 
+// GNU extension subroutine FDATE
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *string, std::int64_t length);

yi-wu-arm wrote:

if it is `char` then it won't work for some reason

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


[Lldb-commits] [libcxx] [clang-tools-extra] [flang] [lldb] [clang] [libc] [compiler-rt] [llvm] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Peter Klausler via lldb-commits


@@ -22,6 +22,9 @@ extern "C" {
 // CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
 void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 
+// GNU extension subroutine FDATE
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *string, std::int64_t length);

klausler wrote:

Like what?

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


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

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

adrian-prantl wrote:

Ping @JDevlieghere 

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] [compiler-rt] [libcxx] [clang] [llvm] [libc] [flang] [lldb] [clang-tools-extra] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits


@@ -22,6 +22,9 @@ extern "C" {
 // CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
 void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 
+// GNU extension subroutine FDATE
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *string, std::int64_t length);

yi-wu-arm wrote:

its my problem, I design the test wrong, it can be `char`, I will change it in 
the next commit

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


[Lldb-commits] [lldb] [flang] [compiler-rt] [clang-tools-extra] [llvm] [clang] [libc] [libcxx] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits


@@ -22,6 +22,9 @@ extern "C" {
 // CALL FLUSH(n) antedates the Fortran 2003 FLUSH statement.
 void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 
+// GNU extension subroutine FDATE
+void FORTRAN_PROCEDURE_NAME(fdate)(std::byte *string, std::int64_t length);

yi-wu-arm wrote:

should I change `getlog` and `getarg` as well?

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


[Lldb-commits] [compiler-rt] [libcxx] [openmp] [clang] [llvm] [libc] [flang] [mlir] [lldb] [clang-tools-extra] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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


@@ -0,0 +1,101 @@
+//===--===//
+//
+// 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 TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 26
+
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+
+#  if defined(_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+#include 
+#  else
+#include 
+#  endif
+
+#  include "check_assertion.h"
+#  include "platform_support.h"
+#  include "types.h"
+
+inline bool is_handle_valid(NativeHandleT handle) {

H-G-Hristov wrote:

I admit this looks ugly :)

Or I could move `if TEST_STD_VER >= 26` right before `#  include 
"check_assertion.h"`, where it is needed:}

```c++
#else
#include 
#endif

#include "test_macros.h"

#if TEST_STD_VER >= 26

#  include "check_assertion.h"
#  include "platform_support.h"
#  include "types.h"

inline bool is_handle_valid(NativeHandleT handle) {
```

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


[Lldb-commits] [compiler-rt] [flang] [libcxx] [libc] [lldb] [llvm] [clang] [clang-tools-extra] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits

https://github.com/yi-wu-arm updated 
https://github.com/llvm/llvm-project/pull/71222

>From e0d99fb5baa4231ab351f7fd5abf0a1ffe589547 Mon Sep 17 00:00:00 2001
From: Yi Wu 
Date: Mon, 6 Nov 2023 19:55:06 +
Subject: [PATCH 01/18] FDATE extension implementation: get date and time in
 ctime format

reference to gfortran fdate https://gcc.gnu.org/onlinedocs/gfortran/FDATE.html
usage:
CHARACTER(32) :: time
CALL fdate(time)
WRITE(*,*) time
---
 flang/docs/Intrinsics.md |  2 +-
 flang/include/flang/Runtime/command.h|  5 +
 flang/include/flang/Runtime/extensions.h |  2 ++
 flang/runtime/command.cpp| 28 
 flang/runtime/extensions.cpp |  5 +
 flang/unittests/Runtime/CommandTest.cpp  | 14 
 6 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md
index ab0a940e53e553..982be820816429 100644
--- a/flang/docs/Intrinsics.md
+++ b/flang/docs/Intrinsics.md
@@ -751,7 +751,7 @@ This phase currently supports all the intrinsic procedures 
listed above but the
 | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, 
EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
 | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, 
MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
 | Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, 
SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, 
KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, 
RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, 
IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, 
INT_PTR_KIND, ISNAN, MALLOC |
-| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
+| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, FDATE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
 | Atomic intrinsic subroutines | ATOMIC_ADD |
 | Collective intrinsic subroutines | CO_REDUCE |
 
diff --git a/flang/include/flang/Runtime/command.h 
b/flang/include/flang/Runtime/command.h
index ec628939054547..07f6d8e169ead6 100644
--- a/flang/include/flang/Runtime/command.h
+++ b/flang/include/flang/Runtime/command.h
@@ -23,6 +23,11 @@ extern "C" {
 // integer kind.
 std::int32_t RTNAME(ArgumentCount)();
 
+// Try to get the the current date (same format as CTIME: convert to a string)
+// Return a STATUS as described in the standard.
+std::int32_t RTNAME(FDate)(
+const Descriptor *argument = nullptr, const Descriptor *errmsg = nullptr);
+
 // 16.9.82 GET_COMMAND
 // Try to get the value of the whole command. All of the parameters are
 // optional.
diff --git a/flang/include/flang/Runtime/extensions.h 
b/flang/include/flang/Runtime/extensions.h
index ad592814e5acb7..92b9907860121a 100644
--- a/flang/include/flang/Runtime/extensions.h
+++ b/flang/include/flang/Runtime/extensions.h
@@ -24,6 +24,8 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 // GNU Fortran 77 compatibility function IARGC.
 std::int32_t FORTRAN_PROCEDURE_NAME(iargc)();
 
+void FORTRAN_PROCEDURE_NAME(fdate)(std::int8_t *string, std::int64_t length);
+
 // GNU Fortran 77 compatibility subroutine GETARG(N, ARG).
 void FORTRAN_PROCEDURE_NAME(getarg)(
 std::int32_t &n, std::int8_t *arg, std::int64_t length);
diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp
index b81a0791c5e571..da0803c39f49b6 100644
--- a/flang/runtime/command.cpp
+++ b/flang/runtime/command.cpp
@@ -14,6 +14,7 @@
 #include "flang/Runtime/descriptor.h"
 #include 
 #include 
+#include 
 
 namespace Fortran::runtime {
 std::int32_t RTNAME(ArgumentCount)() {
@@ -125,6 +126,33 @@ static bool FitsInDescriptor(
   kind, terminator, value);
 }
 
+void removeNewLine(char *str) {
+  char *newlinePos = strchr(str, '\n');
+  if (newlinePos != NULL) {
+*newlinePos = '\0'; // Replace with null terminator
+  }
+}
+
+std::int32_t RTNAME(FDate)(const Descriptor *value, const Descriptor *errmsg) {
+  FillWithSpaces(*value);
+
+  time_t current_time;
+  time(¤t_time);
+
+  char *time_string = ctime(¤t_time);
+  removeNewLine(time_string);
+  std::int64_t stringLen{StringLength(time_string)};
+  if (stringLen <= 0) {
+return ToErrmsg(errmsg, StatMissingArgument);
+  }
+
+  if (value) {
+return CopyToDescriptor(*value, time_string, stringLen, errmsg);
+  }
+
+  return StatOk;
+}
+
 std::int32_t RTNAME(GetCommandArgument)(std::int32_t n, const Descriptor 
*value,
 const Descriptor *length, const Descriptor *errmsg, const char *sourceFile,
 int line) {
diff --git a/flang/runtime/e

[Lldb-commits] [compiler-rt] [libcxx] [openmp] [clang] [llvm] [libc] [flang] [mlir] [lldb] [clang-tools-extra] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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

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


[Lldb-commits] [lld] [llvm] [openmp] [clang-tools-extra] [flang] [libcxx] [compiler-rt] [mlir] [lldb] [clang] [libc] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

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


@@ -0,0 +1,101 @@
+//===--===//
+//
+// 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 TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 26
+
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+#  include 
+
+#  if defined(_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+#include 
+#  else
+#include 
+#  endif
+
+#  include "check_assertion.h"
+#  include "platform_support.h"
+#  include "types.h"
+
+inline bool is_handle_valid(NativeHandleT handle) {

mordante wrote:

I would do it after the all the includes, that is the natural way.

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


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

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


@@ -17,13 +17,41 @@
 namespace lldb_private {
 class Stream;
 
+/// Represents a source file whose contents is known (for example

JDevlieghere wrote:

 - Presumably this class is primarily used for source files but can hold any 
file?
 - Represents a path to a file?
 - I think a common name for something like this is a "spooled" file, so maybe 
"SpooledFileSpec". 
 - I'm surprised this isn't a subclass of FileSpec.

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


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

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


@@ -17,13 +17,41 @@
 namespace lldb_private {
 class Stream;
 
+/// Represents a source file whose contents is known (for example

JDevlieghere wrote:

Let's call this `LazySupportFile` maybe?

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


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

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


@@ -45,13 +48,61 @@ class FileSpecHolder {
   }
 };
 
+class SupportFileList {

JDevlieghere wrote:

Let's call this `SupportFile` to match the `SupportFileList`. This is where 
I'll add my MD5 checksum to. 

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


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

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


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

rampitec wrote:

> PseudoSourceValue::mayAlias is supposed to report aliasing to possible IR 
> values. It looks like it's layered weirdly, and expects you to go through 
> MachineInstr::mayAlias. MachineInstr::mayAlias ought to be using the AA tags, 
> it shouldn't be a fundamental limitation

This is all PSV::mayAlias() does:
```
bool PseudoSourceValue::mayAlias(const MachineFrameInfo *) const {
  return !(isGOT() || isConstantPool() || isJumpTable());
}
```
No very useful. Then even to get to the AA tags check MI:mayAlias() shall go 
through all IR values' checks first.

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


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

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


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

rampitec wrote:

> It looks to me like it does use it if you pass UseTBAA=true. Not sure why 
> this would be a parameter in the first place

I am passing it, but to get to that check it shall first go through all Value 
and offset checks. Using AA is the last thing it does: 
https://llvm.org/doxygen/MachineInstr_8cpp_source.html#l01285

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


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

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


@@ -703,8 +713,37 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
 setRegScore(RegNo, T, CurrScore);
   }
 }
-if (Inst.mayStore() && (TII->isDS(Inst) || mayWriteLDSThroughDMA(Inst))) {
-  setRegScore(SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS, T, CurrScore);
+if (Inst.mayStore() &&
+(TII->isDS(Inst) || TII->mayWriteLDSThroughDMA(Inst))) {
+  // MUBUF and FLAT LDS DMA operations need a wait on vmcnt before LDS
+  // written can be accessed. A load from LDS to VMEM does not need a wait.
+  unsigned Slot = 0;
+  for (const auto *MemOp : Inst.memoperands()) {
+if (!MemOp->isStore() ||
+MemOp->getAddrSpace() != AMDGPUAS::LOCAL_ADDRESS)
+  continue;
+// Comparing just AA info does not guarantee memoperands are equal

rampitec wrote:

> The values don't need to be identical, that's the point of the AA query. 
> BasicAA will parse through the offsets

I also think that values don't need to be identical. But that is what 
MI:mayAlias() does *before* it checks AA: 
https://llvm.org/doxygen/MachineInstr_8cpp_source.html#l01285

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


[Lldb-commits] [llvm] [clang-tools-extra] [libcxx] [compiler-rt] [clang] [libc] [flang] [lldb] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

2024-01-03 Thread Yi Wu via lldb-commits

https://github.com/yi-wu-arm updated 
https://github.com/llvm/llvm-project/pull/71222

>From e0d99fb5baa4231ab351f7fd5abf0a1ffe589547 Mon Sep 17 00:00:00 2001
From: Yi Wu 
Date: Mon, 6 Nov 2023 19:55:06 +
Subject: [PATCH 01/19] FDATE extension implementation: get date and time in
 ctime format

reference to gfortran fdate https://gcc.gnu.org/onlinedocs/gfortran/FDATE.html
usage:
CHARACTER(32) :: time
CALL fdate(time)
WRITE(*,*) time
---
 flang/docs/Intrinsics.md |  2 +-
 flang/include/flang/Runtime/command.h|  5 +
 flang/include/flang/Runtime/extensions.h |  2 ++
 flang/runtime/command.cpp| 28 
 flang/runtime/extensions.cpp |  5 +
 flang/unittests/Runtime/CommandTest.cpp  | 14 
 6 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md
index ab0a940e53e553..982be820816429 100644
--- a/flang/docs/Intrinsics.md
+++ b/flang/docs/Intrinsics.md
@@ -751,7 +751,7 @@ This phase currently supports all the intrinsic procedures 
listed above but the
 | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, 
EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
 | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, 
MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
 | Non-standard intrinsic functions | AND, OR, XOR, SHIFT, ZEXT, IZEXT, COSD, 
SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, EQV, NEQV, INT8, JINT, JNINT, 
KNINT, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, 
RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, 
IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, 
INT_PTR_KIND, ISNAN, MALLOC |
-| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
+| Intrinsic subroutines |MVBITS (elemental), CPU_TIME, DATE_AND_TIME, 
EVENT_QUERY, EXECUTE_COMMAND_LINE, FDATE, GET_COMMAND, GET_COMMAND_ARGUMENT, 
GET_ENVIRONMENT_VARIABLE, MOVE_ALLOC, RANDOM_INIT, RANDOM_NUMBER, RANDOM_SEED, 
SYSTEM_CLOCK |
 | Atomic intrinsic subroutines | ATOMIC_ADD |
 | Collective intrinsic subroutines | CO_REDUCE |
 
diff --git a/flang/include/flang/Runtime/command.h 
b/flang/include/flang/Runtime/command.h
index ec628939054547..07f6d8e169ead6 100644
--- a/flang/include/flang/Runtime/command.h
+++ b/flang/include/flang/Runtime/command.h
@@ -23,6 +23,11 @@ extern "C" {
 // integer kind.
 std::int32_t RTNAME(ArgumentCount)();
 
+// Try to get the the current date (same format as CTIME: convert to a string)
+// Return a STATUS as described in the standard.
+std::int32_t RTNAME(FDate)(
+const Descriptor *argument = nullptr, const Descriptor *errmsg = nullptr);
+
 // 16.9.82 GET_COMMAND
 // Try to get the value of the whole command. All of the parameters are
 // optional.
diff --git a/flang/include/flang/Runtime/extensions.h 
b/flang/include/flang/Runtime/extensions.h
index ad592814e5acb7..92b9907860121a 100644
--- a/flang/include/flang/Runtime/extensions.h
+++ b/flang/include/flang/Runtime/extensions.h
@@ -24,6 +24,8 @@ void FORTRAN_PROCEDURE_NAME(flush)(const int &unit);
 // GNU Fortran 77 compatibility function IARGC.
 std::int32_t FORTRAN_PROCEDURE_NAME(iargc)();
 
+void FORTRAN_PROCEDURE_NAME(fdate)(std::int8_t *string, std::int64_t length);
+
 // GNU Fortran 77 compatibility subroutine GETARG(N, ARG).
 void FORTRAN_PROCEDURE_NAME(getarg)(
 std::int32_t &n, std::int8_t *arg, std::int64_t length);
diff --git a/flang/runtime/command.cpp b/flang/runtime/command.cpp
index b81a0791c5e571..da0803c39f49b6 100644
--- a/flang/runtime/command.cpp
+++ b/flang/runtime/command.cpp
@@ -14,6 +14,7 @@
 #include "flang/Runtime/descriptor.h"
 #include 
 #include 
+#include 
 
 namespace Fortran::runtime {
 std::int32_t RTNAME(ArgumentCount)() {
@@ -125,6 +126,33 @@ static bool FitsInDescriptor(
   kind, terminator, value);
 }
 
+void removeNewLine(char *str) {
+  char *newlinePos = strchr(str, '\n');
+  if (newlinePos != NULL) {
+*newlinePos = '\0'; // Replace with null terminator
+  }
+}
+
+std::int32_t RTNAME(FDate)(const Descriptor *value, const Descriptor *errmsg) {
+  FillWithSpaces(*value);
+
+  time_t current_time;
+  time(¤t_time);
+
+  char *time_string = ctime(¤t_time);
+  removeNewLine(time_string);
+  std::int64_t stringLen{StringLength(time_string)};
+  if (stringLen <= 0) {
+return ToErrmsg(errmsg, StatMissingArgument);
+  }
+
+  if (value) {
+return CopyToDescriptor(*value, time_string, stringLen, errmsg);
+  }
+
+  return StatOk;
+}
+
 std::int32_t RTNAME(GetCommandArgument)(std::int32_t n, const Descriptor 
*value,
 const Descriptor *length, const Descriptor *errmsg, const char *sourceFile,
 int line) {
diff --git a/flang/runtime/e

[Lldb-commits] [lldb] [libc] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [lldb][NFC] Fix compilation issue on windows (PR #76453)

2024-01-03 Thread via lldb-commits

https://github.com/gmh5225 updated 
https://github.com/llvm/llvm-project/pull/76453

>From 362c9380964e13878afae57428028f93bd80d03a Mon Sep 17 00:00:00 2001
From: gmh <1391+gmh5...@users.noreply.github.com>
Date: Thu, 28 Dec 2023 01:00:40 +0800
Subject: [PATCH] [lldb][NFC] Fix compilation issue on windows

---
 .../Plugins/Process/Windows/Common/TargetThreadWindows.cpp| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
index ad67e764fe10f2..a69c10081ff190 100644
--- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -29,8 +29,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
-using GetThreadDescriptionFunctionPtr = HRESULT
-WINAPI (*)(HANDLE hThread, PWSTR *ppszThreadDescription);
+using GetThreadDescriptionFunctionPtr =
+HRESULT(WINAPI *)(HANDLE hThread, PWSTR *ppszThreadDescription);
 
 TargetThreadWindows::TargetThreadWindows(ProcessWindows &process,
  const HostThread &thread)

___
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] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] Warn inf nan fast fp (PR #76854)

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

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/76854

None

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0..3ce317d318f9bb 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333..ca883689b05c28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortF

[Lldb-commits] [llvm] [clang-tools-extra] [compiler-rt] [clang] [libc] [flang] [lldb] [lldb][NFC] Fix compilation issue on windows (PR #76453)

2024-01-03 Thread via lldb-commits

https://github.com/gmh5225 updated 
https://github.com/llvm/llvm-project/pull/76453

>From 362c9380964e13878afae57428028f93bd80d03a Mon Sep 17 00:00:00 2001
From: gmh <1391+gmh5...@users.noreply.github.com>
Date: Thu, 28 Dec 2023 01:00:40 +0800
Subject: [PATCH 1/2] [lldb][NFC] Fix compilation issue on windows

---
 .../Plugins/Process/Windows/Common/TargetThreadWindows.cpp| 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp 
b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
index ad67e764fe10f2..a69c10081ff190 100644
--- a/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -29,8 +29,8 @@
 using namespace lldb;
 using namespace lldb_private;
 
-using GetThreadDescriptionFunctionPtr = HRESULT
-WINAPI (*)(HANDLE hThread, PWSTR *ppszThreadDescription);
+using GetThreadDescriptionFunctionPtr =
+HRESULT(WINAPI *)(HANDLE hThread, PWSTR *ppszThreadDescription);
 
 TargetThreadWindows::TargetThreadWindows(ProcessWindows &process,
  const HostThread &thread)

>From db9a5b3fa99b4e24ef8f164c0bb86c2a0e8c646c Mon Sep 17 00:00:00 2001
From: gmh <1391+gmh5...@users.noreply.github.com>
Date: Thu, 4 Jan 2024 03:40:27 +0800
Subject: [PATCH 2/2] [lldb][NFC] Fix compilation issue on windows

---
 lldb/unittests/Thread/ThreadTest.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/unittests/Thread/ThreadTest.cpp 
b/lldb/unittests/Thread/ThreadTest.cpp
index 4c660e9815c3ef..542585969c07b1 100644
--- a/lldb/unittests/Thread/ThreadTest.cpp
+++ b/lldb/unittests/Thread/ThreadTest.cpp
@@ -34,8 +34,8 @@ using namespace lldb;
 namespace {
 
 #ifdef _WIN32
-using SetThreadDescriptionFunctionPtr = HRESULT
-WINAPI (*)(HANDLE hThread, PCWSTR lpThreadDescription);
+using SetThreadDescriptionFunctionPtr =
+HRESULT(WINAPI *)(HANDLE hThread, PCWSTR lpThreadDescription);
 
 static SetThreadDescriptionFunctionPtr SetThreadName;
 #endif

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


[Lldb-commits] [lldb] [libc] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [lldb][NFC] Fix compilation issue on windows (PR #76453)

2024-01-03 Thread via lldb-commits

gmh5225 wrote:

> Please update `lldb/unittests/Thread/ThreadTest.cpp` as well.

Thanks for your correction.

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


[Lldb-commits] [lldb] [libunwind] [lld] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [mlir] Warn inf nan fast fp (PR #76854)

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

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

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0..3ce317d318f9bb 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333..ca883689b05c28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortFract:

[Lldb-commits] [llvm] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] [mlir] Test pr1 (PR #76856)

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

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/76856

None

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0..3ce317d318f9bb 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333..ca883689b05c28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortF

[Lldb-commits] [llvm] [clang-tools-extra] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] [mlir] Test pr1 (PR #76856)

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

https://github.com/zahiraam closed 
https://github.com/llvm/llvm-project/pull/76856
___
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] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] [mlir] Test pr1 (PR #76856)

2024-01-03 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 7fbc1de9896029636dd572a692ee90ba88285943 
27851334a4229defa0772b78057c6e42a1e90c5e -- toto.cpp
``





View the diff from clang-format here.


``diff
diff --git a/toto.cpp b/toto.cpp
index 1a4baf536d..8b13789179 100644
--- a/toto.cpp
+++ b/toto.cpp
@@ -1 +1 @@
-  
+

``




https://github.com/llvm/llvm-project/pull/76856
___
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] [libcxx] [compiler-rt] [lld] [clang] [libc] [libunwind] [flang] [lldb] [mlir] Warn inf nan fast fp (PR #76854)

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

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


[Lldb-commits] [lldb] [libunwind] [lld] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [mlir] Test pr (PR #76859)

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

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/76859

None

>From 340e3777509f70b5b300adcb181261e84247cf1a Mon Sep 17 00:00:00 2001
From: Ammarguellat 
Date: Mon, 23 Oct 2023 12:51:21 -0700
Subject: [PATCH 1/4] Revert "[clang] Support fixed point types in C++
 (#67750)"

This reverts commit a3a7d6318027bb86e6614c022e77e0bd81aef6dc.

When compiling with MSVC2022 in  C++32 mode this is giving an
error.
Compiling this simple test case:
t1.cpp:
with -std=c++23 will give the following error:

In file included from C:\Users\zahiraam\t1.cpp:1:
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:16:
error:
  compile with '-ffixed-point' to enable fixed point types
   3329 | _Vbase _Accum = 0;
 |^
c:\Program files\Microsoft Visual
Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\vector:3329:23:
error:
  expected unqualified-id
   3329 | _Vbase _Accum = 0;
 |   ^
Please full error in
https://github.com/llvm/llvm-project/pull/67750#issuecomment-1775264907
---
 clang/include/clang/Basic/TokenKinds.def |  6 +-
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/AST/ItaniumMangle.cpp  | 59 +---
 clang/lib/Parse/ParseExpr.cpp|  3 -
 clang/lib/Parse/ParseExprCXX.cpp |  9 ---
 clang/lib/Parse/ParseTentative.cpp   |  6 --
 clang/test/CodeGenCXX/fixed-point-mangle.cpp | 45 ---
 clang/test/Frontend/fixed_point_errors.cpp   | 24 
 8 files changed, 15 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/fixed-point-mangle.cpp

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index bbae1200d376c0..3ce317d318f9bb 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -423,9 +423,9 @@ C23_KEYWORD(typeof  , KEYGNU)
 C23_KEYWORD(typeof_unqual   , 0)
 
 // ISO/IEC JTC1 SC22 WG14 N1169 Extension
-KEYWORD(_Accum  , KEYALL)
-KEYWORD(_Fract  , KEYALL)
-KEYWORD(_Sat, KEYALL)
+KEYWORD(_Accum  , KEYNOCXX)
+KEYWORD(_Fract  , KEYNOCXX)
+KEYWORD(_Sat, KEYNOCXX)
 
 // GNU Extensions (in impl-reserved namespace)
 KEYWORD(_Decimal32  , KEYALL)
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e63158fb0e5333..ca883689b05c28 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2097,7 +2097,7 @@ defm fixed_point : BoolFOption<"fixed-point",
   LangOpts<"FixedPoint">, DefaultFalse,
   PosFlag,
   NegFlag,
-  BothFlags<[], [ClangOption], " fixed point types">>;
+  BothFlags<[], [ClangOption], " fixed point types">>, 
ShouldParseIf;
 defm cxx_static_destructors : BoolFOption<"c++-static-destructors",
   LangOpts<"RegisterStaticDestructors">, DefaultTrue,
   NegFlag# vendor extended type
-  //
-  //  
-  // ::= s # short
-  // ::= t # unsigned short
-  // ::= i # plain
-  // ::= j # unsigned
-  // ::= l # long
-  // ::= m # unsigned long
   std::string type_name;
   // Normalize integer types as vendor extended types:
   // ui
@@ -3205,77 +3195,30 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
 Out << "DF16_";
 break;
   case BuiltinType::ShortAccum:
-Out << "DAs";
-break;
   case BuiltinType::Accum:
-Out << "DAi";
-break;
   case BuiltinType::LongAccum:
-Out << "DAl";
-break;
   case BuiltinType::UShortAccum:
-Out << "DAt";
-break;
   case BuiltinType::UAccum:
-Out << "DAj";
-break;
   case BuiltinType::ULongAccum:
-Out << "DAm";
-break;
   case BuiltinType::ShortFract:
-Out << "DRs";
-break;
   case BuiltinType::Fract:
-Out << "DRi";
-break;
   case BuiltinType::LongFract:
-Out << "DRl";
-break;
   case BuiltinType::UShortFract:
-Out << "DRt";
-break;
   case BuiltinType::UFract:
-Out << "DRj";
-break;
   case BuiltinType::ULongFract:
-Out << "DRm";
-break;
   case BuiltinType::SatShortAccum:
-Out << "DSDAs";
-break;
   case BuiltinType::SatAccum:
-Out << "DSDAi";
-break;
   case BuiltinType::SatLongAccum:
-Out << "DSDAl";
-break;
   case BuiltinType::SatUShortAccum:
-Out << "DSDAt";
-break;
   case BuiltinType::SatUAccum:
-Out << "DSDAj";
-break;
   case BuiltinType::SatULongAccum:
-Out << "DSDAm";
-break;
   case BuiltinType::SatShortFract:
-Out << "DSDRs";
-break;
   case BuiltinType::SatFract:
-Out << "DSDRi";
-break;
   case BuiltinType::SatLongFract:
-Out << "DSDRl";
-break;
   case BuiltinType::SatUShortF

[Lldb-commits] [lldb] [libunwind] [lld] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [mlir] Test pr (PR #76859)

2024-01-03 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 7fbc1de9896029636dd572a692ee90ba88285943 
0006e82ff03affbd440a678bf6078ad0b2b6e07e -- clang/foo.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/foo.cpp b/clang/foo.cpp
index 8d1c8b69c3..8b13789179 100644
--- a/clang/foo.cpp
+++ b/clang/foo.cpp
@@ -1 +1 @@
- 
+

``




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


[Lldb-commits] [lldb] [libunwind] [lld] [libc] [libcxx] [clang-tools-extra] [compiler-rt] [flang] [clang] [llvm] [mlir] Test pr (PR #76859)

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

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

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

>From a9b6b6fee19fd19bf1fdce6fe8e9ed35f7c1567a Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Tue, 2 Jan 2024 15:44:30 -0800
Subject: [PATCH] [lldb] Fix breakpoint resolver serialization bug

BreakpointResolverAddress optionally can include the module name related
to the address that gets resolved. Currently this will never work
because it sets the name to itself (which is empty).
---
 .../Breakpoint/BreakpointResolverAddress.cpp  | 12 --
 .../serialize/TestBreakpointSerialization.py  | 23 +++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp 
b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index a0c628a8e299ce..ee4cbd50f9eee2 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -65,13 +65,11 @@ BreakpointResolverAddress::SerializeToStructuredData() {
   new StructuredData::Dictionary());
   SectionSP section_sp = m_addr.GetSection();
   if (section_sp) {
-ModuleSP module_sp = section_sp->GetModule();
-ConstString module_name;
-if (module_sp)
-  module_name.SetCString(module_name.GetCString());
-
-options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
-   module_name.GetCString());
+if (ModuleSP module_sp = section_sp->GetModule()) {
+  const FileSpec &module_fspec = module_sp->GetFileSpec();
+  options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
+ module_fspec.GetPath().c_str());
+}
 options_dict_sp->AddIntegerItem(GetKey(OptionNames::AddressOffset),
 m_addr.GetOffset());
   } else {
diff --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index be9b4e587b2969..54366b11aa6c00 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -49,6 +49,29 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(sym_ctx.IsValid(), "SBSymbolContext representing 
function `main' is invalid")
+main_func = sym_ctx.GetFunction()
+self.assertTrue(main_func.IsValid(), "SBFunction representing `main' 
is invalid")
+main_addr = main_func.GetStartAddress()
+
+bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
+self.assertTrue(bkpt.IsValid(), "Could not place breakpoint on `main' 
by address")
+stream = lldb.SBStream()
+sd = bkpt.SerializeToStructuredData()
+sd.GetAsJSON(stream)
+serialized_data = json.loads(stream.GetData())
+
+self.assertIn("a.out",
+  
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"])
+
 def test_structured_data_serialization(self):
 target = self.dbg.GetDummyTarget()
 self.assertTrue(target.IsValid(), VALID_TARGET)

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

bulbazord wrote:

@clayborg I was able to write a test similar to what you suggested (without 
needing to set two breakpoints). I also changed the actual fix since a module's 
object name isn't quite what I wanted in the first place.

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

2024-01-03 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
b49e0ebedfefa2f3323081425016ca2ada902263...a9b6b6fee19fd19bf1fdce6fe8e9ed35f7c1567a
 
lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
``





View the diff from darker here.


``diff
--- TestBreakpointSerialization.py  2024-01-03 20:40:03.00 +
+++ TestBreakpointSerialization.py  2024-01-03 20:42:48.388892 +
@@ -55,24 +55,32 @@
 self.setup_targets_and_cleanup()
 
 sym_ctx_list = self.orig_target.FindFunctions("main")
 self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
 sym_ctx = sym_ctx_list.GetContextAtIndex(0)
-self.assertTrue(sym_ctx.IsValid(), "SBSymbolContext representing 
function `main' is invalid")
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function `main' 
is invalid"
+)
 main_func = sym_ctx.GetFunction()
-self.assertTrue(main_func.IsValid(), "SBFunction representing `main' 
is invalid")
+self.assertTrue(
+main_func.IsValid(), "SBFunction representing `main' is invalid"
+)
 main_addr = main_func.GetStartAddress()
 
 bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
-self.assertTrue(bkpt.IsValid(), "Could not place breakpoint on `main' 
by address")
+self.assertTrue(
+bkpt.IsValid(), "Could not place breakpoint on `main' by address"
+)
 stream = lldb.SBStream()
 sd = bkpt.SerializeToStructuredData()
 sd.GetAsJSON(stream)
 serialized_data = json.loads(stream.GetData())
 
-self.assertIn("a.out",
-  
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"])
+self.assertIn(
+"a.out",
+
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"],
+)
 
 def test_structured_data_serialization(self):
 target = self.dbg.GetDummyTarget()
 self.assertTrue(target.IsValid(), VALID_TARGET)
 

``




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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

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

>From 9688e85a01c8c952a3db17510cc97ce6db570e96 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Tue, 2 Jan 2024 15:44:30 -0800
Subject: [PATCH] [lldb] Fix breakpoint resolver serialization bug

BreakpointResolverAddress optionally can include the module name related
to the address that gets resolved. Currently this will never work
because it sets the name to itself (which is empty).
---
 .../Breakpoint/BreakpointResolverAddress.cpp  | 12 +++
 .../serialize/TestBreakpointSerialization.py  | 31 +++
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp 
b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index a0c628a8e299ce..ee4cbd50f9eee2 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -65,13 +65,11 @@ BreakpointResolverAddress::SerializeToStructuredData() {
   new StructuredData::Dictionary());
   SectionSP section_sp = m_addr.GetSection();
   if (section_sp) {
-ModuleSP module_sp = section_sp->GetModule();
-ConstString module_name;
-if (module_sp)
-  module_name.SetCString(module_name.GetCString());
-
-options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
-   module_name.GetCString());
+if (ModuleSP module_sp = section_sp->GetModule()) {
+  const FileSpec &module_fspec = module_sp->GetFileSpec();
+  options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
+ module_fspec.GetPath().c_str());
+}
 options_dict_sp->AddIntegerItem(GetKey(OptionNames::AddressOffset),
 m_addr.GetOffset());
   } else {
diff --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index be9b4e587b2969..4f128aa33bc40a 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function `main' 
is invalid"
+)
+main_func = sym_ctx.GetFunction()
+self.assertTrue(
+main_func.IsValid(), "SBFunction representing `main' is invalid"
+)
+main_addr = main_func.GetStartAddress()
+
+bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
+self.assertTrue(
+bkpt.IsValid(), "Could not place breakpoint on `main' by address"
+)
+stream = lldb.SBStream()
+sd = bkpt.SerializeToStructuredData()
+sd.GetAsJSON(stream)
+serialized_data = json.loads(stream.GetData())
+
+self.assertIn(
+"a.out",
+
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"],
+)
+
 def test_structured_data_serialization(self):
 target = self.dbg.GetDummyTarget()
 self.assertTrue(target.IsValid(), VALID_TARGET)

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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


@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")

clayborg wrote:

If you want to be really safe you can call FindFunctions on the main module 
only:
```
sym_ctx_list = self.orig_target.module[0].FindFunctions("main")
```
This will ensure we never find more than one 'main'.

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

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

One quick fix suggested, but looks good.



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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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


@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")

bulbazord wrote:

Can we guarantee that the first module is always the binary we're debugging? 
This feels like an implicit assumption.

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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


@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")

clayborg wrote:

yes, this will always work, but if it makes you feel better you can do:
```
exe_path = self.getBuildArtifact("a.out")
exe_module = self.orig_target.module[exe_path]
self.assertTrue(exe_module.IsValid(), 'Make sure we found the executable 
module')
sym_ctx_list = exe_module.FindFunctions("main")
```

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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


@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function `main' 
is invalid"

clayborg wrote:

Do we want mixed quotes here? Backtick and single quote?

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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


@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function `main' 
is invalid"
+)
+main_func = sym_ctx.GetFunction()
+self.assertTrue(
+main_func.IsValid(), "SBFunction representing `main' is invalid"
+)
+main_addr = main_func.GetStartAddress()
+
+bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
+self.assertTrue(
+bkpt.IsValid(), "Could not place breakpoint on `main' by address"
+)
+stream = lldb.SBStream()
+sd = bkpt.SerializeToStructuredData()
+sd.GetAsJSON(stream)
+serialized_data = json.loads(stream.GetData())
+
+self.assertIn(
+"a.out",

clayborg wrote:

If you make the change suggested in the comment, you can possibly switch 
`"a.out"` with `exe_path`

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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


@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function `main' 
is invalid"
+)
+main_func = sym_ctx.GetFunction()
+self.assertTrue(
+main_func.IsValid(), "SBFunction representing `main' is invalid"

clayborg wrote:

Do we want mixed quotes here? Backtick and single quote?

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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


@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function `main' 
is invalid"
+)
+main_func = sym_ctx.GetFunction()
+self.assertTrue(
+main_func.IsValid(), "SBFunction representing `main' is invalid"
+)
+main_addr = main_func.GetStartAddress()
+
+bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
+self.assertTrue(
+bkpt.IsValid(), "Could not place breakpoint on `main' by address"

clayborg wrote:

Do we want mixed quotes here? Backtick and single quote?

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


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

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

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

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

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

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

[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

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

>From 9688e85a01c8c952a3db17510cc97ce6db570e96 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Tue, 2 Jan 2024 15:44:30 -0800
Subject: [PATCH 1/2] [lldb] Fix breakpoint resolver serialization bug

BreakpointResolverAddress optionally can include the module name related
to the address that gets resolved. Currently this will never work
because it sets the name to itself (which is empty).
---
 .../Breakpoint/BreakpointResolverAddress.cpp  | 12 +++
 .../serialize/TestBreakpointSerialization.py  | 31 +++
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp 
b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index a0c628a8e299ce..ee4cbd50f9eee2 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -65,13 +65,11 @@ BreakpointResolverAddress::SerializeToStructuredData() {
   new StructuredData::Dictionary());
   SectionSP section_sp = m_addr.GetSection();
   if (section_sp) {
-ModuleSP module_sp = section_sp->GetModule();
-ConstString module_name;
-if (module_sp)
-  module_name.SetCString(module_name.GetCString());
-
-options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
-   module_name.GetCString());
+if (ModuleSP module_sp = section_sp->GetModule()) {
+  const FileSpec &module_fspec = module_sp->GetFileSpec();
+  options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
+ module_fspec.GetPath().c_str());
+}
 options_dict_sp->AddIntegerItem(GetKey(OptionNames::AddressOffset),
 m_addr.GetOffset());
   } else {
diff --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index be9b4e587b2969..4f128aa33bc40a 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function `main' 
is invalid"
+)
+main_func = sym_ctx.GetFunction()
+self.assertTrue(
+main_func.IsValid(), "SBFunction representing `main' is invalid"
+)
+main_addr = main_func.GetStartAddress()
+
+bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
+self.assertTrue(
+bkpt.IsValid(), "Could not place breakpoint on `main' by address"
+)
+stream = lldb.SBStream()
+sd = bkpt.SerializeToStructuredData()
+sd.GetAsJSON(stream)
+serialized_data = json.loads(stream.GetData())
+
+self.assertIn(
+"a.out",
+
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"],
+)
+
 def test_structured_data_serialization(self):
 target = self.dbg.GetDummyTarget()
 self.assertTrue(target.IsValid(), VALID_TARGET)

>From a5b8e974f4e2c433b926b53c4708f1a1f7b7632e Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Wed, 3 Jan 2024 14:29:04 -0800
Subject: [PATCH 2/2] change formatting and make test more robust

---
 .../serialize/TestBreakpointSerialization.py  | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index 4f128aa33bc40a..deb83e03e1b74c 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -54,21 +54,24 @@ def test_resolver_serialization(self):
 self.build()
 self.setup_targets_and_cleanup()
 
-sym_ctx_list = self.orig_target.FindFunctions("main")
-self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+exe_path = self.getBuildArtifact("a.out")
+exe_module = self.orig_target.module[exe_path]
+self.assertTrue(exe_module.IsValid(), "Failed to find the executable 
module in target")
+sym_ctx_list

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

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

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

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

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

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

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

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

adrian-prantl wrote:

@JDevlieghere I think I addressed your comments. Mind taking another look?

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

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

Looks good!

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


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

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

https://github.com/JDevlieghere commented:

This looks awesome. Without the need for copying the SupportFileList, can we 
make the UnspooledSupportFile a subclass of SupportFile and store unique 
pointers in the support file list? 

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

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

>From 9688e85a01c8c952a3db17510cc97ce6db570e96 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Tue, 2 Jan 2024 15:44:30 -0800
Subject: [PATCH 1/3] [lldb] Fix breakpoint resolver serialization bug

BreakpointResolverAddress optionally can include the module name related
to the address that gets resolved. Currently this will never work
because it sets the name to itself (which is empty).
---
 .../Breakpoint/BreakpointResolverAddress.cpp  | 12 +++
 .../serialize/TestBreakpointSerialization.py  | 31 +++
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp 
b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index a0c628a8e299ce..ee4cbd50f9eee2 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -65,13 +65,11 @@ BreakpointResolverAddress::SerializeToStructuredData() {
   new StructuredData::Dictionary());
   SectionSP section_sp = m_addr.GetSection();
   if (section_sp) {
-ModuleSP module_sp = section_sp->GetModule();
-ConstString module_name;
-if (module_sp)
-  module_name.SetCString(module_name.GetCString());
-
-options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
-   module_name.GetCString());
+if (ModuleSP module_sp = section_sp->GetModule()) {
+  const FileSpec &module_fspec = module_sp->GetFileSpec();
+  options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
+ module_fspec.GetPath().c_str());
+}
 options_dict_sp->AddIntegerItem(GetKey(OptionNames::AddressOffset),
 m_addr.GetOffset());
   } else {
diff --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index be9b4e587b2969..4f128aa33bc40a 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -49,6 +49,37 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+sym_ctx_list = self.orig_target.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function `main' 
is invalid"
+)
+main_func = sym_ctx.GetFunction()
+self.assertTrue(
+main_func.IsValid(), "SBFunction representing `main' is invalid"
+)
+main_addr = main_func.GetStartAddress()
+
+bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
+self.assertTrue(
+bkpt.IsValid(), "Could not place breakpoint on `main' by address"
+)
+stream = lldb.SBStream()
+sd = bkpt.SerializeToStructuredData()
+sd.GetAsJSON(stream)
+serialized_data = json.loads(stream.GetData())
+
+self.assertIn(
+"a.out",
+
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"],
+)
+
 def test_structured_data_serialization(self):
 target = self.dbg.GetDummyTarget()
 self.assertTrue(target.IsValid(), VALID_TARGET)

>From a5b8e974f4e2c433b926b53c4708f1a1f7b7632e Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Wed, 3 Jan 2024 14:29:04 -0800
Subject: [PATCH 2/3] change formatting and make test more robust

---
 .../serialize/TestBreakpointSerialization.py  | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index 4f128aa33bc40a..deb83e03e1b74c 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -54,21 +54,24 @@ def test_resolver_serialization(self):
 self.build()
 self.setup_targets_and_cleanup()
 
-sym_ctx_list = self.orig_target.FindFunctions("main")
-self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
`main'")
+exe_path = self.getBuildArtifact("a.out")
+exe_module = self.orig_target.module[exe_path]
+self.assertTrue(exe_module.IsValid(), "Failed to find the executable 
module in target")
+sym_ctx_list

[Lldb-commits] [lldb] 49029f9 - [lldb] Fix breakpoint resolver serialization bug (#76766)

2024-01-03 Thread via lldb-commits

Author: Alex Langford
Date: 2024-01-03T15:02:37-08:00
New Revision: 49029f926d359075d59ad4aec2d01a21d9514b02

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

LOG: [lldb] Fix breakpoint resolver serialization bug (#76766)

BreakpointResolverAddress optionally can include the module name related
to the address that gets resolved. Currently this will never work
because it sets the name to itself (which is empty).

Added: 


Modified: 
lldb/source/Breakpoint/BreakpointResolverAddress.cpp

lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py

Removed: 




diff  --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp 
b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index a0c628a8e299ce..ee4cbd50f9eee2 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -65,13 +65,11 @@ BreakpointResolverAddress::SerializeToStructuredData() {
   new StructuredData::Dictionary());
   SectionSP section_sp = m_addr.GetSection();
   if (section_sp) {
-ModuleSP module_sp = section_sp->GetModule();
-ConstString module_name;
-if (module_sp)
-  module_name.SetCString(module_name.GetCString());
-
-options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
-   module_name.GetCString());
+if (ModuleSP module_sp = section_sp->GetModule()) {
+  const FileSpec &module_fspec = module_sp->GetFileSpec();
+  options_dict_sp->AddStringItem(GetKey(OptionNames::ModuleName),
+ module_fspec.GetPath().c_str());
+}
 options_dict_sp->AddIntegerItem(GetKey(OptionNames::AddressOffset),
 m_addr.GetOffset());
   } else {

diff  --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index be9b4e587b2969..b6cc3d9989a699 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -49,6 +49,42 @@ def test_scripted_extra_args(self):
 self.setup_targets_and_cleanup()
 self.do_check_extra_args()
 
+def test_resolver_serialization(self):
+"""Test that breakpoint resolvers contain the expected information"""
+self.build()
+self.setup_targets_and_cleanup()
+
+exe_path = self.getBuildArtifact("a.out")
+exe_module = self.orig_target.module[exe_path]
+self.assertTrue(
+exe_module.IsValid(), "Failed to find the executable module in 
target"
+)
+sym_ctx_list = exe_module.FindFunctions("main")
+self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 
'main'")
+sym_ctx = sym_ctx_list.GetContextAtIndex(0)
+self.assertTrue(
+sym_ctx.IsValid(), "SBSymbolContext representing function 'main' 
is invalid"
+)
+main_func = sym_ctx.GetFunction()
+self.assertTrue(
+main_func.IsValid(), "SBFunction representing 'main' is invalid"
+)
+main_addr = main_func.GetStartAddress()
+
+bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
+self.assertTrue(
+bkpt.IsValid(), "Could not place breakpoint on 'main' by address"
+)
+stream = lldb.SBStream()
+sd = bkpt.SerializeToStructuredData()
+sd.GetAsJSON(stream)
+serialized_data = json.loads(stream.GetData())
+
+self.assertIn(
+exe_path,
+
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"],
+)
+
 def test_structured_data_serialization(self):
 target = self.dbg.GetDummyTarget()
 self.assertTrue(target.IsValid(), VALID_TARGET)



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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

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

clayborg wrote:

I recently ran into this issue when looking at new failures in:

https://github.com/llvm/llvm-project/pull/74786#issuecomment-1874921872

And this was referred to in bug report:

https://github.com/llvm/llvm-project/issues/53904

After looking at the code, I believe we do need to parse contained types for a 
struct/class/union as we don't get an external AST source call for them. So I 
do believe this is the right thing to do. Even if we do parse the extra types, 
if we have a class within a class, then it will add a forward declaration to it 
only, and expand it later if any only if it is needed. I have attached a 
slightly different version of this patch to 
https://github.com/llvm/llvm-project/issues/53904 for reference.

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


[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] Resolve nested types when parsing structures (PR #66879)

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

clayborg wrote:

So while you were able to work around issues with the expression parser with 
#68705, I do believe a modified version of this patch is needed.

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


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

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

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

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

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

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

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

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

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

[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

bulbazord wrote:

Looks like this broke on aarch64-windows. Taking a look now.

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

bulbazord wrote:

```
==
ERROR: test_resolver_serialization 
(TestBreakpointSerialization.BreakpointSerialization)
   Test that breakpoint resolvers contain the expected information
--
Traceback (most recent call last):
  File 
"C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\functionalities\breakpoint\serialize\TestBreakpointSerialization.py",
 line 60, in test_resolver_serialization
exe_module.IsValid(), "Failed to find the executable module in target"
^^
AttributeError: 'NoneType' object has no attribute 'IsValid'
Config=aarch64-C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe
--
```

@clayborg Any idea why the executable module wouldn't be found here? Looks like 
`exe_module` is `None`.

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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

clayborg wrote:

> ```
> ==
> ERROR: test_resolver_serialization 
> (TestBreakpointSerialization.BreakpointSerialization)
>Test that breakpoint resolvers contain the expected information
> --
> Traceback (most recent call last):
>   File 
> "C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\API\functionalities\breakpoint\serialize\TestBreakpointSerialization.py",
>  line 60, in test_resolver_serialization
> exe_module.IsValid(), "Failed to find the executable module in target"
> ^^
> AttributeError: 'NoneType' object has no attribute 'IsValid'
> Config=aarch64-C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\clang.exe
> --
> ```
> 
> @clayborg Any idea why the executable module wouldn't be found here? Looks 
> like `exe_module` is `None`.

You can just use "a.out" when doing the lookup, do this:
```
exe_module = self.orig_target.module["a.out"]
```
The full path isn't needed. I would guess there might be some sort of path 
issue with the value returned from `self.getBuildArtifact("a.out")` that 
doesn't match exactly with the windows path from the module list?

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


[Lldb-commits] [lldb] bdaedff - [lldb] Speculatively fix TestBreakpointSerialization on Windows

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

Author: Alex Langford
Date: 2024-01-03T15:50:25-08:00
New Revision: bdaedffc43a608ef5fdc8a0e0c524be0a3a8f72e

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

LOG: [lldb] Speculatively fix TestBreakpointSerialization on Windows

See: https://lab.llvm.org/buildbot/#/builders/219/builds/7961/steps/6/logs/stdio

Added: 


Modified: 

lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
index b6cc3d9989a699..985bafabdc5bcc 100644
--- 
a/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
+++ 
b/lldb/test/API/functionalities/breakpoint/serialize/TestBreakpointSerialization.py
@@ -55,7 +55,7 @@ def test_resolver_serialization(self):
 self.setup_targets_and_cleanup()
 
 exe_path = self.getBuildArtifact("a.out")
-exe_module = self.orig_target.module[exe_path]
+exe_module = self.orig_target.module["a.out"]
 self.assertTrue(
 exe_module.IsValid(), "Failed to find the executable module in 
target"
 )



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


[Lldb-commits] [lldb] [lldb] Fix breakpoint resolver serialization bug (PR #76766)

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

bulbazord wrote:

Speculative fix in bdaedffc43a608ef5fdc8a0e0c524be0a3a8f72e

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


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

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

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

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

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

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

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

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

adrian-prantl wrote:

@JDevlieghere I merged the two. This made the regular (on-disk) case somewhat 
less efficient because all SupportFiles are now on the Heap but that probably 
isn't even measurable.

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


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

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

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

LGTM!

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


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

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

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


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

2024-01-03 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/11] 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/11] 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/11] 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] [libcxx] [clang-tools-extra] [llvm] [lld] [libc] [libcxxabi] [compiler-rt] [lldb] [flang] [mlir] [polly] [clang] Make clang report invalid target versions. (PR #75373)

2024-01-03 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/12] 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/12] 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/12] 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] Add support for inline DWARF source files. (PR #75880)

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

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

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

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

As an implementation detail, this patch separate SupportFileList from
FileSpecList and makes SupportFileList uncopyable.
---
 lldb/include/lldb/Symbol/CompileUnit.h|  23 ++--
 lldb/include/lldb/Symbol/SymbolFile.h |   2 +-
 lldb/include/lldb/Symbol/SymbolFileOnDemand.h |   2 +-
 lldb/include/lldb/Utility/FileSpecList.h  | 109 +-
 lldb/source/API/SBCompileUnit.cpp |   2 +-
 lldb/source/Commands/CommandObjectSource.cpp  |   2 +-
 lldb/source/Core/ModuleList.cpp   |   2 +-
 .../Clang/ClangUserExpression.cpp |  12 +-
 .../Clang/CppModuleConfiguration.cpp  |   6 +-
 .../Breakpad/SymbolFileBreakpad.cpp   |   5 +-
 .../SymbolFile/Breakpad/SymbolFileBreakpad.h  |   3 +-
 .../Plugins/SymbolFile/CTF/SymbolFileCTF.h|   2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 107 -
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   9 +-
 .../DWARF/SymbolFileDWARFDebugMap.cpp |   4 +-
 .../DWARF/SymbolFileDWARFDebugMap.h   |   2 +-
 .../Plugins/SymbolFile/JSON/SymbolFileJSON.h  |   2 +-
 .../NativePDB/SymbolFileNativePDB.cpp |   4 +-
 .../NativePDB/SymbolFileNativePDB.h   |   2 +-
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp  |   2 +-
 .../Plugins/SymbolFile/PDB/SymbolFilePDB.h|   2 +-
 .../SymbolFile/Symtab/SymbolFileSymtab.cpp|   2 +-
 .../SymbolFile/Symtab/SymbolFileSymtab.h  |   2 +-
 lldb/source/Symbol/CompileUnit.cpp|  13 +--
 lldb/source/Symbol/SymbolFileOnDemand.cpp |   2 +-
 lldb/source/Utility/FileSpecList.cpp  |  58 --
 .../inline-sourcefile/Makefile|  11 ++
 .../TestInlineSourceFiles.py  |  17 +++
 .../inline-sourcefile/inline.ll   |  39 +++
 .../functionalities/inline-sourcefile/main.c  |   7 ++
 lldb/unittests/Core/FileSpecListTest.cpp  |   8 +-
 .../Expression/CppModuleConfigurationTest.cpp |  48 +---
 32 files changed, 371 insertions(+), 140 deletions(-)
 create mode 100644 lldb/test/API/functionalities/inline-sourcefile/Makefile
 create mode 100644 
lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py
 create mode 100644 lldb/test/API/functionalities/inline-sourcefile/inline.ll
 create mode 100644 lldb/test/API/functionalities/inline-sourcefile/main.c

diff --git a/lldb/include/lldb/Symbol/CompileUnit.h 
b/lldb/include/lldb/Symbol/CompileUnit.h
index 93f191b4998584..89e853ab599d0f 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -112,10 +112,13 @@ class CompileUnit : public 
std::enable_shared_from_this,
   /// the compile unit is optimized will be made when
   /// CompileUnit::GetIsOptimized() is called.
   ///
+  /// \param[in] support_files
+  /// An rvalue list of already parsed support files.
   /// \see lldb::LanguageType
   CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
   const FileSpec &file_spec, lldb::user_id_t uid,
-  lldb::LanguageType language, lldb_private::LazyBool 
is_optimized);
+  lldb::LanguageType language, lldb_private::LazyBool is_optimized,
+  SupportFileList &&support_files = {});
 
   /// Add a function to this compile unit.
   ///
@@ -226,6 +229,9 @@ class CompileUnit : public 
std::enable_shared_from_this,
   /// Return the primary source file associated with this compile unit.
   const FileSpec &GetPrimaryFile() const { return m_file_spec; }
 
+  /// Return the primary source file associated with this compile unit.
+  void SetPrimaryFile(const FileSpec &fs) { m_file_spec = fs; }
+
   /// Get the line table for the compile unit.
   ///
   /// Called by clients and the SymbolFile plug-in. The SymbolFile plug-ins
@@ -265,7 +271,13 @@ class CompileUnit : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// A support file list object.
-  const FileSpecList &GetSupportFiles();
+  const SupportFileList &GetSupportFiles();
+
+  /// Used by plugins that parse the support file list.
+  SupportFileList &GetSupportFileList() {
+m_flags.Set(flagsParsedSupportFiles);
+return m_support_files;
+  }
 
   /// Get the compile unit's imported module list.
   ///
@@ -331,8 +343,6 @@ class CompileUnit : public 
std::enable_shared_from_this,
   /// A line table object pointer that this object now owns.
   void SetLineTable(LineTable *line_table);
 

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

2024-01-03 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 

  1   2   >