[Lldb-commits] [lldb] [clang] [llvm] [mlir] [libc] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/76882 >From ca7a96a40952fe94b916dacc52f07aa90bbdb1e7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 3 Jan 2024 13:22:37 -0800 Subject: [PATCH 1/5] [builtin_object_size] Use classes instead of std::pair (NFC) The use of std::pair makes the values it holds opaque. Using classes improves this while keeping the POD aspect of a std::pair. As a nice addition, the "known" functions held inappropriately in the Visitor classes can now properly reside in the value classes. :-) --- llvm/include/llvm/Analysis/MemoryBuiltins.h | 192 +++ llvm/lib/Analysis/MemoryBuiltins.cpp | 314 +- .../Transforms/IPO/AttributorAttributes.cpp | 8 +- .../Instrumentation/AddressSanitizer.cpp | 12 +- .../Instrumentation/BoundsChecking.cpp| 8 +- 5 files changed, 299 insertions(+), 235 deletions(-) diff --git a/llvm/include/llvm/Analysis/MemoryBuiltins.h b/llvm/include/llvm/Analysis/MemoryBuiltins.h index 827b5081b2ce75..56faa32fb0b226 100644 --- a/llvm/include/llvm/Analysis/MemoryBuiltins.h +++ b/llvm/include/llvm/Analysis/MemoryBuiltins.h @@ -187,80 +187,146 @@ Value *lowerObjectSizeCall( const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed, SmallVectorImpl *InsertedInstructions = nullptr); -using SizeOffsetType = std::pair; +/// SizeOffsetType - A base template class for the object size visitors. Used +/// here as a self-documenting way to handle the values rather than using a +/// \p std::pair. +template struct SizeOffsetType { + T Size; + T Offset; + + bool knownSize() const; + bool knownOffset() const; + bool anyKnown() const; + bool bothKnown() const; +}; + +/// SizeOffsetType - Used by \p ObjectSizeOffsetVisitor, which works +/// with \p APInts. +template <> struct SizeOffsetType { + APInt Size; + APInt Offset; + + SizeOffsetType() = default; + SizeOffsetType(APInt Size, APInt Offset) : Size(Size), Offset(Offset) {} + + bool knownSize() const { return Size.getBitWidth() > 1; } + bool knownOffset() const { return Offset.getBitWidth() > 1; } + bool anyKnown() const { return knownSize() || knownOffset(); } + bool bothKnown() const { return knownSize() && knownOffset(); } + + bool operator==(const SizeOffsetType &RHS) { +return Size == RHS.Size && Offset == RHS.Offset; + } + bool operator!=(const SizeOffsetType &RHS) { return !(*this == RHS); } +}; +using SizeOffsetAPInt = SizeOffsetType; /// Evaluate the size and offset of an object pointed to by a Value* /// statically. Fails if size or offset are not known at compile time. class ObjectSizeOffsetVisitor - : public InstVisitor { +: public InstVisitor { const DataLayout &DL; const TargetLibraryInfo *TLI; ObjectSizeOpts Options; unsigned IntTyBits; APInt Zero; - SmallDenseMap SeenInsts; + SmallDenseMap SeenInsts; unsigned InstructionsVisited; APInt align(APInt Size, MaybeAlign Align); - SizeOffsetType unknown() { -return std::make_pair(APInt(), APInt()); - } + static SizeOffsetAPInt unknown; public: ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts Options = {}); - SizeOffsetType compute(Value *V); - - static bool knownSize(const SizeOffsetType &SizeOffset) { -return SizeOffset.first.getBitWidth() > 1; - } - - static bool knownOffset(const SizeOffsetType &SizeOffset) { -return SizeOffset.second.getBitWidth() > 1; - } - - static bool bothKnown(const SizeOffsetType &SizeOffset) { -return knownSize(SizeOffset) && knownOffset(SizeOffset); - } + SizeOffsetAPInt compute(Value *V); // These are "private", except they can't actually be made private. Only // compute() should be used by external users. - SizeOffsetType visitAllocaInst(AllocaInst &I); - SizeOffsetType visitArgument(Argument &A); - SizeOffsetType visitCallBase(CallBase &CB); - SizeOffsetType visitConstantPointerNull(ConstantPointerNull&); - SizeOffsetType visitExtractElementInst(ExtractElementInst &I); - SizeOffsetType visitExtractValueInst(ExtractValueInst &I); - SizeOffsetType visitGlobalAlias(GlobalAlias &GA); - SizeOffsetType visitGlobalVariable(GlobalVariable &GV); - SizeOffsetType visitIntToPtrInst(IntToPtrInst&); - SizeOffsetType visitLoadInst(LoadInst &I); - SizeOffsetType visitPHINode(PHINode&); - SizeOffsetType visitSelectInst(SelectInst &I); - SizeOffsetType visitUndefValue(UndefValue&); - SizeOffsetType visitInstruction(Instruction &I); + SizeOffsetAPInt visitAllocaInst(AllocaInst &I); + SizeOffsetAPInt visitArgument(Argument &A); + SizeOffsetAPInt visitCallBase(CallBase &CB); + SizeOffsetAPInt visitConstantPointerNull(ConstantPointerNull &); + SizeOffsetAPInt visitExtractElementInst(ExtractElementInst &I); + SizeOffsetAPInt visitExtractValueInst(ExtractValueInst &I); + SizeOffsetAPInt visitGlobalAlias(GlobalAlias &GA); + SizeOffsetAPInt
[Lldb-commits] [lldb] [clang] [llvm] [lld] [compiler-rt] [libcxx] [flang] [libc] [clang-tools-extra] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)
H-G-Hristov wrote: > Thanks for working on this! There's a fair bit that I've provided comments > for, but I think you're off to a great start, and I would like to see this > merged in January, if at all possible. > > Some comments are short and repetitive: those are usually coupled with a > starter comment that explains my perspective, and then I just flag the others > as I see them in a (hopefully) non-intrusive way. Thank you very much for the review! https://github.com/llvm/llvm-project/pull/73617 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f3f4387 - [lldb][NFC] Fix compilation issue on windows (#76453)
Author: gmh Date: 2024-01-04T08:39:50Z New Revision: f3f4387e02b0ed637b5d843e8937116334329a65 URL: https://github.com/llvm/llvm-project/commit/f3f4387e02b0ed637b5d843e8937116334329a65 DIFF: https://github.com/llvm/llvm-project/commit/f3f4387e02b0ed637b5d843e8937116334329a65.diff LOG: [lldb][NFC] Fix compilation issue on windows (#76453) Added: Modified: lldb/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp lldb/unittests/Thread/ThreadTest.cpp Removed: 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) 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] [clang-tools-extra] [lldb] [compiler-rt] [llvm] [clang] [flang] [libc] [lldb][NFC] Fix compilation issue on windows (PR #76453)
https://github.com/DavidSpickett closed 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] [lld] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [clang] [flang] [libc] [libcxx] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)
@@ -0,0 +1,333 @@ +// -*- 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 _LIBCPP___RANGES_ENUMERATE_VIEW_H +#define _LIBCPP___RANGES_ENUMERATE_VIEW_H + +#include <__concepts/convertible_to.h> +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/distance.h> +#include <__iterator/iter_move.h> +#include <__iterator/iterator_traits.h> +#include <__ranges/access.h> +#include <__ranges/all.h> +#include <__ranges/concepts.h> +#include <__ranges/enable_borrowed_range.h> +#include <__ranges/range_adaptor.h> +#include <__ranges/size.h> +#include <__ranges/view_interface.h> +#include <__type_traits/maybe_const.h> +#include <__utility/forward.h> +#include <__utility/move.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 23 + +namespace ranges { + +// [concept.object] + +template +concept __range_with_movable_references = +ranges::input_range<_Rp> && std::move_constructible> && +std::move_constructible>; + +// [range.enumerate.view] + +template + requires __range_with_movable_references<_View> +class enumerate_view : public view_interface> { + _View __base_ = _View(); + + // [range.enumerate.iterator] + template + class __iterator; + + // [range.enumerate.sentinel] + template + class __sentinel; + + template + _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_current(const __iterator<_AnyConst>& __iter) { +return (__iter.__current_); + } + +public: + _LIBCPP_HIDE_FROM_ABI constexpr enumerate_view() +requires(default_initializable<_View>) + = default; + _LIBCPP_HIDE_FROM_ABI constexpr explicit enumerate_view(_View __base) : __base_(std::move(__base)){}; + + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() +requires(!__simple_view<_View>) + { +return __iterator(ranges::begin(__base_), 0); + } + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const +requires __range_with_movable_references + { +return __iterator(ranges::begin(__base_), 0); + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto end() +requires(!__simple_view<_View>) + { +if constexpr (common_range<_View> && sized_range<_View>) + return __iterator(ranges::end(__base_), ranges::distance(__base_)); +else + return __sentinel(ranges::end(__base_)); + } + _LIBCPP_HIDE_FROM_ABI constexpr auto end() const +requires __range_with_movable_references + { +if constexpr (common_range && sized_range) + return __iterator(ranges::end(__base_), ranges::distance(__base_)); +else + return __sentinel(ranges::end(__base_)); + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto size() +requires sized_range<_View> + { +return ranges::size(__base_); + } + _LIBCPP_HIDE_FROM_ABI constexpr auto size() const +requires sized_range + { +return ranges::size(__base_); + } + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& +requires copy_constructible<_View> + { +return __base_; + } + _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } +}; + +template +enumerate_view(_Range&&) -> enumerate_view>; + +// [range.enumerate.iterator] + +template + requires __range_with_movable_references<_View> +template +class enumerate_view<_View>::__iterator { + using _Base = __maybe_const<_Const, _View>; + + static consteval auto __get_iterator_concept() { +if constexpr (random_access_range<_Base>) { + return random_access_iterator_tag{}; +} else if constexpr (bidirectional_range<_Base>) { + return bidirectional_iterator_tag{}; +} else if constexpr (forward_range<_Base>) { + return forward_iterator_tag{}; +} else { + return input_iterator_tag{}; +} + } + + friend class enumerate_view<_View>; + +public: + using iterator_category = input_iterator_tag; + using iterator_concept = decltype(__get_iterator_concept()); + using difference_type = range_difference_t<_Base>; + using value_type= tuple>; + +private: + using __reference_type = tuple>; + iterator_t<_Base> __current_ = iterator_t<_Base>(); + difference_type __pos_ = 0; + + _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(iterator_t<_Base> __current, difference_type __pos) + : __current_(std::move(__current)), __pos_(__pos) {} + +public: + _LIBCPP_HIDE_FROM_ABI __iterator() +requires(default_initializable>) + = default; + _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator __i) +requires _Const && convertible_to, iterator_t<_Base>> + : __current_(std::move(__i.__current_)), __pos_(__i.__pos_) {} + + _L
[Lldb-commits] [flang] [llvm] [compiler-rt] [clang-tools-extra] [libc] [lldb] [clang] [GlobalIsel] Combine select of binops (PR #76763)
Thorsten =?utf-8?q?Schütt?= , Thorsten =?utf-8?q?Schütt?= , Thorsten =?utf-8?q?Schütt?= Message-ID: In-Reply-To: @@ -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(); arsenm wrote: I would have split this by matching the DAG behavior in the initial commit but doesn't really matter. I *think* this is OK but would be nice to have alive verify 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] [llvm] [compiler-rt] [clang-tools-extra] [libc] [lldb] [clang] [GlobalIsel] Combine select of binops (PR #76763)
Thorsten =?utf-8?q?Sch=C3=BCtt?= , Thorsten =?utf-8?q?Sch=C3=BCtt?= , Thorsten =?utf-8?q?Sch=C3=BCtt?= Message-ID: In-Reply-To: https://github.com/arsenm approved this pull request. 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] [lldb] [libc] [clang] [llvm] [mlir] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/76882 >From ca7a96a40952fe94b916dacc52f07aa90bbdb1e7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 3 Jan 2024 13:22:37 -0800 Subject: [PATCH 1/6] [builtin_object_size] Use classes instead of std::pair (NFC) The use of std::pair makes the values it holds opaque. Using classes improves this while keeping the POD aspect of a std::pair. As a nice addition, the "known" functions held inappropriately in the Visitor classes can now properly reside in the value classes. :-) --- llvm/include/llvm/Analysis/MemoryBuiltins.h | 192 +++ llvm/lib/Analysis/MemoryBuiltins.cpp | 314 +- .../Transforms/IPO/AttributorAttributes.cpp | 8 +- .../Instrumentation/AddressSanitizer.cpp | 12 +- .../Instrumentation/BoundsChecking.cpp| 8 +- 5 files changed, 299 insertions(+), 235 deletions(-) diff --git a/llvm/include/llvm/Analysis/MemoryBuiltins.h b/llvm/include/llvm/Analysis/MemoryBuiltins.h index 827b5081b2ce75..56faa32fb0b226 100644 --- a/llvm/include/llvm/Analysis/MemoryBuiltins.h +++ b/llvm/include/llvm/Analysis/MemoryBuiltins.h @@ -187,80 +187,146 @@ Value *lowerObjectSizeCall( const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed, SmallVectorImpl *InsertedInstructions = nullptr); -using SizeOffsetType = std::pair; +/// SizeOffsetType - A base template class for the object size visitors. Used +/// here as a self-documenting way to handle the values rather than using a +/// \p std::pair. +template struct SizeOffsetType { + T Size; + T Offset; + + bool knownSize() const; + bool knownOffset() const; + bool anyKnown() const; + bool bothKnown() const; +}; + +/// SizeOffsetType - Used by \p ObjectSizeOffsetVisitor, which works +/// with \p APInts. +template <> struct SizeOffsetType { + APInt Size; + APInt Offset; + + SizeOffsetType() = default; + SizeOffsetType(APInt Size, APInt Offset) : Size(Size), Offset(Offset) {} + + bool knownSize() const { return Size.getBitWidth() > 1; } + bool knownOffset() const { return Offset.getBitWidth() > 1; } + bool anyKnown() const { return knownSize() || knownOffset(); } + bool bothKnown() const { return knownSize() && knownOffset(); } + + bool operator==(const SizeOffsetType &RHS) { +return Size == RHS.Size && Offset == RHS.Offset; + } + bool operator!=(const SizeOffsetType &RHS) { return !(*this == RHS); } +}; +using SizeOffsetAPInt = SizeOffsetType; /// Evaluate the size and offset of an object pointed to by a Value* /// statically. Fails if size or offset are not known at compile time. class ObjectSizeOffsetVisitor - : public InstVisitor { +: public InstVisitor { const DataLayout &DL; const TargetLibraryInfo *TLI; ObjectSizeOpts Options; unsigned IntTyBits; APInt Zero; - SmallDenseMap SeenInsts; + SmallDenseMap SeenInsts; unsigned InstructionsVisited; APInt align(APInt Size, MaybeAlign Align); - SizeOffsetType unknown() { -return std::make_pair(APInt(), APInt()); - } + static SizeOffsetAPInt unknown; public: ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts Options = {}); - SizeOffsetType compute(Value *V); - - static bool knownSize(const SizeOffsetType &SizeOffset) { -return SizeOffset.first.getBitWidth() > 1; - } - - static bool knownOffset(const SizeOffsetType &SizeOffset) { -return SizeOffset.second.getBitWidth() > 1; - } - - static bool bothKnown(const SizeOffsetType &SizeOffset) { -return knownSize(SizeOffset) && knownOffset(SizeOffset); - } + SizeOffsetAPInt compute(Value *V); // These are "private", except they can't actually be made private. Only // compute() should be used by external users. - SizeOffsetType visitAllocaInst(AllocaInst &I); - SizeOffsetType visitArgument(Argument &A); - SizeOffsetType visitCallBase(CallBase &CB); - SizeOffsetType visitConstantPointerNull(ConstantPointerNull&); - SizeOffsetType visitExtractElementInst(ExtractElementInst &I); - SizeOffsetType visitExtractValueInst(ExtractValueInst &I); - SizeOffsetType visitGlobalAlias(GlobalAlias &GA); - SizeOffsetType visitGlobalVariable(GlobalVariable &GV); - SizeOffsetType visitIntToPtrInst(IntToPtrInst&); - SizeOffsetType visitLoadInst(LoadInst &I); - SizeOffsetType visitPHINode(PHINode&); - SizeOffsetType visitSelectInst(SelectInst &I); - SizeOffsetType visitUndefValue(UndefValue&); - SizeOffsetType visitInstruction(Instruction &I); + SizeOffsetAPInt visitAllocaInst(AllocaInst &I); + SizeOffsetAPInt visitArgument(Argument &A); + SizeOffsetAPInt visitCallBase(CallBase &CB); + SizeOffsetAPInt visitConstantPointerNull(ConstantPointerNull &); + SizeOffsetAPInt visitExtractElementInst(ExtractElementInst &I); + SizeOffsetAPInt visitExtractValueInst(ExtractValueInst &I); + SizeOffsetAPInt visitGlobalAlias(GlobalAlias &GA); + SizeOffsetAPInt
[Lldb-commits] [clang] [compiler-rt] [flang] [clang-tools-extra] [libc] [lld] [lldb] [llvm] [libcxx] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)
@@ -0,0 +1,333 @@ +// -*- 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 _LIBCPP___RANGES_ENUMERATE_VIEW_H +#define _LIBCPP___RANGES_ENUMERATE_VIEW_H + +#include <__concepts/convertible_to.h> +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/distance.h> +#include <__iterator/iter_move.h> +#include <__iterator/iterator_traits.h> +#include <__ranges/access.h> +#include <__ranges/all.h> +#include <__ranges/concepts.h> +#include <__ranges/enable_borrowed_range.h> +#include <__ranges/range_adaptor.h> +#include <__ranges/size.h> +#include <__ranges/view_interface.h> +#include <__type_traits/maybe_const.h> +#include <__utility/forward.h> +#include <__utility/move.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 23 + +namespace ranges { + +// [concept.object] + +template +concept __range_with_movable_references = +ranges::input_range<_Rp> && std::move_constructible> && +std::move_constructible>; + +// [range.enumerate.view] + +template + requires __range_with_movable_references<_View> +class enumerate_view : public view_interface> { + _View __base_ = _View(); + + // [range.enumerate.iterator] + template + class __iterator; + + // [range.enumerate.sentinel] + template + class __sentinel; + + template + _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_current(const __iterator<_AnyConst>& __iter) { +return (__iter.__current_); + } + +public: + _LIBCPP_HIDE_FROM_ABI constexpr enumerate_view() +requires(default_initializable<_View>) + = default; + _LIBCPP_HIDE_FROM_ABI constexpr explicit enumerate_view(_View __base) : __base_(std::move(__base)){}; + + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() +requires(!__simple_view<_View>) + { +return __iterator(ranges::begin(__base_), 0); + } + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const +requires __range_with_movable_references + { +return __iterator(ranges::begin(__base_), 0); + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto end() +requires(!__simple_view<_View>) + { +if constexpr (common_range<_View> && sized_range<_View>) + return __iterator(ranges::end(__base_), ranges::distance(__base_)); +else + return __sentinel(ranges::end(__base_)); + } + _LIBCPP_HIDE_FROM_ABI constexpr auto end() const +requires __range_with_movable_references + { +if constexpr (common_range && sized_range) + return __iterator(ranges::end(__base_), ranges::distance(__base_)); +else + return __sentinel(ranges::end(__base_)); + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto size() +requires sized_range<_View> + { +return ranges::size(__base_); + } + _LIBCPP_HIDE_FROM_ABI constexpr auto size() const +requires sized_range + { +return ranges::size(__base_); + } + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& +requires copy_constructible<_View> + { +return __base_; + } + _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } +}; + +template +enumerate_view(_Range&&) -> enumerate_view>; + +// [range.enumerate.iterator] + +template + requires __range_with_movable_references<_View> +template +class enumerate_view<_View>::__iterator { + using _Base = __maybe_const<_Const, _View>; + + static consteval auto __get_iterator_concept() { +if constexpr (random_access_range<_Base>) { + return random_access_iterator_tag{}; +} else if constexpr (bidirectional_range<_Base>) { + return bidirectional_iterator_tag{}; +} else if constexpr (forward_range<_Base>) { + return forward_iterator_tag{}; +} else { + return input_iterator_tag{}; +} + } + + friend class enumerate_view<_View>; + +public: + using iterator_category = input_iterator_tag; + using iterator_concept = decltype(__get_iterator_concept()); + using difference_type = range_difference_t<_Base>; + using value_type= tuple>; + +private: + using __reference_type = tuple>; + iterator_t<_Base> __current_ = iterator_t<_Base>(); + difference_type __pos_ = 0; + + _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(iterator_t<_Base> __current, difference_type __pos) + : __current_(std::move(__current)), __pos_(__pos) {} + +public: + _LIBCPP_HIDE_FROM_ABI __iterator() +requires(default_initializable>) + = default; + _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator __i) +requires _Const && convertible_to, iterator_t<_Base>> + : __current_(std::move(__i.__current_)), __pos_(__i.__pos_) {} + + _L
[Lldb-commits] [lldb] [libc] [llvm] [clang] [mlir] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)
@@ -187,80 +187,124 @@ Value *lowerObjectSizeCall( const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed, SmallVectorImpl *InsertedInstructions = nullptr); -using SizeOffsetType = std::pair; +/// SizeOffsetType - A base template class for the object size visitors. Used +/// here as a self-documenting way to handle the values rather than using a +/// \p std::pair. +template struct SizeOffsetType { + T Size; + T Offset; + + SizeOffsetType() = default; + SizeOffsetType(T Size, T Offset) : Size(Size), Offset(Offset) {} + virtual ~SizeOffsetType() = default; + + virtual bool knownSize() const = 0; + virtual bool knownOffset() const = 0; nikic wrote: Use CRTP instead of virtual dispatch? Should at least make the child classes final if you're using virtual. https://github.com/llvm/llvm-project/pull/76882 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang] [libcxx] [clang-tools-extra] [mlir] [lldb] [libc] [BOLT][NFC] Print BAT section size (PR #76897)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76897 >From 5106f9e921aa426cf3272277c4aee4bdf76215e8 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Wed, 3 Jan 2024 21:25:02 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- bolt/lib/Rewrite/RewriteInstance.cpp| 1 + bolt/test/X86/bolt-address-translation.test | 1 + 2 files changed, 2 insertions(+) diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index a95b1650753cfd..f5a8a5b7168745 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -4112,6 +4112,7 @@ void RewriteInstance::encodeBATSection() { copyByteArray(BoltInfo), BoltInfo.size(), /*Alignment=*/1, /*IsReadOnly=*/true, ELF::SHT_NOTE); + outs() << "BOLT-INFO: BAT section size (bytes): " << BoltInfo.size() << '\n'; } template diff --git a/bolt/test/X86/bolt-address-translation.test b/bolt/test/X86/bolt-address-translation.test index f68a8f7e9bcb7f..c5813b411d87ba 100644 --- a/bolt/test/X86/bolt-address-translation.test +++ b/bolt/test/X86/bolt-address-translation.test @@ -37,6 +37,7 @@ # CHECK: BOLT: 3 out of 7 functions were overwritten. # CHECK: BOLT-INFO: Wrote 6 BAT maps # CHECK: BOLT-INFO: Wrote 3 BAT cold-to-hot entries +# CHECK: BOLT-INFO: BAT section size (bytes): 1436 # # usqrt mappings (hot part). We match against any key (left side containing # the bolted binary offsets) because BOLT may change where it puts instructions ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang] [libcxx] [clang-tools-extra] [mlir] [lldb] [libc] [BOLT][NFC] Print BAT section size (PR #76897)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/76897 >From 5106f9e921aa426cf3272277c4aee4bdf76215e8 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Wed, 3 Jan 2024 21:25:02 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- bolt/lib/Rewrite/RewriteInstance.cpp| 1 + bolt/test/X86/bolt-address-translation.test | 1 + 2 files changed, 2 insertions(+) diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index a95b1650753cfd..f5a8a5b7168745 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -4112,6 +4112,7 @@ void RewriteInstance::encodeBATSection() { copyByteArray(BoltInfo), BoltInfo.size(), /*Alignment=*/1, /*IsReadOnly=*/true, ELF::SHT_NOTE); + outs() << "BOLT-INFO: BAT section size (bytes): " << BoltInfo.size() << '\n'; } template diff --git a/bolt/test/X86/bolt-address-translation.test b/bolt/test/X86/bolt-address-translation.test index f68a8f7e9bcb7f..c5813b411d87ba 100644 --- a/bolt/test/X86/bolt-address-translation.test +++ b/bolt/test/X86/bolt-address-translation.test @@ -37,6 +37,7 @@ # CHECK: BOLT: 3 out of 7 functions were overwritten. # CHECK: BOLT-INFO: Wrote 6 BAT maps # CHECK: BOLT-INFO: Wrote 3 BAT cold-to-hot entries +# CHECK: BOLT-INFO: BAT section size (bytes): 1436 # # usqrt mappings (hot part). We match against any key (left side containing # the bolted binary offsets) because BOLT may change where it puts instructions ___ 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)
@@ -235,6 +233,53 @@ ParseSupportFilesFromPrologue(const lldb::ModuleSP &module, for (size_t idx = first_file_idx; idx <= last_file_idx; ++idx) { std::string remapped_file; if (auto file_path = GetFileByIndex(prologue, idx, compile_dir, style)) { + auto entry = prologue.getFileNameEntry(idx); + auto source = entry.Source.getAsCString(); + if (!source) +consumeError(source.takeError()); + else { +llvm::StringRef source_ref(*source); +if (!source_ref.empty()) { + /// Wrap a path for an in-DWARF source file. Lazily write it + /// to disk when Materialize() is called. + struct LazyDWARFSourceFile : public SupportFile { adrian-prantl wrote: I thought since it is only used there, defining it inline like a lambda makes sense, but I have no strong feelings about it. 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)
https://github.com/adrian-prantl updated https://github.com/llvm/llvm-project/pull/75880 >From 919f93cdb351b35853d236641c727f1eade0fefd 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 | 108 +- 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 +- 31 files changed, 339 insertions(+), 123 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); - void SetSupportFiles(FileSpecList support_files); - void
[Lldb-commits] [lldb] Add support for inline DWARF source files. (PR #75880)
@@ -17,6 +17,89 @@ namespace lldb_private { class Stream; +/// Wraps either a FileSpec that represents a local file or 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 +/// file yet. +class SupportFile { +protected: + FileSpec m_file_spec; + +public: + SupportFile(const FileSpec &spec) : m_file_spec(spec) {} + SupportFile(const SupportFile &other) = delete; + SupportFile(SupportFile &&other) = default; + virtual ~SupportFile() = default; + bool operator==(const SupportFile &other) { +return m_file_spec == other.m_file_spec; + } + /// Return the file name only. Useful for resolving breakpoints by file name. + const FileSpec &GetSpecOnly() const { return m_file_spec; }; + /// Materialize the file to disk and return the path to that temporary file. + virtual const FileSpec &Materialize() { +return m_file_spec; + } +}; + +/// A list of support files for a CompileUnit. +class SupportFileList { +public: + SupportFileList(){}; + SupportFileList(const SupportFileList &) = delete; + SupportFileList(SupportFileList &&other) adrian-prantl wrote: Yes. 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][nfc] Mark function as const (PR #76974)
https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/76974 This function has no mutable behavior >From e3504ef67116945613bdfc36f0844d799097c2f8 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Thu, 4 Jan 2024 13:25:33 -0300 Subject: [PATCH] [lldb][nfc] Mark function as const This function has no mutable behavior --- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 2 +- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 7c253553d57b48..b718f98340a70b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -48,7 +48,7 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { } std::optional -DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { +DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) const { // Look for a DWARF unit offset (CU offset or local TU offset) as they are // both offsets into the .debug_info section. std::optional unit_offset = entry.getCUOffset(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h index 7ce630a56137d1..cca0913c4124c9 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h @@ -79,7 +79,7 @@ class DebugNamesDWARFIndex : public DWARFIndex { std::unique_ptr m_debug_names_up; ManualDWARFIndex m_fallback; - std::optional ToDIERef(const DebugNames::Entry &entry); + std::optional ToDIERef(const DebugNames::Entry &entry) const; bool ProcessEntry(const DebugNames::Entry &entry, llvm::function_ref callback); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Mark function as const (PR #76974)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Felipe de Azevedo Piovezan (felipepiovezan) Changes This function has no mutable behavior --- Full diff: https://github.com/llvm/llvm-project/pull/76974.diff 2 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp (+1-1) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h (+1-1) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 7c253553d57b48..b718f98340a70b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -48,7 +48,7 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { } std::optional -DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { +DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) const { // Look for a DWARF unit offset (CU offset or local TU offset) as they are // both offsets into the .debug_info section. std::optional unit_offset = entry.getCUOffset(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h index 7ce630a56137d1..cca0913c4124c9 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h @@ -79,7 +79,7 @@ class DebugNamesDWARFIndex : public DWARFIndex { std::unique_ptr m_debug_names_up; ManualDWARFIndex m_fallback; - std::optional ToDIERef(const DebugNames::Entry &entry); + std::optional ToDIERef(const DebugNames::Entry &entry) const; bool ProcessEntry(const DebugNames::Entry &entry, llvm::function_ref callback); `` https://github.com/llvm/llvm-project/pull/76974 ___ 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)
https://github.com/adrian-prantl updated https://github.com/llvm/llvm-project/pull/75880 >From 9af00c37715c614cac700cd8763ee3d8167111e5 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 | 106 - 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 | 15 +++ .../inline-sourcefile/inline.ll | 39 +++ .../functionalities/inline-sourcefile/main.c | 7 ++ lldb/unittests/Core/FileSpecListTest.cpp | 8 +- 31 files changed, 335 insertions(+), 123 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); - void SetSupportFiles(FileSpecList support_files); - void
[Lldb-commits] [lldb] Add support for inline DWARF source files. (PR #75880)
https://github.com/adrian-prantl closed 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] 917b404 - Add support for inline DWARF source files. (#75880)
Author: Adrian Prantl Date: 2024-01-04T09:04:05-08:00 New Revision: 917b404e2ccdcc31d2d64971ad094b80967a240b URL: https://github.com/llvm/llvm-project/commit/917b404e2ccdcc31d2d64971ad094b80967a240b DIFF: https://github.com/llvm/llvm-project/commit/917b404e2ccdcc31d2d64971ad094b80967a240b.diff LOG: Add support for inline DWARF source files. (#75880) 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. rdar://110926168 Added: lldb/test/API/functionalities/inline-sourcefile/Makefile lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py lldb/test/API/functionalities/inline-sourcefile/inline.ll lldb/test/API/functionalities/inline-sourcefile/main.c Modified: lldb/include/lldb/Symbol/CompileUnit.h lldb/include/lldb/Symbol/SymbolFile.h lldb/include/lldb/Symbol/SymbolFileOnDemand.h lldb/include/lldb/Utility/FileSpecList.h lldb/source/API/SBCompileUnit.cpp lldb/source/Commands/CommandObjectSource.cpp lldb/source/Core/ModuleList.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/JSON/SymbolFileJSON.h lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h lldb/source/Symbol/CompileUnit.cpp lldb/source/Symbol/SymbolFileOnDemand.cpp lldb/source/Utility/FileSpecList.cpp lldb/unittests/Core/FileSpecListTest.cpp Removed: 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); - void SetSupportFiles(FileSpecList support_files); - void SetDebugMacros(const DebugMacrosSP &debug_macros); /// Set accessor for the variable list. @@ -410,9 +420,8 @@ class CompileUnit : public std::enable_shared_from_this, std::vector m_imported_modules; /// The primary file associated with this compile unit. FileSpec m_file_spec; - /// Files associated with this
[Lldb-commits] [compiler-rt] [libc] [mlir] [clang-tools-extra] [lldb] [lld] [openmp] [flang] [clang] [libcxx] [llvm] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)
@@ -0,0 +1,97 @@ +//===--===// +// +// 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 +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +# include +# include +#else +# include +#endif + +#include "platform_support.h" +#include "test_macros.h" +#include "types.h" + +#if TEST_STD_VER >= 26 + +# include "check_assertion.h" + +inline bool is_handle_valid(NativeHandleT handle) { +# if defined(_WIN32) + BY_HANDLE_FILE_INFORMATION fileInformation; + return GetFileInformationByHandle(handle, &fileInformation)); +# elif __has_include() // POSIX + return fcntl(handle, F_GETFL) != -1 || errno != EBADF; +# else +#error "Provide a native file handle!" +# endif +} + +template +inline void test_native_handle() { + static_assert( + std::is_same_v::native_handle_type, typename StreamT::native_handle_type>); + + StreamT f; + std::filesystem::path p = get_temp_file_name(); + + // non-const + { +f.open(p); +std::same_as decltype(auto) handle = f.native_handle(); +assert(is_handle_valid(handle)); +assert(f.rdbuf()->native_handle() == handle); +assert(std::as_const(f).rdbuf()->native_handle() == handle); +f.close(); +assert(!is_handle_valid(handle)); +static_assert(noexcept(f.native_handle())); + } + // const + { +f.open(p); +std::same_as decltype(auto) const_handle = std::as_const(f).native_handle(); +assert(is_handle_valid(const_handle)); +assert(f.rdbuf()->native_handle() == const_handle); +assert(std::as_const(f).rdbuf()->native_handle() == const_handle); +f.close(); +assert(!is_handle_valid(const_handle)); +static_assert(noexcept(std::as_const(f).native_handle())); + } +} + +template +inline void test_native_handle_assertion() { + StreamT f; + + // non-const + { TEST_LIBCPP_ASSERT_FAILURE(f.native_handle(), "File must be opened"); } mordante wrote: nit: We don't need an extra scope here. I'm not objecting either. 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] [libc] [llvm] [openmp] [mlir] [lldb] [flang] [lld] [clang] [libcxx] [compiler-rt] [clang-tools-extra] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)
https://github.com/mordante approved this pull request. Thanks LGTM! 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] [lld] [llvm] [libcxx] [lldb] [clang-tools-extra] [mlir] [flang] [compiler-rt] [libc] [clang] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)
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] [lldb] [lldb][DWARFIndex][nfc] Factor out fully qualified name query (PR #76977)
https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/76977 This moves the functionally of finding a DIE based on a fully qualified name from SymbolFileDWARF into DWARFIndex itself, so that specializations of DWARFIndex can implement faster versions of this query. >From c8adfbbaeca8228b53a22a0c071cb833f1711161 Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Thu, 4 Jan 2024 12:44:43 -0300 Subject: [PATCH] [lldb][DWARFIndex][nfc] Factor out fully qualified name query This moves the functionally of finding a DIE based on a fully qualified name from SymbolFileDWARF into DWARFIndex itself, so that specializations of DWARFIndex can implement faster versions of this query. --- .../source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp | 14 ++ lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h | 8 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 9 ++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp index b1c323b101cef3..01b47551b25c30 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp @@ -7,6 +7,8 @@ //===--===// #include "Plugins/SymbolFile/DWARF/DWARFIndex.h" +#include "DWARFDebugInfoEntry.h" +#include "DWARFDeclContext.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" #include "Plugins/SymbolFile/DWARF/DWARFDIE.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" @@ -112,3 +114,15 @@ void DWARFIndex::ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const { "bad die {0:x16} for '{1}')\n", ref.die_offset(), name.str().c_str()); } + +void DWARFIndex::GetFullyQualifiedType( +const DWARFDeclContext &context, +llvm::function_ref callback) { + GetTypes(context, [&](DWARFDIE die) { +DWARFDeclContext dwarf_decl_ctx = +die.GetDIE()->GetDWARFDeclContext(die.GetCU()); +if (dwarf_decl_ctx == context && callback(die)) + return false; +return true; + }); +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h index 9aadeddbb21753..4fd10a634fc57f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h @@ -53,6 +53,14 @@ class DWARFIndex { llvm::function_ref callback) = 0; virtual void GetTypes(const DWARFDeclContext &context, llvm::function_ref callback) = 0; + + /// Finds all DIEs whose fully qualified name matches `context`. A base + /// implementation is provided, and it uses the entire CU to check the DIE + /// parent hierarchy. Specializations should override this if they are able + /// to provide a faster implementation. + virtual void + GetFullyQualifiedType(const DWARFDeclContext &context, +llvm::function_ref callback); virtual void GetNamespaces(ConstString name, llvm::function_ref callback) = 0; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 505ea29ca4d4f5..e7dc9115cd80e7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3095,7 +3095,7 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { } const DWARFDeclContext die_dwarf_decl_ctx = GetDWARFDeclContext(die); -m_index->GetTypes(die_dwarf_decl_ctx, [&](DWARFDIE type_die) { +m_index->GetFullyQualifiedType(die_dwarf_decl_ctx, [&](DWARFDIE type_die) { // Make sure type_die's language matches the type system we are // looking for. We don't want to find a "Foo" type from Java if we // are looking for a "Foo" type for C, C++, ObjC, or ObjC++. @@ -3122,9 +3122,8 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { return true; } - DWARFDeclContext type_dwarf_decl_ctx = GetDWARFDeclContext(type_die); - if (log) { +DWARFDeclContext type_dwarf_decl_ctx = GetDWARFDeclContext(type_die); GetObjectFile()->GetModule()->LogMessage( log, "SymbolFileDWARF::" @@ -3134,10 +3133,6 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { type_dwarf_decl_ctx.GetQualifiedName()); } - // Make sure the decl contexts match all the way up - if (die_dwarf_decl_ctx != type_dwarf_decl_ctx) -return true; - Type *resolved_type = ResolveType(type_die, false); if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED) return true; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://
[Lldb-commits] [lldb] [lldb][DWARFIndex][nfc] Factor out fully qualified name query (PR #76977)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Felipe de Azevedo Piovezan (felipepiovezan) Changes This moves the functionally of finding a DIE based on a fully qualified name from SymbolFileDWARF into DWARFIndex itself, so that specializations of DWARFIndex can implement faster versions of this query. --- Full diff: https://github.com/llvm/llvm-project/pull/76977.diff 3 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp (+14) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h (+8) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+2-7) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp index b1c323b101cef3..01b47551b25c30 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp @@ -7,6 +7,8 @@ //===--===// #include "Plugins/SymbolFile/DWARF/DWARFIndex.h" +#include "DWARFDebugInfoEntry.h" +#include "DWARFDeclContext.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" #include "Plugins/SymbolFile/DWARF/DWARFDIE.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" @@ -112,3 +114,15 @@ void DWARFIndex::ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const { "bad die {0:x16} for '{1}')\n", ref.die_offset(), name.str().c_str()); } + +void DWARFIndex::GetFullyQualifiedType( +const DWARFDeclContext &context, +llvm::function_ref callback) { + GetTypes(context, [&](DWARFDIE die) { +DWARFDeclContext dwarf_decl_ctx = +die.GetDIE()->GetDWARFDeclContext(die.GetCU()); +if (dwarf_decl_ctx == context && callback(die)) + return false; +return true; + }); +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h index 9aadeddbb21753..4fd10a634fc57f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h @@ -53,6 +53,14 @@ class DWARFIndex { llvm::function_ref callback) = 0; virtual void GetTypes(const DWARFDeclContext &context, llvm::function_ref callback) = 0; + + /// Finds all DIEs whose fully qualified name matches `context`. A base + /// implementation is provided, and it uses the entire CU to check the DIE + /// parent hierarchy. Specializations should override this if they are able + /// to provide a faster implementation. + virtual void + GetFullyQualifiedType(const DWARFDeclContext &context, +llvm::function_ref callback); virtual void GetNamespaces(ConstString name, llvm::function_ref callback) = 0; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 505ea29ca4d4f5..e7dc9115cd80e7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3095,7 +3095,7 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { } const DWARFDeclContext die_dwarf_decl_ctx = GetDWARFDeclContext(die); -m_index->GetTypes(die_dwarf_decl_ctx, [&](DWARFDIE type_die) { +m_index->GetFullyQualifiedType(die_dwarf_decl_ctx, [&](DWARFDIE type_die) { // Make sure type_die's language matches the type system we are // looking for. We don't want to find a "Foo" type from Java if we // are looking for a "Foo" type for C, C++, ObjC, or ObjC++. @@ -3122,9 +3122,8 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { return true; } - DWARFDeclContext type_dwarf_decl_ctx = GetDWARFDeclContext(type_die); - if (log) { +DWARFDeclContext type_dwarf_decl_ctx = GetDWARFDeclContext(type_die); GetObjectFile()->GetModule()->LogMessage( log, "SymbolFileDWARF::" @@ -3134,10 +3133,6 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { type_dwarf_decl_ctx.GetQualifiedName()); } - // Make sure the decl contexts match all the way up - if (die_dwarf_decl_ctx != type_dwarf_decl_ctx) -return true; - Type *resolved_type = ResolveType(type_die, false); if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED) return true; `` https://github.com/llvm/llvm-project/pull/76977 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
mgorny wrote: Ping. https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9f9dd6b - Wrap local type declarations in anonymous namespace to fix modules build.
Author: Adrian Prantl Date: 2024-01-04T09:30:00-08:00 New Revision: 9f9dd6be0d21a156dcfee01ebbd571eca79b08bd URL: https://github.com/llvm/llvm-project/commit/9f9dd6be0d21a156dcfee01ebbd571eca79b08bd DIFF: https://github.com/llvm/llvm-project/commit/9f9dd6be0d21a156dcfee01ebbd571eca79b08bd.diff LOG: Wrap local type declarations in anonymous namespace to fix modules build. Added: Modified: lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp Removed: diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp index 5326a73166e72e..1688fb27430a7a 100644 --- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -35,6 +35,7 @@ using namespace lldb_private; LLDB_PLUGIN_DEFINE(JITLoaderGDB) +namespace { // Debug Interface Structures enum jit_actions_t { JIT_NOACTION = 0, JIT_REGISTER_FN, JIT_UNREGISTER_FN }; @@ -52,7 +53,6 @@ template struct jit_descriptor { ptr_t first_entry;// pointer }; -namespace { enum EnableJITLoaderGDB { eEnableJITLoaderGDBDefault, eEnableJITLoaderGDBOn, ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4004f65 - [LLDB][NativePDB] Fix use-after-free error detected by asan.
Author: Zequan Wu Date: 2024-01-04T12:32:40-05:00 New Revision: 4004f655ceb9623608ba0471aa7037c142956e31 URL: https://github.com/llvm/llvm-project/commit/4004f655ceb9623608ba0471aa7037c142956e31 DIFF: https://github.com/llvm/llvm-project/commit/4004f655ceb9623608ba0471aa7037c142956e31.diff LOG: [LLDB][NativePDB] Fix use-after-free error detected by asan. Added: Modified: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 8375010ae3dedd..9234768323e713 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -2265,7 +2265,8 @@ void SymbolFileNativePDB::BuildParentMap() { } for (TypeIndex fwd : fwd_keys) { TypeIndex full = forward_to_full[fwd]; -m_parent_types[full] = m_parent_types[fwd]; +TypeIndex parent_idx = m_parent_types[fwd]; +m_parent_types[full] = parent_idx; } for (TypeIndex full : full_keys) { TypeIndex fwd = full_to_forward[full]; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)
https://github.com/mordante created https://github.com/llvm/llvm-project/pull/76983 This adds a subset of the C++20 calendar data formatters: - day, - month, - year, - month_day, - month_day_last, and - year_month_day. A followup patch will add the missing calendar data formatters: - weekday, - weekday_indexed, - weekday_last, - month_weekday, - month_weekday_last, - year_month, - year_month_day_last - year_month_weekday, and - year_month_weekday_last. >From f92402067fcdb6b87adcf3d727bff1888ebf4ab7 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Thu, 4 Jan 2024 18:43:54 +0100 Subject: [PATCH] [lldb][libc++] Adds some C++20 calendar data formatters. This adds a subset of the C++20 calendar data formatters: - day, - month, - year, - month_day, - month_day_last, and - year_month_day. A followup patch will add the missing calendar data formatters: - weekday, - weekday_indexed, - weekday_last, - month_weekday, - month_weekday_last, - year_month, - year_month_day_last - year_month_weekday, and - year_month_weekday_last. --- .../Language/CPlusPlus/CPlusPlusLanguage.cpp | 35 ++ .../Plugins/Language/CPlusPlus/LibCxx.cpp | 40 +++ .../Plugins/Language/CPlusPlus/LibCxx.h | 8 +++ .../chrono/TestDataFormatterLibcxxChrono.py | 67 +++ .../data-formatter-stl/libcxx/chrono/main.cpp | 54 +++ 5 files changed, 204 insertions(+) diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 586cc08a6f1233..c6937ebca319fa 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1031,6 +1031,41 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { "^std::__[[:alnum:]]+::chrono::seconds", eFormatterMatchRegex, TypeSummaryImplSP(new StringSummaryFormat( eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} s"))); + + // Chrono calendar types + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::day$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"day=${var.__d_%u}"))); + AddCXXSummary(cpp_category_sp, +lldb_private::formatters::LibcxxChronoMonthSummaryProvider, +"libc++ std::chrono::month summary provider", +"^std::__[[:alnum:]]+::chrono::month$", +eTypeOptionHideChildren | eTypeOptionHideValue, true); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat( + eTypeOptionHideChildren | eTypeOptionHideValue, "year=${var.__y_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_day$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__m_} ${var.__d_}"))); + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_day_last$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__m_} day=last"))); + AddCXXSummary( + cpp_category_sp, + lldb_private::formatters::LibcxxChronoYearMonthDaySummaryProvider, + "libc++ std::chrono::year_month_day summary provider", + "^std::__[[:alnum:]]+::chrono::year_month_day$", + eTypeOptionHideChildren | eTypeOptionHideValue, true); } static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index cae17ef992b215..5f9228c7b020c8 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1084,3 +1084,43 @@ bool lldb_private::formatters::LibcxxWStringViewSummaryProvider( return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options, dataobj, size); } + +bool lldb_private::formatters::LibcxxChronoMonthSummaryProvider( +ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { + // These are the names used in the C++20 ostream operator. Since LLVM uses + // C++17 it's not possible to use the ostream operator directly. + static const std::array months = { + "January", "February", "March", "April", "May", "June", + "July","August", "September", "October", "November", "December"}; + + unsigned month = valobj.GetCh
[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Mark de Wever (mordante) Changes This adds a subset of the C++20 calendar data formatters: - day, - month, - year, - month_day, - month_day_last, and - year_month_day. A followup patch will add the missing calendar data formatters: - weekday, - weekday_indexed, - weekday_last, - month_weekday, - month_weekday_last, - year_month, - year_month_day_last - year_month_weekday, and - year_month_weekday_last. --- Full diff: https://github.com/llvm/llvm-project/pull/76983.diff 5 Files Affected: - (modified) lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (+35) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (+40) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (+8) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py (+67) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp (+54) ``diff diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 586cc08a6f1233..c6937ebca319fa 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1031,6 +1031,41 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { "^std::__[[:alnum:]]+::chrono::seconds", eFormatterMatchRegex, TypeSummaryImplSP(new StringSummaryFormat( eTypeOptionHideChildren | eTypeOptionHideValue, "${var.__rep_} s"))); + + // Chrono calendar types + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::day$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"day=${var.__d_%u}"))); + AddCXXSummary(cpp_category_sp, +lldb_private::formatters::LibcxxChronoMonthSummaryProvider, +"libc++ std::chrono::month summary provider", +"^std::__[[:alnum:]]+::chrono::month$", +eTypeOptionHideChildren | eTypeOptionHideValue, true); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::year$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat( + eTypeOptionHideChildren | eTypeOptionHideValue, "year=${var.__y_}"))); + + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_day$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__m_} ${var.__d_}"))); + cpp_category_sp->AddTypeSummary( + "^std::__[[:alnum:]]+::chrono::month_day_last$", eFormatterMatchRegex, + TypeSummaryImplSP(new StringSummaryFormat(eTypeOptionHideChildren | +eTypeOptionHideValue, +"${var.__m_} day=last"))); + AddCXXSummary( + cpp_category_sp, + lldb_private::formatters::LibcxxChronoYearMonthDaySummaryProvider, + "libc++ std::chrono::year_month_day summary provider", + "^std::__[[:alnum:]]+::chrono::year_month_day$", + eTypeOptionHideChildren | eTypeOptionHideValue, true); } static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index cae17ef992b215..5f9228c7b020c8 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -1084,3 +1084,43 @@ bool lldb_private::formatters::LibcxxWStringViewSummaryProvider( return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options, dataobj, size); } + +bool lldb_private::formatters::LibcxxChronoMonthSummaryProvider( +ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { + // These are the names used in the C++20 ostream operator. Since LLVM uses + // C++17 it's not possible to use the ostream operator directly. + static const std::array months = { + "January", "February", "March", "April", "May", "June", + "July","August", "September", "October", "November", "December"}; + + unsigned month = valobj.GetChildMemberWithName("__m_")->GetValueAsUnsigned(0); + if (month >= 1 && month <= 12) +stream << "month=" << months[month - 1]; + else +stream.Printf("month=%u", month); + + return true; +} + +bool lldb_private::formatters::LibcxxChronoYearMonthDaySummaryProvider( +ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { + + stream << "date=
[Lldb-commits] [lldb] [lldb][libc++] Adds some C++20 calendar data formatters. (PR #76983)
mordante wrote: Note: I'd be happy to add the missing calendar data formatters to this review. I just want to make sure we're happy with the proposed output before adding them. https://github.com/llvm/llvm-project/pull/76983 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [lld] [lldb] [openmp] [compiler-rt] [libc] [mlir] [clang] [clang-tools-extra] [llvm] [libcxx] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)
@@ -0,0 +1,97 @@ +//===--===// +// +// 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 +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +# include +# include +#else +# include +#endif + +#include "platform_support.h" +#include "test_macros.h" +#include "types.h" + +#if TEST_STD_VER >= 26 + +# include "check_assertion.h" + +inline bool is_handle_valid(NativeHandleT handle) { +# if defined(_WIN32) + BY_HANDLE_FILE_INFORMATION fileInformation; + return GetFileInformationByHandle(handle, &fileInformation)); +# elif __has_include() // POSIX + return fcntl(handle, F_GETFL) != -1 || errno != EBADF; +# else +#error "Provide a native file handle!" +# endif +} + +template +inline void test_native_handle() { + static_assert( + std::is_same_v::native_handle_type, typename StreamT::native_handle_type>); + + StreamT f; + std::filesystem::path p = get_temp_file_name(); + + // non-const + { +f.open(p); +std::same_as decltype(auto) handle = f.native_handle(); +assert(is_handle_valid(handle)); +assert(f.rdbuf()->native_handle() == handle); +assert(std::as_const(f).rdbuf()->native_handle() == handle); +f.close(); +assert(!is_handle_valid(handle)); +static_assert(noexcept(f.native_handle())); + } + // const + { +f.open(p); +std::same_as decltype(auto) const_handle = std::as_const(f).native_handle(); +assert(is_handle_valid(const_handle)); +assert(f.rdbuf()->native_handle() == const_handle); +assert(std::as_const(f).rdbuf()->native_handle() == const_handle); +f.close(); +assert(!is_handle_valid(const_handle)); +static_assert(noexcept(std::as_const(f).native_handle())); + } +} + +template +inline void test_native_handle_assertion() { + StreamT f; + + // non-const + { TEST_LIBCPP_ASSERT_FAILURE(f.native_handle(), "File must be opened"); } + // const + { TEST_LIBCPP_ASSERT_FAILURE(std::as_const(f).native_handle(), "File must be opened"); } Zingam wrote: ```suggestion // non-const TEST_LIBCPP_ASSERT_FAILURE(f.native_handle(), "File must be opened"); // const TEST_LIBCPP_ASSERT_FAILURE(std::as_const(f).native_handle(), "File must be opened"); ``` 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] [llvm] [libc] [mlir] [clang-tools-extra] [lldb] [compiler-rt] [openmp] [flang] [libcxx] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)
Zingam wrote: > Thanks LGTM! Thank you very much for the review! 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] [lldb][DWARFIndex][nfc] Factor out fully qualified name query (PR #76977)
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/76977 >From b828fb2a9e6317ee8f355ce88334cc33bb1b36ee Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Thu, 4 Jan 2024 12:44:43 -0300 Subject: [PATCH] [lldb][DWARFIndex][nfc] Factor out fully qualified name query This moves the functionally of finding a DIE based on a fully qualified name from SymbolFileDWARF into DWARFIndex itself, so that specializations of DWARFIndex can implement faster versions of this query. --- .../source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp | 14 ++ lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h | 8 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 9 ++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp index b1c323b101cef3..614b606a974feb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp @@ -7,6 +7,8 @@ //===--===// #include "Plugins/SymbolFile/DWARF/DWARFIndex.h" +#include "DWARFDebugInfoEntry.h" +#include "DWARFDeclContext.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" #include "Plugins/SymbolFile/DWARF/DWARFDIE.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" @@ -112,3 +114,15 @@ void DWARFIndex::ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const { "bad die {0:x16} for '{1}')\n", ref.die_offset(), name.str().c_str()); } + +void DWARFIndex::GetFullyQualifiedType( +const DWARFDeclContext &context, +llvm::function_ref callback) { + GetTypes(context, [&](DWARFDIE die) { +DWARFDeclContext dwarf_decl_ctx = +die.GetDIE()->GetDWARFDeclContext(die.GetCU()); +if (dwarf_decl_ctx == context) + return callback(die); +return true; + }); +} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h index 9aadeddbb21753..4fd10a634fc57f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h @@ -53,6 +53,14 @@ class DWARFIndex { llvm::function_ref callback) = 0; virtual void GetTypes(const DWARFDeclContext &context, llvm::function_ref callback) = 0; + + /// Finds all DIEs whose fully qualified name matches `context`. A base + /// implementation is provided, and it uses the entire CU to check the DIE + /// parent hierarchy. Specializations should override this if they are able + /// to provide a faster implementation. + virtual void + GetFullyQualifiedType(const DWARFDeclContext &context, +llvm::function_ref callback); virtual void GetNamespaces(ConstString name, llvm::function_ref callback) = 0; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 505ea29ca4d4f5..e7dc9115cd80e7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3095,7 +3095,7 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { } const DWARFDeclContext die_dwarf_decl_ctx = GetDWARFDeclContext(die); -m_index->GetTypes(die_dwarf_decl_ctx, [&](DWARFDIE type_die) { +m_index->GetFullyQualifiedType(die_dwarf_decl_ctx, [&](DWARFDIE type_die) { // Make sure type_die's language matches the type system we are // looking for. We don't want to find a "Foo" type from Java if we // are looking for a "Foo" type for C, C++, ObjC, or ObjC++. @@ -3122,9 +3122,8 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { return true; } - DWARFDeclContext type_dwarf_decl_ctx = GetDWARFDeclContext(type_die); - if (log) { +DWARFDeclContext type_dwarf_decl_ctx = GetDWARFDeclContext(type_die); GetObjectFile()->GetModule()->LogMessage( log, "SymbolFileDWARF::" @@ -3134,10 +3133,6 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) { type_dwarf_decl_ctx.GetQualifiedName()); } - // Make sure the decl contexts match all the way up - if (die_dwarf_decl_ctx != type_dwarf_decl_ctx) -return true; - Type *resolved_type = ResolveType(type_die, false); if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED) return true; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c041fa1 - XFAIL test with dsymutil
Author: Adrian Prantl Date: 2024-01-04T10:25:47-08:00 New Revision: c041fa1093c3ad7be040fb362a10ca3900c698a4 URL: https://github.com/llvm/llvm-project/commit/c041fa1093c3ad7be040fb362a10ca3900c698a4 DIFF: https://github.com/llvm/llvm-project/commit/c041fa1093c3ad7be040fb362a10ca3900c698a4.diff LOG: XFAIL test with dsymutil Added: Modified: lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py Removed: diff --git a/lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py b/lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py index 20ed0ce00661f0..ce7ac6fc503ed7 100644 --- a/lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py +++ b/lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py @@ -8,6 +8,8 @@ class InlineSourceFilesTestCase(TestBase): @skipIf(compiler="gcc") @skipIf(compiler="clang", compiler_version=["<", "18.0"]) +# dsymutil doesn't yet copy the sources +@expectedFailureDarwin(debug_info=["dsym"]) def test(self): """Test DWARF inline source files.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang] [clang-tools-extra] [libc] [flang] [libcxxabi] [libcxx] [compiler-rt] [lldb] Move nondiscard tests of ranges::contains() to the right place. (PR #76887)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/76887 >From 9b90c41bd209a49de85987529bd7286401b01ef2 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Wed, 3 Jan 2024 18:27:09 -0800 Subject: [PATCH] Move nondiscard tests of ranges::contains() to the right place. --- .../libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp | 3 --- .../test/libcxx/diagnostics/nodiscard_extensions.verify.cpp | 5 - .../diagnostics/ranges.nodiscard_extensions.compile.pass.cpp | 2 ++ .../diagnostics/ranges.nodiscard_extensions.verify.cpp | 4 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp index 641fcd9233bc2e..e9fab0c75a98e9 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp @@ -45,9 +45,6 @@ void test_algorithms() { #if TEST_STD_VER >= 17 std::clamp(2, 1, 3); std::clamp(2, 3, 1, std::greater()); -#endif -#if TEST_STD_VER >= 23 - std::ranges::contains(arr, arr + 1, 1); #endif std::count_if(std::begin(arr), std::end(arr), P()); std::count(std::begin(arr), std::end(arr), 1); diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp index 1e3f537f01ed6e..d7a26d99e52233 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp @@ -60,11 +60,6 @@ void test_algorithms() { std::clamp(2, 1, 3, std::greater()); #endif -#if TEST_STD_VER >= 23 - // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}} - std::ranges::contains(arr, arr + 1, 1); -#endif - // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}} std::count_if(std::begin(arr), std::end(arr), P()); diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp index 7e2d64b8c9b618..9dc9c46ad89090 100644 --- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp @@ -28,6 +28,8 @@ void test() { std::ranges::binary_search(range, 1); std::ranges::binary_search(iter, iter, 1); std::ranges::clamp(1, 2, 3); + std::ranges::contains(range, 1); + std::ranges::contains(iter, iter, 1); std::ranges::count_if(range, pred); std::ranges::count_if(iter, iter, pred); std::ranges::count(range, 1); diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp index f0a0e4889a7603..5e45ad086cbd08 100644 --- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp @@ -91,6 +91,10 @@ void test() { std::ranges::upper_bound(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} #if TEST_STD_VER >= 23 + std::ranges::contains(range, 1); + // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::contains(iter, iter, 1); + // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} std::ranges::fold_left(range, 0, std::plus()); // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} std::ranges::fold_left(iter, iter, 0, std::plus()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Mark function as const (PR #76974)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/76974 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [mlir] [flang] [clang-tools-extra] [compiler-rt] [lldb] [lld] [libc] [polly] [libcxxabi] [libcxx] Make clang report invalid target versions. (PR #75373)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/75373 >From 74f256d8a77ee2ba8e0d5bbb6519aa2729cf94d5 Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Wed, 13 Dec 2023 20:07:45 + Subject: [PATCH 01/13] Make clang report garbage target versions. Clang always silently ignores garbage target versions and this makes debug harder. So clang will report when target versions are invalid. --- llvm/lib/TargetParser/Triple.cpp | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index c5e9ad43d22588..335253194d1cf8 100644 --- a/llvm/lib/TargetParser/Triple.cpp +++ b/llvm/lib/TargetParser/Triple.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/SwapByteOrder.h" #include "llvm/Support/VersionTuple.h" #include "llvm/TargetParser/ARMTargetParser.h" @@ -1199,7 +1200,11 @@ StringRef Triple::getOSAndEnvironmentName() const { static VersionTuple parseVersionFromName(StringRef Name) { VersionTuple Version; - Version.tryParse(Name); + if (Version.tryParse(Name)) { +errs() << "The input is "<< Name << " and it is invalid. Should pass an "<< +"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n"; +exit(1); + } return Version.withoutBuild(); } >From 0d159b2a9b76e233e020ac0aef15b49b03f4d86c Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Wed, 13 Dec 2023 20:23:54 + Subject: [PATCH 02/13] rephrase --- llvm/lib/TargetParser/Triple.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index 335253194d1cf8..713ca447403d50 100644 --- a/llvm/lib/TargetParser/Triple.cpp +++ b/llvm/lib/TargetParser/Triple.cpp @@ -1201,8 +1201,7 @@ StringRef Triple::getOSAndEnvironmentName() const { static VersionTuple parseVersionFromName(StringRef Name) { VersionTuple Version; if (Version.tryParse(Name)) { -errs() << "The input is "<< Name << " and it is invalid. Should pass an "<< -"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n"; +errs() << "version "<< Name << " is invalid\n"; exit(1); } return Version.withoutBuild(); >From b2dda9ce95804783c59aa1ca4e81a7941aae805d Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Wed, 13 Dec 2023 20:07:45 + Subject: [PATCH 03/13] Make clang report garbage target versions. Clang always silently ignores garbage target versions and this makes debug harder. So clang will report when target versions are invalid. --- clang/lib/Basic/Targets/OSTargets.h | 5 + llvm/include/llvm/TargetParser/Triple.h | 4 llvm/lib/TargetParser/Triple.cpp| 8 3 files changed, 17 insertions(+) diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 342af4bbc42b7b..bc28066019971c 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -323,6 +323,11 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo { // This historical but ambiguous name for the minSdkVersion macro. Keep // defined for compatibility. Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__"); + } else { +llvm::errs() << "version "<< Triple.getVersionName() << +" in triple " << Triple.getArchName() << "-" << Triple.getVendorName() +<< "-" << Triple.getOSAndEnvironmentName() << " is invalid\n"; +exit(1); } } else { Builder.defineMacro("__gnu_linux__"); diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index 47904621c0967f..05df1c489ad06e 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -434,6 +434,10 @@ class Triple { /// string (separated by a '-' if the environment component is present). StringRef getOSAndEnvironmentName() const; + /// Get the version component of the environment component as a single + /// string (the version after the environment). + StringRef getVersionName() const; + /// @} /// @name Convenience Predicates /// @{ diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index 49bc24ffbfae6c..db4ba7100781bc 100644 --- a/llvm/lib/TargetParser/Triple.cpp +++ b/llvm/lib/TargetParser/Triple.cpp @@ -1199,6 +1199,14 @@ StringRef Triple::getOSAndEnvironmentName() const { return Tmp.split('-').second; // Strip second component } +StringRef Triple::getVersionName() const { + StringRef VersionName = getEnvironmentName(); + StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment()); + if (VersionName.startswith(EnvironmentTypeName)) +return VersionName.substr(EnvironmentTypeName.size()); + return VersionName; +} + static
[Lldb-commits] [clang] [llvm] [mlir] [flang] [clang-tools-extra] [compiler-rt] [lldb] [lld] [libc] [polly] [libcxxabi] [libcxx] Make clang report invalid target versions. (PR #75373)
https://github.com/ZijunZhaoCCK ready_for_review https://github.com/llvm/llvm-project/pull/75373 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [libcxx] [flang] [libc] [clang-tools-extra] [clang] [compiler-rt] [libunwind] [libunwind] Replace process_vm_readv with SYS_rt_sigprocmask (PR #74791)
https://github.com/ajordanr-google updated https://github.com/llvm/llvm-project/pull/74791 >From 9d4665cf1ddda98129af2f6ff575989cec49af6d Mon Sep 17 00:00:00 2001 From: Jordan R Abrahams-Whitehead Date: Fri, 8 Dec 2023 00:09:59 + Subject: [PATCH 01/13] [libunwind] Replace process_vm_readv with pipe process_vm_readv is generally considered dangerous from a syscall perspective, and is frequently blanket banned in seccomp filters such as those in Chromium and ChromiumOS. We can get the same behaviour during the invalid PC address case with pipes and write/read. Testing to ensure that process_vm_readv does not appear, I ran the output of check-unwind on an ARM64 device under strace. Previously, bad_unwind_info in particular would use process_vm_readv, but with this commit, it now uses pipe2: ``` strace test/Output/bad_unwind_info.pass.cpp.dir/t.tmp.exe \ |& grep process_vm_readv strace test/Output/bad_unwind_info.pass.cpp.dir/t.tmp.exe \ |& grep pipe2 ``` --- libunwind/src/UnwindCursor.hpp | 50 -- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 647a5a9c9d92d9..5e4e376220daa0 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -33,6 +33,7 @@ #if defined(_LIBUNWIND_TARGET_LINUX) && \ (defined(_LIBUNWIND_TARGET_AARCH64) || defined(_LIBUNWIND_TARGET_RISCV) || \ defined(_LIBUNWIND_TARGET_S390X)) +#include #include #include #include @@ -2700,19 +2701,18 @@ bool UnwindCursor::setInfoForSigReturn(Registers_arm64 &) { // [1] https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/vdso/sigreturn.S const pint_t pc = static_cast(this->getReg(UNW_REG_IP)); // The PC might contain an invalid address if the unwind info is bad, so - // directly accessing it could cause a segfault. Use process_vm_readv to read - // the memory safely instead. process_vm_readv was added in Linux 3.2, and - // AArch64 supported was added in Linux 3.7, so the syscall is guaranteed to - // be present. Unfortunately, there are Linux AArch64 environments where the - // libc wrapper for the syscall might not be present (e.g. Android 5), so call - // the syscall directly instead. + // directly accessing it could cause a segfault. Use pipe/write/read to read + // the memory safely instead. + int pipefd[2]; + if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) +return false; uint32_t instructions[2]; - struct iovec local_iov = {&instructions, sizeof instructions}; - struct iovec remote_iov = {reinterpret_cast(pc), sizeof instructions}; - long bytesRead = - syscall(SYS_process_vm_readv, getpid(), &local_iov, 1, &remote_iov, 1, 0); + const auto bufferSize = sizeof instructions; + if (write(pipefd[1], reinterpret_cast(pc), bufferSize) != bufferSize) +return false; + const auto bytesRead = read(pipefd[0], instructions, bufferSize); // Look for instructions: mov x8, #0x8b; svc #0x0 - if (bytesRead != sizeof instructions || instructions[0] != 0xd2801168 || + if (bytesRead != bufferSize || instructions[0] != 0xd2801168 || instructions[1] != 0xd401) return false; @@ -2762,17 +2762,20 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) { template bool UnwindCursor::setInfoForSigReturn(Registers_riscv &) { const pint_t pc = static_cast(getReg(UNW_REG_IP)); + int pipefd[2]; + if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) +return false; uint32_t instructions[2]; - struct iovec local_iov = {&instructions, sizeof instructions}; - struct iovec remote_iov = {reinterpret_cast(pc), sizeof instructions}; - long bytesRead = - syscall(SYS_process_vm_readv, getpid(), &local_iov, 1, &remote_iov, 1, 0); + const auto bufferSize = sizeof instructions; + if (write(pipefd[1], reinterpret_cast(pc), bufferSize) != bufferSize) +return false; + const auto bytesRead = read(pipefd[0], instructions, bufferSize); // Look for the two instructions used in the sigreturn trampoline // __vdso_rt_sigreturn: // // 0x08b00893 li a7,0x8b // 0x0073 ecall - if (bytesRead != sizeof instructions || instructions[0] != 0x08b00893 || + if (bytesRead != bufferSize || instructions[0] != 0x08b00893 || instructions[1] != 0x0073) return false; @@ -2822,13 +2825,18 @@ bool UnwindCursor::setInfoForSigReturn(Registers_s390x &) { // onto the stack. const pint_t pc = static_cast(this->getReg(UNW_REG_IP)); // The PC might contain an invalid address if the unwind info is bad, so - // directly accessing it could cause a segfault. Use process_vm_readv to + // directly accessing it could cause a segfault. Use pipe/write/read to // read the memory safely instead. uint16_t inst; - struct iovec local_iov = {&inst, sizeof inst}; - struct iovec remote_iov = {reinterpret_cast(pc), sizeof inst}; - long bytesRead = process_vm_readv(
[Lldb-commits] [lldb] [llvm] [libcxx] [mlir] [flang] [libc] [libcxxabi] [clang-tools-extra] [clang] [compiler-rt] [mlir][flang][openacc] Support device_type on loop construct (PR #76892)
https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/76892 >From ee784de88ed77d406eefe9f4ea65e823bde53e2e Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Tue, 2 Jan 2024 16:08:02 -0800 Subject: [PATCH 1/2] [mlir][flang][openacc] Support device_type on loop construct --- flang/lib/Lower/OpenACC.cpp | 183 +--- flang/test/Lower/OpenACC/acc-kernels-loop.f90 | 36 +- flang/test/Lower/OpenACC/acc-loop.f90 | 41 +- .../test/Lower/OpenACC/acc-parallel-loop.f90 | 36 +- flang/test/Lower/OpenACC/acc-reduction.f90| 6 +- flang/test/Lower/OpenACC/acc-serial-loop.f90 | 36 +- .../mlir/Dialect/OpenACC/OpenACCOps.td| 150 +- mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp | 438 ++ mlir/test/Dialect/OpenACC/invalid.mlir| 57 ++- mlir/test/Dialect/OpenACC/ops.mlir| 80 ++-- 10 files changed, 747 insertions(+), 316 deletions(-) diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index ecf70818c4ac0f..d8aedca90acf4b 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -1542,67 +1542,89 @@ createLoopOp(Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClauseList &accClauseList, bool needEarlyReturnHandling = false) { fir::FirOpBuilder &builder = converter.getFirOpBuilder(); - - mlir::Value workerNum; - mlir::Value vectorNum; - mlir::Value gangNum; - mlir::Value gangDim; - mlir::Value gangStatic; llvm::SmallVector tileOperands, privateOperands, - reductionOperands, cacheOperands; + reductionOperands, cacheOperands, vectorOperands, workerNumOperands, + gangOperands; llvm::SmallVector privatizations, reductionRecipes; - bool hasGang = false, hasVector = false, hasWorker = false; + llvm::SmallVector tileOperandsSegments, gangOperandsSegments; + llvm::SmallVector collapseValues; + + llvm::SmallVector gangArgTypes; + llvm::SmallVector seqDeviceTypes, independentDeviceTypes, + autoDeviceTypes, vectorOperandsDeviceTypes, workerNumOperandsDeviceTypes, + vectorDeviceTypes, workerNumDeviceTypes, tileOperandsDeviceTypes, + collapseDeviceTypes, gangDeviceTypes, gangOperandsDeviceTypes; + + // device_type attribute is set to `none` until a device_type clause is + // encountered. + auto crtDeviceTypeAttr = mlir::acc::DeviceTypeAttr::get( + builder.getContext(), mlir::acc::DeviceType::None); for (const Fortran::parser::AccClause &clause : accClauseList.v) { mlir::Location clauseLocation = converter.genLocation(clause.source); if (const auto *gangClause = std::get_if(&clause.u)) { if (gangClause->v) { +auto crtGangOperands = gangOperands.size(); const Fortran::parser::AccGangArgList &x = *gangClause->v; for (const Fortran::parser::AccGangArg &gangArg : x.v) { if (const auto *num = std::get_if(&gangArg.u)) { -gangNum = fir::getBase(converter.genExprValue( -*Fortran::semantics::GetExpr(num->v), stmtCtx)); +gangOperands.push_back(fir::getBase(converter.genExprValue( +*Fortran::semantics::GetExpr(num->v), stmtCtx))); +gangArgTypes.push_back(mlir::acc::GangArgTypeAttr::get( +builder.getContext(), mlir::acc::GangArgType::Num)); } else if (const auto *staticArg = std::get_if( &gangArg.u)) { const Fortran::parser::AccSizeExpr &sizeExpr = staticArg->v; if (sizeExpr.v) { - gangStatic = fir::getBase(converter.genExprValue( - *Fortran::semantics::GetExpr(*sizeExpr.v), stmtCtx)); + gangOperands.push_back(fir::getBase(converter.genExprValue( + *Fortran::semantics::GetExpr(*sizeExpr.v), stmtCtx))); } else { // * was passed as value and will be represented as a special // constant. - gangStatic = builder.createIntegerConstant( - clauseLocation, builder.getIndexType(), starCst); + gangOperands.push_back(builder.createIntegerConstant( + clauseLocation, builder.getIndexType(), starCst)); } +gangArgTypes.push_back(mlir::acc::GangArgTypeAttr::get( +builder.getContext(), mlir::acc::GangArgType::Static)); } else if (const auto *dim = std::get_if( &gangArg.u)) { -gangDim = fir::getBase(converter.genExprValue( -*Fortran::semantics::GetExpr(dim->v), stmtCtx)); +gangOperands.push_back(fir::getBase(converter.genExprValue( +*Fortran::semantics::GetExpr(dim->v), stmtCtx))); +gangArgTypes.push_back(mlir::acc::GangArgTypeAttr::get( +builder.getContext(), mlir::acc::GangArgType::Dim))
[Lldb-commits] [lldb] 8f40783 - [lldb][nfc] Mark function as const (#76974)
Author: Felipe de Azevedo Piovezan Date: 2024-01-04T16:30:49-03:00 New Revision: 8f40783944fcdd33a2ad134be0d26a671202fd85 URL: https://github.com/llvm/llvm-project/commit/8f40783944fcdd33a2ad134be0d26a671202fd85 DIFF: https://github.com/llvm/llvm-project/commit/8f40783944fcdd33a2ad134be0d26a671202fd85.diff LOG: [lldb][nfc] Mark function as const (#76974) This function has no mutable behavior Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 7c253553d57b48..b718f98340a70b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -48,7 +48,7 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { } std::optional -DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) { +DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) const { // Look for a DWARF unit offset (CU offset or local TU offset) as they are // both offsets into the .debug_info section. std::optional unit_offset = entry.getCUOffset(); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h index 7ce630a56137d1..cca0913c4124c9 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h @@ -79,7 +79,7 @@ class DebugNamesDWARFIndex : public DWARFIndex { std::unique_ptr m_debug_names_up; ManualDWARFIndex m_fallback; - std::optional ToDIERef(const DebugNames::Entry &entry); + std::optional ToDIERef(const DebugNames::Entry &entry) const; bool ProcessEntry(const DebugNames::Entry &entry, llvm::function_ref callback); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][nfc] Mark function as const (PR #76974)
https://github.com/felipepiovezan closed https://github.com/llvm/llvm-project/pull/76974 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [libcxx] [flang] [libc] [libcxxabi] [clang-tools-extra] [clang] [compiler-rt] Move nondiscard tests of ranges::contains() to the right place. (PR #76887)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/76887 >From 9b90c41bd209a49de85987529bd7286401b01ef2 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Wed, 3 Jan 2024 18:27:09 -0800 Subject: [PATCH 1/2] Move nondiscard tests of ranges::contains() to the right place. --- .../libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp | 3 --- .../test/libcxx/diagnostics/nodiscard_extensions.verify.cpp | 5 - .../diagnostics/ranges.nodiscard_extensions.compile.pass.cpp | 2 ++ .../diagnostics/ranges.nodiscard_extensions.verify.cpp | 4 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp index 641fcd9233bc2e..e9fab0c75a98e9 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp @@ -45,9 +45,6 @@ void test_algorithms() { #if TEST_STD_VER >= 17 std::clamp(2, 1, 3); std::clamp(2, 3, 1, std::greater()); -#endif -#if TEST_STD_VER >= 23 - std::ranges::contains(arr, arr + 1, 1); #endif std::count_if(std::begin(arr), std::end(arr), P()); std::count(std::begin(arr), std::end(arr), 1); diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp index 1e3f537f01ed6e..d7a26d99e52233 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp @@ -60,11 +60,6 @@ void test_algorithms() { std::clamp(2, 1, 3, std::greater()); #endif -#if TEST_STD_VER >= 23 - // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}} - std::ranges::contains(arr, arr + 1, 1); -#endif - // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}} std::count_if(std::begin(arr), std::end(arr), P()); diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp index 7e2d64b8c9b618..9dc9c46ad89090 100644 --- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp @@ -28,6 +28,8 @@ void test() { std::ranges::binary_search(range, 1); std::ranges::binary_search(iter, iter, 1); std::ranges::clamp(1, 2, 3); + std::ranges::contains(range, 1); + std::ranges::contains(iter, iter, 1); std::ranges::count_if(range, pred); std::ranges::count_if(iter, iter, pred); std::ranges::count(range, 1); diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp index f0a0e4889a7603..5e45ad086cbd08 100644 --- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp @@ -91,6 +91,10 @@ void test() { std::ranges::upper_bound(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} #if TEST_STD_VER >= 23 + std::ranges::contains(range, 1); + // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::contains(iter, iter, 1); + // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} std::ranges::fold_left(range, 0, std::plus()); // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} std::ranges::fold_left(iter, iter, 0, std::plus()); >From 8df3a07eb4d9a13d6300ce7e5ea6dba383bac379 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Thu, 4 Jan 2024 11:34:09 -0800 Subject: [PATCH 2/2] Add TEST_STD_VER condition --- .../diagnostics/ranges.nodiscard_extensions.compile.pass.cpp | 4 1 file changed, 4 insertions(+) diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp index 9dc9c46ad89090..19e07b83079c78 100644 --- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp @@ -15,6 +15,8 @@ #include +#include "test_macros.h" + void test() { int range[1]; int* iter = range; @@ -28,8 +30,10 @@ void test() { std::ranges::binary_search(range, 1); std::ranges::binary_search(iter, iter, 1); std::ranges::clamp(1, 2, 3); +#if TEST_STD_VER >= 23 std::ranges::contains(range, 1); std::ranges::contains(iter, iter, 1); +#endif std::ranges::count_if(range, pred); std::ranges::count_if(iter, iter, pred); std::ranges::count(range, 1);
[Lldb-commits] [lldb] [llvm] [libcxx] [flang] [libc] [libcxxabi] [clang-tools-extra] [clang] [compiler-rt] Move nondiscard tests of ranges::contains() to the right place. (PR #76887)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/76887 >From 9b90c41bd209a49de85987529bd7286401b01ef2 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Wed, 3 Jan 2024 18:27:09 -0800 Subject: [PATCH 1/2] Move nondiscard tests of ranges::contains() to the right place. --- .../libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp | 3 --- .../test/libcxx/diagnostics/nodiscard_extensions.verify.cpp | 5 - .../diagnostics/ranges.nodiscard_extensions.compile.pass.cpp | 2 ++ .../diagnostics/ranges.nodiscard_extensions.verify.cpp | 4 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp index 641fcd9233bc2e..e9fab0c75a98e9 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp @@ -45,9 +45,6 @@ void test_algorithms() { #if TEST_STD_VER >= 17 std::clamp(2, 1, 3); std::clamp(2, 3, 1, std::greater()); -#endif -#if TEST_STD_VER >= 23 - std::ranges::contains(arr, arr + 1, 1); #endif std::count_if(std::begin(arr), std::end(arr), P()); std::count(std::begin(arr), std::end(arr), 1); diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp index 1e3f537f01ed6e..d7a26d99e52233 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp @@ -60,11 +60,6 @@ void test_algorithms() { std::clamp(2, 1, 3, std::greater()); #endif -#if TEST_STD_VER >= 23 - // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}} - std::ranges::contains(arr, arr + 1, 1); -#endif - // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}} std::count_if(std::begin(arr), std::end(arr), P()); diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp index 7e2d64b8c9b618..9dc9c46ad89090 100644 --- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp @@ -28,6 +28,8 @@ void test() { std::ranges::binary_search(range, 1); std::ranges::binary_search(iter, iter, 1); std::ranges::clamp(1, 2, 3); + std::ranges::contains(range, 1); + std::ranges::contains(iter, iter, 1); std::ranges::count_if(range, pred); std::ranges::count_if(iter, iter, pred); std::ranges::count(range, 1); diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp index f0a0e4889a7603..5e45ad086cbd08 100644 --- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp @@ -91,6 +91,10 @@ void test() { std::ranges::upper_bound(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} #if TEST_STD_VER >= 23 + std::ranges::contains(range, 1); + // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::contains(iter, iter, 1); + // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} std::ranges::fold_left(range, 0, std::plus()); // expected-warning@-1{{ignoring return value of function declared with 'nodiscard' attribute}} std::ranges::fold_left(iter, iter, 0, std::plus()); >From 8df3a07eb4d9a13d6300ce7e5ea6dba383bac379 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Thu, 4 Jan 2024 11:34:09 -0800 Subject: [PATCH 2/2] Add TEST_STD_VER condition --- .../diagnostics/ranges.nodiscard_extensions.compile.pass.cpp | 4 1 file changed, 4 insertions(+) diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp index 9dc9c46ad89090..19e07b83079c78 100644 --- a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp @@ -15,6 +15,8 @@ #include +#include "test_macros.h" + void test() { int range[1]; int* iter = range; @@ -28,8 +30,10 @@ void test() { std::ranges::binary_search(range, 1); std::ranges::binary_search(iter, iter, 1); std::ranges::clamp(1, 2, 3); +#if TEST_STD_VER >= 23 std::ranges::contains(range, 1); std::ranges::contains(iter, iter, 1); +#endif std::ranges::count_if(range, pred); std::ranges::count_if(iter, iter, pred); std::ranges::count(range, 1);
[Lldb-commits] [lldb] [llvm] [libcxx] [flang] [libc] [libcxxabi] [clang-tools-extra] [clang] [compiler-rt] Move nondiscard tests of ranges::contains() to the right place. (PR #76887)
ZijunZhaoCCK wrote: > Maybe you need to update the status page, papers and release notes too: > https://libcxx.llvm.org/Status/Ranges.html > https://libcxx.llvm.org/ReleaseNotes/18.html Thank you for reminding! I will update those files after I finish `ranges::contains_subrange`. https://github.com/llvm/llvm-project/pull/76887 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [mlir] [libc] [clang] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/76882 >From ca7a96a40952fe94b916dacc52f07aa90bbdb1e7 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 3 Jan 2024 13:22:37 -0800 Subject: [PATCH 1/7] [builtin_object_size] Use classes instead of std::pair (NFC) The use of std::pair makes the values it holds opaque. Using classes improves this while keeping the POD aspect of a std::pair. As a nice addition, the "known" functions held inappropriately in the Visitor classes can now properly reside in the value classes. :-) --- llvm/include/llvm/Analysis/MemoryBuiltins.h | 192 +++ llvm/lib/Analysis/MemoryBuiltins.cpp | 314 +- .../Transforms/IPO/AttributorAttributes.cpp | 8 +- .../Instrumentation/AddressSanitizer.cpp | 12 +- .../Instrumentation/BoundsChecking.cpp| 8 +- 5 files changed, 299 insertions(+), 235 deletions(-) diff --git a/llvm/include/llvm/Analysis/MemoryBuiltins.h b/llvm/include/llvm/Analysis/MemoryBuiltins.h index 827b5081b2ce75..56faa32fb0b226 100644 --- a/llvm/include/llvm/Analysis/MemoryBuiltins.h +++ b/llvm/include/llvm/Analysis/MemoryBuiltins.h @@ -187,80 +187,146 @@ Value *lowerObjectSizeCall( const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed, SmallVectorImpl *InsertedInstructions = nullptr); -using SizeOffsetType = std::pair; +/// SizeOffsetType - A base template class for the object size visitors. Used +/// here as a self-documenting way to handle the values rather than using a +/// \p std::pair. +template struct SizeOffsetType { + T Size; + T Offset; + + bool knownSize() const; + bool knownOffset() const; + bool anyKnown() const; + bool bothKnown() const; +}; + +/// SizeOffsetType - Used by \p ObjectSizeOffsetVisitor, which works +/// with \p APInts. +template <> struct SizeOffsetType { + APInt Size; + APInt Offset; + + SizeOffsetType() = default; + SizeOffsetType(APInt Size, APInt Offset) : Size(Size), Offset(Offset) {} + + bool knownSize() const { return Size.getBitWidth() > 1; } + bool knownOffset() const { return Offset.getBitWidth() > 1; } + bool anyKnown() const { return knownSize() || knownOffset(); } + bool bothKnown() const { return knownSize() && knownOffset(); } + + bool operator==(const SizeOffsetType &RHS) { +return Size == RHS.Size && Offset == RHS.Offset; + } + bool operator!=(const SizeOffsetType &RHS) { return !(*this == RHS); } +}; +using SizeOffsetAPInt = SizeOffsetType; /// Evaluate the size and offset of an object pointed to by a Value* /// statically. Fails if size or offset are not known at compile time. class ObjectSizeOffsetVisitor - : public InstVisitor { +: public InstVisitor { const DataLayout &DL; const TargetLibraryInfo *TLI; ObjectSizeOpts Options; unsigned IntTyBits; APInt Zero; - SmallDenseMap SeenInsts; + SmallDenseMap SeenInsts; unsigned InstructionsVisited; APInt align(APInt Size, MaybeAlign Align); - SizeOffsetType unknown() { -return std::make_pair(APInt(), APInt()); - } + static SizeOffsetAPInt unknown; public: ObjectSizeOffsetVisitor(const DataLayout &DL, const TargetLibraryInfo *TLI, LLVMContext &Context, ObjectSizeOpts Options = {}); - SizeOffsetType compute(Value *V); - - static bool knownSize(const SizeOffsetType &SizeOffset) { -return SizeOffset.first.getBitWidth() > 1; - } - - static bool knownOffset(const SizeOffsetType &SizeOffset) { -return SizeOffset.second.getBitWidth() > 1; - } - - static bool bothKnown(const SizeOffsetType &SizeOffset) { -return knownSize(SizeOffset) && knownOffset(SizeOffset); - } + SizeOffsetAPInt compute(Value *V); // These are "private", except they can't actually be made private. Only // compute() should be used by external users. - SizeOffsetType visitAllocaInst(AllocaInst &I); - SizeOffsetType visitArgument(Argument &A); - SizeOffsetType visitCallBase(CallBase &CB); - SizeOffsetType visitConstantPointerNull(ConstantPointerNull&); - SizeOffsetType visitExtractElementInst(ExtractElementInst &I); - SizeOffsetType visitExtractValueInst(ExtractValueInst &I); - SizeOffsetType visitGlobalAlias(GlobalAlias &GA); - SizeOffsetType visitGlobalVariable(GlobalVariable &GV); - SizeOffsetType visitIntToPtrInst(IntToPtrInst&); - SizeOffsetType visitLoadInst(LoadInst &I); - SizeOffsetType visitPHINode(PHINode&); - SizeOffsetType visitSelectInst(SelectInst &I); - SizeOffsetType visitUndefValue(UndefValue&); - SizeOffsetType visitInstruction(Instruction &I); + SizeOffsetAPInt visitAllocaInst(AllocaInst &I); + SizeOffsetAPInt visitArgument(Argument &A); + SizeOffsetAPInt visitCallBase(CallBase &CB); + SizeOffsetAPInt visitConstantPointerNull(ConstantPointerNull &); + SizeOffsetAPInt visitExtractElementInst(ExtractElementInst &I); + SizeOffsetAPInt visitExtractValueInst(ExtractValueInst &I); + SizeOffsetAPInt visitGlobalAlias(GlobalAlias &GA); + SizeOffsetAPInt
[Lldb-commits] [lldb] [llvm] [mlir] [libc] [clang] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)
@@ -187,80 +187,124 @@ Value *lowerObjectSizeCall( const TargetLibraryInfo *TLI, AAResults *AA, bool MustSucceed, SmallVectorImpl *InsertedInstructions = nullptr); -using SizeOffsetType = std::pair; +/// SizeOffsetType - A base template class for the object size visitors. Used +/// here as a self-documenting way to handle the values rather than using a +/// \p std::pair. +template struct SizeOffsetType { + T Size; + T Offset; + + SizeOffsetType() = default; + SizeOffsetType(T Size, T Offset) : Size(Size), Offset(Offset) {} + virtual ~SizeOffsetType() = default; + + virtual bool knownSize() const = 0; + virtual bool knownOffset() const = 0; bwendling wrote: Good idea! :-) CRTP done. https://github.com/llvm/llvm-project/pull/76882 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
kevinfrei wrote: Sorry: nice long holiday break. So calling that library a "left over from a previous build" confuses me. What's the point of the `-DLLVM_DIR=/home/freik/src/rel-llvm/lib/cmake/llvm` argument to the second cmake config if not to instruct the build where to find stuff from the full LLVM build? If I delete that library, I can, indeed, reproduce the issue [now working on it] but that also leads me to believe that my repro still isn't actually doing what your configuration is. Because of that, I have no confidence that what I do to fix the issue is going to *actually* fix it 😞 https://github.com/llvm/llvm-project/pull/70996 ___ 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 #76683)
https://github.com/paolosevMSFT updated https://github.com/llvm/llvm-project/pull/76683 >From 739b26b03fd3661d1c22b975e241cbbe60ca6531 Mon Sep 17 00:00:00 2001 From: Paolo Severini Date: Mon, 1 Jan 2024 06:55:40 -0800 Subject: [PATCH 1/2] [lldb] Implement WebAssembly debugging Add support for source-level debugging of WebAssembly code. --- lldb/include/lldb/Target/Process.h| 40 +++ lldb/include/lldb/Target/UnwindWasm.h | 47 +++ lldb/source/Core/Value.cpp| 2 +- lldb/source/Expression/DWARFExpression.cpp| 42 +++ .../source/Interpreter/CommandInterpreter.cpp | 18 ++ lldb/source/Plugins/Process/CMakeLists.txt| 1 + .../Process/gdb-remote/ProcessGDBRemote.cpp | 7 +- .../Process/gdb-remote/ProcessGDBRemote.h | 2 + .../Plugins/Process/wasm/CMakeLists.txt | 15 + .../Plugins/Process/wasm/ProcessWasm.cpp | 296 ++ .../source/Plugins/Process/wasm/ProcessWasm.h | 135 .../Plugins/Process/wasm/ThreadWasm.cpp | 57 lldb/source/Plugins/Process/wasm/ThreadWasm.h | 47 +++ .../Plugins/Process/wasm/UnwindWasm.cpp | 79 + lldb/source/Plugins/Process/wasm/UnwindWasm.h | 58 .../Process/wasm/wasmRegisterContext.cpp | 103 ++ .../Process/wasm/wasmRegisterContext.h| 70 + lldb/source/Target/Platform.cpp | 8 + 18 files changed, 1025 insertions(+), 2 deletions(-) create mode 100644 lldb/include/lldb/Target/UnwindWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/CMakeLists.txt create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/ProcessWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/ThreadWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.cpp create mode 100644 lldb/source/Plugins/Process/wasm/UnwindWasm.h create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.cpp create mode 100644 lldb/source/Plugins/Process/wasm/wasmRegisterContext.h diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 24c599e044c78f..587ae085b479b7 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1548,6 +1548,46 @@ class Process : public std::enable_shared_from_this, virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error); + /// Read of memory from a process. + /// + /// This function will read memory from the current process's address space + /// and remove any traps that may have been inserted into the memory. + /// + /// This overloads accepts an ExecutionContext as additional argument. By + /// default, it calls the previous overload without the ExecutionContext + /// argument, but it can be overridden by Process subclasses. + /// + /// \param[in] vm_addr + /// A virtual load address that indicates where to start reading + /// memory from. + /// + /// \param[out] buf + /// A byte buffer that is at least \a size bytes long that + /// will receive the memory bytes. + /// + /// \param[in] size + /// The number of bytes to read. + /// + /// \param[in] exe_ctx + ///The current execution context, if available. + /// + /// \param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// + /// \return + /// The number of bytes that were actually read into \a buf. If + /// the returned number is greater than zero, yet less than \a + /// size, then this function will get called again with \a + /// vm_addr, \a buf, and \a size updated appropriately. Zero is + /// returned in the case of an error. + virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, +ExecutionContext *exe_ctx, Status &error) { +return ReadMemory(vm_addr, buf, size, error); + } + /// Read of memory from a process. /// /// This function has the same semantics of ReadMemory except that it diff --git a/lldb/include/lldb/Target/UnwindWasm.h b/lldb/include/lldb/Target/UnwindWasm.h new file mode 100644 index 00..3880f1dd62edf2 --- /dev/null +++ b/lldb/include/lldb/Target/UnwindWasm.h @@ -0,0 +1,47 @@ +//===-- UnwindWasm.h *- 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 LLDB_TARGET_UNWINDWASM_H +#define LLDB_TARGET_UNWINDWASM_H + +#includ
[Lldb-commits] [lld] [libc] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [flang] [libcxx] [openmp] [clang] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); jhuber6 wrote: Made a patch in https://github.com/llvm/llvm-project/pull/76992 and https://github.com/llvm/llvm-project/pull/76970 to make this actually work. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [clang] [lld] [clang-tools-extra] [compiler-rt] [flang] [lldb] [libcxx] [llvm] [openmp] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); + // Iterate through elf symbols + for (auto &sym : ELFObj->symbols()) { +if (auto name = sym.getName()) { + // Check if given current global is a profiling global based + // on name + if (name->equals(getInstrProfNamesVarName())) { +// Read in profiled function names +std::vector chars(sym.getSize() / sizeof(char), ' '); jhuber6 wrote: Why are we turning this into a vector of chars? Also isn't `sizeof(char)` pretty much always going to be `1`? https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [lldb] [openmp] [llvm] [clang-tools-extra] [lld] [flang] [clang] [libcxx] [libc] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); + // Iterate through elf symbols + for (auto &sym : ELFObj->symbols()) { +if (auto name = sym.getName()) { + // Check if given current global is a profiling global based + // on name + if (name->equals(getInstrProfNamesVarName())) { +// Read in profiled function names +std::vector chars(sym.getSize() / sizeof(char), ' '); +GlobalTy NamesGlobal(name->str(), sym.getSize(), chars.data()); +if (auto Err = readGlobalFromDevice(Device, Image, NamesGlobal)) + return Err; +std::string names(chars.begin(), chars.end()); +profdata.names = std::move(names); + } else if (name->starts_with(getInstrProfCountersVarPrefix())) { +// Read global variable profiling counts +std::vector counts(sym.getSize() / sizeof(int64_t), 0); +GlobalTy CountGlobal(name->str(), sym.getSize(), counts.data()); +if (auto Err = readGlobalFromDevice(Device, Image, CountGlobal)) + return Err; +profdata.counts.push_back(std::move(counts)); + } else if (name->starts_with(getInstrProfDataVarPrefix())) { +// Read profiling data for this global variable +__llvm_profile_data data{}; +GlobalTy DataGlobal(name->str(), sym.getSize(), &data); +if (auto Err = readGlobalFromDevice(Device, Image, DataGlobal)) + return Err; +profdata.data.push_back(std::move(data)); + } +} + } + return profdata; +} jhuber6 wrote: LLVM style for everything here. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [clang] [clang-tools-extra] [flang] [llvm] [libcxx] [lld] [lldb] [libc] [openmp] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -58,6 +60,22 @@ class GlobalTy { void setPtr(void *P) { Ptr = P; } }; +typedef void *IntPtrT; jhuber6 wrote: What's the utility of this? https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [clang-tools-extra] [openmp] [flang] [libc] [libcxx] [llvm] [lldb] [compiler-rt] [clang] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -58,6 +60,22 @@ class GlobalTy { void setPtr(void *P) { Ptr = P; } }; +typedef void *IntPtrT; +struct __llvm_profile_data { +#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) Type Name; +#include "llvm/ProfileData/InstrProfData.inc" +}; + +/// PGO profiling data extracted from a GPU device +struct GPUProfGlobals { + std::string names; + std::vector> counts; + std::vector<__llvm_profile_data> data; + Triple targetTriple; + jhuber6 wrote: These should probably use LLVM structs. E.g. `StringRef` is the name is a constant string with stable storage and `SmallVector`. I'd really appreciate some descriptions of how this is supposed to look and how it interacts with the existing profile data. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [libcxx] [clang-tools-extra] [compiler-rt] [clang] [flang] [llvm] [libc] [openmp] [lldb] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; jhuber6 wrote: ```suggestion GPUProfGlobals ProfData; ``` LLVM style. Also not a fan of the name. Maybe `DeviceProfileData` or something. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [openmp] [compiler-rt] [libcxx] [clang-tools-extra] [lld] [llvm] [clang] [flang] [lldb] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); + // Iterate through elf symbols + for (auto &sym : ELFObj->symbols()) { +if (auto name = sym.getName()) { + // Check if given current global is a profiling global based + // on name + if (name->equals(getInstrProfNamesVarName())) { +// Read in profiled function names +std::vector chars(sym.getSize() / sizeof(char), ' '); +GlobalTy NamesGlobal(name->str(), sym.getSize(), chars.data()); +if (auto Err = readGlobalFromDevice(Device, Image, NamesGlobal)) + return Err; +std::string names(chars.begin(), chars.end()); +profdata.names = std::move(names); + } else if (name->starts_with(getInstrProfCountersVarPrefix())) { jhuber6 wrote: Are the `getInstrProfCountersVarPrefix` function preexisting? I don't see them defined in this patch set. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [lldb] [clang-tools-extra] [compiler-rt] [flang] [llvm] [clang] [libcxx] [openmp] [libc] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); + // Iterate through elf symbols + for (auto &sym : ELFObj->symbols()) { +if (auto name = sym.getName()) { + // Check if given current global is a profiling global based + // on name + if (name->equals(getInstrProfNamesVarName())) { +// Read in profiled function names +std::vector chars(sym.getSize() / sizeof(char), ' '); +GlobalTy NamesGlobal(name->str(), sym.getSize(), chars.data()); jhuber6 wrote: Okay, we're reading a string back from the device? What's the purpose of that? Also, just so you know, the ELF will only contain the correct size if it's emitted as an array. E.g. ``` const char a[] = "a"; // strlen("a") + 1 in ELF const char *b = "b"; // sizeof(char *) in ELF ``` https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [openmp] [lld] [clang-tools-extra] [libcxx] [llvm] [flang] [libc] [clang] [lldb] [compiler-rt] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); + // Iterate through elf symbols + for (auto &sym : ELFObj->symbols()) { +if (auto name = sym.getName()) { jhuber6 wrote: This is incorrect. If this returns an error it will exit the if, call the deconstructor, and then crash the program because it was not handled. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lld] [libc] [clang-tools-extra] [polly] [compiler-rt] [llvm] [clang] [flang] [libcxxabi] [mlir] [lldb] Make clang report invalid target versions. (PR #75373)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/75373 >From 74f256d8a77ee2ba8e0d5bbb6519aa2729cf94d5 Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Wed, 13 Dec 2023 20:07:45 + Subject: [PATCH 01/13] Make clang report garbage target versions. Clang always silently ignores garbage target versions and this makes debug harder. So clang will report when target versions are invalid. --- llvm/lib/TargetParser/Triple.cpp | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index c5e9ad43d22588..335253194d1cf8 100644 --- a/llvm/lib/TargetParser/Triple.cpp +++ b/llvm/lib/TargetParser/Triple.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/SwapByteOrder.h" #include "llvm/Support/VersionTuple.h" #include "llvm/TargetParser/ARMTargetParser.h" @@ -1199,7 +1200,11 @@ StringRef Triple::getOSAndEnvironmentName() const { static VersionTuple parseVersionFromName(StringRef Name) { VersionTuple Version; - Version.tryParse(Name); + if (Version.tryParse(Name)) { +errs() << "The input is "<< Name << " and it is invalid. Should pass an "<< +"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n"; +exit(1); + } return Version.withoutBuild(); } >From 0d159b2a9b76e233e020ac0aef15b49b03f4d86c Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Wed, 13 Dec 2023 20:23:54 + Subject: [PATCH 02/13] rephrase --- llvm/lib/TargetParser/Triple.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index 335253194d1cf8..713ca447403d50 100644 --- a/llvm/lib/TargetParser/Triple.cpp +++ b/llvm/lib/TargetParser/Triple.cpp @@ -1201,8 +1201,7 @@ StringRef Triple::getOSAndEnvironmentName() const { static VersionTuple parseVersionFromName(StringRef Name) { VersionTuple Version; if (Version.tryParse(Name)) { -errs() << "The input is "<< Name << " and it is invalid. Should pass an "<< -"integer or integer combination! e.g. 2, 9.5 or 3.4.5\n"; +errs() << "version "<< Name << " is invalid\n"; exit(1); } return Version.withoutBuild(); >From b2dda9ce95804783c59aa1ca4e81a7941aae805d Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Wed, 13 Dec 2023 20:07:45 + Subject: [PATCH 03/13] Make clang report garbage target versions. Clang always silently ignores garbage target versions and this makes debug harder. So clang will report when target versions are invalid. --- clang/lib/Basic/Targets/OSTargets.h | 5 + llvm/include/llvm/TargetParser/Triple.h | 4 llvm/lib/TargetParser/Triple.cpp| 8 3 files changed, 17 insertions(+) diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 342af4bbc42b7b..bc28066019971c 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -323,6 +323,11 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo { // This historical but ambiguous name for the minSdkVersion macro. Keep // defined for compatibility. Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__"); + } else { +llvm::errs() << "version "<< Triple.getVersionName() << +" in triple " << Triple.getArchName() << "-" << Triple.getVendorName() +<< "-" << Triple.getOSAndEnvironmentName() << " is invalid\n"; +exit(1); } } else { Builder.defineMacro("__gnu_linux__"); diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index 47904621c0967f..05df1c489ad06e 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -434,6 +434,10 @@ class Triple { /// string (separated by a '-' if the environment component is present). StringRef getOSAndEnvironmentName() const; + /// Get the version component of the environment component as a single + /// string (the version after the environment). + StringRef getVersionName() const; + /// @} /// @name Convenience Predicates /// @{ diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index 49bc24ffbfae6c..db4ba7100781bc 100644 --- a/llvm/lib/TargetParser/Triple.cpp +++ b/llvm/lib/TargetParser/Triple.cpp @@ -1199,6 +1199,14 @@ StringRef Triple::getOSAndEnvironmentName() const { return Tmp.split('-').second; // Strip second component } +StringRef Triple::getVersionName() const { + StringRef VersionName = getEnvironmentName(); + StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment()); + if (VersionName.startswith(EnvironmentTypeName)) +return VersionName.substr(EnvironmentTypeName.size()); + return VersionName; +} + static
[Lldb-commits] [clang] [flang] [lldb] [llvm] [clang] Split out DebugOptions.def into its own top-level options group. (PR #75530)
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 b047c9116432375586ddf7f01bf272f99d9a005c 8040f300b57fe0706ee0d5b81678ee9b7927c796 -- clang/include/clang/Basic/DebugOptions.h clang/lib/Basic/DebugOptions.cpp clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Basic/TargetInfo.h clang/include/clang/CodeGen/BackendUtil.h clang/include/clang/CodeGen/ModuleBuilder.h clang/include/clang/Driver/ToolChain.h clang/include/clang/Frontend/CompilerInstance.h clang/include/clang/Frontend/CompilerInvocation.h clang/lib/Basic/CodeGenOptions.cpp clang/lib/CodeGen/BackendConsumer.h clang/lib/CodeGen/BackendUtil.cpp clang/lib/CodeGen/CGBlocks.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CGVTables.cpp clang/lib/CodeGen/CodeGenAction.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ModuleBuilder.cpp clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.h clang/lib/Driver/ToolChains/Cuda.cpp clang/lib/Driver/ToolChains/Cuda.h clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/HIPSPV.cpp clang/lib/Driver/ToolChains/HIPSPV.h clang/lib/Driver/ToolChains/MSVC.h clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/FrontendAction.cpp clang/lib/Frontend/Rewrite/FrontendActions.cpp clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp clang/lib/Interpreter/DeviceOffload.cpp clang/lib/Interpreter/Interpreter.cpp clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp clang/lib/Tooling/Tooling.cpp clang/tools/clang-import-test/clang-import-test.cpp clang/unittests/CodeGen/TestCompiler.h clang/unittests/Frontend/CodeGenActionTest.cpp clang/unittests/Frontend/CompilerInvocationTest.cpp flang/include/flang/Tools/CLOptions.inc flang/include/flang/Tools/CrossToolHelpers.h flang/lib/Frontend/CompilerInvocation.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp llvm/include/llvm/Frontend/Debug/Options.h `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h index fb662e88a7..586c0fc215 100644 --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -233,20 +233,20 @@ public: /// @{ // Note: These need to be pulled in manually. Otherwise, they get hidden by // the mutable getters with the same names. - using CompilerInvocationBase::getLangOpts; - using CompilerInvocationBase::getTargetOpts; - using CompilerInvocationBase::getDiagnosticOpts; - using CompilerInvocationBase::getHeaderSearchOpts; - using CompilerInvocationBase::getPreprocessorOpts; using CompilerInvocationBase::getAnalyzerOpts; - using CompilerInvocationBase::getMigratorOpts; using CompilerInvocationBase::getAPINotesOpts; using CompilerInvocationBase::getCodeGenOpts; using CompilerInvocationBase::getDebugOpts; + using CompilerInvocationBase::getDependencyOutputOpts; + using CompilerInvocationBase::getDiagnosticOpts; using CompilerInvocationBase::getFileSystemOpts; using CompilerInvocationBase::getFrontendOpts; - using CompilerInvocationBase::getDependencyOutputOpts; + using CompilerInvocationBase::getHeaderSearchOpts; + using CompilerInvocationBase::getLangOpts; + using CompilerInvocationBase::getMigratorOpts; + using CompilerInvocationBase::getPreprocessorOpts; using CompilerInvocationBase::getPreprocessorOutputOpts; + using CompilerInvocationBase::getTargetOpts; /// @} /// Mutable getters. `` https://github.com/llvm/llvm-project/pull/75530 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [flang] [llvm] [lldb] [libc] [libcxx] [clang-tools-extra] [clang] [libcxxabi] [lld] [mlir] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/66963 >From 647f5fe641b30c874bab770fced9fcec9b601161 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Wed, 13 Sep 2023 14:26:01 -0700 Subject: [PATCH 1/7] [libc++] Implement ranges::contains_subrange --- libcxx/include/CMakeLists.txt | 1 + .../__algorithm/ranges_contains_subrange.h| 145 + libcxx/include/algorithm | 14 + ...obust_against_copying_projections.pass.cpp | 2 + .../ranges.contains_subrange.pass.cpp | 293 ++ .../niebloid.compile.pass.cpp | 1 + 6 files changed, 456 insertions(+) create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h create mode 100644 libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 0fe3ab44d2466e..dd3ff541fbc7ba 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -110,6 +110,7 @@ set(files __algorithm/ranges_binary_search.h __algorithm/ranges_clamp.h __algorithm/ranges_contains.h + __algorithm/ranges_contains_subrange.h __algorithm/ranges_copy.h __algorithm/ranges_copy_backward.h __algorithm/ranges_copy_if.h diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h b/libcxx/include/__algorithm/ranges_contains_subrange.h new file mode 100644 index 00..16de6c29cb2a1a --- /dev/null +++ b/libcxx/include/__algorithm/ranges_contains_subrange.h @@ -0,0 +1,145 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H +#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H + +#include <__algorithm/ranges_starts_with.h> +#include <__config> +#include <__functional/identity.h> +#include <__functional/ranges_operations.h> +#include <__functional/reference_wrapper.h> +#include <__iterator/concepts.h> +#include <__iterator/distance.h> +#include <__iterator/indirectly_comparable.h> +#include <__iterator/projected.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 23 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace ranges { +namespace __contains_subrange { +struct __fn { + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred, +class _Proj1, +class _Proj2, +class _Offset> + static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred& __pred, + _Proj1& __proj1, + _Proj2& __proj2, + _Offset __offset) { +if (__offset < 0) + return false; +else { + for (; __offset >= 0; __offset--, __first1++) { +auto result = ranges::starts_with( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +std::ref(__pred), +std::ref(__proj1), +std::ref(__proj2)); +if (result) + return true; + } + return false; +} + } + + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred = ranges::equal_to, +class _Proj1 = identity, +class _Proj2 = identity> +requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred __pred = {}, + _Proj1 __proj1 = {}, + _Proj2 __proj2 = {}) const { +auto __n1 = ranges::distance(__first1, __last1); +auto __n2 = ranges::distance(__first2, __last2); +auto __offset = __n1 - __n2; + +return __contains_subrange_fn_impl( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +__pred, +__proj1, +__proj2, +std::move(__offset)); + } + + template +requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { +auto __n1 = 0; +auto __n2 = 0; + +if conste
[Lldb-commits] [compiler-rt] [clang] [flang] [clang-tools-extra] [llvm] [libcxxabi] [libcxx] [lldb] [libc] Move nondiscard tests of ranges::contains() to the right place. (PR #76887)
https://github.com/ZijunZhaoCCK closed https://github.com/llvm/llvm-project/pull/76887 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lld] [mlir] [libc] [llvm] [clang] [clang-tools-extra] [compiler-rt] [libcxxabi] [flang] [libcxx] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/66963 >From 647f5fe641b30c874bab770fced9fcec9b601161 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Wed, 13 Sep 2023 14:26:01 -0700 Subject: [PATCH 1/7] [libc++] Implement ranges::contains_subrange --- libcxx/include/CMakeLists.txt | 1 + .../__algorithm/ranges_contains_subrange.h| 145 + libcxx/include/algorithm | 14 + ...obust_against_copying_projections.pass.cpp | 2 + .../ranges.contains_subrange.pass.cpp | 293 ++ .../niebloid.compile.pass.cpp | 1 + 6 files changed, 456 insertions(+) create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h create mode 100644 libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 0fe3ab44d2466e..dd3ff541fbc7ba 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -110,6 +110,7 @@ set(files __algorithm/ranges_binary_search.h __algorithm/ranges_clamp.h __algorithm/ranges_contains.h + __algorithm/ranges_contains_subrange.h __algorithm/ranges_copy.h __algorithm/ranges_copy_backward.h __algorithm/ranges_copy_if.h diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h b/libcxx/include/__algorithm/ranges_contains_subrange.h new file mode 100644 index 00..16de6c29cb2a1a --- /dev/null +++ b/libcxx/include/__algorithm/ranges_contains_subrange.h @@ -0,0 +1,145 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H +#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H + +#include <__algorithm/ranges_starts_with.h> +#include <__config> +#include <__functional/identity.h> +#include <__functional/ranges_operations.h> +#include <__functional/reference_wrapper.h> +#include <__iterator/concepts.h> +#include <__iterator/distance.h> +#include <__iterator/indirectly_comparable.h> +#include <__iterator/projected.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 23 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace ranges { +namespace __contains_subrange { +struct __fn { + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred, +class _Proj1, +class _Proj2, +class _Offset> + static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred& __pred, + _Proj1& __proj1, + _Proj2& __proj2, + _Offset __offset) { +if (__offset < 0) + return false; +else { + for (; __offset >= 0; __offset--, __first1++) { +auto result = ranges::starts_with( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +std::ref(__pred), +std::ref(__proj1), +std::ref(__proj2)); +if (result) + return true; + } + return false; +} + } + + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred = ranges::equal_to, +class _Proj1 = identity, +class _Proj2 = identity> +requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred __pred = {}, + _Proj1 __proj1 = {}, + _Proj2 __proj2 = {}) const { +auto __n1 = ranges::distance(__first1, __last1); +auto __n2 = ranges::distance(__first2, __last2); +auto __offset = __n1 - __n2; + +return __contains_subrange_fn_impl( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +__pred, +__proj1, +__proj2, +std::move(__offset)); + } + + template +requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { +auto __n1 = 0; +auto __n2 = 0; + +if conste
[Lldb-commits] [lldb] [lldb][DWARFIndex][nfc] Factor out fully qualified name query (PR #76977)
clayborg wrote: LGTM https://github.com/llvm/llvm-project/pull/76977 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/77026 When generating a `display_value` for a variable the current approach calls `SBValue::GetValue()` and `SBValue::GetSummary()` to generate a `display_value` for the `SBValue`. However, there are cases where both of these return an empty string and the fallback is to print a pointer and type name instead (e.g. `FooBarType @ 0x00321`). For swift types, lldb includes a langauge runtime plugin that can generate a description of the object but this is only used with `SBValue::GetDescription()`. For example: ``` $ lldb swift-binary ... stop at breakpoint ... lldb> script >>> event = lldb.frame.GetValueForVariablePath("event") >>> print("Value", event.GetValue()) Value None >>> print("Summary", event.GetSummary()) Summary None >>> print("Description", event) # __str__ calls SBValue::GetDescription() Description (main.Event) event = (name = "Greetings", time = 2024-01-04 23:38:06 UTC) ``` With this change, if GetValue and GetSummary return empty then we try `SBValue::GetDescription()` as a fallback before using the previous logic of printing ` @ `. >From 7656af47e058aa7101504cb31aaa067178110351 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Thu, 4 Jan 2024 15:42:35 -0800 Subject: [PATCH] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. When generating a `display_value` for a variable the current approach calls `SBValue::GetValue()` and `SBValue::GetSummary()` to generate a `display_value` for the `SBValue`. However, there are cases where both of these return an empty string and the fallback is to print a pointer and type name instead (e.g. "FooBarType @ 0x00321"). For swift types, lldb includes a langauge runtime plugin that can generate a user description of the object but this is only used with `SBValue::GetDescription()`. For example: ``` $ lldb swift-binary ... stop at breakpoint ... lldb> script >>> event = lldb.frame.GetValueForVariablePath("event") >>> print("Value", event.GetValue()) Value None >>> print("Summary", event.GetSummary()) Summary None >>> print("Description", event) Description (main.Event) event = (name = "Greetings", time = 2024-01-04 23:38:06 UTC) ``` With this change, if GetValue and GetSummary return empty then we try `SBValue::GetDescription()` as a fallback before using the previous logic of printing " @ ". --- lldb/tools/lldb-dap/JSONUtils.cpp | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index df17ac9d849176..f8ac53ef809e6e 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -1042,10 +1042,14 @@ VariableDescription::VariableDescription(lldb::SBValue v, bool format_hex, os_display_value << " " << *effective_summary; } else if (effective_summary) { os_display_value << *effective_summary; - - // As last resort, we print its type and address if available. } else { - if (!raw_display_type_name.empty()) { + lldb::SBStream description; + // Try letting lldb generate a description. + if (v.GetDescription(description) && description.GetSize()) { +os_display_value << description.GetData(); + +// As last resort, we print its type and address if available. + } else if (!raw_display_type_name.empty()) { os_display_value << raw_display_type_name; lldb::addr_t address = v.GetLoadAddress(); if (address != LLDB_INVALID_ADDRESS) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: John Harrison (ashgti) Changes When generating a `display_value` for a variable the current approach calls `SBValue::GetValue()` and `SBValue::GetSummary()` to generate a `display_value` for the `SBValue`. However, there are cases where both of these return an empty string and the fallback is to print a pointer and type name instead (e.g. `FooBarType @ 0x00321`). For swift types, lldb includes a langauge runtime plugin that can generate a description of the object but this is only used with `SBValue::GetDescription()`. For example: ``` $ lldb swift-binary ... stop at breakpoint ... lldb> script >>> event = lldb.frame.GetValueForVariablePath("event") >>> print("Value", event.GetValue()) Value None >>> print("Summary", event.GetSummary()) Summary None >>> print("Description", event) # __str__ calls SBValue::GetDescription() Description (main.Event) event = (name = "Greetings", time = 2024-01-04 23:38:06 UTC) ``` With this change, if GetValue and GetSummary return empty then we try `SBValue::GetDescription()` as a fallback before using the previous logic of printing `@ `. --- Full diff: https://github.com/llvm/llvm-project/pull/77026.diff 1 Files Affected: - (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+7-3) ``diff diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index df17ac9d849176..f8ac53ef809e6e 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -1042,10 +1042,14 @@ VariableDescription::VariableDescription(lldb::SBValue v, bool format_hex, os_display_value << " " << *effective_summary; } else if (effective_summary) { os_display_value << *effective_summary; - - // As last resort, we print its type and address if available. } else { - if (!raw_display_type_name.empty()) { + lldb::SBStream description; + // Try letting lldb generate a description. + if (v.GetDescription(description) && description.GetSize()) { +os_display_value << description.GetData(); + +// As last resort, we print its type and address if available. + } else if (!raw_display_type_name.empty()) { os_display_value << raw_display_type_name; lldb::addr_t address = v.GetLoadAddress(); if (address != LLDB_INVALID_ADDRESS) `` https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix expressions that involve nested structs/classes/unions. (PR #77029)
https://github.com/clayborg created https://github.com/llvm/llvm-project/pull/77029 The LLDB expression parser relies on using the external AST source support in LLDB. This allows us to find a class at the root namespace level, but it wouldn't allow us to find nested classes all of the time. When LLDB finds a class via this mechanism, it would be able to complete this class when needed, but during completion, we wouldn't populate nested types within this class which would prevent us from finding contained types when needed as clang would expect them to be present if a class was completed. When we parse a type for a class, struct or union, we make a forward declaration to the class which can be completed. Now when the class is completed, we also add any contained types to the class' declaration context which now allows these types to be found. If we have a struct that contains a struct, we will add the forward declaration of the contained structure which can be c ompleted later. Having this forward declaration makes it possible for LLDB to find everything it needs now. This should fix an existing issue: https://github.com/llvm/llvm-project/issues/53904 Previously, contained types could be parsed by accident and allow expression to complete successfully. Other times we would have to run an expression multiple times because our old type lookup from our expressions would cau se a type to be parsed, but not used in the current expression, but this would have parsed a type into the containing decl context and the expression might succeed if it is run again. >From ceb740dcce0ac870b1ef145d41670385a1d24f1c Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Thu, 4 Jan 2024 16:17:44 -0800 Subject: [PATCH] Fix expressions that involve nested structs/classes/unions. The LLDB expression parser relies on using the external AST source support in LLDB. This allows us to find a class at the root namespace level, but it wouldn't allow us to find nested classes all of the time. When LLDB finds a class via this mechanism, it would be able to complete this class when needed, but during completion, we wouldn't populate nested types within this class which would prevent us from finding contained types when needed as clang would expect them to be present if a class was completed. When we parse a type for a class, struct or union, we make a forward declaration to the class which can be completed. Now when the class is completed, we also add any contained types to the class' declaration context which now allows these types to be found. If we have a struct that contains a struct, we will add the forward declaration of the contained structure which can be c ompleted later. Having this forward declaration makes it possible for LLDB to find everything it needs now. This should fix an existing issue: https://github.com/llvm/llvm-project/issues/53904 Previously, contained types could be parsed by accident and allow expression to complete successfully. Other times we would have to run an expression multiple times because our old type lookup from our expressions would cau se a type to be parsed, but not used in the current expression, but this would have parsed a type into the containing decl context and the expression might succeed if it is run again. --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 44 +++- .../SymbolFile/DWARF/DWARFASTParserClang.h| 1 + .../API/commands/expression/nested/Makefile | 3 + .../nested/TestNestedExpressions.py | 70 +++ .../API/commands/expression/nested/main.cpp | 35 ++ 5 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/commands/expression/nested/Makefile create mode 100644 lldb/test/API/commands/expression/nested/TestNestedExpressions.py create mode 100644 lldb/test/API/commands/expression/nested/main.cpp diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 3e08f2550081f2..233de2f1ac58cc 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2150,6 +2150,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, SymbolFileDWARF *dwarf = die.GetDWARF(); ClangASTImporter::LayoutInfo layout_info; + std::vector contained_type_dies; if (die.HasChildren()) { const bool type_is_objc_object_or_interface = @@ -2175,7 +2176,8 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, DelayedPropertyList delayed_properties; ParseChildMembers(die, clang_type, bases, member_function_dies, - delayed_properties, default_accessibility, layout_info); + contained_type_dies, delayed_properties, + default_accessibility, layout_info); // Now parse any methods if there were any... for (
[Lldb-commits] [lldb] Fix expressions that involve nested structs/classes/unions. (PR #77029)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Greg Clayton (clayborg) Changes The LLDB expression parser relies on using the external AST source support in LLDB. This allows us to find a class at the root namespace level, but it wouldn't allow us to find nested classes all of the time. When LLDB finds a class via this mechanism, it would be able to complete this class when needed, but during completion, we wouldn't populate nested types within this class which would prevent us from finding contained types when needed as clang would expect them to be present if a class was completed. When we parse a type for a class, struct or union, we make a forward declaration to the class which can be completed. Now when the class is completed, we also add any contained types to the class' declaration context which now allows these types to be found. If we have a struct that contains a struct, we will add the forward declaration of the contained structure which can be c ompleted later. Having this forward declaration makes it possible for LLDB to find everything it needs now. This should fix an existing issue: https://github.com/llvm/llvm-project/issues/53904 Previously, contained types could be parsed by accident and allow expression to complete successfully. Other times we would have to run an expression multiple times because our old type lookup from our expressions would cau se a type to be parsed, but not used in the current expression, but this would have parsed a type into the containing decl context and the expression might succeed if it is run again. --- Full diff: https://github.com/llvm/llvm-project/pull/77029.diff 5 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+42-2) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h (+1) - (added) lldb/test/API/commands/expression/nested/Makefile (+3) - (added) lldb/test/API/commands/expression/nested/TestNestedExpressions.py (+70) - (added) lldb/test/API/commands/expression/nested/main.cpp (+35) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 3e08f2550081f2..233de2f1ac58cc 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2150,6 +2150,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, SymbolFileDWARF *dwarf = die.GetDWARF(); ClangASTImporter::LayoutInfo layout_info; + std::vector contained_type_dies; if (die.HasChildren()) { const bool type_is_objc_object_or_interface = @@ -2175,7 +2176,8 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, DelayedPropertyList delayed_properties; ParseChildMembers(die, clang_type, bases, member_function_dies, - delayed_properties, default_accessibility, layout_info); + contained_type_dies, delayed_properties, + default_accessibility, layout_info); // Now parse any methods if there were any... for (const DWARFDIE &die : member_function_dies) @@ -2231,6 +2233,13 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, if (record_decl) GetClangASTImporter().SetRecordLayout(record_decl, layout_info); } + // Now parse all contained types inside of the class. We make forward + // declarations to all classes, but we need the CXXRecordDecl to have decls + // for all contained types because we don't get asked for them via the + // external AST support. + for (const DWARFDIE &die : contained_type_dies) +dwarf->ResolveType(die); + return (bool)clang_type; } @@ -2260,7 +2269,7 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, // Disable external storage for this type so we don't get anymore // clang::ExternalASTSource queries for this type. - m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), false); + //m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), false); if (!die) return false; @@ -3106,10 +3115,39 @@ void DWARFASTParserClang::ParseSingleMember( std::make_pair(field_decl, field_bit_offset)); } +static bool IsTypeTag(dw_tag_t tag) { + switch (tag) { +case DW_TAG_typedef: +case DW_TAG_base_type: +case DW_TAG_pointer_type: +case DW_TAG_reference_type: +case DW_TAG_rvalue_reference_type: +case DW_TAG_const_type: +case DW_TAG_restrict_type: +case DW_TAG_volatile_type: +case DW_TAG_atomic_type: +case DW_TAG_unspecified_type: +case DW_TAG_structure_type: +case DW_TAG_union_type: +case DW_TAG_class_type: +case DW_TAG_enumeration_type: +case DW_TAG_inlined_subroutine: +case DW_TAG_subprogram: +case DW_TAG_subroutine_type: +case DW_TAG_array_type: +case DW_TAG_ptr_to_member_type: + return true; +default:
[Lldb-commits] [lldb] Fix expressions that involve nested structs/classes/unions. (PR #77029)
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 e68a0320a1592bf408ac6458efa2d1c548cfed7a...ceb740dcce0ac870b1ef145d41670385a1d24f1c lldb/test/API/commands/expression/nested/TestNestedExpressions.py `` View the diff from darker here. ``diff --- TestNestedExpressions.py2024-01-05 00:17:44.00 + +++ TestNestedExpressions.py2024-01-05 00:21:49.644060 + @@ -7,64 +7,65 @@ from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil class NestedExpressions(TestBase): - def test_enum_in_nested_structs(self): """ -Test expressions that references an enumeration in nested structs. +Test expressions that references an enumeration in nested structs. """ self.build() exe_path = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe_path) self.assertTrue(target, "Target: %s is not valid." % (exe_path)) -self.expect_expr("A::B::C::EnumType::Eleven", - result_type="A::B::C::EnumType", - result_value="Eleven") +self.expect_expr( +"A::B::C::EnumType::Eleven", +result_type="A::B::C::EnumType", +result_value="Eleven", +) def test_struct_in_nested_structs(self): """ -Test expressions that references a struct in nested structs. +Test expressions that references a struct in nested structs. """ self.build() exe_path = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe_path) self.assertTrue(target, "Target: %s is not valid." % (exe_path)) self.expect_expr("sizeof(A::B::C)", result_value="1") self.expect_expr("sizeof(A::B)", result_value="2") def test_static_in_nested_structs(self): """ -Test expressions that references a static variable in nested structs. +Test expressions that references a static variable in nested structs. """ self.build() (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Stop here to evaluate expressions", lldb.SBFileSpec("main.cpp") ) -self.expect_expr("A::B::C::enum_static", - result_type="A::B::C::EnumType", - result_value="Eleven") +self.expect_expr( +"A::B::C::enum_static", +result_type="A::B::C::EnumType", +result_value="Eleven", +) def test_enum_in_nested_namespaces(self): """ -Test expressions that references an enumeration in nested namespaces. +Test expressions that references an enumeration in nested namespaces. """ self.build() exe_path = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe_path) self.assertTrue(target, "Target: %s is not valid." % (exe_path)) -self.expect_expr("a::b::c::Color::Blue", - result_type="a::b::c::Color", - result_value="Blue") +self.expect_expr( +"a::b::c::Color::Blue", result_type="a::b::c::Color", result_value="Blue" +) def test_static_in_nested_namespaces(self): """ -Test expressions that references an enumeration in nested namespaces. +Test expressions that references an enumeration in nested namespaces. """ self.build() (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, "Stop here to evaluate expressions", lldb.SBFileSpec("main.cpp") ) -self.expect_expr("a::b::c::d", - result_type="int", - result_value="12") +self.expect_expr("a::b::c::d", result_type="int", result_value="12") `` https://github.com/llvm/llvm-project/pull/77029 ___ 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)
clayborg wrote: https://github.com/llvm/llvm-project/pull/77029 is a slightly modified version of this patch where it parses the types after the struct/union/class is created. 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] Fix expressions that involve nested structs/classes/unions. (PR #77029)
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 e68a0320a1592bf408ac6458efa2d1c548cfed7a ceb740dcce0ac870b1ef145d41670385a1d24f1c -- lldb/test/API/commands/expression/nested/main.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 233de2f1ac..4eaeb54b9e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2240,7 +2240,6 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, for (const DWARFDIE &die : contained_type_dies) dwarf->ResolveType(die); - return (bool)clang_type; } @@ -2269,7 +2268,7 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die, // Disable external storage for this type so we don't get anymore // clang::ExternalASTSource queries for this type. - //m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), false); + // m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), false); if (!die) return false; @@ -3117,28 +3116,28 @@ void DWARFASTParserClang::ParseSingleMember( static bool IsTypeTag(dw_tag_t tag) { switch (tag) { -case DW_TAG_typedef: -case DW_TAG_base_type: -case DW_TAG_pointer_type: -case DW_TAG_reference_type: -case DW_TAG_rvalue_reference_type: -case DW_TAG_const_type: -case DW_TAG_restrict_type: -case DW_TAG_volatile_type: -case DW_TAG_atomic_type: -case DW_TAG_unspecified_type: -case DW_TAG_structure_type: -case DW_TAG_union_type: -case DW_TAG_class_type: -case DW_TAG_enumeration_type: -case DW_TAG_inlined_subroutine: -case DW_TAG_subprogram: -case DW_TAG_subroutine_type: -case DW_TAG_array_type: -case DW_TAG_ptr_to_member_type: - return true; -default: - break; + case DW_TAG_typedef: + case DW_TAG_base_type: + case DW_TAG_pointer_type: + case DW_TAG_reference_type: + case DW_TAG_rvalue_reference_type: + case DW_TAG_const_type: + case DW_TAG_restrict_type: + case DW_TAG_volatile_type: + case DW_TAG_atomic_type: + case DW_TAG_unspecified_type: + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + case DW_TAG_enumeration_type: + case DW_TAG_inlined_subroutine: + case DW_TAG_subprogram: + case DW_TAG_subroutine_type: + case DW_TAG_array_type: + case DW_TAG_ptr_to_member_type: +return true; + default: +break; } return false; } diff --git a/lldb/test/API/commands/expression/nested/main.cpp b/lldb/test/API/commands/expression/nested/main.cpp index 9f8baaf355..620535fa09 100644 --- a/lldb/test/API/commands/expression/nested/main.cpp +++ b/lldb/test/API/commands/expression/nested/main.cpp @@ -1,13 +1,11 @@ namespace a { - namespace b { -namespace c { - static int d = 12; - enum Color { -Red, Green, Blue - }; -} - } -} +namespace b { +namespace c { +static int d = 12; +enum Color { Red, Green, Blue }; +} // namespace c +} // namespace b +} // namespace a struct A { int _a = 'a'; @@ -15,9 +13,7 @@ struct A { short _b = 'b'; struct C { char _c = 'c'; - enum EnumType : int { -Eleven = 11 - }; + enum EnumType : int { Eleven = 11 }; static EnumType enum_static; }; }; `` https://github.com/llvm/llvm-project/pull/77029 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix expressions that involve nested structs/classes/unions. (PR #77029)
clayborg wrote: This patch was in response to this issue: https://github.com/llvm/llvm-project/pull/74786#issuecomment-1874921872 And is related to https://github.com/llvm/llvm-project/pull/66879, but does things a bit differently. https://github.com/llvm/llvm-project/pull/77029 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix expressions that involve nested structs/classes/unions. (PR #77029)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/77029 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [libc] [mlir] [llvm] [compiler-rt] [lldb] [clang-tools-extra] [libcxxabi] [libcxx] [clang] [mlir][flang][openacc] Support device_type on loop construct (PR #76892)
https://github.com/razvanlupusoru approved this pull request. Looks great to me! Thank you! https://github.com/llvm/llvm-project/pull/76892 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Updating VariableDescription to use GetDescription() as a fallback. (PR #77026)
https://github.com/clayborg commented: Looks fine to me. Can we add a test? https://github.com/llvm/llvm-project/pull/77026 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [flang] [mlir] [libc] [compiler-rt] [lldb] [clang-tools-extra] [libcxxabi] [libcxx] [llvm] [mlir][flang][openacc] Support device_type on loop construct (PR #76892)
https://github.com/clementval closed https://github.com/llvm/llvm-project/pull/76892 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5fd18bd - Revert "XFAIL test with dsymutil"
Author: Jonas Devlieghere Date: 2024-01-04T16:47:16-08:00 New Revision: 5fd18bdef9e1f18d6069a542551f046f1a179b38 URL: https://github.com/llvm/llvm-project/commit/5fd18bdef9e1f18d6069a542551f046f1a179b38 DIFF: https://github.com/llvm/llvm-project/commit/5fd18bdef9e1f18d6069a542551f046f1a179b38.diff LOG: Revert "XFAIL test with dsymutil" This reverts commit c041fa1093c3ad7be040fb362a10ca3900c698a4 as Adrian added support to dsymutil. Added: Modified: lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py Removed: diff --git a/lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py b/lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py index ce7ac6fc503ed7..20ed0ce00661f0 100644 --- a/lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py +++ b/lldb/test/API/functionalities/inline-sourcefile/TestInlineSourceFiles.py @@ -8,8 +8,6 @@ class InlineSourceFilesTestCase(TestBase): @skipIf(compiler="gcc") @skipIf(compiler="clang", compiler_version=["<", "18.0"]) -# dsymutil doesn't yet copy the sources -@expectedFailureDarwin(debug_info=["dsym"]) def test(self): """Test DWARF inline source files.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [flang] [clang-tools-extra] [compiler-rt] [libcxx] [lldb] [llvm] [clang] AMDGPU: Make v4bf16 a legal type (PR #76217)
https://github.com/arsenm closed https://github.com/llvm/llvm-project/pull/76217 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [libcxxabi] [clang] [clang-tools-extra] [compiler-rt] [lldb] [flang] [libcxx] [mlir] [libc] [llvm] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)
@@ -0,0 +1,303 @@ +//===--===// +// +// 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 +// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200 + +// template S, class T, class Proj = identity> +// requires indirect_binary_predicate, const T*> +// constexpr bool ranges::contains(I first, S last, const T& value, Proj proj = {}); // since C++23 + +// template +// requires indirect_binary_predicate, Proj>, const T*> +// constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); // since C++23 + +#include +#include +#include +#include +#include + +#include "almost_satisfies_types.h" +#include "boolean_testable.h" ZijunZhaoCCK wrote: no, removed https://github.com/llvm/llvm-project/pull/66963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxxabi] [llvm] [flang] [libc] [mlir] [clang] [libcxx] [clang-tools-extra] [compiler-rt] [lldb] [lld] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/66963 >From 647f5fe641b30c874bab770fced9fcec9b601161 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Wed, 13 Sep 2023 14:26:01 -0700 Subject: [PATCH 1/8] [libc++] Implement ranges::contains_subrange --- libcxx/include/CMakeLists.txt | 1 + .../__algorithm/ranges_contains_subrange.h| 145 + libcxx/include/algorithm | 14 + ...obust_against_copying_projections.pass.cpp | 2 + .../ranges.contains_subrange.pass.cpp | 293 ++ .../niebloid.compile.pass.cpp | 1 + 6 files changed, 456 insertions(+) create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h create mode 100644 libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 0fe3ab44d2466e..dd3ff541fbc7ba 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -110,6 +110,7 @@ set(files __algorithm/ranges_binary_search.h __algorithm/ranges_clamp.h __algorithm/ranges_contains.h + __algorithm/ranges_contains_subrange.h __algorithm/ranges_copy.h __algorithm/ranges_copy_backward.h __algorithm/ranges_copy_if.h diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h b/libcxx/include/__algorithm/ranges_contains_subrange.h new file mode 100644 index 00..16de6c29cb2a1a --- /dev/null +++ b/libcxx/include/__algorithm/ranges_contains_subrange.h @@ -0,0 +1,145 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H +#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H + +#include <__algorithm/ranges_starts_with.h> +#include <__config> +#include <__functional/identity.h> +#include <__functional/ranges_operations.h> +#include <__functional/reference_wrapper.h> +#include <__iterator/concepts.h> +#include <__iterator/distance.h> +#include <__iterator/indirectly_comparable.h> +#include <__iterator/projected.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 23 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace ranges { +namespace __contains_subrange { +struct __fn { + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred, +class _Proj1, +class _Proj2, +class _Offset> + static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred& __pred, + _Proj1& __proj1, + _Proj2& __proj2, + _Offset __offset) { +if (__offset < 0) + return false; +else { + for (; __offset >= 0; __offset--, __first1++) { +auto result = ranges::starts_with( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +std::ref(__pred), +std::ref(__proj1), +std::ref(__proj2)); +if (result) + return true; + } + return false; +} + } + + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred = ranges::equal_to, +class _Proj1 = identity, +class _Proj2 = identity> +requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred __pred = {}, + _Proj1 __proj1 = {}, + _Proj2 __proj2 = {}) const { +auto __n1 = ranges::distance(__first1, __last1); +auto __n2 = ranges::distance(__first2, __last2); +auto __offset = __n1 - __n2; + +return __contains_subrange_fn_impl( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +__pred, +__proj1, +__proj2, +std::move(__offset)); + } + + template +requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { +auto __n1 = 0; +auto __n2 = 0; + +if conste
[Lldb-commits] [compiler-rt] [mlir] [libcxx] [clang-tools-extra] [lld] [clang] [flang] [libcxxabi] [libc] [lldb] [llvm] [libc++][ranges] Implement ranges::contains_subrange (PR #66963)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/66963 >From 647f5fe641b30c874bab770fced9fcec9b601161 Mon Sep 17 00:00:00 2001 From: Zijun Zhao Date: Wed, 13 Sep 2023 14:26:01 -0700 Subject: [PATCH 1/8] [libc++] Implement ranges::contains_subrange --- libcxx/include/CMakeLists.txt | 1 + .../__algorithm/ranges_contains_subrange.h| 145 + libcxx/include/algorithm | 14 + ...obust_against_copying_projections.pass.cpp | 2 + .../ranges.contains_subrange.pass.cpp | 293 ++ .../niebloid.compile.pass.cpp | 1 + 6 files changed, 456 insertions(+) create mode 100644 libcxx/include/__algorithm/ranges_contains_subrange.h create mode 100644 libcxx/test/std/algorithms/alg.nonmodifying/alg.contains/ranges.contains_subrange.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 0fe3ab44d2466e..dd3ff541fbc7ba 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -110,6 +110,7 @@ set(files __algorithm/ranges_binary_search.h __algorithm/ranges_clamp.h __algorithm/ranges_contains.h + __algorithm/ranges_contains_subrange.h __algorithm/ranges_copy.h __algorithm/ranges_copy_backward.h __algorithm/ranges_copy_if.h diff --git a/libcxx/include/__algorithm/ranges_contains_subrange.h b/libcxx/include/__algorithm/ranges_contains_subrange.h new file mode 100644 index 00..16de6c29cb2a1a --- /dev/null +++ b/libcxx/include/__algorithm/ranges_contains_subrange.h @@ -0,0 +1,145 @@ +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H +#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H + +#include <__algorithm/ranges_starts_with.h> +#include <__config> +#include <__functional/identity.h> +#include <__functional/ranges_operations.h> +#include <__functional/reference_wrapper.h> +#include <__iterator/concepts.h> +#include <__iterator/distance.h> +#include <__iterator/indirectly_comparable.h> +#include <__iterator/projected.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 23 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace ranges { +namespace __contains_subrange { +struct __fn { + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred, +class _Proj1, +class _Proj2, +class _Offset> + static _LIBCPP_HIDE_FROM_ABI constexpr bool __contains_subrange_fn_impl( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred& __pred, + _Proj1& __proj1, + _Proj2& __proj2, + _Offset __offset) { +if (__offset < 0) + return false; +else { + for (; __offset >= 0; __offset--, __first1++) { +auto result = ranges::starts_with( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +std::ref(__pred), +std::ref(__proj1), +std::ref(__proj2)); +if (result) + return true; + } + return false; +} + } + + template _Sent1, +input_iterator _Iter2, +sentinel_for<_Iter2> _Sent2, +class _Pred = ranges::equal_to, +class _Proj1 = identity, +class _Proj2 = identity> +requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred __pred = {}, + _Proj1 __proj1 = {}, + _Proj2 __proj2 = {}) const { +auto __n1 = ranges::distance(__first1, __last1); +auto __n2 = ranges::distance(__first2, __last2); +auto __offset = __n1 - __n2; + +return __contains_subrange_fn_impl( +std::move(__first1), +std::move(__last1), +std::move(__first2), +std::move(__last2), +__pred, +__proj1, +__proj2, +std::move(__offset)); + } + + template +requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { +auto __n1 = 0; +auto __n2 = 0; + +if conste
[Lldb-commits] [libcxx] [compiler-rt] [libc] [flang] [lldb] [lld] [clang] [libcxxabi] [mlir] [clang-tools-extra] [llvm] [clang] static operators should evaluate object argument (PR #68485)
https://github.com/SuperSodaSea updated https://github.com/llvm/llvm-project/pull/68485 >From 03276260c48d9cafb2a0d80825156e77cdf02eba Mon Sep 17 00:00:00 2001 From: SuperSodaSea Date: Sat, 7 Oct 2023 21:05:17 +0800 Subject: [PATCH 1/8] [clang] static operators should evaluate object argument --- clang/lib/AST/ExprConstant.cpp| 3 +- clang/lib/CodeGen/CGExpr.cpp | 2 +- clang/lib/CodeGen/CGExprCXX.cpp | 41 -- clang/lib/CodeGen/CodeGenFunction.h | 3 + clang/lib/Sema/SemaChecking.cpp | 5 +- clang/lib/Sema/SemaOverload.cpp | 33 --- clang/test/AST/ast-dump-static-operators.cpp | 55 +++ .../CodeGenCXX/cxx2b-static-call-operator.cpp | 26 ++--- .../cxx2b-static-subscript-operator.cpp | 11 +++- 9 files changed, 137 insertions(+), 42 deletions(-) create mode 100644 clang/test/AST/ast-dump-static-operators.cpp diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5a33e918db8e8c..a6c81f467fbe01 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -7806,7 +7806,8 @@ class ExprEvaluatorBase // Overloaded operator calls to member functions are represented as normal // calls with '*this' as the first argument. const CXXMethodDecl *MD = dyn_cast(FD); - if (MD && MD->isImplicitObjectMemberFunction()) { + if (MD && + (MD->isImplicitObjectMemberFunction() || (OCE && MD->isStatic( { // FIXME: When selecting an implicit conversion for an overloaded // operator delete, we sometimes try to evaluate calls to conversion // operators without a 'this' parameter! diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 54a1d300a9ac73..19406ff174dea1 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -5070,7 +5070,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, if (const auto *CE = dyn_cast(E)) if (const auto *MD = dyn_cast_if_present(CE->getCalleeDecl()); -MD && MD->isImplicitObjectMemberFunction()) +MD && !MD->isExplicitObjectMemberFunction()) return EmitCXXOperatorMemberCallExpr(CE, MD, ReturnValue); CGCallee callee = EmitCallee(E->getCallee()); diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 2e7059cc8f5b63..a580c635998510 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -489,11 +489,42 @@ RValue CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue) { - assert(MD->isImplicitObjectMemberFunction() && - "Trying to emit a member call expr on a static method!"); - return EmitCXXMemberOrOperatorMemberCallExpr( - E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr, - /*IsArrow=*/false, E->getArg(0)); + assert(!MD->isExplicitObjectMemberFunction() && + "Trying to emit a member call expr on an explicit object member " + "function!"); + + if (MD->isStatic()) +return EmitCXXStaticOperatorMemberCallExpr(E, MD, ReturnValue); + else +return EmitCXXMemberOrOperatorMemberCallExpr( +E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr, +/*IsArrow=*/false, E->getArg(0)); +} + +RValue CodeGenFunction::EmitCXXStaticOperatorMemberCallExpr( +const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, +ReturnValueSlot ReturnValue) { + assert(MD->isStatic()); + + CGCallee Callee = EmitCallee(E->getCallee()); + + // Emit and ignore `this` pointer. + EmitIgnoredExpr(E->getArg(0)); + + auto ProtoType = MD->getFunctionType()->castAs(); + + // Emit the rest of the call args. + CallArgList Args; + EmitCallArgs(Args, ProtoType, drop_begin(E->arguments(), 1), + E->getDirectCallee()); + + bool Chain = E == MustTailCall; + const CGFunctionInfo &FnInfo = + CGM.getTypes().arrangeFreeFunctionCall(Args, ProtoType, Chain); + llvm::CallBase *CallOrInvoke = nullptr; + + return EmitCall(FnInfo, Callee, ReturnValue, Args, &CallOrInvoke, Chain, + E->getExprLoc()); } RValue CodeGenFunction::EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index d5336382a2b9c9..42de125e748991 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4163,6 +4163,9 @@ class CodeGenFunction : public CodeGenTypeCache { RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue); + RValue EmitCXXStaticOperatorMemberCallExpr(const CXXOperatorCallExpr *CE,
[Lldb-commits] [libcxx] [compiler-rt] [flang] [libc] [lldb] [clang] [clang-tools-extra] [llvm] [X86][BF16] Try to use `f16` for lowering (PR #76901)
@@ -22,10 +22,7 @@ define void @add(ptr %pa, ptr %pb, ptr %pc) nounwind { ; X86-NEXT:vaddss %xmm0, %xmm1, %xmm0 ; X86-NEXT:vmovss %xmm0, (%esp) ; X86-NEXT:calll __truncsfbf2 -; X86-NEXT:fstps {{[0-9]+}}(%esp) -; X86-NEXT:vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero -; X86-NEXT:vmovd %xmm0, %eax -; X86-NEXT:movw %ax, (%esi) +; X86-NEXT:vmovsh %xmm0, (%esi) FreddyLeaf wrote: This change seems to will miss the truncate operation. https://github.com/llvm/llvm-project/pull/76901 ___ 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] [mlir] [openmp] [llvm] [clang] [lldb] [SEH] Fix register liveness verification for EHa (PR #76933)
https://github.com/HaohaiWen updated https://github.com/llvm/llvm-project/pull/76933 >From 8305e5e15eaaedba58a57b179e32c6d4b2a11a44 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Thu, 4 Jan 2024 15:35:52 +0800 Subject: [PATCH 1/5] [SEH] Add test to track EHa register liveness verification This test tracks bug of MachineVerifier to check live range segment for EHa. Async exception can happen at any place within seh scope, not only the call instruction. Need to teach MachineVerifier to know that. --- .../X86/windows-seh-EHa-RegisterLiveness.ll | 69 +++ 1 file changed, 69 insertions(+) create mode 100644 llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll diff --git a/llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll b/llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll new file mode 100644 index 00..d23318c6e16a11 --- /dev/null +++ b/llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll @@ -0,0 +1,69 @@ +; XFAIL: * +; RUN: llc --verify-machineinstrs < %s | FileCheck %s +source_filename = "test.cpp" +target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.12.0" + +$"?test@Test@@Plugin@@Host@@@Z" = comdat any + +declare dso_local i32 @__CxxFrameHandler3(...) + +; Function Attrs: nounwind memory(none) +declare dso_local void @llvm.seh.scope.begin() #1 + +; Function Attrs: nobuiltin allocsize(0) +declare dso_local noundef nonnull ptr @"??2@Test@Z"(i64 noundef) #1 + +; Function Attrs: nounwind memory(none) +declare dso_local void @llvm.seh.scope.end() #0 + +; Function Attrs: nobuiltin nounwind +declare dso_local void @"??3@YAXPEAX@Z"(ptr noundef) #2 + +; Function Attrs: mustprogress uwtable +define weak_odr dso_local noundef ptr @"?test@Test@@Plugin@@Host@@@Z"(ptr noundef nonnull align 8 dereferenceable(48) %this, ptr noundef %host) unnamed_addr #3 comdat align 2 personality ptr @__CxxFrameHandler3 { +entry: + %host.addr = alloca ptr, align 8 + %this.addr = alloca ptr, align 8 + store ptr %host, ptr %host.addr, align 8 + store ptr %this, ptr %this.addr, align 8 + %this1 = load ptr, ptr %this.addr, align 8 + %call = call noalias noundef nonnull ptr @"??2@Test@Z"(i64 noundef 152) #5 + invoke void @llvm.seh.scope.begin() + to label %invoke.cont unwind label %ehcleanup + +invoke.cont: ; preds = %entry + %call3 = invoke noundef ptr @"??Test@?A0x2749C4FD@@QEAA@Test@Test@@@Z"(ptr noundef nonnull align 8 dereferenceable(152) %call, ptr noundef %this1) + to label %invoke.cont2 unwind label %ehcleanup + +invoke.cont2: ; preds = %invoke.cont + invoke void @llvm.seh.scope.end() + to label %invoke.cont4 unwind label %ehcleanup + +invoke.cont4: ; preds = %invoke.cont2 + ret ptr %call + +ehcleanup:; preds = %invoke.cont2, %invoke.cont, %entry + %0 = cleanuppad within none [] + call void @"??3@YAXPEAX@Z"(ptr noundef %call) #6 [ "funclet"(token %0) ] + cleanupret from %0 unwind to caller +} + +; Function Attrs: uwtable +declare hidden noundef ptr @"??Test@?A0x2749C4FD@@QEAA@Test@Test@@@Z"(ptr noundef nonnull returned align 8 dereferenceable(152), ptr noundef) unnamed_addr #4 align 2 + +attributes #0 = { nounwind memory(none) } +attributes #1 = { nobuiltin allocsize(0) "target-cpu"="x86-64" "target-features"="+cmov,+crc32,+cx8,+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "tune-cpu"="generic" } +attributes #2 = { nobuiltin nounwind "target-cpu"="x86-64" "target-features"="+cmov,+crc32,+cx8,+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "tune-cpu"="generic" } +attributes #3 = { mustprogress uwtable "target-cpu"="x86-64" "target-features"="+cmov,+crc32,+cx8,+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "tune-cpu"="generic" } +attributes #4 = { uwtable "target-cpu"="x86-64" "target-features"="+cmov,+crc32,+cx8,+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "tune-cpu"="generic" } +attributes #5 = { builtin allocsize(0) } +attributes #6 = { builtin nounwind } + +!llvm.module.flags = !{!1, !2, !3, !4, !5} + +!1 = !{i32 1, !"wchar_size", i32 2} +!2 = !{i32 2, !"eh-asynch", i32 1} +!3 = !{i32 8, !"PIC Level", i32 2} +!4 = !{i32 7, !"uwtable", i32 2} +!5 = !{i32 1, !"MaxTLSAlign", i32 65536} >From 2d60e94362fdfbcf6964f9b50369c45f37a20398 Mon Sep 17 00:00:00 2001 From: Haohai Wen Date: Thu, 4 Jan 2024 17:15:59 +0800 Subject: [PATCH 2/5] Fix typo --- llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll b/llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll index d23318c6e16a11..c21ac1b5436c9c 100644 --- a/llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll +++ b/llvm/test/
[Lldb-commits] [clang-tools-extra] [libc] [compiler-rt] [libcxx] [mlir] [llvm] [lld] [clang] [lldb] [libcxxabi] [flang] [clang] static operators should evaluate object argument (PR #68485)
SuperSodaSea wrote: Wait a minute, it failes to compile this situation: ```c++ struct Foo { static int operator()(int a, int b) { return a + b; } }; void f() { const Foo foo; foo(1, 2); // 'this' argument to member function 'operator()' has type 'const Foo', but function is not marked const } ``` Let me try to fix this... https://github.com/llvm/llvm-project/pull/68485 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [openmp] [libcxx] [clang-tools-extra] [clang] [llvm] [libc] [flang] [lld] [lldb] [compiler-rt] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -58,6 +60,22 @@ class GlobalTy { void setPtr(void *P) { Ptr = P; } }; +typedef void *IntPtrT; +struct __llvm_profile_data { +#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) Type Name; +#include "llvm/ProfileData/InstrProfData.inc" +}; + +/// PGO profiling data extracted from a GPU device +struct GPUProfGlobals { + std::string names; + std::vector> counts; + std::vector<__llvm_profile_data> data; + Triple targetTriple; + EthanLuisMcDonough wrote: The basic idea is that the fields in this struct are going to be passed to compiler-rt to be made into a profraw file for this specific target. I don't know if `llvm::StringRef` would work for the names field. The names data is constant on the GPU device, but dynamic data still has to be allocated on the host in order to read the GPU value. I think it makes the most sense to make the struct own the name data. Do you think I should change all the vectors to `SmallVector` or just the innermost `Counts` vector? https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libc] [lld] [openmp] [llvm] [flang] [libcxx] [lldb] [compiler-rt] [clang-tools-extra] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -58,6 +60,22 @@ class GlobalTy { void setPtr(void *P) { Ptr = P; } }; +typedef void *IntPtrT; EthanLuisMcDonough wrote: `IntPtrT` isn't defined in `profile/InstrProfData.inc`. There are multiple examples of this type being defined. before InstProfData.inc is included. I'm not entirely sure what its for, but I'm assuming its to account for different platforms with different integer sizes. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [openmp] [clang] [lldb] [libc] [compiler-rt] [libcxx] [flang] [lld] [clang-tools-extra] [llvm] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); + // Iterate through elf symbols + for (auto &sym : ELFObj->symbols()) { +if (auto name = sym.getName()) { + // Check if given current global is a profiling global based + // on name + if (name->equals(getInstrProfNamesVarName())) { +// Read in profiled function names +std::vector chars(sym.getSize() / sizeof(char), ' '); EthanLuisMcDonough wrote: I'm allocating a vector so that I have memory to write the GPU value to. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [openmp] [libc] [compiler-rt] [llvm] [clang] [lld] [flang] [libcxx] [lldb] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); + // Iterate through elf symbols + for (auto &sym : ELFObj->symbols()) { +if (auto name = sym.getName()) { + // Check if given current global is a profiling global based + // on name + if (name->equals(getInstrProfNamesVarName())) { +// Read in profiled function names +std::vector chars(sym.getSize() / sizeof(char), ' '); +GlobalTy NamesGlobal(name->str(), sym.getSize(), chars.data()); EthanLuisMcDonough wrote: `__llvm_prf_nm` is emitted as an array. For example: ``` @__llvm_prf_nm = protected addrspace(1) constant [63 x i8] c"_=x\DA+I-.\D1K\B6\8A\8F\CF\CF-\88\CFOK\CB\C9OL\C9\CCK\8F7\B1\887M65J41\B5\88\CFM\CC\CC\8B\CF1\B4d,!Z\B1\B1\01X\B1!\00O\F6 \CF", section "__llvm_prf_names", align 1 ``` Eventually this data is going to be passed to a function in compiler-rt's profiling library so it can be used to generate a profiling file. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libc] [lld] [openmp] [llvm] [flang] [libcxx] [lldb] [compiler-rt] [clang-tools-extra] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
@@ -163,3 +163,87 @@ Error GenericGlobalHandlerTy::readGlobalFromImage(GenericDeviceTy &Device, return Plugin::success(); } + +bool GenericGlobalHandlerTy::hasProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GlobalTy global(getInstrProfNamesVarName().str(), 0); + if (auto Err = getGlobalMetadataFromImage(Device, Image, global)) { +consumeError(std::move(Err)); +return false; + } + return true; +} + +Expected +GenericGlobalHandlerTy::readProfilingGlobals(GenericDeviceTy &Device, + DeviceImageTy &Image) { + GPUProfGlobals profdata; + auto ELFObj = getELFObjectFile(Image); + if (!ELFObj) +return ELFObj.takeError(); + profdata.targetTriple = ELFObj->makeTriple(); + // Iterate through elf symbols + for (auto &sym : ELFObj->symbols()) { +if (auto name = sym.getName()) { + // Check if given current global is a profiling global based + // on name + if (name->equals(getInstrProfNamesVarName())) { +// Read in profiled function names +std::vector chars(sym.getSize() / sizeof(char), ' '); +GlobalTy NamesGlobal(name->str(), sym.getSize(), chars.data()); +if (auto Err = readGlobalFromDevice(Device, Image, NamesGlobal)) + return Err; +std::string names(chars.begin(), chars.end()); +profdata.names = std::move(names); + } else if (name->starts_with(getInstrProfCountersVarPrefix())) { EthanLuisMcDonough wrote: Those functions are defined in [InstrProf.h](https://github.com/llvm/llvm-project/blob/597086c60959dd5b3c032552e8b42dd1d053f233/llvm/include/llvm/ProfileData/InstrProf.h#L92-L96). https://github.com/llvm/llvm-project/blob/597086c60959dd5b3c032552e8b42dd1d053f233/llvm/include/llvm/ProfileData/InstrProf.h#L92-L96 They're used in the creation of PGO global names. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [openmp] [libc] [compiler-rt] [llvm] [clang] [lld] [flang] [libcxx] [lldb] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)
WenleiHe wrote: > ongoing effort to extends PGO instrumentation to GPU device code Is there a high level description for this effort and its goal? Traditional compiler PGO is mostly for profiling control-flow, but we don't usually have a lot of control flow for GPU kernels. https://github.com/llvm/llvm-project/pull/76587 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [libc] [mlir] [compiler-rt] [llvm] [clang] [lld] [libcxxabi] [flang] [libcxx] [lldb] [clang] static operators should evaluate object argument (PR #68485)
https://github.com/SuperSodaSea updated https://github.com/llvm/llvm-project/pull/68485 >From 03276260c48d9cafb2a0d80825156e77cdf02eba Mon Sep 17 00:00:00 2001 From: SuperSodaSea Date: Sat, 7 Oct 2023 21:05:17 +0800 Subject: [PATCH 1/9] [clang] static operators should evaluate object argument --- clang/lib/AST/ExprConstant.cpp| 3 +- clang/lib/CodeGen/CGExpr.cpp | 2 +- clang/lib/CodeGen/CGExprCXX.cpp | 41 -- clang/lib/CodeGen/CodeGenFunction.h | 3 + clang/lib/Sema/SemaChecking.cpp | 5 +- clang/lib/Sema/SemaOverload.cpp | 33 --- clang/test/AST/ast-dump-static-operators.cpp | 55 +++ .../CodeGenCXX/cxx2b-static-call-operator.cpp | 26 ++--- .../cxx2b-static-subscript-operator.cpp | 11 +++- 9 files changed, 137 insertions(+), 42 deletions(-) create mode 100644 clang/test/AST/ast-dump-static-operators.cpp diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5a33e918db8e8c..a6c81f467fbe01 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -7806,7 +7806,8 @@ class ExprEvaluatorBase // Overloaded operator calls to member functions are represented as normal // calls with '*this' as the first argument. const CXXMethodDecl *MD = dyn_cast(FD); - if (MD && MD->isImplicitObjectMemberFunction()) { + if (MD && + (MD->isImplicitObjectMemberFunction() || (OCE && MD->isStatic( { // FIXME: When selecting an implicit conversion for an overloaded // operator delete, we sometimes try to evaluate calls to conversion // operators without a 'this' parameter! diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 54a1d300a9ac73..19406ff174dea1 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -5070,7 +5070,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, if (const auto *CE = dyn_cast(E)) if (const auto *MD = dyn_cast_if_present(CE->getCalleeDecl()); -MD && MD->isImplicitObjectMemberFunction()) +MD && !MD->isExplicitObjectMemberFunction()) return EmitCXXOperatorMemberCallExpr(CE, MD, ReturnValue); CGCallee callee = EmitCallee(E->getCallee()); diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 2e7059cc8f5b63..a580c635998510 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -489,11 +489,42 @@ RValue CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue) { - assert(MD->isImplicitObjectMemberFunction() && - "Trying to emit a member call expr on a static method!"); - return EmitCXXMemberOrOperatorMemberCallExpr( - E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr, - /*IsArrow=*/false, E->getArg(0)); + assert(!MD->isExplicitObjectMemberFunction() && + "Trying to emit a member call expr on an explicit object member " + "function!"); + + if (MD->isStatic()) +return EmitCXXStaticOperatorMemberCallExpr(E, MD, ReturnValue); + else +return EmitCXXMemberOrOperatorMemberCallExpr( +E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr, +/*IsArrow=*/false, E->getArg(0)); +} + +RValue CodeGenFunction::EmitCXXStaticOperatorMemberCallExpr( +const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, +ReturnValueSlot ReturnValue) { + assert(MD->isStatic()); + + CGCallee Callee = EmitCallee(E->getCallee()); + + // Emit and ignore `this` pointer. + EmitIgnoredExpr(E->getArg(0)); + + auto ProtoType = MD->getFunctionType()->castAs(); + + // Emit the rest of the call args. + CallArgList Args; + EmitCallArgs(Args, ProtoType, drop_begin(E->arguments(), 1), + E->getDirectCallee()); + + bool Chain = E == MustTailCall; + const CGFunctionInfo &FnInfo = + CGM.getTypes().arrangeFreeFunctionCall(Args, ProtoType, Chain); + llvm::CallBase *CallOrInvoke = nullptr; + + return EmitCall(FnInfo, Callee, ReturnValue, Args, &CallOrInvoke, Chain, + E->getExprLoc()); } RValue CodeGenFunction::EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index d5336382a2b9c9..42de125e748991 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4163,6 +4163,9 @@ class CodeGenFunction : public CodeGenTypeCache { RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue); + RValue EmitCXXStaticOperatorMemberCallExpr(const CXXOperatorCallExpr *CE,
[Lldb-commits] [clang-tools-extra] [libc] [mlir] [compiler-rt] [llvm] [clang] [lld] [libcxxabi] [flang] [libcxx] [lldb] [clang] static operators should evaluate object argument (PR #68485)
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 054b5fc0fd41bcbadcc6967c39a5f6bb151bdcd1 eb42407a523f9a79afca4fbf221b344330888cc6 -- clang/test/AST/ast-dump-static-operators.cpp clang/test/SemaCXX/cxx2b-static-operator.cpp clang/lib/AST/ExprConstant.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaOverload.cpp clang/test/CodeGenCXX/cxx2b-static-call-operator.cpp clang/test/CodeGenCXX/cxx2b-static-subscript-operator.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 1810fdd12b..f9c7cf9b65 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5682,7 +5682,9 @@ static ImplicitConversionSequence TryObjectArgumentInitialization( // const volatile object. // Also, a static operator can be invoked for a const, volatile or const // volatile object, apparently. - bool IsStaticOperator = Method->getDeclName().getCXXOverloadedOperator() != OO_None && Method->isStatic(); + bool IsStaticOperator = + Method->getDeclName().getCXXOverloadedOperator() != OO_None && + Method->isStatic(); Qualifiers Quals = Method->getMethodQualifiers(); if (isa(Method) || IsStaticOperator) { Quals.addConst(); `` https://github.com/llvm/llvm-project/pull/68485 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [libc] [mlir] [compiler-rt] [llvm] [clang] [lld] [libcxxabi] [flang] [libcxx] [lldb] [clang] static operators should evaluate object argument (PR #68485)
https://github.com/SuperSodaSea updated https://github.com/llvm/llvm-project/pull/68485 >From 03276260c48d9cafb2a0d80825156e77cdf02eba Mon Sep 17 00:00:00 2001 From: SuperSodaSea Date: Sat, 7 Oct 2023 21:05:17 +0800 Subject: [PATCH 01/10] [clang] static operators should evaluate object argument --- clang/lib/AST/ExprConstant.cpp| 3 +- clang/lib/CodeGen/CGExpr.cpp | 2 +- clang/lib/CodeGen/CGExprCXX.cpp | 41 -- clang/lib/CodeGen/CodeGenFunction.h | 3 + clang/lib/Sema/SemaChecking.cpp | 5 +- clang/lib/Sema/SemaOverload.cpp | 33 --- clang/test/AST/ast-dump-static-operators.cpp | 55 +++ .../CodeGenCXX/cxx2b-static-call-operator.cpp | 26 ++--- .../cxx2b-static-subscript-operator.cpp | 11 +++- 9 files changed, 137 insertions(+), 42 deletions(-) create mode 100644 clang/test/AST/ast-dump-static-operators.cpp diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5a33e918db8e8c..a6c81f467fbe01 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -7806,7 +7806,8 @@ class ExprEvaluatorBase // Overloaded operator calls to member functions are represented as normal // calls with '*this' as the first argument. const CXXMethodDecl *MD = dyn_cast(FD); - if (MD && MD->isImplicitObjectMemberFunction()) { + if (MD && + (MD->isImplicitObjectMemberFunction() || (OCE && MD->isStatic( { // FIXME: When selecting an implicit conversion for an overloaded // operator delete, we sometimes try to evaluate calls to conversion // operators without a 'this' parameter! diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 54a1d300a9ac73..19406ff174dea1 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -5070,7 +5070,7 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, if (const auto *CE = dyn_cast(E)) if (const auto *MD = dyn_cast_if_present(CE->getCalleeDecl()); -MD && MD->isImplicitObjectMemberFunction()) +MD && !MD->isExplicitObjectMemberFunction()) return EmitCXXOperatorMemberCallExpr(CE, MD, ReturnValue); CGCallee callee = EmitCallee(E->getCallee()); diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 2e7059cc8f5b63..a580c635998510 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -489,11 +489,42 @@ RValue CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue) { - assert(MD->isImplicitObjectMemberFunction() && - "Trying to emit a member call expr on a static method!"); - return EmitCXXMemberOrOperatorMemberCallExpr( - E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr, - /*IsArrow=*/false, E->getArg(0)); + assert(!MD->isExplicitObjectMemberFunction() && + "Trying to emit a member call expr on an explicit object member " + "function!"); + + if (MD->isStatic()) +return EmitCXXStaticOperatorMemberCallExpr(E, MD, ReturnValue); + else +return EmitCXXMemberOrOperatorMemberCallExpr( +E, MD, ReturnValue, /*HasQualifier=*/false, /*Qualifier=*/nullptr, +/*IsArrow=*/false, E->getArg(0)); +} + +RValue CodeGenFunction::EmitCXXStaticOperatorMemberCallExpr( +const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, +ReturnValueSlot ReturnValue) { + assert(MD->isStatic()); + + CGCallee Callee = EmitCallee(E->getCallee()); + + // Emit and ignore `this` pointer. + EmitIgnoredExpr(E->getArg(0)); + + auto ProtoType = MD->getFunctionType()->castAs(); + + // Emit the rest of the call args. + CallArgList Args; + EmitCallArgs(Args, ProtoType, drop_begin(E->arguments(), 1), + E->getDirectCallee()); + + bool Chain = E == MustTailCall; + const CGFunctionInfo &FnInfo = + CGM.getTypes().arrangeFreeFunctionCall(Args, ProtoType, Chain); + llvm::CallBase *CallOrInvoke = nullptr; + + return EmitCall(FnInfo, Callee, ReturnValue, Args, &CallOrInvoke, Chain, + E->getExprLoc()); } RValue CodeGenFunction::EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index d5336382a2b9c9..42de125e748991 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -4163,6 +4163,9 @@ class CodeGenFunction : public CodeGenTypeCache { RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue); + RValue EmitCXXStaticOperatorMemberCallExpr(const CXXOperatorCallExpr *C
[Lldb-commits] [clang] [llvm] [openmp] [lldb] [clang-tools-extra] [mlir] [libcxx] [SEH] Fix register liveness verification for EHa (PR #76933)
HaohaiWen wrote: Refer https://github.com/llvm/llvm-project/pull/76921 for failure output https://github.com/llvm/llvm-project/pull/76933 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [llvm] [lldb] [clang] [openmp] [mlir] [libcxx] [SEH] Fix register liveness verification for EHa (PR #76933)
@@ -0,0 +1,65 @@ +; RUN: llc --verify-machineinstrs < %s +source_filename = "test.cpp" +target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.12.0" + +$"?test@Test@@Plugin@@Host@@@Z" = comdat any + +declare i32 @__CxxFrameHandler3(...) + +; Function Attrs: nounwind memory(none) +declare void @llvm.seh.scope.begin() #1 + +; Function Attrs: nobuiltin allocsize(0) +declare ptr @"??2@Test@Z"(i64) #1 + +; Function Attrs: nounwind memory(none) +declare void @llvm.seh.scope.end() #0 + +; Function Attrs: nobuiltin nounwind +declare void @"??3@YAXPEAX@Z"(ptr) #2 + +; Function Attrs: mustprogress uwtable +define ptr @"?test@Test@@Plugin@@Host@@@Z"(ptr %this, ptr %host) #3 comdat align 2 personality ptr @__CxxFrameHandler3 { +entry: + %host.addr = alloca ptr, align 8 + %this.addr = alloca ptr, align 8 + store ptr %host, ptr %host.addr, align 8 + store ptr %this, ptr %this.addr, align 8 + %this1 = load ptr, ptr %this.addr, align 8 + %call = call noalias ptr @"??2@Test@Z"(i64 152) #5 HaohaiWen wrote: ``` // Check that VNI is live-out of all predecessors. for (const MachineBasicBlock *Pred : MFI->predecessors()) { SlotIndex PEnd = LiveInts->getMBBEndIdx(Pred); // Predecessor of landing pad live-out on last call for sync EH. if (MFI->isEHPad()) { assert(!IsEHa && "EHa may raise exception on non call"); for (const MachineInstr &MI : llvm::reverse(*Pred)) { if (MI.isCall()) { PEnd = Indexes->getInstructionIndex(MI).getBoundaryIndex(); break; } } } const VNInfo *PVNI = LR.getVNInfoBefore(PEnd); ``` Verifier think exception raised only by call so it trims live range until call. From bellowing log we can see %1 was defined after call but before scope.begin. It's valid. ``` # After Register Coalescer ** INTERVALS ** CH [0B,32r:0)[112r,128r:3)[304r,336r:2)[544r,560r:1) 0@0B-phi 1@544r 2@304r 3@112r CL [0B,32r:0)[112r,128r:3)[304r,336r:2)[544r,560r:1) 0@0B-phi 1@544r 2@304r 3@112r DH [0B,16r:0)[320r,336r:1) 0@0B-phi 1@320r DL [0B,16r:0)[320r,336r:1) 0@0B-phi 1@320r HCX [0B,32r:0)[112r,128r:3)[304r,336r:2)[544r,560r:1) 0@0B-phi 1@544r 2@304r 3@112r HDX [0B,16r:0)[320r,336r:1) 0@0B-phi 1@320r %0 [32r,320r:0) 0@32r weight:0.00e+00 %1 [160r,464r:0)[496B,544r:0) 0@160r weight:0.00e+00 %3 [16r,64r:0) 0@16r weight:0.00e+00 RegMasks: 128r 336r 496B 560r ** MACHINEINSTRS ** # Machine code for function ?test@Test@@Plugin@@Host@@@Z: NoPHIs, TracksLiveness, TiedOpsRewritten Frame Objects: fi#0: size=8, align=8, at location [SP+8] fi#1: size=8, align=8, at location [SP+8] Function Live Ins: $rcx in %2, $rdx in %3 0B bb.0.entry: successors: %bb.1(0x7800), %bb.4(0x0800); %bb.1(100.00%), %bb.4(0.00%) liveins: $rcx, $rdx 16B %3:gr64 = COPY $rdx 32B %0:gr64 = COPY $rcx 48B EH_LABEL 64B MOV64mr %stack.0.host.addr, 1, $noreg, 0, $noreg, %3:gr64 :: (store (s64) into %ir.host.addr) 80B MOV64mr %stack.1.this.addr, 1, $noreg, 0, $noreg, %0:gr64 :: (store (s64) into %ir.this.addr) 96B ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp 112B $rcx = MOV32ri64 152 128B CALL64pcrel32 @"??2@Test@Z", , implicit $rsp, implicit $ssp, implicit $rcx, implicit-def $rsp, implicit-def $ssp, implicit-def $rax 144B ADJCALLSTACKUP64 32, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp 160B %1:gr64 = COPY killed $rax 192B EH_LABEL 208B JMP_1 %bb.1 224Bbb.1.invoke.cont: ; predecessors: %bb.0 successors: %bb.2(0x7800), %bb.4(0x0800); %bb.2(100.00%), %bb.4(0.00%) 240B EH_LABEL 256B EH_LABEL 288B ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp 304B $rcx = COPY %1:gr64 320B $rdx = COPY %0:gr64 336B CALL64pcrel32 @"??Test@?A0x2749C4FD@@QEAA@Test@Test@@@Z", , implicit $rsp, implicit $ssp, implicit $rcx, implicit $rdx, implicit-def $rsp, implicit-def $ssp, implicit-def dead $rax 352B ADJCALLSTACKUP64 32, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp 368B EH_LABEL 384B EH_LABEL 400B JMP_1 %bb.2 416Bbb.2.invoke.cont2: ; predecessors: %bb.1 successors: %bb.3(0x7800), %bb.4(0x0800); %bb.3(100.00%), %bb.4(0.00%) 432B JMP_1 %bb.3 448Bbb.3.invoke.cont4: ; predecessors: %bb.2 464B $rax = COPY %1:gr64 480B RET 0, killed $rax 496Bbb.4.ehcleanup (machine-block-address-taken, landing-pad, ehfunclet-entry): ; predecessors: %bb.0, %bb.1, %bb.2 512B
[Lldb-commits] [flang] [libc] [lldb] [compiler-rt] [clang-tools-extra] [llvm] [libcxx] [clang] [X86][BF16] Try to use `f16` for lowering (PR #76901)
@@ -22,10 +22,7 @@ define void @add(ptr %pa, ptr %pb, ptr %pc) nounwind { ; X86-NEXT:vaddss %xmm0, %xmm1, %xmm0 ; X86-NEXT:vmovss %xmm0, (%esp) ; X86-NEXT:calll __truncsfbf2 -; X86-NEXT:fstps {{[0-9]+}}(%esp) -; X86-NEXT:vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero -; X86-NEXT:vmovd %xmm0, %eax -; X86-NEXT:movw %ax, (%esi) +; X86-NEXT:vmovsh %xmm0, (%esi) phoebewang wrote: What's the mean by truncate? https://github.com/llvm/llvm-project/pull/76901 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [flang] [clang-tools-extra] [lldb] [llvm] [clang] [libcxx] [compiler-rt] [X86][BF16] Try to use `f16` for lowering (PR #76901)
@@ -22,10 +22,7 @@ define void @add(ptr %pa, ptr %pb, ptr %pc) nounwind { ; X86-NEXT:vaddss %xmm0, %xmm1, %xmm0 ; X86-NEXT:vmovss %xmm0, (%esp) ; X86-NEXT:calll __truncsfbf2 -; X86-NEXT:fstps {{[0-9]+}}(%esp) -; X86-NEXT:vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero -; X86-NEXT:vmovd %xmm0, %eax -; X86-NEXT:movw %ax, (%esi) +; X86-NEXT:vmovsh %xmm0, (%esi) FreddyLeaf wrote: Sorry being not clear. I saw the original codes containing `; X86-NEXT: movw %ax, (%esi)` seems like we are changing from a word store to a xmm store here. https://github.com/llvm/llvm-project/pull/76901 ___ 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] [clang-tools-extra] [libc] [libcxx] [lldb] [llvm] [X86][BF16] Try to use `f16` for lowering (PR #76901)
@@ -22,10 +22,7 @@ define void @add(ptr %pa, ptr %pb, ptr %pc) nounwind { ; X86-NEXT:vaddss %xmm0, %xmm1, %xmm0 ; X86-NEXT:vmovss %xmm0, (%esp) ; X86-NEXT:calll __truncsfbf2 -; X86-NEXT:fstps {{[0-9]+}}(%esp) -; X86-NEXT:vmovd {{.*#+}} xmm0 = mem[0],zero,zero,zero -; X86-NEXT:vmovd %xmm0, %eax -; X86-NEXT:movw %ax, (%esi) +; X86-NEXT:vmovsh %xmm0, (%esi) phoebewang wrote: `vmovsh` can store the low 16-bit to memory directly. The original codes has ABI mistake, which store `bf16` without `f32`. Since `f32` uses X87 registers on 32-bit target, it need to store to another memory first, reload to store again. The patch makes the result in XMM0, so one `vmovsh` is enough. https://github.com/llvm/llvm-project/pull/76901 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits