[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
DavidSpickett wrote: > A WebAssembly debugging session can be started using the new command: > wasm [:] What about wasm requires a new command, given that you are connecting to a GDB server as existing targets do. https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] [libcxx] [clang-tools-extra] [clang] [lld] [flang] [mlir] [compiler-rt] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)
https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/78022 >From 0988bb25a35e5d50b44bf53d459098777280c3e5 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Sat, 13 Jan 2024 16:00:16 +0800 Subject: [PATCH 1/3] [clang-tidy]Add new check readability-avoid-nested-conditional-operator Finds nested conditional operator. Nested conditional operators lead code hard to understand, so they should be splited as several statement and stored in temporary varibale. --- .../AvoidNestedConditionalOperatorCheck.cpp | 56 +++ .../AvoidNestedConditionalOperatorCheck.h | 33 +++ .../clang-tidy/readability/CMakeLists.txt | 1 + .../readability/ReadabilityTidyModule.cpp | 3 + clang-tools-extra/docs/ReleaseNotes.rst | 5 ++ .../docs/clang-tidy/checks/list.rst | 1 + .../avoid-nested-conditional-operator.rst | 20 +++ .../avoid-nested-conditional-operator.cpp | 23 8 files changed, 142 insertions(+) create mode 100644 clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp create mode 100644 clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h create mode 100644 clang-tools-extra/docs/clang-tidy/checks/readability/avoid-nested-conditional-operator.rst create mode 100644 clang-tools-extra/test/clang-tidy/checkers/readability/avoid-nested-conditional-operator.cpp diff --git a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp new file mode 100644 index 00..a0278c3ae32fa7 --- /dev/null +++ b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.cpp @@ -0,0 +1,56 @@ +//===--- AvoidNestedConditionalOperatorCheck.cpp - clang-tidy --===// +// +// 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 "AvoidNestedConditionalOperatorCheck.h" +#include "clang/AST/Expr.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/Basic/DiagnosticIDs.h" + +using namespace clang::ast_matchers; + +namespace clang::tidy::readability { + +namespace { +constexpr const char *Description = "don't use nested conditional operator"; +constexpr const char *OutSideConditionalOperatorNote = +"outside conditional operator here"; +} // namespace + +void AvoidNestedConditionalOperatorCheck::registerMatchers( +MatchFinder *Finder) { + Finder->addMatcher( + conditionalOperator( + anyOf( + hasCondition(ignoringParenCasts( + conditionalOperator().bind("nested-conditional-operator"))), + hasTrueExpression(ignoringParenCasts( + conditionalOperator().bind("nested-conditional-operator"))), + hasFalseExpression(ignoringParenCasts( + conditionalOperator().bind("nested-conditional-operator") + .bind("conditional-operator"), + this); +} + +void AvoidNestedConditionalOperatorCheck::check( +const MatchFinder::MatchResult &Result) { + const auto *CO = + Result.Nodes.getNodeAs("conditional-operator"); + const auto *NCO = Result.Nodes.getNodeAs( + "nested-conditional-operator"); + assert(CO); + assert(NCO); + + if (CO->getBeginLoc().isMacroID() || NCO->getBeginLoc().isMacroID()) +return; + + diag(NCO->getBeginLoc(), Description); + diag(CO->getBeginLoc(), OutSideConditionalOperatorNote, DiagnosticIDs::Note); +} + +} // namespace clang::tidy::readability diff --git a/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h new file mode 100644 index 00..2f82ea86cd849d --- /dev/null +++ b/clang-tools-extra/clang-tidy/readability/AvoidNestedConditionalOperatorCheck.h @@ -0,0 +1,33 @@ +//===--- AvoidNestedConditionalOperatorCheck.h - clang-tidy --*- 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 LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_AVOIDNestedConditionalOperatorCHECK_H + +#include "../ClangTidyCheck.h" + +namespace clang::tidy::readability { + +/// Finds nested conditional operator. +/// +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/readability/avoid-nested-conditional-ope
[Lldb-commits] [compiler-rt] [clang-tools-extra] [lld] [clang] [lldb] [libcxx] [llvm] [mlir] [flang] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)
https://github.com/HerrCai0907 closed https://github.com/llvm/llvm-project/pull/78022 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [libc] [clang] [llvm] [libcxxabi] [clang-tools-extra] [lld] [flang] [compiler-rt] [libcxx] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
@@ -3358,14 +3396,17 @@ genOMP(Fortran::lower::AbstractConverter &converter, .t); // Currently only private/firstprivate clause is handled, and // all privatization is done within `omp.section` operations. + symTable.pushScope(); skatrak wrote: Thanks for the explanation, that clears it for me https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [libcxx] [compiler-rt] [flang] [libc] [lldb] [clang-tools-extra] [lld] [libcxxabi] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
https://github.com/skatrak approved this pull request. Thanks for addressing my comments, LGTM. https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [libc] [clang] [llvm] [libcxxabi] [clang-tools-extra] [lld] [flang] [compiler-rt] [libcxx] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lld] [compiler-rt] [flang] [clang] [libcxxabi] [lldb] [libcxx] [clang-tools-extra] [libc] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
@@ -110,6 +110,34 @@ static void gatherFuncAndVarSyms( } } +static Fortran::lower::pft::Evaluation * +getCollapsedEval(Fortran::lower::pft::Evaluation &eval, int collapseValue) { skatrak wrote: Nit: Maybe `getCollapsedLoopEval` would be slightly more self-explanatory? https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [libcxx] [compiler-rt] [libc] [lldb] [libcxxabi] [flang] [lld] [clang] [llvm] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
https://github.com/kiranchandramohan edited https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [flang] [libcxx] [lld] [libcxxabi] [llvm] [lldb] [libc] [clang] [compiler-rt] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
https://github.com/kiranchandramohan approved this pull request. LG. Please add a pointer to the discussion where it was agreed to pass a reference to the localSymbolTable. https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [libcxxabi] [libcxx] [llvm] [libc] [clang-tools-extra] [lldb] [flang] [lld] [clang] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
@@ -110,6 +110,34 @@ static void gatherFuncAndVarSyms( } } +static Fortran::lower::pft::Evaluation * +getCollapsedEval(Fortran::lower::pft::Evaluation &eval, int collapseValue) { + // Return the Evaluation of the innermost collapsed loop, or the current + // evaluation, if there is nothing to collapse. + if (collapseValue == 0) +return &eval; kiranchandramohan wrote: Nit: Is it better to convert this to an assert (for > 0) and move this code to the parent function? https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
@@ -80,6 +81,13 @@ class TemplateArgument { /// that was provided for an integral non-type template parameter. Integral, +/// The template argument is a non-type template argument that can't be +/// represented by the special-case Declaration, NullPtr, or Integral +/// forms. These values are only ever produced by constant evaluation, +/// so cannot be dependent. +/// TODO: merge Declaration, NullPtr and Integral into this? cor3ntin wrote: That's fine, i wanted to check! https://github.com/llvm/llvm-project/pull/78041 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
cor3ntin wrote: > > Should we add a couple of PCH tests ? > > [clang/test/Modules/odr_hash.cpp](https://github.com/llvm/llvm-project/pull/78041/files#diff-b0662120e3a8a2bf3ccd95b9e8943640816b457c00e662ebfdd648632e383314) > should cover AST serialization/deserialization. But I could missing > something, of course. What is your concern? Looking at those tests again, they seem sufficient. https://github.com/llvm/llvm-project/pull/78041 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [clang] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
cor3ntin wrote: I'm tempted to think that we should accept / merge this now @AaronBallman The logic is that this is a pretty big hole in our C++20 support and I don't think it's reasonable to try a merge after the deadline for 18. WDYT? https://github.com/llvm/llvm-project/pull/78041 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 14268ad - [lldb] Skip part of TestDataFormatterAdv (#72233)
Author: Pavel Labath Date: 2024-01-15T12:49:24Z New Revision: 14268ad2a2ea0b3bbe6b767d67ace1d0ae992a6d URL: https://github.com/llvm/llvm-project/commit/14268ad2a2ea0b3bbe6b767d67ace1d0ae992a6d DIFF: https://github.com/llvm/llvm-project/commit/14268ad2a2ea0b3bbe6b767d67ace1d0ae992a6d.diff LOG: [lldb] Skip part of TestDataFormatterAdv (#72233) libstdc++ data formatter simply forwards to the `const char *` formatter -- which means it suffers from the same problem/bug as that one. Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py index c275904eaf2014..d296e60d6e6e99 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py @@ -6,6 +6,7 @@ import lldb from lldbsuite.test.lldbtest import * import lldbsuite.test.lldbutil as lldbutil +import re class AdvDataFormatterTestCase(TestBase): @@ -298,7 +299,11 @@ def cleanup(): self.runCmd("settings set target.max-string-summary-length 5") some_string = self.frame().FindVariable("some_string") some_string_summary = some_string.GetSummary() -self.assertEqual(some_string_summary, '"01234"...') +if (re.match(r"^std::__\w+::", some_string.GetTypeName())): + self.assertEqual(some_string_summary, '"01234"...') +else: + #libstdc++ string formatter suffers from the same problem as some_cstring below + pass some_carr = self.frame().FindVariable("some_carr") some_carr_summary = some_carr.GetSummary() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] [clang-tools-extra] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)
Endilll wrote: > The logic is that this is a pretty big hole in our C++20 support and I don't > think it's reasonable to try a merge after the deadline for 18. WDYT? >From our past experience with release managers, they seem quite generous with >deadlines to merge stuff in, as long as maintainers agree. I think the real >question is how much time do we want this to bake in tree before users get to >see it. https://github.com/llvm/llvm-project/pull/78041 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lld] [clang-tools-extra] [lldb] [compiler-rt] [clang] [libcxx] [flang] [libcxxabi] [libc] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
kparzysz wrote: Here's link to my comment about symbol table in the thread, followed by response from Valentin: https://discourse.llvm.org/t/openmp-lowering-from-pft-to-fir/75263/49 https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libc] [llvm] [libcxx] [compiler-rt] [lld] [libcxxabi] [lldb] [clang-tools-extra] [flang] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
@@ -110,6 +110,34 @@ static void gatherFuncAndVarSyms( } } +static Fortran::lower::pft::Evaluation * +getCollapsedEval(Fortran::lower::pft::Evaluation &eval, int collapseValue) { kparzysz wrote: I'll make this change in another commit. https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [lldb] [libcxx] [compiler-rt] [libcxxabi] [lld] [clang-tools-extra] [clang] [flang] [llvm] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
@@ -110,6 +110,34 @@ static void gatherFuncAndVarSyms( } } +static Fortran::lower::pft::Evaluation * +getCollapsedEval(Fortran::lower::pft::Evaluation &eval, int collapseValue) { + // Return the Evaluation of the innermost collapsed loop, or the current + // evaluation, if there is nothing to collapse. + if (collapseValue == 0) +return &eval; kparzysz wrote: I'll make this change in another commit. https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [clang] [libcxx] [lld] [llvm] [compiler-rt] [lldb] [clang-tools-extra] [libcxxabi] [libc] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
https://github.com/kparzysz closed https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libc] [llvm] [libcxx] [compiler-rt] [lld] [libcxxabi] [lldb] [clang-tools-extra] [flang] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)
https://github.com/kparzysz edited https://github.com/llvm/llvm-project/pull/77759 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [openmp] [clang] [libcxx] [lld] [llvm] [compiler-rt] [mlir] [libunwind] [lldb] [clang-tools-extra] [libcxxabi] [libc] [C23] Implement N3018: The constexpr specifier for object d
Fznamznon wrote: Ping. https://github.com/llvm/llvm-project/pull/73099 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [lldb] [libcxx] [compiler-rt] [libcxxabi] [lld] [clang-tools-extra] [clang] [flang] [llvm] [Flang][OpenMP] Push genEval calls to individual operations, NFC (PR #77758)
kparzysz wrote: Suggested changed made in https://github.com/llvm/llvm-project/commit/705d9273c5417e04dc542f0e46b90960c235c753. The buildkite times are really long now (7h on Friday), and I didn't want to delay merging of this PR by that much, plus the changes were really minor. https://github.com/llvm/llvm-project/pull/77758 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [lldb] [libcxx] [compiler-rt] [lld] [clang-tools-extra] [clang] [flang] [llvm] [IPSCCP] Variable not visible at Og: (PR #77901)
https://github.com/CarlosAlbertoEnciso updated https://github.com/llvm/llvm-project/pull/77901 >From cea029185ad219a4a0b6d03be00b0612675933ab Mon Sep 17 00:00:00 2001 From: Carlos Alberto Enciso Date: Fri, 12 Jan 2024 09:27:53 + Subject: [PATCH] [IPSCCP] Variable not visible at Og: https://bugs.llvm.org/show_bug.cgi?id=51559 https://github.com/llvm/llvm-project/issues/50901 IPSCCP pass removes the global variable and does not create a constant expression for the initializer value. Extend test coverage to include: - half and bfloat types. - checks for undef (int32 and ptr). --- llvm/lib/Transforms/Utils/Local.cpp | 3 +- llvm/test/Transforms/SCCP/pr50901.ll | 41 ++- llvm/unittests/Transforms/Utils/LocalTest.cpp | 20 + 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index b9cad764aaef8b..ecbefca4549caf 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -3594,7 +3594,8 @@ DIExpression *llvm::getExpressionForConstant(DIBuilder &DIB, const Constant &C, return createIntegerExpression(C); auto *FP = dyn_cast(&C); - if (FP && (Ty.isFloatTy() || Ty.isDoubleTy())) { + if (FP && + (Ty.isFloatTy() || Ty.isDoubleTy() || Ty.isHalfTy() || Ty.isBFloatTy())) { const APFloat &APF = FP->getValueAPF(); return DIB.createConstantValueExpression( APF.bitcastToAPInt().getZExtValue()); diff --git a/llvm/test/Transforms/SCCP/pr50901.ll b/llvm/test/Transforms/SCCP/pr50901.ll index 11d6bba6f6a935..d48d67532d88bd 100644 --- a/llvm/test/Transforms/SCCP/pr50901.ll +++ b/llvm/test/Transforms/SCCP/pr50901.ll @@ -52,6 +52,16 @@ ; CHECK: = !DIGlobalVariableExpression(var: ![[DBG_FLOAT_UNDEF:.+]], expr: !DIExpression()) ; CHECK-DAG: ![[DBG_FLOAT_UNDEF]] = distinct !DIGlobalVariable(name: "g_float_undef" +; CHECK: ![[G8:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG8:[0-9]+]], expr: !DIExpression(DW_OP_constu, 22136, DW_OP_stack_value)) +; CHECK-DAG: ![[DBG8]] = distinct !DIGlobalVariable(name: "g_88", {{.*}} +; CHECK: ![[G9:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBG9:[0-9]+]], expr: !DIExpression(DW_OP_constu, 23726, DW_OP_stack_value)) +; CHECK-DAG: ![[DBG9]] = distinct !DIGlobalVariable(name: "g_99", {{.*}} + +; CHECK-DAG: ![[DBGA:[0-9]+]] = distinct !DIGlobalVariable(name: "g_i32_undef" +; CHECK-DAG: ![[GA:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBGA]], expr: !DIExpression()) +; CHECK-DAG: ![[DBGB:[0-9]+]] = distinct !DIGlobalVariable(name: "g_ptr_undef" +; CHECK-DAG: ![[GB:[0-9]+]] = !DIGlobalVariableExpression(var: ![[DBGB]], expr: !DIExpression()) + @g_1 = dso_local global i32 -4, align 4, !dbg !0 @g_2 = dso_local global float 0x4011C28F6000, align 4, !dbg !8 @g_3 = dso_local global i8 97, align 1, !dbg !10 @@ -59,6 +69,8 @@ @g_5 = dso_local global i8 1, align 1, !dbg !16 @g_6 = dso_local global ptr null, align 8, !dbg !19 @g_7 = dso_local global ptr null, align 8, !dbg !23 +@g_8 = dso_local global half 0xH4321, align 4, !dbg !86 +@g_9 = dso_local global bfloat 0xR3F80, align 4, !dbg !90 @_ZL4g_11 = internal global i32 -5, align 4, !dbg !25 @_ZL4g_22 = internal global float 0x40164000, align 4, !dbg !27 @_ZL4g_33 = internal global i8 98, align 1, !dbg !29 @@ -67,6 +79,10 @@ @_ZL4g_66 = internal global ptr null, align 8, !dbg !35 @_ZL4g_77 = internal global ptr inttoptr (i64 70 to ptr), align 8, !dbg !37 @g_float_undef = internal global float undef, align 4, !dbg !83 +@_ZL4g_88 = internal global half 0xH5678, align 4, !dbg !88 +@_ZL4g_99 = internal global bfloat 0xR5CAE, align 4, !dbg !92 +@g_i32_undef = internal global i32 undef, align 4, !dbg !95 +@g_ptr_undef = internal global ptr undef, align 8, !dbg !97 define dso_local void @_Z3barv() !dbg !46 { entry: @@ -88,6 +104,15 @@ entry: store ptr %6, ptr @g_7, align 8, !dbg !59 %l = load float, ptr @g_float_undef, align 8, !dbg !59 store float %l, ptr @g_2, align 8, !dbg !59 + %7 = load half, ptr @_ZL4g_88, align 4, !dbg !59 + store half %7, ptr @g_8, align 4, !dbg !59 + %8 = load bfloat, ptr @_ZL4g_99, align 4, !dbg !59 + store bfloat %8, ptr @g_9, align 4, !dbg !59 + %9 = load i32, ptr @g_i32_undef, align 4, !dbg !59 + store i32 %9, ptr @g_1, align 4, !dbg !59 + %10 = load ptr, ptr @g_ptr_undef, align 8, !dbg !59 + store ptr %10, ptr @g_6, align 8, !dbg !59 + ret void, !dbg !59 } @@ -108,7 +133,7 @@ entry: !4 = !{!5} !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64) !6 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) -!7 = !{!0, !8, !10, !13, !16, !19, !23, !25, !27, !29, !31, !33, !35, !37, !83} +!7 = !{!0, !8, !10, !13, !16, !19, !23, !25, !27, !29, !31, !33, !35, !37, !83, !86, !88, !90, !92, !95, !97} !8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression()) !9 = distinct !DIGlobalVariable(name: "g_2", scope: !2, file: !3, l
[Lldb-commits] [llvm] [clang-tools-extra] [lld] [clang] [compiler-rt] [flang] [libc] [lldb] [libcxx] [libcxxabi] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/77759 >From 62f31654ec66fe0e2a27200d0484d3c70d4ce2c1 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Wed, 20 Dec 2023 15:12:04 -0600 Subject: [PATCH 1/7] [Flang][OpenMP] Separate creation of work-sharing and SIMD loops, NFC These two constructs were both handled in `genOMP` for loop constructs. There is some shared code between the two, but there are also enough differences to separate these two cases into individual functions. The shared code may be placed into a helper function later if needed. Recursive lowering [1/5] --- flang/lib/Lower/OpenMP.cpp | 252 ++--- 1 file changed, 153 insertions(+), 99 deletions(-) diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index c3a570bf15ea0d..350cb29121da93 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -2968,24 +2968,150 @@ genOMP(Fortran::lower::AbstractConverter &converter, standaloneConstruct.u); } -static void genOMP(Fortran::lower::AbstractConverter &converter, - Fortran::lower::pft::Evaluation &eval, - Fortran::semantics::SemanticsContext &semanticsContext, - const Fortran::parser::OpenMPLoopConstruct &loopConstruct) { +static void +createSimdLoop(Fortran::lower::AbstractConverter &converter, + Fortran::lower::pft::Evaluation &eval, + llvm::omp::Directive ompDirective, + const Fortran::parser::OmpClauseList &loopOpClauseList, + mlir::Location loc) { fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder(); - llvm::SmallVector lowerBound, upperBound, step, linearVars, - linearStepVars, reductionVars; + DataSharingProcessor dsp(converter, loopOpClauseList, eval); + dsp.processStep1(); + + Fortran::lower::StatementContext stmtCtx; mlir::Value scheduleChunkClauseOperand; - mlir::IntegerAttr orderedClauseOperand; + llvm::SmallVector lowerBound, upperBound, step, reductionVars; + llvm::SmallVector iv; + llvm::SmallVector reductionDeclSymbols; + mlir::omp::ClauseOrderKindAttr orderClauseOperand; + std::size_t loopVarTypeSize; + + ClauseProcessor cp(converter, loopOpClauseList); + cp.processCollapse(loc, eval, lowerBound, upperBound, step, iv, + loopVarTypeSize); + cp.processScheduleChunk(stmtCtx, scheduleChunkClauseOperand); + cp.processReduction(loc, reductionVars, reductionDeclSymbols); + cp.processTODO(loc, ompDirective); + + // The types of lower bound, upper bound, and step are converted into the + // type of the loop variable if necessary. + mlir::Type loopVarType = getLoopVarType(converter, loopVarTypeSize); + for (unsigned it = 0; it < (unsigned)lowerBound.size(); it++) { +lowerBound[it] = +firOpBuilder.createConvert(loc, loopVarType, lowerBound[it]); +upperBound[it] = +firOpBuilder.createConvert(loc, loopVarType, upperBound[it]); +step[it] = firOpBuilder.createConvert(loc, loopVarType, step[it]); + } + + llvm::SmallVector alignedVars, nontemporalVars; + mlir::Value ifClauseOperand; + mlir::IntegerAttr simdlenClauseOperand, safelenClauseOperand; + cp.processIf(Fortran::parser::OmpIfClause::DirectiveNameModifier::Simd, + ifClauseOperand); + cp.processSimdlen(simdlenClauseOperand); + cp.processSafelen(safelenClauseOperand); + cp.processTODO(loc, ompDirective); + + mlir::TypeRange resultType; + auto simdLoopOp = firOpBuilder.create( + loc, resultType, lowerBound, upperBound, step, alignedVars, + /*alignment_values=*/nullptr, ifClauseOperand, nontemporalVars, + orderClauseOperand, simdlenClauseOperand, safelenClauseOperand, + /*inclusive=*/firOpBuilder.getUnitAttr()); + createBodyOfOp(simdLoopOp, converter, loc, eval, +&loopOpClauseList, iv, +/*outer=*/false, &dsp); +} + +static void createWsLoop(Fortran::lower::AbstractConverter &converter, + Fortran::lower::pft::Evaluation &eval, + llvm::omp::Directive ompDirective, + const Fortran::parser::OmpClauseList &beginClauseList, + const Fortran::parser::OmpClauseList *endClauseList, + mlir::Location loc) { + fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder(); + DataSharingProcessor dsp(converter, beginClauseList, eval); + dsp.processStep1(); + + Fortran::lower::StatementContext stmtCtx; + mlir::Value scheduleChunkClauseOperand; + llvm::SmallVector lowerBound, upperBound, step, reductionVars, + linearVars, linearStepVars; + llvm::SmallVector iv; + llvm::SmallVector reductionDeclSymbols; mlir::omp::ClauseOrderKindAttr orderClauseOperand; mlir::omp::ClauseScheduleKindAttr scheduleValClauseOperand; - mlir::omp::ScheduleModifierAttr scheduleModClauseOperand; mlir::UnitAttr
[Lldb-commits] [libc] [llvm] [clang] [libcxx] [clang-tools-extra] [flang] [compiler-rt] [lldb] [libunwind] [libc++] Implement ranges::iota (PR #68494)
https://github.com/jamesETsmith edited https://github.com/llvm/llvm-project/pull/68494 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [libcxx] [lldb] [mlir] [flang] [clang-tools-extra] [llvm] [clang] [lld] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)
@@ -0,0 +1,52 @@ +//===--- AvoidNestedConditionalOperatorCheck.cpp - clang-tidy --===// EugeneZelenko wrote: Please add `-` https://github.com/llvm/llvm-project/pull/78022 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [libc] [clang-tools-extra] [libcxx] [libcxxabi] [llvm] [lldb] [clang] [lld] [flang] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)
kiranchandramohan wrote: > Introduce createSectionOp `genSectionOp`? https://github.com/llvm/llvm-project/pull/77759 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [libc] [clang-tools-extra] [libcxx] [libcxxabi] [llvm] [lldb] [clang] [lld] [flang] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)
https://github.com/kiranchandramohan approved this pull request. LG. https://github.com/llvm/llvm-project/pull/77759 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [libcxx] [libcxxabi] [lldb] [flang] [clang-tools-extra] [libc] [llvm] [clang] [lld] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)
https://github.com/kparzysz closed https://github.com/llvm/llvm-project/pull/77759 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [libcxx] [libcxxabi] [lldb] [flang] [clang-tools-extra] [libc] [llvm] [clang] [lld] [Flang][OpenMP] Handle SECTION construct from within SECTIONS (PR #77759)
kparzysz wrote: > > Introduce createSectionOp > > `genSectionOp`? Yes---fixed the commit message. https://github.com/llvm/llvm-project/pull/77759 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Further remove redundant parameters to ReadPointedString (PR #78029)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/78029 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Further remove redundant parameters to ReadPointedString (PR #78029)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/78029 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [lld] [clang-tools-extra] [llvm] [compiler-rt] [lldb] [clang] [libc] [libcxx] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
https://github.com/rampitec updated https://github.com/llvm/llvm-project/pull/74537 >From 7e382620cdc5999c645ed0746f242595f0294c58 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Mon, 4 Dec 2023 16:11:53 -0800 Subject: [PATCH 01/11] [AMDGPU] Use alias info to relax waitcounts for LDS DMA LDA DMA loads increase VMCNT and a load from the LDS stored must wait on this counter to only read memory after it is written. Wait count insertion pass does not track memory dependencies, it tracks register dependencies. To model the LDS dependency a psuedo register is used in the scoreboard, acting like if LDS DMA writes it and LDS load reads it. This patch adds 8 more pseudo registers to use for independent LDS locations if we can prove they are disjoint using alias analysis. Fixes: SWDEV-433427 --- llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 16 +- llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 73 +- llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | 4 +- llvm/lib/Target/AMDGPU/SIInstrInfo.h| 8 + llvm/lib/Target/AMDGPU/lds-dma-waits.ll | 154 llvm/test/CodeGen/AMDGPU/llc-pipeline.ll| 2 + 6 files changed, 241 insertions(+), 16 deletions(-) create mode 100644 llvm/lib/Target/AMDGPU/lds-dma-waits.ll diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index a7f4d63229b7eff..2e079404b087faa 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -1128,11 +1128,10 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info, MachineMemOperand::MOStore | MachineMemOperand::MODereferenceable; - // XXX - Should this be volatile without known ordering? - Info.flags |= MachineMemOperand::MOVolatile; - switch (IntrID) { default: +// XXX - Should this be volatile without known ordering? +Info.flags |= MachineMemOperand::MOVolatile; break; case Intrinsic::amdgcn_raw_buffer_load_lds: case Intrinsic::amdgcn_raw_ptr_buffer_load_lds: @@ -1140,6 +1139,7 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info, case Intrinsic::amdgcn_struct_ptr_buffer_load_lds: { unsigned Width = cast(CI.getArgOperand(2))->getZExtValue(); Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8); +Info.ptrVal = CI.getArgOperand(1); return true; } } @@ -1268,8 +1268,8 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info, Info.opc = ISD::INTRINSIC_VOID; unsigned Width = cast(CI.getArgOperand(2))->getZExtValue(); Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8); -Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore | - MachineMemOperand::MOVolatile; +Info.ptrVal = CI.getArgOperand(1); +Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore; return true; } case Intrinsic::amdgcn_ds_bvh_stack_rtn: { @@ -9084,7 +9084,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op, MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo(); MachinePointerInfo StorePtrI = LoadPtrI; -StorePtrI.V = nullptr; +LoadPtrI.V = UndefValue::get( +PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS)); +LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS; StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS; auto F = LoadMMO->getFlags() & @@ -9162,6 +9164,8 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op, MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo(); LoadPtrI.Offset = Op->getConstantOperandVal(5); MachinePointerInfo StorePtrI = LoadPtrI; +LoadPtrI.V = UndefValue::get( +PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS)); LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS; StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS; auto F = LoadMMO->getFlags() & diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp index ede4841b8a5fd7d..50ad22130e939e2 100644 --- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp +++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp @@ -31,6 +31,7 @@ #include "llvm/ADT/MapVector.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/Sequence.h" +#include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/MachinePostDominators.h" #include "llvm/InitializePasses.h" @@ -121,8 +122,13 @@ enum RegisterMapping { SQ_MAX_PGM_VGPRS = 512, // Maximum programmable VGPRs across all targets. AGPR_OFFSET = 256, // Maximum programmable ArchVGPRs across all targets. SQ_MAX_PGM_SGPRS = 256, // Maximum programmable SGPRs across all targets. - NUM_EXTRA_VGPRS = 1,// A reserved slot for DS. - EXTRA_VGPR_LDS = 0, // An artificial register to track LDS writes. + NUM_EXTRA_VGPRS = 9,// Reserved s
[Lldb-commits] [libcxx] [flang] [llvm] [libc] [compiler-rt] [clang-tools-extra] [clang] [lld] [lldb] [AMDGPU] Use alias info to relax waitcounts for LDS DMA (PR #74537)
@@ -1183,9 +1228,21 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(MachineInstr &MI, // No need to wait before load from VMEM to LDS. if (TII->mayWriteLDSThroughDMA(MI)) continue; -unsigned RegNo = SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS; + // VM_CNT is only relevant to vgpr or LDS. -ScoreBrackets.determineWait(VM_CNT, RegNo, Wait); +unsigned RegNo = SQ_MAX_PGM_VGPRS + EXTRA_VGPR_LDS; +bool FoundAliasingStore = false; +if (Ptr && Memop->getAAInfo() && Memop->getAAInfo().Scope) { rampitec wrote: I have added more comments to explain this. The place which fills the LDS DMA slot bails if there is no scope info not to waste limited tracking slots. In that case a generic first slot is still used for such operation (it is always used, regardless if we can or cannot be more specific about the underlying object). Here AA will be unable to disambiguate aliasing if there is no scope info, so this condition is simply a shortcut to avoid an expensive loop and AA query. I can remove this part of the condition here and nothing will change except it will work slower. Note that not entering this 'if' statement will always produce a conservatively correct wait using first generic tracking slot, which always gets a score regardless of our ability to track a specific object. The condition is around the relaxation code to avoid a generic and conservative 'wait for everything' part below. 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][Progress] Separate title and details (PR #77547)
https://github.com/clayborg approved this pull request. https://github.com/llvm/llvm-project/pull/77547 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [lldb] Add LLDB_BUG_REPORT_URL macro to allow a different URL for lldb bug reporting. (PR #78210)
https://github.com/ZequanWu created https://github.com/llvm/llvm-project/pull/78210 This allows release teams to customize the bug report url for lldb. It also removes unnecessary constructions of `llvm::PrettyStackTraceProgram` as it's already constructed inside `llvm::InitLLVM`. >From 69623d789b2ef28c9df5ffe327b7fb1f9a1d975c Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Mon, 15 Jan 2024 15:37:29 -0500 Subject: [PATCH] [lldb] Add LLDB_BUG_REPORT_URL macro to allow a different URL for lldb bug reporting. --- lldb/include/lldb/Host/Config.h.cmake | 2 ++ lldb/tools/driver/Driver.cpp| 3 +++ lldb/tools/lldb-dap/lldb-dap.cpp| 4 +++- lldb/tools/lldb-server/lldb-server.cpp | 4 +++- llvm/CMakeLists.txt | 2 ++ llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn | 1 + 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake index 14ce46f6559c8c..3defa454f6d420 100644 --- a/lldb/include/lldb/Host/Config.h.cmake +++ b/lldb/include/lldb/Host/Config.h.cmake @@ -55,4 +55,6 @@ #cmakedefine LLDB_GLOBAL_INIT_DIRECTORY R"(${LLDB_GLOBAL_INIT_DIRECTORY})" +#define LLDB_BUG_REPORT_URL "${LLDB_BUG_REPORT_URL}" + #endif // #ifndef LLDB_HOST_CONFIG_H diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index f8058f868d53ff..c63ff0ff597e5c 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -18,6 +18,7 @@ #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" +#include "lldb/Host/Config.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Format.h" @@ -746,6 +747,8 @@ int main(int argc, char const *argv[]) { // Setup LLVM signal handlers and make sure we call llvm_shutdown() on // destruction. llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); + llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL +" and include the crash backtrace.\n"); // Parse arguments. LLDBOptTable T; diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index e91b4115156b73..8c8e92146e63c0 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -47,6 +47,7 @@ #include #include +#include "lldb/Host/Config.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/ScopeExit.h" @@ -3733,7 +3734,8 @@ int SetupStdoutStderrRedirection() { int main(int argc, char *argv[]) { llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); - llvm::PrettyStackTraceProgram X(argc, argv); + llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL +" and include the crash backtrace.\n"); llvm::SmallString<256> program_path(argv[0]); llvm::sys::fs::make_absolute(program_path); diff --git a/lldb/tools/lldb-server/lldb-server.cpp b/lldb/tools/lldb-server/lldb-server.cpp index 1808ffc0c97904..e2e6bfcd8645c7 100644 --- a/lldb/tools/lldb-server/lldb-server.cpp +++ b/lldb/tools/lldb-server/lldb-server.cpp @@ -7,6 +7,7 @@ //===--===// #include "SystemInitializerLLGS.h" +#include "lldb/Host/Config.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Version/Version.h" @@ -50,7 +51,8 @@ static void terminate_debugger() { g_debugger_lifetime->Terminate(); } // main int main(int argc, char *argv[]) { llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); - llvm::PrettyStackTraceProgram X(argc, argv); + llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL +" and include the crash backtrace.\n"); int option_error = 0; const char *progname = argv[0]; diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 1ecfb36ab41a3c..61ab69d237470f 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -346,6 +346,8 @@ set(PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/";) set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING "Default URL where bug reports are to be submitted.") +set(LLDB_BUG_REPORT_URL "${BUG_REPORT_URL}" CACHE STRING + "Default URL where lldb bug reports are to be submitted.") # Configure CPack. if(NOT DEFINED CPACK_PACKAGE_INSTALL_DIRECTORY) diff --git a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn index b4f0f291144350..c46a916373ed01 100644 --- a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn +++ b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn @@ -25,6 +25,7 @@ write_cmake_config("Config") { "LLDB_GLOBAL_INIT_DIRECTORY=", "LLDB_PYTHON_HOME=", +"LLDB_BUG_REPORT_URL=https://github.com/llvm
[Lldb-commits] [lldb] [llvm] [lldb] Add LLDB_BUG_REPORT_URL macro to allow a different URL for lldb bug reporting. (PR #78210)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Zequan Wu (ZequanWu) Changes This allows release teams to customize the bug report url for lldb. It also removes unnecessary constructions of `llvm::PrettyStackTraceProgram` as it's already constructed inside `llvm::InitLLVM`. --- Full diff: https://github.com/llvm/llvm-project/pull/78210.diff 6 Files Affected: - (modified) lldb/include/lldb/Host/Config.h.cmake (+2) - (modified) lldb/tools/driver/Driver.cpp (+3) - (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+3-1) - (modified) lldb/tools/lldb-server/lldb-server.cpp (+3-1) - (modified) llvm/CMakeLists.txt (+2) - (modified) llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn (+1) ``diff diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake index 14ce46f6559c8c7..3defa454f6d4206 100644 --- a/lldb/include/lldb/Host/Config.h.cmake +++ b/lldb/include/lldb/Host/Config.h.cmake @@ -55,4 +55,6 @@ #cmakedefine LLDB_GLOBAL_INIT_DIRECTORY R"(${LLDB_GLOBAL_INIT_DIRECTORY})" +#define LLDB_BUG_REPORT_URL "${LLDB_BUG_REPORT_URL}" + #endif // #ifndef LLDB_HOST_CONFIG_H diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index f8058f868d53ffe..c63ff0ff597e5c7 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -18,6 +18,7 @@ #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" +#include "lldb/Host/Config.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Format.h" @@ -746,6 +747,8 @@ int main(int argc, char const *argv[]) { // Setup LLVM signal handlers and make sure we call llvm_shutdown() on // destruction. llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); + llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL +" and include the crash backtrace.\n"); // Parse arguments. LLDBOptTable T; diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index e91b4115156b73e..8c8e92146e63c0a 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -47,6 +47,7 @@ #include #include +#include "lldb/Host/Config.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/ScopeExit.h" @@ -3733,7 +3734,8 @@ int SetupStdoutStderrRedirection() { int main(int argc, char *argv[]) { llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); - llvm::PrettyStackTraceProgram X(argc, argv); + llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL +" and include the crash backtrace.\n"); llvm::SmallString<256> program_path(argv[0]); llvm::sys::fs::make_absolute(program_path); diff --git a/lldb/tools/lldb-server/lldb-server.cpp b/lldb/tools/lldb-server/lldb-server.cpp index 1808ffc0c97904e..e2e6bfcd8645c7a 100644 --- a/lldb/tools/lldb-server/lldb-server.cpp +++ b/lldb/tools/lldb-server/lldb-server.cpp @@ -7,6 +7,7 @@ //===--===// #include "SystemInitializerLLGS.h" +#include "lldb/Host/Config.h" #include "lldb/Initialization/SystemLifetimeManager.h" #include "lldb/Version/Version.h" @@ -50,7 +51,8 @@ static void terminate_debugger() { g_debugger_lifetime->Terminate(); } // main int main(int argc, char *argv[]) { llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false); - llvm::PrettyStackTraceProgram X(argc, argv); + llvm::setBugReportMsg("PLEASE submit a bug report to " LLDB_BUG_REPORT_URL +" and include the crash backtrace.\n"); int option_error = 0; const char *progname = argv[0]; diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 1ecfb36ab41a3c1..61ab69d237470f2 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -346,6 +346,8 @@ set(PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/";) set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING "Default URL where bug reports are to be submitted.") +set(LLDB_BUG_REPORT_URL "${BUG_REPORT_URL}" CACHE STRING + "Default URL where lldb bug reports are to be submitted.") # Configure CPack. if(NOT DEFINED CPACK_PACKAGE_INSTALL_DIRECTORY) diff --git a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn index b4f0f291144350f..c46a916373ed014 100644 --- a/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn +++ b/llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn @@ -25,6 +25,7 @@ write_cmake_config("Config") { "LLDB_GLOBAL_INIT_DIRECTORY=", "LLDB_PYTHON_HOME=", +"LLDB_BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/";, "HAVE_LIBCOMPRESSION=", ] `` https://github.com/llvm/llvm-project/pull/78210 ___ lldb-commits mailing list lldb-commits@lists.llvm.or
[Lldb-commits] [lldb] [llvm] [lldb] Add LLDB_BUG_REPORT_URL macro to allow a different URL for lldb bug reporting. (PR #78210)
walter-erquinigo wrote: nice! https://github.com/llvm/llvm-project/pull/78210 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2bb2a42 - [lldb][ValueObject][NFC] Further remove redundant parameters to ReadPointedString (#78029)
Author: Michael Buch Date: 2024-01-15T21:04:05Z New Revision: 2bb2a42fa261d728e32ba0b1f9cf27ba7991440f URL: https://github.com/llvm/llvm-project/commit/2bb2a42fa261d728e32ba0b1f9cf27ba7991440f DIFF: https://github.com/llvm/llvm-project/commit/2bb2a42fa261d728e32ba0b1f9cf27ba7991440f.diff LOG: [lldb][ValueObject][NFC] Further remove redundant parameters to ReadPointedString (#78029) We only ever call this function once, without relying on the defaulted `honor_array` parameter, so make it non-defaulted. Also `max_length` is always set to `0`, so remove it entirely. This simplifies some upcoming refactoring. Added: Modified: lldb/include/lldb/Core/ValueObject.h lldb/source/Core/ValueObject.cpp Removed: diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index dec1c7b237ac27..4c0b0b2dae6cd4 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -670,7 +670,7 @@ class ValueObject { std::pair ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, Status &error, -uint32_t max_length = 0, bool honor_array = true); +bool honor_array); virtual size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0, uint32_t item_count = 1); diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index a5d155d3c6675f..9208047be36668 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -813,8 +813,7 @@ static bool CopyStringDataToBufferSP(const StreamString &source, std::pair ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, - Status &error, uint32_t max_length, - bool honor_array) { + Status &error, bool honor_array) { bool was_capped = false; StreamString s; ExecutionContext exe_ctx(GetExecutionContextRef()); @@ -827,8 +826,7 @@ ValueObject::ReadPointedString(lldb::WritableDataBufferSP &buffer_sp, return {0, was_capped}; } - if (max_length == 0) -max_length = target->GetMaximumSizeOfStringSummary(); + const auto max_length = target->GetMaximumSizeOfStringSummary(); size_t bytes_read = 0; size_t total_bytes_read = 0; @@ -1149,9 +1147,10 @@ bool ValueObject::DumpPrintableRepresentation( { Status error; lldb::WritableDataBufferSP buffer_sp; -std::pair read_string = ReadPointedString( -buffer_sp, error, 0, (custom_format == eFormatVectorOfChar) || - (custom_format == eFormatCharArray)); +std::pair read_string = +ReadPointedString(buffer_sp, error, + (custom_format == eFormatVectorOfChar) || + (custom_format == eFormatCharArray)); lldb_private::formatters::StringPrinter:: ReadBufferAndDumpToStreamOptions options(*this); options.SetData(DataExtractor( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ValueObject][NFC] Further remove redundant parameters to ReadPointedString (PR #78029)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/78029 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libunwind] [flang] [mlir] [llvm] [libcxx] [clang-tools-extra] [lldb] [clang] [libunwind] fix dynamic .eh_frame registration (PR #77185)
https://github.com/lhames approved this pull request. Ok -- local testing seems to confirm that this is the right fix. We need to add a testcase for this API, but that can happen as a follow-up. https://github.com/llvm/llvm-project/pull/77185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
https://github.com/walter-erquinigo edited https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
@@ -395,43 +402,56 @@ ExpressionContext DAP::DetectExpressionContext(lldb::SBFrame &frame, case ReplMode::Command: return ExpressionContext::Command; case ReplMode::Auto: -// If the frame is invalid then there is no variables to complete, assume -// this is an lldb command instead. -if (!frame.IsValid()) { - return ExpressionContext::Command; -} - +// To determine if the expression is a command or not, check if the first +// term is a variable or command. If its a variable in scope we will prefer walter-erquinigo wrote: ```suggestion // term is a variable or command. If it's a variable in scope we will prefer ``` https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
@@ -380,12 +380,19 @@ llvm::json::Value DAP::CreateTopLevelScopes() { return llvm::json::Value(std::move(scopes)); } -ExpressionContext DAP::DetectExpressionContext(lldb::SBFrame &frame, - std::string &text) { +static std::string FirstTerm(llvm::StringRef input) { walter-erquinigo wrote: better return `std::optional` https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
@@ -395,43 +402,56 @@ ExpressionContext DAP::DetectExpressionContext(lldb::SBFrame &frame, case ReplMode::Command: return ExpressionContext::Command; case ReplMode::Auto: -// If the frame is invalid then there is no variables to complete, assume -// this is an lldb command instead. -if (!frame.IsValid()) { - return ExpressionContext::Command; -} - +// To determine if the expression is a command or not, check if the first +// term is a variable or command. If its a variable in scope we will prefer +// that behavior and give a warning to the user if they meant to invoke the +// operation as a command. +// +// Example use case: +// int p and expression "p + 1" > variable +// int i and expression "i" > variable +// int var and expression "va" > command +const auto term = FirstTerm(expression); +auto ci = debugger.GetCommandInterpreter(); lldb::SBCommandReturnObject result; -debugger.GetCommandInterpreter().ResolveCommand(text.data(), result); - -// If this command is a simple expression like `var + 1` check if there is -// a local variable name that is in the current expression. If so, ensure -// the expression runs in the variable context. -lldb::SBValueList variables = frame.GetVariables(true, true, true, true); -llvm::StringRef input = text; -for (uint32_t i = 0; i < variables.GetSize(); i++) { - llvm::StringRef name = variables.GetValueAtIndex(i).GetName(); - // Check both directions in case the input is a partial of a variable - // (e.g. input = `va` and local variable = `var1`). - if (input.contains(name) || name.contains(input)) { -if (!auto_repl_mode_collision_warning) { - llvm::errs() << "Variable expression '" << text - << "' is hiding an lldb command, prefix an expression " - "with '" - << g_dap.command_escape_prefix - << "' to ensure it runs as a lldb command.\n"; - auto_repl_mode_collision_warning = true; -} -return ExpressionContext::Variable; +ci.ResolveCommand(term.c_str(), result); +bool term_is_command = result.Succeeded(); +bool term_is_variable = frame.FindVariable(term.c_str()).IsValid(); + +// If we have both a variable and command, warn the user about the conflict. +if (term_is_command && term_is_variable) { + llvm::errs() + << "warning: Expression '" << term + << "' is both an lldb command and variable, evaluating the " + "expression as a variable. To evaluate the lldb command, use '" walter-erquinigo wrote: ```suggestion << "Warning: '" << term << "' is both an LLDB command and variable. It will be " "evaluated as a variable. To evaluate the expression as an LLDB command, use '"... ``` https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
@@ -395,43 +402,56 @@ ExpressionContext DAP::DetectExpressionContext(lldb::SBFrame &frame, case ReplMode::Command: return ExpressionContext::Command; case ReplMode::Auto: -// If the frame is invalid then there is no variables to complete, assume -// this is an lldb command instead. -if (!frame.IsValid()) { - return ExpressionContext::Command; -} - +// To determine if the expression is a command or not, check if the first +// term is a variable or command. If its a variable in scope we will prefer +// that behavior and give a warning to the user if they meant to invoke the +// operation as a command. +// +// Example use case: +// int p and expression "p + 1" > variable +// int i and expression "i" > variable +// int var and expression "va" > command +const auto term = FirstTerm(expression); walter-erquinigo wrote: don't use `auto` https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
@@ -395,43 +402,56 @@ ExpressionContext DAP::DetectExpressionContext(lldb::SBFrame &frame, case ReplMode::Command: return ExpressionContext::Command; case ReplMode::Auto: -// If the frame is invalid then there is no variables to complete, assume -// this is an lldb command instead. -if (!frame.IsValid()) { - return ExpressionContext::Command; -} - +// To determine if the expression is a command or not, check if the first +// term is a variable or command. If its a variable in scope we will prefer +// that behavior and give a warning to the user if they meant to invoke the +// operation as a command. +// +// Example use case: +// int p and expression "p + 1" > variable +// int i and expression "i" > variable +// int var and expression "va" > command +const auto term = FirstTerm(expression); +auto ci = debugger.GetCommandInterpreter(); lldb::SBCommandReturnObject result; -debugger.GetCommandInterpreter().ResolveCommand(text.data(), result); - -// If this command is a simple expression like `var + 1` check if there is -// a local variable name that is in the current expression. If so, ensure -// the expression runs in the variable context. -lldb::SBValueList variables = frame.GetVariables(true, true, true, true); -llvm::StringRef input = text; -for (uint32_t i = 0; i < variables.GetSize(); i++) { - llvm::StringRef name = variables.GetValueAtIndex(i).GetName(); - // Check both directions in case the input is a partial of a variable - // (e.g. input = `va` and local variable = `var1`). - if (input.contains(name) || name.contains(input)) { -if (!auto_repl_mode_collision_warning) { - llvm::errs() << "Variable expression '" << text - << "' is hiding an lldb command, prefix an expression " - "with '" - << g_dap.command_escape_prefix - << "' to ensure it runs as a lldb command.\n"; - auto_repl_mode_collision_warning = true; -} -return ExpressionContext::Variable; +ci.ResolveCommand(term.c_str(), result); +bool term_is_command = result.Succeeded(); +bool term_is_variable = frame.FindVariable(term.c_str()).IsValid(); + +// If we have both a variable and command, warn the user about the conflict. +if (term_is_command && term_is_variable) { + llvm::errs() + << "warning: Expression '" << term + << "' is both an lldb command and variable, evaluating the " + "expression as a variable. To evaluate the lldb command, use '" + << g_dap.command_escape_prefix << "' as a prefix.\n"; + if (!repl_mode_behavior_description_shown) { +repl_mode_behavior_description_shown = true; +llvm::errs() +<< "\nnote: This error message is only displayed once. Use '" +<< g_dap.command_escape_prefix +<< "' as a prefix ensure expressions are evaluated as lldb " + "commands.\n\nTo change the repl behavior use:\n'" +<< g_dap.command_escape_prefix +<< "lldb-dap repl-mode variable' to evaluate all expressions " + "as variables.\n'" +<< g_dap.command_escape_prefix +<< "lldb-dap repl-mode command' to evaluate all expressions as " + "commands.\n'" +<< g_dap.command_escape_prefix +<< "lldb-dap repl-mode auto' to use a heuristic to detect the " + "mode based on the input and local variables.\n"; walter-erquinigo wrote: I'd rather not show this, because: - if the user configured lldb-dap on their own, they'll know what the auto mode does and they can troubleshoot themselves - if the user doesn't configure lldb-dap and they get it from someone else, then they can't simply troubleshoot themselves, so this message might be confusing. https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
https://github.com/walter-erquinigo commented: This makes a lot of sense. Just a few comments https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
@@ -380,12 +380,19 @@ llvm::json::Value DAP::CreateTopLevelScopes() { return llvm::json::Value(std::move(scopes)); } -ExpressionContext DAP::DetectExpressionContext(lldb::SBFrame &frame, - std::string &text) { +static std::string FirstTerm(llvm::StringRef input) { + if (input.empty()) +return ""; + const auto terms = llvm::getToken(input, " \t\n\v\f\r.[-("); walter-erquinigo wrote: if the first term is followed by `.[-(`, couldn't we assume that it's code and not a command? https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lld] [compiler-rt] [llvm] [lldb] [flang] [libcxx] [mlir] [clang-tidy]Add new check readability-avoid-nested-conditional-operator (PR #78022)
@@ -0,0 +1,52 @@ +//===--- AvoidNestedConditionalOperatorCheck.cpp - clang-tidy --===// HerrCai0907 wrote: fixed in 10602c2b4a662872d1aaeda1dbc58e5d6f613fda https://github.com/llvm/llvm-project/pull/78022 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [flang] [compiler-rt] [libunwind] [libc] [clang-tools-extra] [lldb] [libcxx] [llvm] [libc++] Implement ranges::iota (PR #68494)
@@ -1172,6 +1198,22 @@ struct Proxy { requires std::three_way_comparable_with, std::decay_t> { return lhs.data <=> rhs.data; } + + // Needed to allow certain types to be weakly_incremental + constexpr Proxy& operator++() +requires(HasPreIncrementOp) + { +++data; +return *this; + } + + constexpr Proxy operator++(int) +requires(HasPostIncrementOp) + { +Proxy tmp = *this; +operator++(); +return tmp; + } jamesETsmith wrote: Should be fixed by [2803493](https://github.com/llvm/llvm-project/pull/68494/commits/2803493cba2a05fce5b3379c8ba43989aa4eaf73) https://github.com/llvm/llvm-project/pull/68494 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [flang] [compiler-rt] [libunwind] [libc] [clang-tools-extra] [lldb] [libcxx] [llvm] [libc++] Implement ranges::iota (PR #68494)
@@ -0,0 +1,171 @@ +//===--===// +// +// 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 +// +//===--===// + +// Testing std::ranges::iota + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +#include +#include +#include +#include +#include // TODO RM + +#include "test_macros.h" +#include "test_iterators.h" +#include "almost_satisfies_types.h" + +// +// Testing constraints +// + +// Concepts to check different overloads of std::ranges::iota +template +concept HasIotaIter = requires(Iter&& iter, Sent&& sent, Value&& val) { + std::ranges::iota(std::forward(iter), std::forward(sent), std::forward(val)); +}; + +template +concept HasIotaRange = +requires(Range&& range, Value&& val) { std::ranges::iota(std::forward(range), std::forward(val)); }; + +// Test constraints of the iterator/sentinel overload +// == +static_assert(HasIotaIter); + +// !input_or_output_iterator +static_assert(!HasIotaIter); + +// !sentinel_for +static_assert(!HasIotaIter); +static_assert(!HasIotaIter); + +// !weakly_incrementable +static_assert(!HasIotaIter); + +// !indirectly writable +static_assert(!HasIotaIter); + +// Test constraints for the range overload +// === +static_assert(HasIotaRange, int>); + +// !weakly_incrementable +static_assert(!HasIotaRange, WeaklyIncrementableNotMovable>); + +// !ranges::output_range +static_assert(!HasIotaRange, OutputIteratorNotIndirectlyWritable>); + +// +// Testing results +// + +struct DangerousCopyAssign { + int val; + using difference_type = int; + + constexpr explicit DangerousCopyAssign(int v) : val(v) {} + + // Needed in postfix + constexpr DangerousCopyAssign(DangerousCopyAssign const& other) { this->val = other.val; } + + // mischievious copy assignment that we won't use if the + // std::as_const inside ranges::iota isn't working, this should perturb the + // results + constexpr DangerousCopyAssign& operator=(DangerousCopyAssign& a) { +++a.val; +this->val = a.val; +return *this; + } + + // safe copy assignment std::as_const inside ranges::iota should ensure this + // overload gets called + constexpr DangerousCopyAssign& operator=(DangerousCopyAssign const& a) { +this->val = a.val; +return *this; + } + + constexpr bool operator==(DangerousCopyAssign const& rhs) { return this->val == rhs.val; } + + // prefix + constexpr DangerousCopyAssign& operator++() { +++(this->val); +return *this; + } + + // postfix + constexpr DangerousCopyAssign operator++(int) { +auto tmp = *this; +++this->val; +return tmp; + } +}; + +template +constexpr void test_result(std::array input, T starting_value, std::array const expected) { + { // (iterator, sentinel) overload +auto in_begin = Iter(input.data()); +auto in_end = Sent(Iter(input.data() + input.size())); +std::same_as> decltype(auto) result = +std::ranges::iota(std::move(in_begin), std::move(in_end), starting_value); +assert(result.out == in_end); +if constexpr (expected.size() > 0) { + assert(result.value == expected.back() + 1); +} else { + assert(result.value == starting_value); +} +assert(std::ranges::equal(input, expected)); + } + + // The range overload adds the additional constraint that it must be an outputrange + // so skip this for the input iterators we test + if constexpr (!std::is_same_v> && +!std::is_same_v>) { // (range) overload +auto in_begin = Iter(input.data()); +auto in_end = Sent(Iter(input.data() + input.size())); +auto range= std::ranges::subrange(std::move(in_begin), std::move(in_end)); + +std::same_as> decltype(auto) result = +std::ranges::iota(range, starting_value); +assert(result.out == in_end); +assert(result.value == starting_value + N); +assert(std::ranges::equal(input, expected)); + } jamesETsmith wrote: I've removed the conditional logic in [2803493](https://github.com/llvm/llvm-project/pull/68494/commits/2803493cba2a05fce5b3379c8ba43989aa4eaf73) https://github.com/llvm/llvm-project/pull/68494 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] [lldb] Add LLDB_BUG_REPORT_URL macro to allow a different URL for lldb bug reporting. (PR #78210)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/78210 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [llvm] [libc] [lldb] [clang] [compiler-rt] [libunwind] [libcxx] [clang-tools-extra] [libc++] Implement ranges::iota (PR #68494)
@@ -1149,9 +1171,11 @@ struct Proxy { // Calling swap(Proxy{}, Proxy{}) would fail (pass prvalues) // Compare operators are defined for the convenience of the tests - friend constexpr bool operator==(const Proxy&, const Proxy&) -requires (std::equality_comparable && !std::is_reference_v) - = default; + friend constexpr bool operator==(const Proxy& lhs, const Proxy& rhs) +requires(std::equality_comparable && !std::is_reference_v) + { +return lhs.data == rhs.data; + }; jamesETsmith wrote: Thanks to an offline discussion with @Quuxplusone, I now know that these operators only started causing problems when I introduced the base class `ProxyDiffTBase` because the base subobject wasn't trivially comparable. Since the `operator==` for `Proxy` is used all over, when they stopped functioning properly a lot of tests started failing which is what prompted me to make those changes to begin with. At @Quuxplusone's suggestion, I've specified the comparison operators for the base class (and derived `Proxy` class) as default, undoing the changes we were talking about here and below. https://github.com/llvm/llvm-project/pull/68494 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [llvm] [lldb] [clang] [mlir] [libunwind] [libcxx] [clang-tools-extra] [libunwind] fix dynamic .eh_frame registration (PR #77185)
https://github.com/hstk30-hw closed https://github.com/llvm/llvm-project/pull/77185 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
medismailben wrote: > > A WebAssembly debugging session can be started using the new command: > > wasm [:] > > What about wasm requires a new command, given that you are connecting to a > GDB server as existing targets do. +1! I don't think this needs a new command, it could just use `gdb-remote [:]` command. https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Adjusting how repl-mode auto determines commands vs variable expressions. (PR #78005)
https://github.com/walter-erquinigo edited https://github.com/llvm/llvm-project/pull/78005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Progress] Separate title and details (PR #77547)
https://github.com/medismailben approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/77547 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)
https://github.com/kpdev updated https://github.com/llvm/llvm-project/pull/67309 >From a0aae1f59fcdc9f0266bdc6248544f674b298e85 Mon Sep 17 00:00:00 2001 From: Pavel Kosov Date: Mon, 25 Sep 2023 13:41:03 +0300 Subject: [PATCH] [lldb] Add SetValueFromCString API to SyntheticFronend It is a first of three patches neded for adding an ability to update std::string/wstring/etc during debug process. Add SetValueFromCString API to SyntheticFronend Overall context is avaliable in the following discussion: https://discourse.llvm.org/t/clarify-hostaddress-loadaddress-logic/72175/3: ~~ Huawei RRI, OS Lab --- lldb/include/lldb/Core/ValueObject.h | 11 +++ lldb/include/lldb/DataFormatters/TypeSynthetic.h | 12 ++-- lldb/source/Core/ValueObject.cpp | 9 +++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 3af94f0a86e2fcc..892f5d0dea4f650 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -589,6 +589,14 @@ class ValueObject { virtual bool IsSynthetic() { return false; } + void SetSyntheticFrontend(SyntheticChildrenFrontEnd *synth_front) { +m_synthetic_frontend = synth_front; + } + + SyntheticChildrenFrontEnd *GetSyntheticFrontend() const { +return m_synthetic_frontend; + } + lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue); @@ -898,6 +906,9 @@ class ValueObject { /// Unique identifier for every value object. UserID m_id; + // If frontend exist - we may try to update our value through it + SyntheticChildrenFrontEnd *m_synthetic_frontend = nullptr; + // Utility class for initializing all bitfields in ValueObject's constructors. // FIXME: This could be done via default initializers once we have C++20. struct Bitflags { diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 41be9b7efda8fdb..8e9bf9da77211ba 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -34,9 +34,13 @@ class SyntheticChildrenFrontEnd { public: SyntheticChildrenFrontEnd(ValueObject &backend) - : m_backend(backend), m_valid(true) {} + : m_backend(backend), m_valid(true) { +m_backend.SetSyntheticFrontend(this); + } - virtual ~SyntheticChildrenFrontEnd() = default; + virtual ~SyntheticChildrenFrontEnd() { +m_backend.SetSyntheticFrontend(nullptr); + } virtual size_t CalculateNumChildren() = 0; @@ -75,6 +79,10 @@ class SyntheticChildrenFrontEnd { // display purposes virtual ConstString GetSyntheticTypeName() { return ConstString(); } + virtual bool SetValueFromCString(const char *value_str, Status &error) { +return false; + } + typedef std::shared_ptr SharedPointer; typedef std::unique_ptr AutoPointer; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index ebfc1cf4d6fe9e1..e6ae56045d5f3ba 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1479,7 +1479,7 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) { if (value_type == Value::ValueType::Scalar) { // If the value is already a scalar, then let the scalar change itself: m_value.GetScalar().SetValueFromCString(value_str, encoding, byte_size); - } else if (byte_size <= 16) { + } else if (byte_size <= 16 && encoding != eEncodingInvalid) { // If the value fits in a scalar, then make a new scalar and again let the // scalar code do the conversion, then figure out where to put the new // value. @@ -1535,7 +1535,12 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) { } } else { // We don't support setting things bigger than a scalar at present. -error.SetErrorString("unable to write aggregate data type"); +// But maybe our frontend knows how to update the value. +if (auto *frontend = GetSyntheticFrontend()) { + return frontend->SetValueFromCString(value_str, error); +} else { + error.SetErrorString("unable to write aggregate data type"); +} return false; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SetValueFromCString API to SyntheticFronend (PR #67309)
https://github.com/kpdev updated https://github.com/llvm/llvm-project/pull/67309 >From 94d31eabaea7edd2cb139a45fdc8b85d2768f29d Mon Sep 17 00:00:00 2001 From: Pavel Kosov Date: Mon, 25 Sep 2023 13:41:03 +0300 Subject: [PATCH] [lldb] Add SetValueFromCString API to SyntheticFronend It is a first of three patches neded for adding an ability to update std::string/wstring/etc during debug process. Add SetValueFromCString API to SyntheticFronend Overall context is avaliable in the following discussion: https://discourse.llvm.org/t/clarify-hostaddress-loadaddress-logic/72175/3: ~~ Huawei RRI, OS Lab --- lldb/include/lldb/Core/ValueObject.h | 11 +++ lldb/include/lldb/DataFormatters/TypeSynthetic.h | 12 ++-- lldb/source/Core/ValueObject.cpp | 5 - 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 3af94f0a86e2fcc..892f5d0dea4f650 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -589,6 +589,14 @@ class ValueObject { virtual bool IsSynthetic() { return false; } + void SetSyntheticFrontend(SyntheticChildrenFrontEnd *synth_front) { +m_synthetic_frontend = synth_front; + } + + SyntheticChildrenFrontEnd *GetSyntheticFrontend() const { +return m_synthetic_frontend; + } + lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue); @@ -898,6 +906,9 @@ class ValueObject { /// Unique identifier for every value object. UserID m_id; + // If frontend exist - we may try to update our value through it + SyntheticChildrenFrontEnd *m_synthetic_frontend = nullptr; + // Utility class for initializing all bitfields in ValueObject's constructors. // FIXME: This could be done via default initializers once we have C++20. struct Bitflags { diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 41be9b7efda8fdb..8e9bf9da77211ba 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -34,9 +34,13 @@ class SyntheticChildrenFrontEnd { public: SyntheticChildrenFrontEnd(ValueObject &backend) - : m_backend(backend), m_valid(true) {} + : m_backend(backend), m_valid(true) { +m_backend.SetSyntheticFrontend(this); + } - virtual ~SyntheticChildrenFrontEnd() = default; + virtual ~SyntheticChildrenFrontEnd() { +m_backend.SetSyntheticFrontend(nullptr); + } virtual size_t CalculateNumChildren() = 0; @@ -75,6 +79,10 @@ class SyntheticChildrenFrontEnd { // display purposes virtual ConstString GetSyntheticTypeName() { return ConstString(); } + virtual bool SetValueFromCString(const char *value_str, Status &error) { +return false; + } + typedef std::shared_ptr SharedPointer; typedef std::unique_ptr AutoPointer; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index ebfc1cf4d6fe9e1..c93c7dd32e0c7f2 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1479,7 +1479,7 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) { if (value_type == Value::ValueType::Scalar) { // If the value is already a scalar, then let the scalar change itself: m_value.GetScalar().SetValueFromCString(value_str, encoding, byte_size); - } else if (byte_size <= 16) { + } else if (byte_size <= 16 && encoding != eEncodingInvalid) { // If the value fits in a scalar, then make a new scalar and again let the // scalar code do the conversion, then figure out where to put the new // value. @@ -1535,6 +1535,9 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) { } } else { // We don't support setting things bigger than a scalar at present. +// But maybe our frontend knows how to update the value. +if (auto *frontend = GetSyntheticFrontend()) + return frontend->SetValueFromCString(value_str, error); error.SetErrorString("unable to write aggregate data type"); return false; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits