[Lldb-commits] [lld] [libc] [clang-tools-extra] [lldb] [libcxxabi] [clang] [flang] [llvm] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)
https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/79512 >From 299a055e271264f918321bf7360ee37c6ede8b26 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 23 Jan 2024 13:39:38 + Subject: [PATCH] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. We are replacing with a wider increment. If both OrigInc and IsomorphicInc are NUW/NSW, then we can preserve them on the wider increment; the narrower IsomorphicInc would wrap before the wider OrigInc, so the replacement won't make IsomorphicInc's uses more poisonous. --- .../Utils/ScalarEvolutionExpander.cpp | 28 +-- .../Transforms/IndVarSimplify/iv-poison.ll| 12 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index cf8cea937a6bf..902c4db883769 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -1607,11 +1607,35 @@ void SCEVExpander::replaceCongruentIVInc( const SCEV *TruncExpr = SE.getTruncateOrNoop(SE.getSCEV(OrigInc), IsomorphicInc->getType()); if (OrigInc == IsomorphicInc || TruncExpr != SE.getSCEV(IsomorphicInc) || - !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) || - !hoistIVInc(OrigInc, IsomorphicInc, + !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc)) +return; + + bool BothHaveNUW = false; + bool BothHaveNSW = false; + auto *OBOIncV = dyn_cast(OrigInc); + auto *OBOIsomorphic = dyn_cast(IsomorphicInc); + assert(OrigInc->getType()->getScalarSizeInBits() >= + IsomorphicInc->getType()->getScalarSizeInBits()) && "Should only replace an increment with a wider one."); + if (OBOIncV && OBOIsomorphic) { +BothHaveNUW = +OBOIncV->hasNoUnsignedWrap() && OBOIsomorphic->hasNoUnsignedWrap(); +BothHaveNSW = +OBOIncV->hasNoSignedWrap() && OBOIsomorphic->hasNoSignedWrap(); + } + + if (!hoistIVInc(OrigInc, IsomorphicInc, /*RecomputePoisonFlags*/ true)) return; + // We are replacing with a wider increment. If both OrigInc and IsomorphicInc + // are NUW/NSW, then we can preserve them on the wider increment; the narrower + // IsomorphicInc would wrap before the wider OrigInc, so the replacement won't + // make IsomorphicInc's uses more poisonous. + if (BothHaveNUW || BothHaveNSW) { +OrigInc->setHasNoUnsignedWrap(OBOIncV->hasNoUnsignedWrap() || BothHaveNUW); +OrigInc->setHasNoSignedWrap(OBOIncV->hasNoSignedWrap() || BothHaveNSW); + } + SCEV_DEBUG_WITH_TYPE(DebugType, dbgs() << "INDVARS: Eliminated congruent iv.inc: " << *IsomorphicInc << '\n'); diff --git a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll index 38299e0a6b353..383599f614357 100644 --- a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll +++ b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll @@ -64,7 +64,7 @@ define i2 @iv_hoist_both_adds_nsw(i2 %arg) { ; CHECK-NEXT:br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], [[LOOP]] ] -; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1 +; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i2 [[IV_0]], 1 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i2 1, [[ARG:%.*]] ; CHECK-NEXT:br i1 [[DOTNOT_NOT]], label [[EXIT:%.*]], label [[LOOP]] ; CHECK: exit: @@ -92,7 +92,7 @@ define i4 @iv_hoist_both_adds_nsw_extra_use(i4 %arg) { ; CHECK-NEXT:br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], [[LOOP]] ] -; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1 +; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]]) ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]]) ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]] @@ -124,7 +124,7 @@ define i4 @iv_hoist_both_adds_nsw_extra_use_incs_reordered(i4 %arg) { ; CHECK-NEXT:br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], [[LOOP]] ] -; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1 +; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]]) ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]]) ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]] @@ -244,7 +244,7 @@ define i2 @iv_hoist_both_adds_nuw(i2 %arg, i2 %start) { ; CHECK-NEXT:br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ [[START:%.*]], [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], [[LOOP]] ] -; CHECK-NEXT:[[IV_0_NEXT]] = add i2 [[IV_0]], 1 +; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1 ; CHECK-NEXT:[[DOTN
[Lldb-commits] [lld] [libc] [clang-tools-extra] [lldb] [libcxxabi] [clang] [flang] [llvm] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)
https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/79512 >From 299a055e271264f918321bf7360ee37c6ede8b26 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 23 Jan 2024 13:39:38 + Subject: [PATCH 1/2] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. We are replacing with a wider increment. If both OrigInc and IsomorphicInc are NUW/NSW, then we can preserve them on the wider increment; the narrower IsomorphicInc would wrap before the wider OrigInc, so the replacement won't make IsomorphicInc's uses more poisonous. --- .../Utils/ScalarEvolutionExpander.cpp | 28 +-- .../Transforms/IndVarSimplify/iv-poison.ll| 12 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index cf8cea937a6bf..902c4db883769 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -1607,11 +1607,35 @@ void SCEVExpander::replaceCongruentIVInc( const SCEV *TruncExpr = SE.getTruncateOrNoop(SE.getSCEV(OrigInc), IsomorphicInc->getType()); if (OrigInc == IsomorphicInc || TruncExpr != SE.getSCEV(IsomorphicInc) || - !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc) || - !hoistIVInc(OrigInc, IsomorphicInc, + !SE.LI.replacementPreservesLCSSAForm(IsomorphicInc, OrigInc)) +return; + + bool BothHaveNUW = false; + bool BothHaveNSW = false; + auto *OBOIncV = dyn_cast(OrigInc); + auto *OBOIsomorphic = dyn_cast(IsomorphicInc); + assert(OrigInc->getType()->getScalarSizeInBits() >= + IsomorphicInc->getType()->getScalarSizeInBits()) && "Should only replace an increment with a wider one."); + if (OBOIncV && OBOIsomorphic) { +BothHaveNUW = +OBOIncV->hasNoUnsignedWrap() && OBOIsomorphic->hasNoUnsignedWrap(); +BothHaveNSW = +OBOIncV->hasNoSignedWrap() && OBOIsomorphic->hasNoSignedWrap(); + } + + if (!hoistIVInc(OrigInc, IsomorphicInc, /*RecomputePoisonFlags*/ true)) return; + // We are replacing with a wider increment. If both OrigInc and IsomorphicInc + // are NUW/NSW, then we can preserve them on the wider increment; the narrower + // IsomorphicInc would wrap before the wider OrigInc, so the replacement won't + // make IsomorphicInc's uses more poisonous. + if (BothHaveNUW || BothHaveNSW) { +OrigInc->setHasNoUnsignedWrap(OBOIncV->hasNoUnsignedWrap() || BothHaveNUW); +OrigInc->setHasNoSignedWrap(OBOIncV->hasNoSignedWrap() || BothHaveNSW); + } + SCEV_DEBUG_WITH_TYPE(DebugType, dbgs() << "INDVARS: Eliminated congruent iv.inc: " << *IsomorphicInc << '\n'); diff --git a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll index 38299e0a6b353..383599f614357 100644 --- a/llvm/test/Transforms/IndVarSimplify/iv-poison.ll +++ b/llvm/test/Transforms/IndVarSimplify/iv-poison.ll @@ -64,7 +64,7 @@ define i2 @iv_hoist_both_adds_nsw(i2 %arg) { ; CHECK-NEXT:br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], [[LOOP]] ] -; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1 +; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i2 [[IV_0]], 1 ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i2 1, [[ARG:%.*]] ; CHECK-NEXT:br i1 [[DOTNOT_NOT]], label [[EXIT:%.*]], label [[LOOP]] ; CHECK: exit: @@ -92,7 +92,7 @@ define i4 @iv_hoist_both_adds_nsw_extra_use(i4 %arg) { ; CHECK-NEXT:br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], [[LOOP]] ] -; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1 +; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]]) ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]]) ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]] @@ -124,7 +124,7 @@ define i4 @iv_hoist_both_adds_nsw_extra_use_incs_reordered(i4 %arg) { ; CHECK-NEXT:br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT:[[IV_0:%.*]] = phi i4 [ 1, [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], [[LOOP]] ] -; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i4 [[IV_0]], 1 +; CHECK-NEXT:[[IV_0_NEXT]] = add nuw nsw i4 [[IV_0]], 1 ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]]) ; CHECK-NEXT:call void @use(i4 [[IV_0_NEXT]]) ; CHECK-NEXT:[[DOTNOT_NOT:%.*]] = icmp ult i4 1, [[ARG:%.*]] @@ -244,7 +244,7 @@ define i2 @iv_hoist_both_adds_nuw(i2 %arg, i2 %start) { ; CHECK-NEXT:br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT:[[IV_0:%.*]] = phi i2 [ [[START:%.*]], [[BB:%.*]] ], [ [[IV_0_NEXT:%.*]], [[LOOP]] ] -; CHECK-NEXT:[[IV_0_NEXT]] = add i2 [[IV_0]], 1 +; CHECK-NEXT:[[IV_0_NEXT]] = add nuw i2 [[IV_0]], 1 ; CHECK-NEXT:[[
[Lldb-commits] [flang] [clang] [libcxxabi] [clang-tools-extra] [llvm] [lld] [libc] [lldb] [SCEVExp] Keep NUW/NSW if both original inc and isomporphic inc agree. (PR #79512)
https://github.com/fhahn closed https://github.com/llvm/llvm-project/pull/79512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [flang] [libcxxabi] [lldb] [clang-tools-extra] [openmp] [lld] [libcxx] [mlir] [llvm] [libc] [clang] [libc++][memory] P2652R2: Disallow Specialization of `allocator_traits`
https://github.com/philnik777 approved this pull request. Thanks! LGTM. https://github.com/llvm/llvm-project/pull/79978 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libc] [libcxx] [lld] [llvm] [clang] [flang] [libcxxabi] [openmp] [compiler-rt] [mlir] [lldb] [clang-tools-extra] [libc++][memory] P2652R2: Disallow Specialization of `allocator_traits`
https://github.com/philnik777 closed https://github.com/llvm/llvm-project/pull/79978 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
DavidSpickett wrote: I didn't have time to review before merge, just looking at this now. > see what the Windows CI thinks. I assume you mean the buildbots (lldb isn't built in the pre-commit CI), but I think given: https://github.com/llvm/llvm-zorg/blob/590f0a62919ad313758362d18a31e7d40255e6e6/buildbot/osuosl/master/config/builders.py#L1342 The tests wouldn't run there anyway. I don't know specifically why we skip those tests on our bot. Could be that the Windows APIs are target specific like ptrace is, and we just didn't implement it for Windows on Arm yet, could be that the hardware we have doesn't support it. I'll found out what the status is there. https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
https://github.com/DavidSpickett commented: Surprised this isn't horribly broken on Linux :) Just a bunch of nits. https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,109 @@ +//===-- WatchpointAlgorithms.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_BREAKPOINT_WATCHPOINTALGORITHMS_H +#define LLDB_BREAKPOINT_WATCHPOINTALGORITHMS_H + +#include "lldb/Breakpoint/WatchpointResource.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/lldb-public.h" + +#include + +namespace lldb_private { + +class WatchpointAlgorithms { + +public: + /// Convert a user's watchpoint request into an array of memory DavidSpickett wrote: Does this mean one register = one memory region Or one register = all the memory regions (at once) I think the former but the phrasing implies the latter. How about: "an array of memory regions, each of which can be watched by one" https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,101 @@ +""" +Watch a large unaligned memory region that +lldb will need multiple hardware watchpoints +to cover. +""" + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class UnalignedLargeWatchpointTestCase(TestBase): +def continue_and_report_stop_reason(self, process, iter_str): +if self.TraceOn(): +self.runCmd("script print('continue')") +process.Continue() +self.assertIn( +process.GetState(), [lldb.eStateStopped, lldb.eStateExited], iter_str +) +thread = process.GetSelectedThread() +return thread.GetStopReason() + +NO_DEBUG_INFO_TESTCASE = True + +# Test on 64-bit targets where we probably have +# four watchpoint registers that can watch doublewords (8-byte). +@skipIf(archs=no_match(["arm64", "arm64e", "aarch64", "x86_64"])) +def test_unaligned_large_watchpoint(self): +"""Test watching an unaligned region of memory that requires multiple watchpoints.""" +self.build() +self.main_source_file = lldb.SBFileSpec("main.c") +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( DavidSpickett wrote: You don't need (): target, process, thread, bkpt = ... Works fine. https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,109 @@ +//===-- WatchpointAlgorithms.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_BREAKPOINT_WATCHPOINTALGORITHMS_H +#define LLDB_BREAKPOINT_WATCHPOINTALGORITHMS_H + +#include "lldb/Breakpoint/WatchpointResource.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/lldb-public.h" + +#include + +namespace lldb_private { + +class WatchpointAlgorithms { + +public: + /// Convert a user's watchpoint request into an array of memory + /// regions that can be watched by one hardware watchpoint register + /// on the current target. + /// + /// \param[in] addr + /// The start address specified by the user. + /// + /// \param[in] size + /// The number of bytes the user wants to watch. + /// + /// \param[in] read + /// True if we are watching for read accesses. + /// + /// \param[in] write + /// True if we are watching for write accesses. + /// \a read and \a write may both be true. + /// There is no "modify" style for WatchpointResources - + /// WatchpointResources are akin to the hardware watchpoint + /// registers which are either in terms of read or write. + /// "modify" distinction is done at the Watchpoint layer, where + /// we check the actual range of bytes the user requested. + /// + /// \param[in] supported_features + /// The bit flags in this parameter are set depending on which + /// WatchpointHardwareFeature enum values the current target supports. + /// The eWatchpointHardwareFeatureUnknown bit may be set if we + /// don't have specific information about what the remote stub + /// can support, and a reasonablec default will be used. + /// + /// \param[in] arch + /// The ArchSpec of the current Target. + /// + /// \return + /// A vector of WatchpointResourceSP's, one per hardware watchpoint + /// register needed. We may return more WatchpointResources than the + /// target can watch at once; if all resources cannot be set, the + /// watchpoint cannot be set. + static std::vector AtomizeWatchpointRequest( + lldb::addr_t addr, size_t size, bool read, bool write, + lldb::WatchpointHardwareFeature supported_features, ArchSpec &arch); + + struct Region { +lldb::addr_t addr; +size_t size; + }; + +protected: + /// Convert a user's watchpoint request into an array of addr+size that + /// can be watched with power-of-2 style hardware watchpoints. + /// + /// This is the default algorithm if we have no further information; + /// most watchpoint implementations can be assumed to be able to watch up + /// to pointer-size regions of memory in power-of-2 sizes and alingments. DavidSpickett wrote: Pointer sized means sizeof(void*) or literally `2^(virtual address bits)-1` sized? alingments -> alignments https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,109 @@ +//===-- WatchpointAlgorithms.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_BREAKPOINT_WATCHPOINTALGORITHMS_H +#define LLDB_BREAKPOINT_WATCHPOINTALGORITHMS_H + +#include "lldb/Breakpoint/WatchpointResource.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/lldb-public.h" + +#include + +namespace lldb_private { + +class WatchpointAlgorithms { + +public: + /// Convert a user's watchpoint request into an array of memory + /// regions that can be watched by one hardware watchpoint register + /// on the current target. + /// + /// \param[in] addr + /// The start address specified by the user. + /// + /// \param[in] size + /// The number of bytes the user wants to watch. + /// + /// \param[in] read + /// True if we are watching for read accesses. + /// + /// \param[in] write + /// True if we are watching for write accesses. + /// \a read and \a write may both be true. + /// There is no "modify" style for WatchpointResources - + /// WatchpointResources are akin to the hardware watchpoint + /// registers which are either in terms of read or write. + /// "modify" distinction is done at the Watchpoint layer, where + /// we check the actual range of bytes the user requested. + /// + /// \param[in] supported_features + /// The bit flags in this parameter are set depending on which + /// WatchpointHardwareFeature enum values the current target supports. + /// The eWatchpointHardwareFeatureUnknown bit may be set if we + /// don't have specific information about what the remote stub + /// can support, and a reasonablec default will be used. + /// + /// \param[in] arch + /// The ArchSpec of the current Target. + /// + /// \return + /// A vector of WatchpointResourceSP's, one per hardware watchpoint + /// register needed. We may return more WatchpointResources than the + /// target can watch at once; if all resources cannot be set, the + /// watchpoint cannot be set. + static std::vector AtomizeWatchpointRequest( + lldb::addr_t addr, size_t size, bool read, bool write, + lldb::WatchpointHardwareFeature supported_features, ArchSpec &arch); + + struct Region { +lldb::addr_t addr; +size_t size; + }; + +protected: + /// Convert a user's watchpoint request into an array of addr+size that + /// can be watched with power-of-2 style hardware watchpoints. + /// + /// This is the default algorithm if we have no further information; + /// most watchpoint implementations can be assumed to be able to watch up + /// to pointer-size regions of memory in power-of-2 sizes and alingments. + /// + /// \param[in] user_addr + /// The user's start address. + /// + /// \param[in] user_size + /// The user's specified byte length. + /// + /// \param[in] min_byte_size + /// The minimum byte size supported on this target. DavidSpickett wrote: Would be helpful to say that this is the minimum byte size *of the range of memory*. Lest anyone think this thing supports architectures where a byte is in fact 8 bytes. https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,142 @@ +//===-- WatchpointAlgorithms.cpp --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Breakpoint/WatchpointAlgorithms.h" +#include "lldb/Breakpoint/WatchpointResource.h" +#include "lldb/Target/Process.h" +#include "lldb/Utility/ArchSpec.h" + +#include +#include + +using namespace lldb; +using namespace lldb_private; + +std::vector +WatchpointAlgorithms::AtomizeWatchpointRequest( +addr_t addr, size_t size, bool read, bool write, +WatchpointHardwareFeature supported_features, ArchSpec &arch) { + + std::vector entries; + + if (supported_features & + WatchpointHardwareFeature::eWatchpointHardwareArmMASK) { +entries = +PowerOf2Watchpoints(addr, size, +/*min_byte_size*/ 1, +/*max_byte_size*/ INT32_MAX, +/*address_byte_size*/ arch.GetAddressByteSize()); + } else { +// As a fallback, assume we can watch any power-of-2 +// number of bytes up through the size of an address in the target. +entries = +PowerOf2Watchpoints(addr, size, +/*min_byte_size*/ 1, +/*max_byte_size*/ arch.GetAddressByteSize(), +/*address_byte_size*/ arch.GetAddressByteSize()); + } DavidSpickett wrote: Seems like it would be simpler to write this as: ``` max_byte_size = 1; if (supported_features & WatchpointHardwareFeature::eWatchpointHardwareArmMASK) max_byte_size = INT32_MAX; std::vector entries = entries = PowerOf2Watchpoints(addr, size, /*min_byte_size=*/ 1, max_byte_size, /*address_byte_size=*/ arch.GetAddressByteSize()); ``` https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,109 @@ +//===-- WatchpointAlgorithms.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_BREAKPOINT_WATCHPOINTALGORITHMS_H +#define LLDB_BREAKPOINT_WATCHPOINTALGORITHMS_H + +#include "lldb/Breakpoint/WatchpointResource.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/lldb-public.h" + +#include + +namespace lldb_private { + +class WatchpointAlgorithms { + +public: + /// Convert a user's watchpoint request into an array of memory + /// regions that can be watched by one hardware watchpoint register + /// on the current target. + /// + /// \param[in] addr + /// The start address specified by the user. + /// + /// \param[in] size + /// The number of bytes the user wants to watch. + /// + /// \param[in] read + /// True if we are watching for read accesses. + /// + /// \param[in] write + /// True if we are watching for write accesses. + /// \a read and \a write may both be true. + /// There is no "modify" style for WatchpointResources - + /// WatchpointResources are akin to the hardware watchpoint + /// registers which are either in terms of read or write. + /// "modify" distinction is done at the Watchpoint layer, where + /// we check the actual range of bytes the user requested. + /// + /// \param[in] supported_features + /// The bit flags in this parameter are set depending on which + /// WatchpointHardwareFeature enum values the current target supports. + /// The eWatchpointHardwareFeatureUnknown bit may be set if we + /// don't have specific information about what the remote stub + /// can support, and a reasonablec default will be used. + /// + /// \param[in] arch + /// The ArchSpec of the current Target. + /// + /// \return + /// A vector of WatchpointResourceSP's, one per hardware watchpoint + /// register needed. We may return more WatchpointResources than the + /// target can watch at once; if all resources cannot be set, the + /// watchpoint cannot be set. + static std::vector AtomizeWatchpointRequest( + lldb::addr_t addr, size_t size, bool read, bool write, + lldb::WatchpointHardwareFeature supported_features, ArchSpec &arch); + + struct Region { +lldb::addr_t addr; +size_t size; + }; + +protected: + /// Convert a user's watchpoint request into an array of addr+size that + /// can be watched with power-of-2 style hardware watchpoints. DavidSpickett wrote: So again, "each of which can be watched with". https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,101 @@ +""" +Watch a large unaligned memory region that +lldb will need multiple hardware watchpoints +to cover. +""" + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class UnalignedLargeWatchpointTestCase(TestBase): +def continue_and_report_stop_reason(self, process, iter_str): +if self.TraceOn(): +self.runCmd("script print('continue')") +process.Continue() +self.assertIn( +process.GetState(), [lldb.eStateStopped, lldb.eStateExited], iter_str +) +thread = process.GetSelectedThread() +return thread.GetStopReason() + +NO_DEBUG_INFO_TESTCASE = True + +# Test on 64-bit targets where we probably have +# four watchpoint registers that can watch doublewords (8-byte). +@skipIf(archs=no_match(["arm64", "arm64e", "aarch64", "x86_64"])) +def test_unaligned_large_watchpoint(self): +"""Test watching an unaligned region of memory that requires multiple watchpoints.""" +self.build() +self.main_source_file = lldb.SBFileSpec("main.c") +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "break here", self.main_source_file +) +self.runCmd("break set -p done") +self.runCmd("break set -p exiting") + +frame = thread.GetFrameAtIndex(0) + +array_addr = frame.GetValueForVariablePath("array").GetValueAsUnsigned() + +# Don't assume that the heap allocated array is aligned +# to a 1024 byte boundary to begin with, force alignment. +# wa_addr = (array_addr + 1024) & ~(1024 - 1) +wa_addr = array_addr + +# Now make the start address unaligned. +wa_addr = wa_addr + 7 + +err = lldb.SBError() +wp_opts = lldb.SBWatchpointOptions() +wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify) +wp = target.WatchpointCreateByAddress(wa_addr, 22, wp_opts, err) +self.assertTrue(wp.IsValid()) +self.assertSuccess(err) +if self.TraceOn(): +self.runCmd("watch list -v") + +c_count = 0 +reason = self.continue_and_report_stop_reason(process, "continue #%d" % c_count) +while reason == lldb.eStopReasonWatchpoint: +c_count = c_count + 1 +reason = self.continue_and_report_stop_reason( +process, "continue #%d" % c_count +) +self.assertLessEqual(c_count, 22) + +self.assertEqual(c_count, 22) +self.expect("watchpoint list -v", substrs=["hit_count = 22"]) +self.assertEqual(wp.GetHitCount(), 22) + +target.DeleteWatchpoint(wp.GetID()) + +# Now try watching a 16 byte variable +# (not unaligned, but a good check to do anyway) +# +frame = thread.GetFrameAtIndex(0) +err = lldb.SBError() +wp = frame.locals["variable"][0].Watch(True, False, True, err) DavidSpickett wrote: What are the bools here doing? https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,101 @@ +""" +Watch a large unaligned memory region that +lldb will need multiple hardware watchpoints +to cover. +""" + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class UnalignedLargeWatchpointTestCase(TestBase): +def continue_and_report_stop_reason(self, process, iter_str): +if self.TraceOn(): +self.runCmd("script print('continue')") +process.Continue() +self.assertIn( +process.GetState(), [lldb.eStateStopped, lldb.eStateExited], iter_str +) +thread = process.GetSelectedThread() +return thread.GetStopReason() + +NO_DEBUG_INFO_TESTCASE = True + +# Test on 64-bit targets where we probably have +# four watchpoint registers that can watch doublewords (8-byte). +@skipIf(archs=no_match(["arm64", "arm64e", "aarch64", "x86_64"])) +def test_unaligned_large_watchpoint(self): +"""Test watching an unaligned region of memory that requires multiple watchpoints.""" +self.build() +self.main_source_file = lldb.SBFileSpec("main.c") +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "break here", self.main_source_file +) +self.runCmd("break set -p done") +self.runCmd("break set -p exiting") + +frame = thread.GetFrameAtIndex(0) + +array_addr = frame.GetValueForVariablePath("array").GetValueAsUnsigned() + +# Don't assume that the heap allocated array is aligned +# to a 1024 byte boundary to begin with, force alignment. +# wa_addr = (array_addr + 1024) & ~(1024 - 1) +wa_addr = array_addr + +# Now make the start address unaligned. +wa_addr = wa_addr + 7 + +err = lldb.SBError() +wp_opts = lldb.SBWatchpointOptions() +wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify) +wp = target.WatchpointCreateByAddress(wa_addr, 22, wp_opts, err) +self.assertTrue(wp.IsValid()) +self.assertSuccess(err) +if self.TraceOn(): +self.runCmd("watch list -v") + +c_count = 0 +reason = self.continue_and_report_stop_reason(process, "continue #%d" % c_count) +while reason == lldb.eStopReasonWatchpoint: +c_count = c_count + 1 +reason = self.continue_and_report_stop_reason( +process, "continue #%d" % c_count +) +self.assertLessEqual(c_count, 22) + +self.assertEqual(c_count, 22) +self.expect("watchpoint list -v", substrs=["hit_count = 22"]) +self.assertEqual(wp.GetHitCount(), 22) + +target.DeleteWatchpoint(wp.GetID()) + +# Now try watching a 16 byte variable +# (not unaligned, but a good check to do anyway) +# DavidSpickett wrote: stray # https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -352,6 +358,20 @@ void Watchpoint::DumpWithLevel(Stream *s, s->Printf("\ndeclare @ '%s'", m_decl_str.c_str()); if (!m_watch_spec_str.empty()) s->Printf("\nwatchpoint spec = '%s'", m_watch_spec_str.c_str()); +if (IsEnabled()) { + if (ProcessSP process_sp = m_target.GetProcessSP()) { +auto &resourcelist = process_sp->GetWatchpointResourceList(); +size_t idx = 0; +s->Printf("\nwatchpoint resources:"); +for (WatchpointResourceSP &wpres : resourcelist.Sites()) { DavidSpickett wrote: Could `llvm::enumerate` this. https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -448,6 +448,32 @@ enum WatchpointWriteType { eWatchpointWriteTypeOnModify }; +/// The hardware and native stub capabilities for a given target, +/// for translating a user's watchpoint request into hardware +/// capable watchpoint resources. +FLAGS_ENUM(WatchpointHardwareFeature){ +/// lldb will fall back to a default that assumes the target +/// can watch up to pointer-size power-of-2 regions, aligned to +/// power-of-2. +eWatchpointHardwareFeatureUnknown = (1u << 0), + +/// Intel systems can watch 1, 2, 4, or 8 bytes (in 64-bit targets), DavidSpickett wrote: "on 64 bit targets"? In sounds off like the watched region is inside something else. https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,109 @@ +//===-- WatchpointAlgorithms.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_BREAKPOINT_WATCHPOINTALGORITHMS_H +#define LLDB_BREAKPOINT_WATCHPOINTALGORITHMS_H + +#include "lldb/Breakpoint/WatchpointResource.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/lldb-public.h" + +#include + +namespace lldb_private { + +class WatchpointAlgorithms { + +public: + /// Convert a user's watchpoint request into an array of memory + /// regions that can be watched by one hardware watchpoint register + /// on the current target. + /// + /// \param[in] addr + /// The start address specified by the user. + /// + /// \param[in] size + /// The number of bytes the user wants to watch. + /// + /// \param[in] read + /// True if we are watching for read accesses. + /// + /// \param[in] write + /// True if we are watching for write accesses. + /// \a read and \a write may both be true. + /// There is no "modify" style for WatchpointResources - + /// WatchpointResources are akin to the hardware watchpoint + /// registers which are either in terms of read or write. + /// "modify" distinction is done at the Watchpoint layer, where + /// we check the actual range of bytes the user requested. + /// + /// \param[in] supported_features + /// The bit flags in this parameter are set depending on which + /// WatchpointHardwareFeature enum values the current target supports. + /// The eWatchpointHardwareFeatureUnknown bit may be set if we + /// don't have specific information about what the remote stub + /// can support, and a reasonablec default will be used. + /// + /// \param[in] arch + /// The ArchSpec of the current Target. + /// + /// \return + /// A vector of WatchpointResourceSP's, one per hardware watchpoint + /// register needed. We may return more WatchpointResources than the + /// target can watch at once; if all resources cannot be set, the + /// watchpoint cannot be set. + static std::vector AtomizeWatchpointRequest( + lldb::addr_t addr, size_t size, bool read, bool write, + lldb::WatchpointHardwareFeature supported_features, ArchSpec &arch); + + struct Region { +lldb::addr_t addr; +size_t size; + }; DavidSpickett wrote: Looks a lot like `Range` from `lldb/include/lldb/Utility/RangeMap.h`. If any of the existing methods on that seem useful, consider using that. (though iirc, it does get cumbersome at times) https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -113,7 +114,8 @@ bool WatchpointResource::ShouldStop(StoppointCallbackContext *context) { } void WatchpointResource::Dump(Stream *s) const { - return; // LWP_TODO + s->Printf("addr = 0x%8.8" PRIx64 " size = %zu", m_addr, m_size); + return; DavidSpickett wrote: Don't need a return, unless this thing is supposed to return something? https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
@@ -0,0 +1,101 @@ +""" +Watch a large unaligned memory region that +lldb will need multiple hardware watchpoints +to cover. +""" + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class UnalignedLargeWatchpointTestCase(TestBase): +def continue_and_report_stop_reason(self, process, iter_str): +if self.TraceOn(): +self.runCmd("script print('continue')") +process.Continue() +self.assertIn( +process.GetState(), [lldb.eStateStopped, lldb.eStateExited], iter_str +) +thread = process.GetSelectedThread() +return thread.GetStopReason() + +NO_DEBUG_INFO_TESTCASE = True + +# Test on 64-bit targets where we probably have +# four watchpoint registers that can watch doublewords (8-byte). +@skipIf(archs=no_match(["arm64", "arm64e", "aarch64", "x86_64"])) +def test_unaligned_large_watchpoint(self): +"""Test watching an unaligned region of memory that requires multiple watchpoints.""" +self.build() +self.main_source_file = lldb.SBFileSpec("main.c") +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "break here", self.main_source_file +) +self.runCmd("break set -p done") +self.runCmd("break set -p exiting") + +frame = thread.GetFrameAtIndex(0) + +array_addr = frame.GetValueForVariablePath("array").GetValueAsUnsigned() + +# Don't assume that the heap allocated array is aligned +# to a 1024 byte boundary to begin with, force alignment. +# wa_addr = (array_addr + 1024) & ~(1024 - 1) +wa_addr = array_addr + +# Now make the start address unaligned. +wa_addr = wa_addr + 7 + +err = lldb.SBError() +wp_opts = lldb.SBWatchpointOptions() +wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify) +wp = target.WatchpointCreateByAddress(wa_addr, 22, wp_opts, err) +self.assertTrue(wp.IsValid()) +self.assertSuccess(err) +if self.TraceOn(): +self.runCmd("watch list -v") + +c_count = 0 +reason = self.continue_and_report_stop_reason(process, "continue #%d" % c_count) +while reason == lldb.eStopReasonWatchpoint: +c_count = c_count + 1 +reason = self.continue_and_report_stop_reason( +process, "continue #%d" % c_count +) +self.assertLessEqual(c_count, 22) + +self.assertEqual(c_count, 22) +self.expect("watchpoint list -v", substrs=["hit_count = 22"]) +self.assertEqual(wp.GetHitCount(), 22) DavidSpickett wrote: This could go in some `expected_watchpoint_hits(self, n)` function and be called below as well. https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Implement WebAssembly debugging (PR #77949)
mh4ck-Thales wrote: > On the other hand, as a managed language, I think most people won't need to > read specific local/global of an instance, just like most of the JavaScript > developer won't care about the value of a register in V8 during debugging, > they just care about the value of their variables. I agree that the average developer will not have much use of the possibility of accessing Wasm locals and globals. I also understand that Wasm locals and global are a very specific, Wasm-only concept and that adding this concept in LLVM core is not pertinent. However for people working on the inner workings of Wasm (like me), it may be very useful. I'm not sure it belongs to this PR but implementing support for accessing Wasm locals/globals in the future (using perhaps a command like `language wasm`) seems an interesting thing to do to complete the debugging experience on Wasm with lldb. What I'm wondering is, does these potential added commands have an impact on this PR ? Or can we imagine commands that will send a specific, Wasm-only request to the debugging server to get the values of the variables without using the implementation of locals and globals of this PR ? https://github.com/llvm/llvm-project/pull/77949 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Don't cause a premature UpdateIfNeeded when checking in SBValue::GetSP (PR #80222)
@@ -114,21 +114,26 @@ class ValueImpl { lldb::ValueObjectSP value_sp = m_valobj_sp; Target *target = value_sp->GetTargetSP().get(); -// If this ValueObject holds an error, then it is valuable for that. -if (value_sp->GetError().Fail()) - return value_sp; - -if (!target) +if (!target) { + // If we can't get the target, the error might still be useful: + if (value_sp->CheckError().Fail()) +return value_sp; adrian-prantl wrote: Doesn't whatever call site this is returned to now also need to call the new non-updating API to surface it to the user? https://github.com/llvm/llvm-project/pull/80222 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Don't cause a premature UpdateIfNeeded when checking in SBValue::GetSP (PR #80222)
@@ -458,7 +458,12 @@ class ValueObject { virtual bool GetDeclaration(Declaration &decl); // The functions below should NOT be modified by subclasses + // This gets the current error for this ValueObject, it may update the value + // to ensure that the error is up to date. const Status &GetError(); + + // Check the current error state without updating the value: adrian-prantl wrote: `///` https://github.com/llvm/llvm-project/pull/80222 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFIndex] Use IDX_parent to implement GetFullyQualifiedType query (PR #79932)
adrian-prantl wrote: > I've added a log message with the `Error` itself being logged as well Thanks! I wasted half a day stepping through the DWARF parser recently, thinking I'm debugging a parser bug, when it was really invalid DWARF produced by an older version of dsymutil, so even just the information that there _was_ a parse error is very useful. https://github.com/llvm/llvm-project/pull/79932 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e0e6236 - Fix debug info size statistics for split dwarf (#80218)
Author: jeffreytan81 Date: 2024-02-01T09:11:25-08:00 New Revision: e0e6236fd61f906f8529dcaa8ecd0beec1f5a18a URL: https://github.com/llvm/llvm-project/commit/e0e6236fd61f906f8529dcaa8ecd0beec1f5a18a DIFF: https://github.com/llvm/llvm-project/commit/e0e6236fd61f906f8529dcaa8ecd0beec1f5a18a.diff LOG: Fix debug info size statistics for split dwarf (#80218) `statistics dump` command relies on `SymbolFile::GetDebugInfoSize()` to get total debug info size. The current implementation is missing debug info for split dwarf scenarios which requires getting debug info from separate dwo/dwp files. This patch fixes this issue for split dwarf by parsing debug info from dwp/dwo. New yaml tests are added. - Co-authored-by: jeffreytan81 Added: lldb/test/API/commands/target/debuginfo/TestDebugInfoSize.py lldb/test/API/commands/target/debuginfo/a.out-foo.dwo.yaml lldb/test/API/commands/target/debuginfo/a.out-main.dwo.yaml lldb/test/API/commands/target/debuginfo/a.out.yaml Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index fed97858c83f8..7ab75a9ce2c6b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2667,6 +2667,29 @@ static bool UpdateCompilerContextForSimpleTemplateNames(TypeQuery &match) { } return any_context_updated; } + +uint64_t SymbolFileDWARF::GetDebugInfoSize() { + DWARFDebugInfo &info = DebugInfo(); + uint32_t num_comp_units = info.GetNumUnits(); + + uint64_t debug_info_size = SymbolFileCommon::GetDebugInfoSize(); + // In dwp scenario, debug info == skeleton debug info + dwp debug info. + if (std::shared_ptr dwp_sp = GetDwpSymbolFile()) +return debug_info_size + dwp_sp->GetDebugInfoSize(); + + // In dwo scenario, debug info == skeleton debug info + all dwo debug info. + for (uint32_t i = 0; i < num_comp_units; i++) { +DWARFUnit *cu = info.GetUnitAtIndex(i); +if (cu == nullptr) + continue; + +SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(); +if (dwo) + debug_info_size += dwo->GetDebugInfoSize(); + } + return debug_info_size; +} + void SymbolFileDWARF::FindTypes(const TypeQuery &query, TypeResults &results) { // Make sure we haven't already searched this SymbolFile before. diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 26a9502f90aa0..6d87530acf833 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -186,6 +186,8 @@ class SymbolFileDWARF : public SymbolFileCommon { GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector &mangled_names) override; + uint64_t GetDebugInfoSize() override; + void FindTypes(const lldb_private::TypeQuery &match, lldb_private::TypeResults &results) override; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp index ca698a84a9146..b52cb514fb190 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -85,6 +85,17 @@ lldb::offset_t SymbolFileDWARFDwo::GetVendorDWARFOpcodeSize( return GetBaseSymbolFile().GetVendorDWARFOpcodeSize(data, data_offset, op); } +uint64_t SymbolFileDWARFDwo::GetDebugInfoSize() { + // Directly get debug info from current dwo object file's section list + // instead of asking SymbolFileCommon::GetDebugInfo() which parses from + // owning module which is wrong. + SectionList *section_list = + m_objfile_sp->GetSectionList(/*update_module_section_list=*/false); + if (section_list) +return section_list->GetDebugInfoSize(); + return 0; +} + bool SymbolFileDWARFDwo::ParseVendorDWARFOpcode( uint8_t op, const lldb_private::DataExtractor &opcodes, lldb::offset_t &offset, std::vector &stack) const { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h index 9f5950e51b0c1..5c4b36328cbac 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -47,6 +47,8 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF { const lldb::offset_t data_offset, const uint8_t op) const override; + uint64_t
[Lldb-commits] [lldb] Fix debug info size statistics for split dwarf (PR #80218)
https://github.com/jeffreytan81 closed https://github.com/llvm/llvm-project/pull/80218 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libcxx] [flang] [llvm] [mlir] [lldb] [libc] [mlir] Skip invalid test on big endian platform (s390x) (PR #80246)
https://github.com/Lewuathe updated https://github.com/llvm/llvm-project/pull/80246 >From e4bfaa1c07a96b9c78bb64368f5b65c49feb4bd7 Mon Sep 17 00:00:00 2001 From: Kai Sasaki Date: Thu, 1 Feb 2024 15:33:00 +0900 Subject: [PATCH 1/2] [mlir] Skip invalid test on big endian platform (s390x) --- mlir/test/Target/LLVMIR/llvmir.mlir | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir index 448aa3a5d85d7..816f6dd03aad7 100644 --- a/mlir/test/Target/LLVMIR/llvmir.mlir +++ b/mlir/test/Target/LLVMIR/llvmir.mlir @@ -1,5 +1,8 @@ // RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s +// Decoding the attribute does not work on big-endian platforms currently +// XFAIL: target=s390x-{{.*}} + // CHECK: @global_aligned32 = private global i64 42, align 32 "llvm.mlir.global"() ({}) {sym_name = "global_aligned32", global_type = i64, value = 42 : i64, linkage = #llvm.linkage, alignment = 32} : () -> () >From 5a468695bf30aa31b9f85f5816b71d3fdde0595a Mon Sep 17 00:00:00 2001 From: Kai Sasaki Date: Thu, 1 Feb 2024 20:08:15 +0900 Subject: [PATCH 2/2] [mlir] Split the LE specific test cases --- .../Target/LLVMIR/llvmir-le-specific.mlir | 27 +++ mlir/test/Target/LLVMIR/llvmir.mlir | 26 -- 2 files changed, 27 insertions(+), 26 deletions(-) create mode 100644 mlir/test/Target/LLVMIR/llvmir-le-specific.mlir diff --git a/mlir/test/Target/LLVMIR/llvmir-le-specific.mlir b/mlir/test/Target/LLVMIR/llvmir-le-specific.mlir new file mode 100644 index 0..f8d082082117c --- /dev/null +++ b/mlir/test/Target/LLVMIR/llvmir-le-specific.mlir @@ -0,0 +1,27 @@ +// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s + +// Decoding the attribute does not work on big-endian platforms currently +// XFAIL: target=s390x-{{.*}} + +// CHECK{LITERAL}: @dense_resource_tensor_constant = internal constant [5 x float] [float 0x3FCA03408000, float 0xBFD04663, float 0xBFD75DDF8000, float 0xBFDE074F4000, float 0x3FDDD3A1C000] +llvm.mlir.global internal constant @dense_resource_tensor_constant(dense_resource : tensor<5xf32>) : !llvm.array<5 x f32> + +// CHECK{LITERAL}: @dense_resource_vector_constant = internal constant <5 x float> +llvm.mlir.global internal constant @dense_resource_vector_constant(dense_resource : vector<5xf32>) : vector<5xf32> + + +// CHECK{LITERAL}: @dense_resource_multidim_tensor_constant = internal constant [1 x [2 x [2 x float]]] [[2 x [2 x float]] [[2 x float] [float 0x3FD6B46A8000, float 0x3FD6781AC000], [2 x float] [float 0xBFB45A2AA000, float 0x3FD77A5CA000]]] +llvm.mlir.global internal constant @dense_resource_multidim_tensor_constant(dense_resource : tensor<1x2x2xf32>) : !llvm.array<1 x !llvm.array<2 x !llvm.array<2 x f32>>> + +// CHECK{LITERAL}: @dense_resource_multidim_vector_constant = internal constant [1 x [2 x <2 x float>]] [[2 x <2 x float>] [<2 x float> , <2 x float> ]] +llvm.mlir.global internal constant @dense_resource_multidim_vector_constant(dense_resource : vector<1x2x2xf32>) : !llvm.array<1 x !llvm.array<2 x vector<2 x f32>>> + +// Resources are kept at end of file. New tests should be added above this. +{-# + dialect_resources: { +builtin: { + dense_resource_test_5xf32: "0x0800041A503E183382BEFCEEBABE7A3AF0BE0E9DEE3E", + dense_resource_test_2x2xf32: "0x080054A3B53ED6C0B33E55D1A2BDE5D2BB3E" +} + } +#-} \ No newline at end of file diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir index 816f6dd03aad7..961c948444684 100644 --- a/mlir/test/Target/LLVMIR/llvmir.mlir +++ b/mlir/test/Target/LLVMIR/llvmir.mlir @@ -1,8 +1,5 @@ // RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s -// Decoding the attribute does not work on big-endian platforms currently -// XFAIL: target=s390x-{{.*}} - // CHECK: @global_aligned32 = private global i64 42, align 32 "llvm.mlir.global"() ({}) {sym_name = "global_aligned32", global_type = i64, value = 42 : i64, linkage = #llvm.linkage, alignment = 32} : () -> () @@ -104,19 +101,6 @@ llvm.mlir.global internal @dense_float_vector_3d(dense<[[[1.0, 2.0], [3.0, 4.0]] // CHECK{LITERAL}: @splat_float_vector_3d = internal global [2 x [2 x <2 x float>]] [[2 x <2 x float>] [<2 x float> , <2 x float> ], [2 x <2 x float>] [<2 x float> , <2 x float> ]] llvm.mlir.global internal @splat_float_vector_3d(dense<42.0> : vector<2x2x2xf32>) : !llvm.array<2 x !llvm.array<2 x vector<2xf32>>> -// CHECK{LITERAL}: @dense_resource_tensor_constant = internal constant [5 x float] [float 0x3FCA03408000, float 0xBFD04663, float 0xBFD75DDF8000, float 0xBFDE074F4000, float 0x3FDDD3A1C000] -llvm.mlir.global internal constant @dense_resource_tensor_constant(dense_resource : tensor<5xf32>) : !llvm.array<5 x f32> - -// CHECK{LITERAL}: @dense_resource_vector_constant
[Lldb-commits] [clang] [llvm] [libc] [clang-tools-extra] [libcxx] [lldb] [flang] [RISCV] Support constraint "s" (PR #80201)
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/80201 >From 7e9a74f18904f689d76bb2ea06ddf5f30d651b5e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 31 Jan 2024 13:39:13 -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 --- clang/lib/Basic/Targets/RISCV.cpp | 3 +- clang/test/CodeGen/RISCV/riscv-inline-asm.c | 16 +++- clang/test/Sema/inline-asm-validate-riscv.c | 8 ++ llvm/docs/LangRef.rst | 3 +- llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 9 +-- .../CodeGen/RISCV/inline-asm-S-constraint.ll | 54 - .../RISCV/inline-asm-s-constraint-error.ll| 14 .../CodeGen/RISCV/inline-asm-s-constraint.ll | 76 +++ 8 files changed, 116 insertions(+), 67 deletions(-) delete mode 100644 llvm/test/CodeGen/RISCV/inline-asm-S-constraint.ll create mode 100644 llvm/test/CodeGen/RISCV/inline-asm-s-constraint-error.ll create mode 100644 llvm/test/CodeGen/RISCV/inline-asm-s-constraint.ll diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp index c71b2e9eeb6c1..837a6e799e3a9 100644 --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -96,7 +96,8 @@ bool RISCVTargetInfo::validateAsmConstraint( // An address that is held in a general-purpose register. Info.setAllowsMemory(); return true; - case 'S': // A symbolic address + case 's': + case 'S': // A symbol or label reference with a constant offset Info.setAllowsRegister(); return true; case 'v': diff --git a/clang/test/CodeGen/RISCV/riscv-inline-asm.c b/clang/test/CodeGen/RISCV/riscv-inline-asm.c index 48de5ba3a27e3..3565705dea713 100644 --- a/clang/test/CodeGen/RISCV/riscv-inline-asm.c +++ b/clang/test/CodeGen/RISCV/riscv-inline-asm.c @@ -45,8 +45,16 @@ void test_A(int *p) { asm volatile("" :: "A"(*p)); } -void test_S(void) { -// CHECK-LABEL: define{{.*}} void @test_S() -// CHECK: call void asm sideeffect "", "S"(ptr nonnull @f) - asm volatile("" :: "S"(&f)); +extern int var, arr[2][2]; +struct Pair { int a, b; } pair; + +// CHECK-LABEL: test_s( +// CHECK: call void asm sideeffect "// $0 $1 $2", "s,s,s"(ptr nonnull @var, ptr nonnull getelementptr inbounds ([2 x [2 x i32]], ptr @arr, {{.*}}), ptr nonnull @test_s) +// CHECK: call void asm sideeffect "// $0", "s"(ptr nonnull getelementptr inbounds (%struct.Pair, ptr @pair, {{.*}})) +// CHECK: call void asm sideeffect "// $0 $1 $2", "S,S,S"(ptr nonnull @var, ptr nonnull getelementptr inbounds ([2 x [2 x i32]], ptr @arr, {{.*}}), ptr nonnull @test_s) +void test_s(void) { + asm("// %0 %1 %2" :: "s"(&var), "s"(&arr[1][1]), "s"(test_s)); + asm("// %0" :: "s"(&pair.b)); + + asm("// %0 %1 %2" :: "S"(&var), "S"(&arr[1][1]), "S"(test_s)); } diff --git a/clang/test/Sema/inline-asm-validate-riscv.c b/clang/test/Sema/inline-asm-validate-riscv.c index 43a5378bc3f25..806ef60dacbec 100644 --- a/clang/test/Sema/inline-asm-validate-riscv.c +++ b/clang/test/Sema/inline-asm-validate-riscv.c @@ -22,6 +22,14 @@ void K(int k) { asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of range for constraint 'K'}} } +void test_s(int i) { + asm("" :: "s"(test_s(0))); // expected-error{{invalid type 'void' in asm input for constraint 's'}} + /// Codegen error + asm("" :: "s"(i)); + + asm("" :: "S"(test_s(0))); // expected-error{{invalid type 'void' in asm input for constraint 'S'}} +} + void test_clobber_conflict(void) { register long x10 asm("x10"); asm volatile("" :: "r"(x10) : "x10"); // expected-error {{conflicts with asm clobber list}} diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 7a7ddc59ba985..3648ea2611dd4 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5075,7 +5075,7 @@ Some constraint codes are typically supported by all targets: - ``i``: An integer constant (of target-specific width). Allows either a simple immediate, or a relocatable value. - ``n``: An integer constant -- *not* including relocatable values. -- ``s``: An integer constant, but allowing *only* relocatable values. +- ``s``: A symbol or label reference with a constant offset. - ``X``: Allows an operand of any kind, no constraint whatsoever. Typically useful to pass a label for an asm branch or call. @@ -5283,6 +5283,7 @@ RISC-V: - ``f``: A 32- or 64-bit floating-point register (requires F or D extension). - ``r``: A 32- or 64-bit general-purpose register (depending on the platform ``XLEN``). +- ``S``: Alias for ``s``. - ``vr``: A vector register. (requires V extension). - ``vm``: A vector register for masking operand. (requires V extension). diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index b8994e7b7bdb2
[Lldb-commits] [clang] [llvm] [libc] [clang-tools-extra] [libcxx] [lldb] [flang] [RISCV] Support constraint "s" (PR #80201)
@@ -0,0 +1,76 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -relocation-model=static < %s | FileCheck %s --check-prefix=RV32 +; RUN: llc -mtriple=riscv64 -relocation-model=pic < %s | FileCheck %s --check-prefix=RV64 + +@var = external dso_local global i32, align 4 +@a = external global [2 x [2 x i32]], align 4 + +define dso_local void @test() { +; CHECK-LABEL: test: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT:#APP +; CHECK-NEXT:# var a+12 test +; CHECK-NEXT:#NO_APP +; CHECK-NEXT:ret{{[l|q]}} MaskRay wrote: Thanks for catching this. Removed https://github.com/llvm/llvm-project/pull/80201 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (PR #80167)
@@ -1305,6 +1305,14 @@ enum CompletionType { eTerminatorCompletion = (1ul << 27) }; +/// Specifies if children need to be re-computed +/// after a call to \ref SyntheticChildrenFrontEnd::Update. +enum class ChildCacheState { + eDynamic = 0, ///< Children need to be recomputed dynamically. + eConstant = + 1, ///< Children will never change and don't need to be recomputed. kastiglione wrote: Is `eConstant` really constant? In other words, if `Update()` returns `eConstant` the first time, will it always return `eConstant` every other invocation? If not, then I would like to see a different name/names. Do you find issue with the verb approach I suggested? https://github.com/llvm/llvm-project/pull/80167 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [flang] [llvm] [libc] [openmp] [lldb] [mlir] [libcxx] Add security group 2023 transparency report. (PR #80272)
smithp35 wrote: Apologies managed to mess up my branch when trying to fix the typo. I'll try and fix. https://github.com/llvm/llvm-project/pull/80272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [openmp] [libc] [llvm] [libcxx] [clang] [mlir] [flang] [lldb] Add security group 2023 transparency report. (PR #80272)
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 f34418c73b718abb24cd5b921b5a2846011e7d0c 7d2c1eb97abf162522d030f9dfe9e281758f24b3 -- bolt/include/bolt/Core/BinaryContext.h bolt/include/bolt/Rewrite/RewriteInstance.h bolt/lib/Passes/BinaryPasses.cpp bolt/lib/Profile/StaleProfileMatching.cpp bolt/lib/Profile/YAMLProfileReader.cpp bolt/lib/Rewrite/RewriteInstance.cpp clang/include/clang/AST/DeclTemplate.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTContext.cpp clang/lib/AST/DeclTemplate.cpp clang/lib/Basic/Targets/AArch64.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Format/UnwrappedLineParser.cpp clang/lib/Parse/ParseDecl.cpp clang/lib/Parse/ParseDeclCXX.cpp clang/lib/Parse/ParseTemplate.cpp clang/lib/Parse/Parser.cpp clang/lib/Sema/SemaConcept.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/test/CXX/temp/p3.cpp clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_zero.c clang/test/CodeGen/aarch64-targetattr.c clang/test/Modules/aarch64-sme-keywords.cppm clang/test/OpenMP/declare_simd_messages.cpp clang/test/Preprocessor/aarch64-target-features.c clang/test/SemaCXX/datasizeof.cpp clang/unittests/Format/TokenAnnotatorTest.cpp flang/lib/Lower/ConvertCall.cpp libc/src/errno/libc_errno.cpp libc/src/errno/libc_errno.h libc/test/integration/startup/linux/tls_test.cpp libc/test/src/errno/errno_test.cpp libc/test/src/stdlib/StrtolTest.h libc/test/src/sys/mman/linux/madvise_test.cpp libc/test/src/sys/mman/linux/mlock_test.cpp libc/test/src/sys/mman/linux/mmap_test.cpp libc/test/src/sys/mman/linux/mprotect_test.cpp libc/test/src/sys/mman/linux/posix_madvise_test.cpp libc/test/src/time/asctime_r_test.cpp libc/test/src/time/asctime_test.cpp libcxx/include/__memory/allocate_at_least.h libcxx/include/__memory/allocator_traits.h libcxx/include/memory libcxx/include/version libcxx/modules/std/memory.inc libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.compile.pass.cpp libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h llvm/include/llvm/DebugInfo/DIContext.h llvm/include/llvm/DebugInfo/DWARF/DWARFVerifier.h llvm/include/llvm/MC/MCDisassembler/MCDisassembler.h llvm/include/llvm/Object/ELFObjectFile.h llvm/include/llvm/TargetParser/AArch64TargetParser.h llvm/lib/CodeGen/MIRPrinter.cpp llvm/lib/DebugInfo/DWARF/DWARFContext.cpp llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp llvm/lib/IR/Verifier.cpp llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp llvm/lib/Target/AArch64/SMEABIPass.cpp llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.cpp llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.h llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h llvm/lib/Target/AMDGPU/R600TargetMachine.cpp llvm/lib/Target/AMDGPU/R600TargetMachine.h llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp llvm/lib/Target/X86/X86FixupVectorConstants.cpp llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp llvm/tools/llvm-objdump/llvm-objdump.cpp llvm/unittests/Target/AArch64/SMEAttributesTest.cpp llvm/unittests/TargetParser/TargetParserTest.cpp mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp mlir/lib/Target/LLVMIR/ModuleImport.cpp mlir/lib/Target/LLVMIR/ModuleTranslation.cpp libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_at_least.pass.cpp `` View the diff from clang-format here. ``diff diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index 6a3710407b..aa7366a87b 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -7621,7 +7621,8 @@ static void foldADDIForLocalExecAccesses(SDNode *N, SelectionDAG *DAG) { // access. The first operand of InitialADDI shou
[Lldb-commits] [libc] [llvm] [libcxx] [clang-tools-extra] [clang] [flang] [lldb] [RISCV] Support constraint "s" (PR #80201)
https://github.com/MaskRay closed https://github.com/llvm/llvm-project/pull/80201 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lld] [libc] [compiler-rt] [llvm] [clang-tools-extra] [libcxx] [clang] [flang] [lldb] Make clang report invalid target versions for all environment types. (PR #78655)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/78655 >From f440f44e7e270d4636ad39f4e4223c904e496d3a Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Fri, 19 Jan 2024 00:47:05 + Subject: [PATCH 1/5] Make clang report invalid target versions for all environment. Followup for https://github.com/llvm/llvm-project/pull/75373 1. Make this feature not just available for android, but everyone. 2. Correct some target triples/ 3. Add opencl to the environment type list. --- clang/lib/Driver/Driver.cpp | 19 ++- clang/test/CodeGen/fp128_complex.c | 2 +- clang/test/Driver/mips-features.c| 4 ++-- clang/test/Frontend/fixed_point_bit_widths.c | 4 ++-- llvm/include/llvm/TargetParser/Triple.h | 2 +- llvm/lib/TargetParser/Triple.cpp | 14 ++ 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 1889ea28079df..2d6986d145483 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1430,15 +1430,16 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { const ToolChain &TC = getToolChain( *UArgs, computeTargetTriple(*this, TargetTriple, *UArgs)); - if (TC.getTriple().isAndroid()) { -llvm::Triple Triple = TC.getTriple(); -StringRef TripleVersionName = Triple.getEnvironmentVersionString(); - -if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "") { - Diags.Report(diag::err_drv_triple_version_invalid) - << TripleVersionName << TC.getTripleString(); - ContainsError = true; -} + // Check if the environment version is valid. + llvm::Triple Triple = TC.getTriple(); + StringRef TripleVersionName = Triple.getEnvironmentVersionString(); + StringRef TripleObjectFormat = Triple.getObjectFormatTypeName(Triple.getObjectFormat()); + + if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "" +&& TripleVersionName != TripleObjectFormat) { +Diags.Report(diag::err_drv_triple_version_invalid) +<< TripleVersionName << TC.getTripleString(); +ContainsError = true; } // Report warning when arm64EC option is overridden by specified target diff --git a/clang/test/CodeGen/fp128_complex.c b/clang/test/CodeGen/fp128_complex.c index 48659d2241684..0e87cbe8ce812 100644 --- a/clang/test/CodeGen/fp128_complex.c +++ b/clang/test/CodeGen/fp128_complex.c @@ -1,4 +1,4 @@ -// RUN: %clang -target aarch64-linux-gnuabi %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -target aarch64-linux-gnueabi %s -S -emit-llvm -o - | FileCheck %s _Complex long double a, b, c, d; void test_fp128_compound_assign(void) { diff --git a/clang/test/Driver/mips-features.c b/clang/test/Driver/mips-features.c index fad6009ffb89b..18edcd05ea85c 100644 --- a/clang/test/Driver/mips-features.c +++ b/clang/test/Driver/mips-features.c @@ -400,12 +400,12 @@ // LONG-CALLS-DEF-NOT: "long-calls" // // -mbranch-likely -// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ +// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ // RUN: | FileCheck --check-prefix=BRANCH-LIKELY %s // BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely' // // -mno-branch-likely -// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ +// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ // RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s // NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' diff --git a/clang/test/Frontend/fixed_point_bit_widths.c b/clang/test/Frontend/fixed_point_bit_widths.c index ac8db49ed516a..e56f787e824f2 100644 --- a/clang/test/Frontend/fixed_point_bit_widths.c +++ b/clang/test/Frontend/fixed_point_bit_widths.c @@ -1,7 +1,7 @@ // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - %s | FileCheck %s -// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-ubuntu-fast %s | FileCheck %s +// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4 %s | FileCheck %s // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=ppc64 %s | FileCheck %s -// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-windows10pro-fast %s | FileCheck %s +// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4 %s | FileCheck %s /* Primary signed _Accum */ diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index 95014a546f724..525ea6df3643c 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -273,7 +273,7 @@ class Triple { Callable, Mesh, Amplification, - +OpenCL, OpenHOS, LastEnvironmentType = OpenHOS diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index b9971c25
[Lldb-commits] [lldb] [openmp] [libcxx] [mlir] [clang] [libc] [llvm] [flang] Add security group 2023 transparency report. (PR #80272)
https://github.com/smithp35 closed https://github.com/llvm/llvm-project/pull/80272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [openmp] [libcxx] [mlir] [clang] [libc] [llvm] [flang] Add security group 2023 transparency report. (PR #80272)
smithp35 wrote: Apologies I'll send a new pull request with the typo fixed. Probably the fastest thing to do than trying to get my local branch back into the same state to recreate the additional commit. https://github.com/llvm/llvm-project/pull/80272 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [libcxx] [lld] [clang] [libc] [llvm] [compiler-rt] [flang] Make clang report invalid target versions for all environment types. (PR #78655)
@@ -1219,8 +1222,24 @@ VersionTuple Triple::getEnvironmentVersion() const { StringRef Triple::getEnvironmentVersionString() const { StringRef EnvironmentName = getEnvironmentName(); + + // none is a valid environment type - it basically amounts to a freestanding + // environment. + if (EnvironmentName == "none") +return ""; + StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment()); EnvironmentName.consume_front(EnvironmentTypeName); + + if (EnvironmentName.contains("-")) { +// -obj is the suffix +if (getObjectFormat() != Triple::UnknownObjectFormat) { + StringRef ObjectFormatTypeName = + getObjectFormatTypeName(getObjectFormat()); + StringRef Suffix = (Twine("-") + ObjectFormatTypeName).str(); MaskRay wrote: This creates a temporary `std::string` and binds it on a StringRef. The temporary `std::string` is then destroyed, leading to a dangling reference, which Clang helpfully warns -Wdangling-gsl https://github.com/llvm/llvm-project/pull/78655 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [libcxx] [lld] [clang] [libc] [llvm] [compiler-rt] [flang] Make clang report invalid target versions for all environment types. (PR #78655)
@@ -400,12 +400,12 @@ // LONG-CALLS-DEF-NOT: "long-calls" // // -mbranch-likely -// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ +// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ MaskRay wrote: while updating, switching to `--target=`. `-target ` has been deprecated since Clang 3.4 https://github.com/llvm/llvm-project/pull/78655 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for large watchpoints in lldb (PR #79962)
jasonmolenda wrote: Thanks for the great feedback @DavidSpickett sorry I merged it before you had a chance to look. These are good points, I'll land a cleanup patch in a bit to address them. https://github.com/llvm/llvm-project/pull/79962 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lld] [libc] [libcxx] [compiler-rt] [llvm] [lldb] [flang] [clang-tools-extra] Make clang report invalid target versions for all environment types. (PR #78655)
MaskRay wrote: If I remove `OpenCL`, `clang/test/CodeGenOpenCL/amdgpu-alignment.cl` won't fail. It seems that OpenCL is a not a necessary change in this PR. ``` --- i/llvm/lib/TargetParser/Triple.cpp +++ w/llvm/lib/TargetParser/Triple.cpp @@ -325,4 +325,2 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) { case Amplification: return "amplification"; - case OpenCL: -return "opencl"; case OpenHOS: return "ohos"; @@ -696,3 +694,2 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { .StartsWith("amplification", Triple::Amplification) - .StartsWith("opencl", Triple::OpenCL) .StartsWith("ohos", Triple::OpenHOS) ``` https://github.com/llvm/llvm-project/pull/78655 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (PR #80167)
jimingham wrote: I agree with Dave that verbs would be more naturally follow the intent of the return. Since the return is telling the caller: either "You can reuse the children you have cached" or "you must refetch the children". So `eReuse`, `eRefetch` would produce code like: if (something.Update() == ChildCacheState::eRefetch) { // Blow away the cached children and refetch. } That seems pretty natural. https://github.com/llvm/llvm-project/pull/80167 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [libcxx] [lld] [libcxxabi] [clang] [libc] [llvm] [compiler-rt] [flang] [SLP]Improve findReusedOrderedScalars and graph rotation. (PR #77529)
https://github.com/alexey-bataev updated https://github.com/llvm/llvm-project/pull/77529 >From 7440ee8ba235fd871af0999f66d5d6130456400b Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Tue, 9 Jan 2024 21:43:31 + 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.5 --- .../Transforms/Vectorize/SLPVectorizer.cpp| 476 ++ .../AArch64/extractelements-to-shuffle.ll | 16 +- .../AArch64/reorder-fmuladd-crash.ll | 7 +- .../SLPVectorizer/AArch64/tsc-s116.ll | 22 +- .../Transforms/SLPVectorizer/X86/pr35497.ll | 16 +- .../SLPVectorizer/X86/reduction-transpose.ll | 16 +- .../X86/reorder-clustered-node.ll | 11 +- .../X86/reorder-reused-masked-gather.ll | 7 +- .../SLPVectorizer/X86/reorder-vf-to-resize.ll | 2 +- .../X86/scatter-vectorize-reorder.ll | 17 +- .../X86/shrink_after_reorder2.ll | 11 +- 11 files changed, 445 insertions(+), 156 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 8e22b54f002d1..4765cef290b9d 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -858,7 +858,7 @@ static void addMask(SmallVectorImpl &Mask, ArrayRef SubMask, /// values 3 and 7 respectively: /// before: 6 9 5 4 9 2 1 0 /// after: 6 3 5 4 7 2 1 0 -static void fixupOrderingIndices(SmallVectorImpl &Order) { +static void fixupOrderingIndices(MutableArrayRef Order) { const unsigned Sz = Order.size(); SmallBitVector UnusedIndices(Sz, /*t=*/true); SmallBitVector MaskedIndices(Sz); @@ -2418,7 +2418,8 @@ class BoUpSLP { std::optional isGatherShuffledSingleRegisterEntry( const TreeEntry *TE, ArrayRef VL, MutableArrayRef Mask, - SmallVectorImpl &Entries, unsigned Part); + SmallVectorImpl &Entries, unsigned Part, + bool ForOrder); /// Checks if the gathered \p VL can be represented as multi-register /// shuffle(s) of previous tree entries. @@ -2432,7 +2433,7 @@ class BoUpSLP { isGatherShuffledEntry( const TreeEntry *TE, ArrayRef VL, SmallVectorImpl &Mask, SmallVectorImpl> &Entries, - unsigned NumParts); + unsigned NumParts, bool ForOrder = false); /// \returns the scalarization cost for this list of values. Assuming that /// this subtree gets vectorized, we may need to extract the values from the @@ -3756,65 +3757,169 @@ static void reorderOrder(SmallVectorImpl &Order, ArrayRef Mask) { std::optional BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE) { assert(TE.State == TreeEntry::NeedToGather && "Expected gather node only."); - unsigned NumScalars = TE.Scalars.size(); + // Try to find subvector extract/insert patterns and reorder only such + // patterns. + SmallVector GatheredScalars(TE.Scalars.begin(), TE.Scalars.end()); + Type *ScalarTy = GatheredScalars.front()->getType(); + int NumScalars = GatheredScalars.size(); + if (!isValidElementType(ScalarTy)) +return std::nullopt; + auto *VecTy = FixedVectorType::get(ScalarTy, NumScalars); + int NumParts = TTI->getNumberOfParts(VecTy); + if (NumParts == 0 || NumParts >= NumScalars) +NumParts = 1; + SmallVector ExtractMask; + SmallVector Mask; + SmallVector> Entries; + SmallVector> ExtractShuffles = + tryToGatherExtractElements(GatheredScalars, ExtractMask, NumParts); + SmallVector> GatherShuffles = + isGatherShuffledEntry(&TE, GatheredScalars, Mask, Entries, NumParts, +/*ForOrder=*/true); + // No shuffled operands - ignore. + if (GatherShuffles.empty() && ExtractShuffles.empty()) +return std::nullopt; OrdersType CurrentOrder(NumScalars, NumScalars); - SmallVector Positions; - SmallBitVector UsedPositions(NumScalars); - const TreeEntry *STE = nullptr; - // Try to find all gathered scalars that are gets vectorized in other - // vectorize node. Here we can have only one single tree vector node to - // correctly identify order of the gathered scalars. - for (unsigned I = 0; I < NumScalars; ++I) { -Value *V = TE.Scalars[I]; -if (!isa(V)) - continue; -if (const auto *LocalSTE = getTreeEntry(V)) { - if (!STE) -STE = LocalSTE; - else if (STE != LocalSTE) -// Take the order only from the single vector node. -return std::nullopt; - unsigned Lane = - std::distance(STE->Scalars.begin(), find(STE->Scalars, V)); - if (Lane >= NumScalars) -return std::nullopt; - if (CurrentOrder[Lane] != NumScalars) { -if (Lane != I) + if (GatherShuffles.size() == 1 && + *GatherShuffles.front() == TTI::SK_PermuteSingleSrc && + Entries.front().front()->isSame(TE.Scalars)) { +// Exclude nodes for strided geps from analysis, better
[Lldb-commits] [lldb] [compiler-rt] [clang-tools-extra] [llvm] [flang] [clang] [libcxx] [libc] [lld] [TTI][RISCV]Improve costs for fixed vector whole reg extract/insert. (PR #80164)
@@ -326,6 +326,50 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, switch (Kind) { default: break; +case TTI::SK_ExtractSubvector: + if (isa(SubTp)) { +unsigned TpRegs = getRegUsageForType(Tp); +unsigned NumElems = +divideCeil(Tp->getElementCount().getFixedValue(), TpRegs); +// Whole vector extract - just the vector itself + (possible) vsetvli. +// TODO: consider adding the cost for vsetvli. +if (Index == 0 || (ST->getRealMaxVLen() == ST->getRealMinVLen() && + Index % NumElems == 0)) { + std::pair SubLT = + getTypeLegalizationCost(SubTp); + return Index == 0 + ? TTI::TCC_Free + : SubLT.first * getRISCVInstructionCost(RISCV::VMV_V_V, preames wrote: For a full VREG case, you never need the VMV_V_V. You only need the VMV_V_V if NumElems < VLMAX. Extending this to sub-register extract with exact VLEN known would be reasonable, but let's do that in a separate patch. https://github.com/llvm/llvm-project/pull/80164 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [clang] [libcxx] [compiler-rt] [lldb] [llvm] [flang] [lld] [libc] [TTI][RISCV]Improve costs for fixed vector whole reg extract/insert. (PR #80164)
@@ -326,6 +326,50 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, switch (Kind) { default: break; +case TTI::SK_ExtractSubvector: + if (isa(SubTp)) { +unsigned TpRegs = getRegUsageForType(Tp); +unsigned NumElems = +divideCeil(Tp->getElementCount().getFixedValue(), TpRegs); +// Whole vector extract - just the vector itself + (possible) vsetvli. +// TODO: consider adding the cost for vsetvli. +if (Index == 0 || (ST->getRealMaxVLen() == ST->getRealMinVLen() && preames wrote: I think this check would be more clearly expressed as an and of the following clauses a) ST->getRealMaxVLen() == ST->getRealMinVLen() b) NumElems * ElementSizeInBits == VLEN c) Index % NumElems == 0 Note that this only supports m1 full extracts. But starting there and extending it to m2, and m4 later seems entirely reasonable. https://github.com/llvm/llvm-project/pull/80164 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [llvm] [clang-tools-extra] [lld] [clang] [libc] [libcxx] [lldb] [flang] [TTI][RISCV]Improve costs for fixed vector whole reg extract/insert. (PR #80164)
@@ -326,6 +326,50 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, switch (Kind) { default: break; +case TTI::SK_ExtractSubvector: + if (isa(SubTp)) { +unsigned TpRegs = getRegUsageForType(Tp); +unsigned NumElems = +divideCeil(Tp->getElementCount().getFixedValue(), TpRegs); +// Whole vector extract - just the vector itself + (possible) vsetvli. +// TODO: consider adding the cost for vsetvli. +if (Index == 0 || (ST->getRealMaxVLen() == ST->getRealMinVLen() && + Index % NumElems == 0)) { + std::pair SubLT = + getTypeLegalizationCost(SubTp); + return Index == 0 + ? TTI::TCC_Free + : SubLT.first * getRISCVInstructionCost(RISCV::VMV_V_V, + SubLT.second, + CostKind); +} + } + break; +case TTI::SK_InsertSubvector: + if (auto *FSubTy = dyn_cast(SubTp)) { +unsigned TpRegs = getRegUsageForType(Tp); preames wrote: Same basic style comments as above. https://github.com/llvm/llvm-project/pull/80164 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [clang-tools-extra] [lld] [lldb] [llvm] [libc] [clang] [libcxx] [compiler-rt] Make clang report invalid target versions for all environment types. (PR #78655)
ZijunZhaoCCK wrote: > If I remove `OpenCL`, `clang/test/CodeGenOpenCL/amdgpu-alignment.cl` won't > fail. It seems that OpenCL is a not a necessary change in this PR. > > ``` > --- i/llvm/lib/TargetParser/Triple.cpp > +++ w/llvm/lib/TargetParser/Triple.cpp > @@ -325,4 +325,2 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType > Kind) { >case Amplification: return "amplification"; > - case OpenCL: > -return "opencl"; >case OpenHOS: return "ohos"; > @@ -696,3 +694,2 @@ static Triple::EnvironmentType parseEnvironment(StringRef > EnvironmentName) { >.StartsWith("amplification", Triple::Amplification) > - .StartsWith("opencl", Triple::OpenCL) >.StartsWith("ohos", Triple::OpenHOS) > ``` Oh , my bad. Failed tests are ```Failed Tests (4): Clang :: CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl Clang :: CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl Clang :: Driver/amdgpu-toolchain-opencl.cl Clang :: Driver/opencl.cl``` https://github.com/llvm/llvm-project/pull/78655 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (PR #80167)
clayborg wrote: I like the `eReuse` and `eRefetch` values as well! https://github.com/llvm/llvm-project/pull/80167 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFIndex] Use IDX_parent to implement GetFullyQualifiedType query (PR #79932)
clayborg wrote: > > I've added a log message with the `Error` itself being logged as well > > Thanks! I wasted half a day stepping through the DWARF parser recently, > thinking I'm debugging a parser bug, when it was really invalid DWARF > produced by an older version of dsymutil, so even just the information that > there _was_ a parse error is very useful. I always run `llvm-dwawfdump --verify` as a first step, though it is nice to get more errors emitted in the DWARF log channels https://github.com/llvm/llvm-project/pull/79932 ___ 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)
clayborg wrote: > > But if it'd require substantial reengineering to clang to get this working > > - this seems an unfortunate regression to carry in the interim, and it > > might be worth reverting to the previous (differently buggy, but at least > > work-around-able) behavior. > > To clarify, the regression @dwblaikie reported in #79668 was introduced in > #74786, not in this current PR. IIUC, this PR just _partially_ fixed #53904? > > > The new flow could be: > > > > * any struct/class gets created as a forward declaration and has the > > external AST source enabled > > * the external AST calls to complete the type when needed by expression > > parser or LLDB APIs > > * we complete the type > > * we leave the external AST enabled so we can get called for contained types > > > > The last item here would require modifications to clang which could be > > debugger specific changes that are only enabled in a special debug compiler > > mode so they don't affect the actual compiler. Thoughts? > > Following overview of the clang<->lldb call-chain might be useful: [#53904 > (comment)](https://github.com/llvm/llvm-project/issues/53904#issuecomment-1877114034). > Not sure I fully understand the "we leave the external AST enabled so we can > get called for contained types" idea. Happy to chat about how to make this > work though When we parse a class, we enable the external AST support on the CXXRecordDecl object. When we are asked to complete the type it will eventually make it down into `DWARFASTParserClang::CompleteTypeFromDWARF(...)` which will call: ``` // 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); ``` So we never get a query again to find anything inside of this class. That being said, I am not sure anything ever was doing another external AST lookup in this class after we completed it. But if we are able to add debugger specific support into the external AST virtual interface, we might be able to gets asked "withing this 'class A' please find me a contained type" and then modify the compiler to use the external AST source when a lookup in a contents fails. We currently modified it so that when we parse a struct/union/class type, we also parse all contained child DIE types so that they are available. This is failing when some classes have contained types defined and others don't because we only add the contained types for the struct/class/union DIE we used to create the type. If we can modify the compiler to make an external lookup call only when debugging, we can avoid this need to parse all contained types and wait until the expresion parser asks for that type. 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][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (PR #80167)
@@ -1305,6 +1305,13 @@ enum CompletionType { eTerminatorCompletion = (1ul << 27) }; +/// Specifies if children need to be re-computed +/// after a call to \ref SyntheticChildrenFrontEnd::Update. +enum class ChildCacheState { + eRefetch = 0, ///< Children need to be recomputed dynamically. + eReuse = 1, ///< Children will never change and don't need to be recomputed. kastiglione wrote: is "will never change" true in all cases? Or should it be "did not change"? https://github.com/llvm/llvm-project/pull/80167 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (PR #80167)
@@ -1305,6 +1305,13 @@ enum CompletionType { eTerminatorCompletion = (1ul << 27) }; +/// Specifies if children need to be re-computed +/// after a call to \ref SyntheticChildrenFrontEnd::Update. +enum class ChildCacheState { + eRefetch = 0, ///< Children need to be recomputed dynamically. + eReuse = 1, ///< Children will never change and don't need to be recomputed. clayborg wrote: After thinking about this, I believe you are correct, it probably means "you can re-use what I gave the last time you called update" https://github.com/llvm/llvm-project/pull/80167 ___ 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] [lldb] [lld] [llvm] [compiler-rt] [libc] [libcxxabi] [flang] [clang] [TTI][RISCV]Improve costs for fixed vector whole reg extract/insert. (PR #80164)
https://github.com/alexey-bataev updated https://github.com/llvm/llvm-project/pull/80164 >From cfd0dcfa1f5fabd12cf4d7bf8d5a10bd324ace0a Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Wed, 31 Jan 2024 16:47:49 + 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.5 --- .../Target/RISCV/RISCVTargetTransformInfo.cpp | 42 + .../RISCV/shuffle-extract_subvector.ll| 174 +- .../RISCV/shuffle-insert_subvector.ll | 42 ++--- .../CostModel/RISCV/shuffle-interleave.ll | 6 +- 4 files changed, 153 insertions(+), 111 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp index fe1cdb2dfa423..465a05b6497a2 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp @@ -326,6 +326,48 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, switch (Kind) { default: break; +case TTI::SK_ExtractSubvector: + if (isa(SubTp)) { +unsigned TpRegs = getRegUsageForType(Tp); +unsigned NumElems = +divideCeil(Tp->getElementCount().getFixedValue(), TpRegs); +// Whole vector extract - just the vector itself + (possible) vsetvli. +// TODO: consider adding the cost for vsetvli. +if (Index % NumElems == 0) { + std::pair SubLT = + getTypeLegalizationCost(SubTp); + return Index == 0 + ? TTI::TCC_Free + : SubLT.first * getRISCVInstructionCost(RISCV::VMV_V_V, + SubLT.second, + CostKind); +} + } + break; +case TTI::SK_InsertSubvector: + if (auto *FSubTy = dyn_cast(SubTp)) { +unsigned TpRegs = getRegUsageForType(Tp); +unsigned SubTpRegs = getRegUsageForType(SubTp); +unsigned NextSubTpRegs = getRegUsageForType(FixedVectorType::get( +Tp->getElementType(), FSubTy->getNumElements() + 1)); +unsigned NumElems = +divideCeil(Tp->getElementCount().getFixedValue(), TpRegs); +// Whole vector insert - just the vector itself + (possible) vsetvli. +// TODO: consider adding the cost for vsetvli. +if (Index % NumElems == 0 && +(any_of(Args, UndefValue::classof) || + (SubTpRegs != 0 && SubTpRegs != NextSubTpRegs && + TpRegs / SubTpRegs > 1))) { + std::pair SubLT = + getTypeLegalizationCost(SubTp); + return Index == 0 + ? TTI::TCC_Free + : SubLT.first * getRISCVInstructionCost(RISCV::VMV_V_V, + SubLT.second, + CostKind); +} + } + break; case TTI::SK_PermuteSingleSrc: { if (Mask.size() >= 2 && LT.second.isFixedLengthVector()) { MVT EltTp = LT.second.getVectorElementType(); diff --git a/llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll b/llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll index 76cb1955a2b37..901d66e1124d8 100644 --- a/llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll +++ b/llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll @@ -9,15 +9,15 @@ define void @test_vXf64(<4 x double> %src256, <8 x double> %src512) { ; CHECK-LABEL: 'test_vXf64' -; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V256_01 = shufflevector <4 x double> %src256, <4 x double> undef, <2 x i32> -; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %V256_23 = shufflevector <4 x double> %src256, <4 x double> undef, <2 x i32> -; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V512_01 = shufflevector <8 x double> %src512, <8 x double> undef, <2 x i32> -; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V512_23 = shufflevector <8 x double> %src512, <8 x double> undef, <2 x i32> -; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V512_45 = shufflevector <8 x double> %src512, <8 x double> undef, <2 x i32> -; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V512_67 = shufflevector <8 x double> %src512, <8 x double> undef, <2 x i32> -; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V512_0123 = shufflevector <8 x double> %src512, <8 x double> undef, <4 x i32> -; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %V512_2345 = shufflevector <8 x double> %src512, <8 x double> undef, <4 x i32> -; CHECK-NEXT: Cost Model: Found an estimat
[Lldb-commits] [llvm] [libcxx] [libc] [clang-tools-extra] [mlir] [lld] [lldb] [openmp] [clang] [flang] [SLP][TTI]Add support for strided loads. (PR #80310)
https://github.com/alexey-bataev updated https://github.com/llvm/llvm-project/pull/80310 >From 92950afd39034c0184a3c807f8062e0053eead5c Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 1 Feb 2024 17:22:34 + Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- .../llvm/Analysis/TargetTransformInfo.h | 34 ++ .../llvm/Analysis/TargetTransformInfoImpl.h | 13 + llvm/lib/Analysis/TargetTransformInfo.cpp | 14 + .../Target/RISCV/RISCVTargetTransformInfo.cpp | 23 + .../Target/RISCV/RISCVTargetTransformInfo.h | 23 + .../Transforms/Vectorize/SLPVectorizer.cpp| 397 -- .../SLPVectorizer/RISCV/complex-loads.ll | 132 +++--- .../RISCV/strided-loads-vectorized.ll | 209 + .../strided-loads-with-external-use-ptr.ll| 4 +- .../SLPVectorizer/RISCV/strided-loads.ll | 13 +- .../X86/gep-nodes-with-non-gep-inst.ll| 2 +- .../X86/remark_gather-load-redux-cost.ll | 2 +- 12 files changed, 478 insertions(+), 388 deletions(-) diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index 3b615bc700bbb..b0b6dab03fa38 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -781,6 +781,9 @@ class TargetTransformInfo { /// Return true if the target supports masked expand load. bool isLegalMaskedExpandLoad(Type *DataType) const; + /// Return true if the target supports strided load. + bool isLegalStridedLoad(Type *DataType, Align Alignment) const; + /// Return true if this is an alternating opcode pattern that can be lowered /// to a single instruction on the target. In X86 this is for the addsub /// instruction which corrsponds to a Shuffle + Fadd + FSub pattern in IR. @@ -1412,6 +1415,20 @@ class TargetTransformInfo { Align Alignment, TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, const Instruction *I = nullptr) const; + /// \return The cost of strided memory operations. + /// \p Opcode - is a type of memory access Load or Store + /// \p DataTy - a vector type of the data to be loaded or stored + /// \p Ptr - pointer [or vector of pointers] - address[es] in memory + /// \p VariableMask - true when the memory access is predicated with a mask + /// that is not a compile-time constant + /// \p Alignment - alignment of single element + /// \p I - the optional original context instruction, if one exists, e.g. the + ///load/store to transform or the call to the gather/scatter intrinsic + InstructionCost getStridedMemoryOpCost( + unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, + Align Alignment, TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, + const Instruction *I = nullptr) const; + /// \return The cost of the interleaved memory operation. /// \p Opcode is the memory operation code /// \p VecTy is the vector type of the interleaved access. @@ -1848,6 +1865,7 @@ class TargetTransformInfo::Concept { Align Alignment) = 0; virtual bool isLegalMaskedCompressStore(Type *DataType) = 0; virtual bool isLegalMaskedExpandLoad(Type *DataType) = 0; + virtual bool isLegalStridedLoad(Type *DataType, Align Alignment) = 0; virtual bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask) const = 0; @@ -2023,6 +2041,11 @@ class TargetTransformInfo::Concept { bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I = nullptr) = 0; + virtual InstructionCost + getStridedMemoryOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, + bool VariableMask, Align Alignment, + TTI::TargetCostKind CostKind, + const Instruction *I = nullptr) = 0; virtual InstructionCost getInterleavedMemoryOpCost( unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef Indices, @@ -2341,6 +2364,9 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept { bool isLegalMaskedExpandLoad(Type *DataType) override { return Impl.isLegalMaskedExpandLoad(DataType); } + bool isLegalStridedLoad(Type *DataType, Align Alignment) override { +return Impl.isLegalStridedLoad(DataType, Alignment); + } bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask) const override { return Impl.isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask); @@ -2671,6 +2697,14 @@ class TargetTransformInfo::Model
[Lldb-commits] [llvm] [libcxx] [libc] [clang-tools-extra] [mlir] [lld] [lldb] [openmp] [clang] [flang] [SLP]Add support for strided loads. (PR #80310)
https://github.com/alexey-bataev edited https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [flang] [openmp] [libcxx] [clang-tools-extra] [mlir] [lldb] [llvm] [lld] [libc] [SLP]Add support for strided loads. (PR #80310)
https://github.com/alexey-bataev edited https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix a crash when using .dwp files and make type lookup reliable with the index cache (PR #79544)
https://github.com/clayborg updated https://github.com/llvm/llvm-project/pull/79544 >From 90cfa4700d8590d58cecd678ce107ba3ec8481c7 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Thu, 25 Jan 2024 19:21:25 -0800 Subject: [PATCH 1/4] Fix a crash when using .dwp files and make type lookup reliable with the index cache. When using split DWARF with .dwp files we had an issue where sometimes the DWO file within the .dwp file would be parsed _before_ the skeleton compile unit. The DWO file expects to be able to always be able to get a link back to the skeleton compile unit. Prior to this fix, the only time the skeleton compile unit backlink would get set, was if the unit headers for the main executable have been parsed _and_ if the unit DIE was parsed in that DWARFUnit. This patch ensures that we can always get the skeleton compile unit for a DWO file by adding a function: ``` DWARFCompileUnit *DWARFUnit::GetSkeletonUnit(); ``` Prior to this fix DWARFUnit had some unsafe accessors that were used to store two different things: ``` void *DWARFUnit::GetUserData() const; void DWARFUnit::SetUserData(void *d); ``` This was used by SymbolFileDWARF to cache the `lldb_private::CompileUnit *` for a SymbolFileDWARF and was also used to store the `DWARFUnit *` for SymbolFileDWARFDwo. This patch clears up this unsafe usage by adding two separate accessors and ivars for this: ``` lldb_private::CompileUnit *DWARFUnit::GetLLDBCompUnit() const { return m_lldb_cu; } void DWARFUnit::SetLLDBCompUnit(lldb_private::CompileUnit *cu) { m_lldb_cu = cu; } DWARFCompileUnit *DWARFUnit::GetSkeletonUnit(); void DWARFUnit::SetSkeletonUnit(DWARFUnit *skeleton_unit); ``` This will stop anyone from calling `void *DWARFUnit::GetUserData() const;` and casting the value to an incorrect value. A crash could occur in `SymbolFileDWARF::GetCompUnitForDWARFCompUnit()` when the `non_dwo_cu`, which is a backlink to the skeleton compile unit, was not set and was NULL. There is an assert() in the code, and then the code just will kill the program if the assert isn't enabled because the code looked like: ``` if (dwarf_cu.IsDWOUnit()) { DWARFCompileUnit *non_dwo_cu = static_cast(dwarf_cu.GetUserData()); assert(non_dwo_cu); return non_dwo_cu->GetSymbolFileDWARF().GetCompUnitForDWARFCompUnit( *non_dwo_cu); } ``` This is now fixed by calling the `DWARFUnit::GetSkeletonUnit()` which will correctly always get the skeleton compile uint for a DWO file regardless of if the skeleton unit headers have been parse or if the skeleton unit DIE wasn't parsed yet. To implement the ability to get the skeleton compile units, I added code the DWARFDebugInfo.cpp/.h that make a map of DWO ID -> skeleton DWARFUnit * that gets filled in for DWARF5 when the unit headers are parsed. The `DWARFUnit::GetSkeletonUnit()` will end up parsing the unit headers of the main executable to fill in this map if it already hasn't been done. For DWARF4 and earlier we maintain a separate map that gets filled in only for any DWARF4 compile units that have a DW_AT_dwo_id or DW_AT_gnu_dwo_id attributes. This is more expensive, so this is done lazily and in a thread safe manor. This allows us to be as efficient as possible when using DWARF5 and also be backward compatible with DWARF4 + split DWARF. There was also an issue that stopped type lookups from succeeding in `DWARFDIE SymbolFileDWARF::GetDIE(const DIERef &die_ref)` where it directly was accessing the `m_dwp_symfile` ivar without calling the accessor function that could end up needing to locate and load the .dwp file. This was fixed by calling the `SymbolFileDWARF::GetDwpSymbolFile()` accessor to ensure we always get a valid value back if we can find the .dwp file. Prior to this fix it was down which APIs were called and if any APIs were called that loaded the .dwp file, it worked fine, but it might not if no APIs were called that did cause it to get loaded. When we have valid debug info indexes and when the lldb index cache was enabled, this would cause this issue to show up more often. I modified an existing test case to test that all of this works correctly and doesn't crash. --- .../SymbolFile/DWARF/DWARFDebugInfo.cpp | 77 +-- .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h | 4 + .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp| 27 ++- .../Plugins/SymbolFile/DWARF/DWARFUnit.h | 28 ++- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 32 .../SymbolFile/DWARF/SymbolFileDWARF.h| 11 +++ .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 19 + .../SymbolFile/DWARF/SymbolFileDWARFDwo.h | 11 ++- .../DWARF/x86/dwp-separate-debug-file.cpp | 38 + 9 files changed, 216 insertions(+), 31 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 340b9acf80d02..e59e328c6e7cb 100644 --- a/lldb/source/Plugins/
[Lldb-commits] [lldb] 9258f3e - [lldb] Fix a crash when using .dwp files and make type lookup reliable with the index cache (#79544)
Author: Greg Clayton Date: 2024-02-01T13:58:18-08:00 New Revision: 9258f3e692493a69e0f4755bb129a5391ef10b50 URL: https://github.com/llvm/llvm-project/commit/9258f3e692493a69e0f4755bb129a5391ef10b50 DIFF: https://github.com/llvm/llvm-project/commit/9258f3e692493a69e0f4755bb129a5391ef10b50.diff LOG: [lldb] Fix a crash when using .dwp files and make type lookup reliable with the index cache (#79544) When using split DWARF with .dwp files we had an issue where sometimes the DWO file within the .dwp file would be parsed _before_ the skeleton compile unit. The DWO file expects to be able to always be able to get a link back to the skeleton compile unit. Prior to this fix, the only time the skeleton compile unit backlink would get set, was if the unit headers for the main executable have been parsed _and_ if the unit DIE was parsed in that DWARFUnit. This patch ensures that we can always get the skeleton compile unit for a DWO file by adding a function: ``` DWARFCompileUnit *DWARFUnit::GetSkeletonUnit(); ``` Prior to this fix DWARFUnit had some unsafe accessors that were used to store two different things: ``` void *DWARFUnit::GetUserData() const; void DWARFUnit::SetUserData(void *d); ``` This was used by SymbolFileDWARF to cache the `lldb_private::CompileUnit *` for a SymbolFileDWARF and was also used to store the `DWARFUnit *` for SymbolFileDWARFDwo. This patch clears up this unsafe usage by adding two separate accessors and ivars for this: ``` lldb_private::CompileUnit *DWARFUnit::GetLLDBCompUnit() const { return m_lldb_cu; } void DWARFUnit::SetLLDBCompUnit(lldb_private::CompileUnit *cu) { m_lldb_cu = cu; } DWARFCompileUnit *DWARFUnit::GetSkeletonUnit(); void DWARFUnit::SetSkeletonUnit(DWARFUnit *skeleton_unit); ``` This will stop anyone from calling `void *DWARFUnit::GetUserData() const;` and casting the value to an incorrect value. A crash could occur in `SymbolFileDWARF::GetCompUnitForDWARFCompUnit()` when the `non_dwo_cu`, which is a backlink to the skeleton compile unit, was not set and was NULL. There is an assert() in the code, and then the code just will kill the program if the assert isn't enabled because the code looked like: ``` if (dwarf_cu.IsDWOUnit()) { DWARFCompileUnit *non_dwo_cu = static_cast(dwarf_cu.GetUserData()); assert(non_dwo_cu); return non_dwo_cu->GetSymbolFileDWARF().GetCompUnitForDWARFCompUnit( *non_dwo_cu); } ``` This is now fixed by calling the `DWARFUnit::GetSkeletonUnit()` which will correctly always get the skeleton compile uint for a DWO file regardless of if the skeleton unit headers have been parse or if the skeleton unit DIE wasn't parsed yet. To implement the ability to get the skeleton compile units, I added code the DWARFDebugInfo.cpp/.h that make a map of DWO ID -> skeleton DWARFUnit * that gets filled in for DWARF5 when the unit headers are parsed. The `DWARFUnit::GetSkeletonUnit()` will end up parsing the unit headers of the main executable to fill in this map if it already hasn't been done. For DWARF4 and earlier we maintain a separate map that gets filled in only for any DWARF4 compile units that have a DW_AT_dwo_id or DW_AT_gnu_dwo_id attributes. This is more expensive, so this is done lazily and in a thread safe manor. This allows us to be as efficient as possible when using DWARF5 and also be backward compatible with DWARF4 + split DWARF. There was also an issue that stopped type lookups from succeeding in `DWARFDIE SymbolFileDWARF::GetDIE(const DIERef &die_ref)` where it directly was accessing the `m_dwp_symfile` ivar without calling the accessor function that could end up needing to locate and load the .dwp file. This was fixed by calling the `SymbolFileDWARF::GetDwpSymbolFile()` accessor to ensure we always get a valid value back if we can find the .dwp file. Prior to this fix it was down which APIs were called and if any APIs were called that loaded the .dwp file, it worked fine, but it might not if no APIs were called that did cause it to get loaded. When we have valid debug info indexes and when the lldb index cache was enabled, this would cause this issue to show up more often. I modified an existing test case to test that all of this works correctly and doesn't crash. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/test/Shell/SymbolFile/DWARF/x86/dwp-separate-debug-file.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/sourc
[Lldb-commits] [lldb] [lldb] Fix a crash when using .dwp files and make type lookup reliable with the index cache (PR #79544)
https://github.com/clayborg closed https://github.com/llvm/llvm-project/pull/79544 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][TypeSynthetic][NFC] Make SyntheticChildrenFrontend::Update() return an enum (PR #80167)
@@ -1305,6 +1305,13 @@ enum CompletionType { eTerminatorCompletion = (1ul << 27) }; +/// Specifies if children need to be re-computed +/// after a call to \ref SyntheticChildrenFrontEnd::Update. +enum class ChildCacheState { + eRefetch = 0, ///< Children need to be recomputed dynamically. + eReuse = 1, ///< Children will never change and don't need to be recomputed. Michael137 wrote: fixed, thanks! https://github.com/llvm/llvm-project/pull/80167 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [libc] [mlir] [clang-tools-extra] [openmp] [llvm] [lldb] [clang] [flang] [lld] [SLP]Add support for strided loads. (PR #80310)
preames wrote: FYI - https://github.com/llvm/llvm-project/pull/80360 adds testing infrastructure to exercise the TTI hooks. https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4eac146 - Fix buildbots after #79544
Author: Greg Clayton Date: 2024-02-01T15:26:26-08:00 New Revision: 4eac14683855e040adaf507ed6b14e28a09f983e URL: https://github.com/llvm/llvm-project/commit/4eac14683855e040adaf507ed6b14e28a09f983e DIFF: https://github.com/llvm/llvm-project/commit/4eac14683855e040adaf507ed6b14e28a09f983e.diff LOG: Fix buildbots after #79544 https://github.com/llvm/llvm-project/pull/79544 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 6bcf95c11a65c..44febcfac3b00 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -88,8 +88,12 @@ void DWARFDebugInfo::ParseUnitsFor(DIERef::Section section) { if (!expected_unit_sp) { Log *log = GetLog(DWARFLog::DebugInfo); - LLDB_LOG(log, "Unable to extract DWARFUnitHeader at {0:x}: {1}", - unit_header_offset, llvm::toString(expected_unit_sp.takeError())); + if (log) +LLDB_LOG(log, "Unable to extract DWARFUnitHeader at {0:x}: {1}", + unit_header_offset, + llvm::toString(expected_unit_sp.takeError())); + else +llvm::consumeError(expected_unit_sp.takeError()); return; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix a crash when using .dwp files and make type lookup reliable with the index cache (PR #79544)
clayborg wrote: This broke the buildbots. Fixed with: ``` commit 4eac14683855e040adaf507ed6b14e28a09f983e (HEAD -> main, origin/main, origin/HEAD) Author: Greg Clayton Date: Thu Feb 1 15:26:26 2024 -0800 Fix buildbots after #79544 https://github.com/llvm/llvm-project/pull/79544 ``` https://github.com/llvm/llvm-project/pull/79544 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [libc] [mlir] [clang-tools-extra] [openmp] [llvm] [lldb] [clang] [flang] [lld] [SLP]Add support for strided loads. (PR #80310)
@@ -7,7 +7,7 @@ define i32 @test(ptr noalias %p, ptr noalias %addr) { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[TMP0:%.*]] = insertelement <8 x ptr> poison, ptr [[ADDR:%.*]], i32 0 ; CHECK-NEXT:[[TMP1:%.*]] = shufflevector <8 x ptr> [[TMP0]], <8 x ptr> poison, <8 x i32> zeroinitializer -; CHECK-NEXT:[[TMP2:%.*]] = getelementptr i32, <8 x ptr> [[TMP1]], <8 x i32> +; CHECK-NEXT:[[TMP2:%.*]] = getelementptr i32, <8 x ptr> [[TMP1]], <8 x i32> preames wrote: Same as last. https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [mlir] [clang] [libc] [lldb] [lld] [openmp] [flang] [libcxx] [clang-tools-extra] [llvm] [SLP]Add support for strided loads. (PR #80310)
https://github.com/preames edited https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [clang] [openmp] [mlir] [libc] [lldb] [lld] [clang-tools-extra] [llvm] [libcxx] [SLP]Add support for strided loads. (PR #80310)
@@ -3930,30 +4065,68 @@ static LoadsState canVectorizeLoads(ArrayRef VL, const Value *VL0, std::optional Diff = getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, DL, SE); // Check that the sorted loads are consecutive. - if (static_cast(*Diff) == VL.size() - 1) + if (static_cast(*Diff) == Sz - 1) return LoadsState::Vectorize; // Simple check if not a strided access - clear order. - IsPossibleStrided = *Diff % (VL.size() - 1) == 0; + bool IsPossibleStrided = *Diff % (Sz - 1) == 0; + // Try to generate strided load node if: + // 1. Target with strided load support is detected. + // 2. The number of loads is greater than MinProfitableStridedLoads, + // or the potential stride <= MaxProfitableLoadStride and the + // potential stride is power-of-2 (to avoid perf regressions for the very + // small number of loads) and max distance > number of loads, or potential + // stride is -1. + // 3. The loads are ordered, or number of unordered loads <= + // MaxProfitableUnorderedLoads, or loads are in reversed order. + // (this check is to avoid extra costs for very expensive shuffles). + if (IsPossibleStrided && (((Sz > MinProfitableStridedLoads || + (static_cast(std::abs(*Diff)) <= + MaxProfitableLoadStride * Sz && + isPowerOf2_32(std::abs(*Diff && + static_cast(std::abs(*Diff)) > Sz) || +*Diff == -(static_cast(Sz) - 1))) { +int Stride = *Diff / static_cast(Sz - 1); +if (*Diff == Stride * static_cast(Sz - 1)) { + if (TTI.isTypeLegal(VecTy) && preames wrote: The isTypeLegal check here should be redundant. https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [libc] [mlir] [libcxx] [lldb] [lld] [clang] [openmp] [clang-tools-extra] [llvm] [SLP]Add support for strided loads. (PR #80310)
@@ -397,27 +241,12 @@ define void @test3([48 x float]* %p, float* noalias %s) { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [48 x float], ptr [[P:%.*]], i64 0, i64 0 ; CHECK-NEXT:[[ARRAYIDX2:%.*]] = getelementptr inbounds float, ptr [[S:%.*]], i64 0 -; CHECK-NEXT:[[ARRAYIDX4:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 4 -; CHECK-NEXT:[[ARRAYIDX11:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 8 -; CHECK-NEXT:[[ARRAYIDX18:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 12 -; CHECK-NEXT:[[ARRAYIDX25:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 16 -; CHECK-NEXT:[[ARRAYIDX32:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 20 -; CHECK-NEXT:[[ARRAYIDX39:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 24 -; CHECK-NEXT:[[ARRAYIDX46:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 28 ; CHECK-NEXT:[[ARRAYIDX48:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 23 -; CHECK-NEXT:[[TMP0:%.*]] = insertelement <8 x ptr> poison, ptr [[ARRAYIDX]], i32 0 -; CHECK-NEXT:[[TMP1:%.*]] = insertelement <8 x ptr> [[TMP0]], ptr [[ARRAYIDX4]], i32 1 -; CHECK-NEXT:[[TMP2:%.*]] = insertelement <8 x ptr> [[TMP1]], ptr [[ARRAYIDX11]], i32 2 -; CHECK-NEXT:[[TMP3:%.*]] = insertelement <8 x ptr> [[TMP2]], ptr [[ARRAYIDX18]], i32 3 -; CHECK-NEXT:[[TMP4:%.*]] = insertelement <8 x ptr> [[TMP3]], ptr [[ARRAYIDX25]], i32 4 -; CHECK-NEXT:[[TMP5:%.*]] = insertelement <8 x ptr> [[TMP4]], ptr [[ARRAYIDX32]], i32 5 -; CHECK-NEXT:[[TMP6:%.*]] = insertelement <8 x ptr> [[TMP5]], ptr [[ARRAYIDX39]], i32 6 -; CHECK-NEXT:[[TMP7:%.*]] = insertelement <8 x ptr> [[TMP6]], ptr [[ARRAYIDX46]], i32 7 -; CHECK-NEXT:[[TMP8:%.*]] = call <8 x float> @llvm.masked.gather.v8f32.v8p0(<8 x ptr> [[TMP7]], i32 4, <8 x i1> , <8 x float> poison) -; CHECK-NEXT:[[TMP9:%.*]] = load <8 x float>, ptr [[ARRAYIDX48]], align 4 -; CHECK-NEXT:[[TMP10:%.*]] = shufflevector <8 x float> [[TMP9]], <8 x float> poison, <8 x i32> -; CHECK-NEXT:[[TMP11:%.*]] = fsub fast <8 x float> [[TMP10]], [[TMP8]] -; CHECK-NEXT:store <8 x float> [[TMP11]], ptr [[ARRAYIDX2]], align 4 +; CHECK-NEXT:[[TMP0:%.*]] = call <8 x float> @llvm.experimental.vp.strided.load.v8f32.p0.i64(ptr align 4 [[ARRAYIDX]], i64 16, <8 x i1> , i32 8) +; CHECK-NEXT:[[TMP1:%.*]] = load <8 x float>, ptr [[ARRAYIDX48]], align 4 +; CHECK-NEXT:[[TMP2:%.*]] = shufflevector <8 x float> [[TMP1]], <8 x float> poison, <8 x i32> preames wrote: Can't this reverse become a negative strided load? https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [libc] [lld] [llvm] [lldb] [libcxx] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -17,7 +17,7 @@ define i16 @test() { ; CHECK-NEXT:[[TMP4:%.*]] = call <2 x i16> @llvm.masked.gather.v2i16.v2p0(<2 x ptr> [[TMP3]], i32 2, <2 x i1> , <2 x i16> poison) ; CHECK-NEXT:[[TMP5:%.*]] = extractelement <2 x i16> [[TMP4]], i32 0 ; CHECK-NEXT:[[TMP6:%.*]] = extractelement <2 x i16> [[TMP4]], i32 1 -; CHECK-NEXT:[[CMP_I178:%.*]] = icmp ult i16 [[TMP6]], [[TMP5]] +; CHECK-NEXT:[[CMP_I178:%.*]] = icmp ult i16 [[TMP5]], [[TMP6]] ; CHECK-NEXT:br label [[WHILE_BODY_I]] ; entry: preames wrote: Unless this is specifically testing something about offsets from null, can you update this test to pass in a pointer argument and index off that? (Separate change, no review needed.) https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [libcxx] [lldb] [lld] [mlir] [clang-tools-extra] [libc] [openmp] [llvm] [clang] [SLP]Add support for strided loads. (PR #80310)
@@ -30,7 +30,7 @@ define void @test() { ; CHECK-SLP-THRESHOLD: bb: ; CHECK-SLP-THRESHOLD-NEXT:[[TMP0:%.*]] = insertelement <4 x ptr> poison, ptr [[COND_IN_V]], i32 0 ; CHECK-SLP-THRESHOLD-NEXT:[[TMP1:%.*]] = shufflevector <4 x ptr> [[TMP0]], <4 x ptr> poison, <4 x i32> zeroinitializer -; CHECK-SLP-THRESHOLD-NEXT:[[TMP2:%.*]] = getelementptr i64, <4 x ptr> [[TMP1]], <4 x i64> +; CHECK-SLP-THRESHOLD-NEXT:[[TMP2:%.*]] = getelementptr i64, <4 x ptr> [[TMP1]], <4 x i64> preames wrote: Shouldn't this be a strided load with a stride of -4*8? If what you're aiming for is test stability, can you use a index which doesn't look anything like a strided load? https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [flang] [mlir] [openmp] [llvm] [clang] [clang-tools-extra] [lldb] [lld] [libc] [SLP]Add support for strided loads. (PR #80310)
https://github.com/preames commented: These comments are trying to be helpful in pointing out bits which might be simplified or split off, but my track record with SLP reviews is not great. Feel free to ignore any or all of these. https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [openmp] [clang-tools-extra] [libcxx] [lld] [flang] [clang] [llvm] [lldb] [mlir] [libc] [SLP]Add support for strided loads. (PR #80310)
@@ -3930,30 +4065,68 @@ static LoadsState canVectorizeLoads(ArrayRef VL, const Value *VL0, std::optional Diff = getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, DL, SE); // Check that the sorted loads are consecutive. - if (static_cast(*Diff) == VL.size() - 1) + if (static_cast(*Diff) == Sz - 1) return LoadsState::Vectorize; // Simple check if not a strided access - clear order. - IsPossibleStrided = *Diff % (VL.size() - 1) == 0; + bool IsPossibleStrided = *Diff % (Sz - 1) == 0; + // Try to generate strided load node if: + // 1. Target with strided load support is detected. + // 2. The number of loads is greater than MinProfitableStridedLoads, + // or the potential stride <= MaxProfitableLoadStride and the + // potential stride is power-of-2 (to avoid perf regressions for the very + // small number of loads) and max distance > number of loads, or potential + // stride is -1. + // 3. The loads are ordered, or number of unordered loads <= + // MaxProfitableUnorderedLoads, or loads are in reversed order. + // (this check is to avoid extra costs for very expensive shuffles). + if (IsPossibleStrided && (((Sz > MinProfitableStridedLoads || + (static_cast(std::abs(*Diff)) <= + MaxProfitableLoadStride * Sz && + isPowerOf2_32(std::abs(*Diff && + static_cast(std::abs(*Diff)) > Sz) || +*Diff == -(static_cast(Sz) - 1))) { +int Stride = *Diff / static_cast(Sz - 1); preames wrote: How is the diff-in-bytes divided by the number of elements the stride? Did you maybe mean to use element size here? It's also possible you have two Sz variables with different meaning. I did not check for this. https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -3878,6 +3883,130 @@ static Align computeCommonAlignment(ArrayRef VL) { return CommonAlignment; } +/// Check if \p Order represents reverse order. +static bool isReverseOrder(ArrayRef Order) { + unsigned Sz = Order.size(); + return !Order.empty() && all_of(enumerate(Order), [&](const auto &Pair) { +return Pair.value() == Sz || Sz - Pair.index() - 1 == Pair.value(); + }); +} + +/// Checks if the provided list of pointers \p Pointers represents the strided +/// pointers for type ElemTy. If they are not, std::nullopt is returned. +/// Otherwise, if \p Inst is not specified, just initialized optional value is +/// returned to show that the pointers represent strided pointers. If \p Inst +/// specified, the runtime stride is materialized before the given \p Inst. +/// \returns std::nullopt if the pointers are not pointers with the runtime +/// stride, nullptr or actual stride value, otherwise. +static std::optional +calculateRtStride(ArrayRef PointerOps, Type *ElemTy, + const DataLayout &DL, ScalarEvolution &SE, + SmallVectorImpl &SortedIndices, + Instruction *Inst = nullptr) { + SmallVector SCEVs; preames wrote: An alternate approach which might be simpler and yet cover many of the interesting test cases might be: * Loop over the pointers, check that getPointerBase matches. * Loop again doing removePointerBase * This gives a list of offsets from base, bail if any non-constant * Sort the list of constant offsets * Check if strided w/shuffle? If you don't want a shuffle afterwards, you can check the delta without sorting. This won't cover non-constant strides, but I'm not sure we really care about those in practice. https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [clang] [openmp] [mlir] [libc] [lldb] [lld] [clang-tools-extra] [compiler-rt] [llvm] [libcxx] Make clang report invalid target versions for all environment types. (PR #78655)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/78655 >From f440f44e7e270d4636ad39f4e4223c904e496d3a Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Fri, 19 Jan 2024 00:47:05 + Subject: [PATCH 1/5] Make clang report invalid target versions for all environment. Followup for https://github.com/llvm/llvm-project/pull/75373 1. Make this feature not just available for android, but everyone. 2. Correct some target triples/ 3. Add opencl to the environment type list. --- clang/lib/Driver/Driver.cpp | 19 ++- clang/test/CodeGen/fp128_complex.c | 2 +- clang/test/Driver/mips-features.c| 4 ++-- clang/test/Frontend/fixed_point_bit_widths.c | 4 ++-- llvm/include/llvm/TargetParser/Triple.h | 2 +- llvm/lib/TargetParser/Triple.cpp | 14 ++ 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 1889ea28079df..2d6986d145483 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1430,15 +1430,16 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { const ToolChain &TC = getToolChain( *UArgs, computeTargetTriple(*this, TargetTriple, *UArgs)); - if (TC.getTriple().isAndroid()) { -llvm::Triple Triple = TC.getTriple(); -StringRef TripleVersionName = Triple.getEnvironmentVersionString(); - -if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "") { - Diags.Report(diag::err_drv_triple_version_invalid) - << TripleVersionName << TC.getTripleString(); - ContainsError = true; -} + // Check if the environment version is valid. + llvm::Triple Triple = TC.getTriple(); + StringRef TripleVersionName = Triple.getEnvironmentVersionString(); + StringRef TripleObjectFormat = Triple.getObjectFormatTypeName(Triple.getObjectFormat()); + + if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "" +&& TripleVersionName != TripleObjectFormat) { +Diags.Report(diag::err_drv_triple_version_invalid) +<< TripleVersionName << TC.getTripleString(); +ContainsError = true; } // Report warning when arm64EC option is overridden by specified target diff --git a/clang/test/CodeGen/fp128_complex.c b/clang/test/CodeGen/fp128_complex.c index 48659d2241684..0e87cbe8ce812 100644 --- a/clang/test/CodeGen/fp128_complex.c +++ b/clang/test/CodeGen/fp128_complex.c @@ -1,4 +1,4 @@ -// RUN: %clang -target aarch64-linux-gnuabi %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -target aarch64-linux-gnueabi %s -S -emit-llvm -o - | FileCheck %s _Complex long double a, b, c, d; void test_fp128_compound_assign(void) { diff --git a/clang/test/Driver/mips-features.c b/clang/test/Driver/mips-features.c index fad6009ffb89b..18edcd05ea85c 100644 --- a/clang/test/Driver/mips-features.c +++ b/clang/test/Driver/mips-features.c @@ -400,12 +400,12 @@ // LONG-CALLS-DEF-NOT: "long-calls" // // -mbranch-likely -// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ +// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ // RUN: | FileCheck --check-prefix=BRANCH-LIKELY %s // BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely' // // -mno-branch-likely -// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ +// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ // RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s // NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' diff --git a/clang/test/Frontend/fixed_point_bit_widths.c b/clang/test/Frontend/fixed_point_bit_widths.c index ac8db49ed516a..e56f787e824f2 100644 --- a/clang/test/Frontend/fixed_point_bit_widths.c +++ b/clang/test/Frontend/fixed_point_bit_widths.c @@ -1,7 +1,7 @@ // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - %s | FileCheck %s -// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-ubuntu-fast %s | FileCheck %s +// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4 %s | FileCheck %s // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=ppc64 %s | FileCheck %s -// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-windows10pro-fast %s | FileCheck %s +// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4 %s | FileCheck %s /* Primary signed _Accum */ diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index 95014a546f724..525ea6df3643c 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -273,7 +273,7 @@ class Triple { Callable, Mesh, Amplification, - +OpenCL, OpenHOS, LastEnvironmentType = OpenHOS diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index b9971c25
[Lldb-commits] [flang] [clang] [openmp] [mlir] [libc] [lldb] [lld] [clang-tools-extra] [compiler-rt] [llvm] [libcxx] Make clang report invalid target versions for all environment types. (PR #78655)
https://github.com/ZijunZhaoCCK updated https://github.com/llvm/llvm-project/pull/78655 >From f440f44e7e270d4636ad39f4e4223c904e496d3a Mon Sep 17 00:00:00 2001 From: zijunzhao Date: Fri, 19 Jan 2024 00:47:05 + Subject: [PATCH 1/6] Make clang report invalid target versions for all environment. Followup for https://github.com/llvm/llvm-project/pull/75373 1. Make this feature not just available for android, but everyone. 2. Correct some target triples/ 3. Add opencl to the environment type list. --- clang/lib/Driver/Driver.cpp | 19 ++- clang/test/CodeGen/fp128_complex.c | 2 +- clang/test/Driver/mips-features.c| 4 ++-- clang/test/Frontend/fixed_point_bit_widths.c | 4 ++-- llvm/include/llvm/TargetParser/Triple.h | 2 +- llvm/lib/TargetParser/Triple.cpp | 14 ++ 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 1889ea28079df..2d6986d145483 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1430,15 +1430,16 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) { const ToolChain &TC = getToolChain( *UArgs, computeTargetTriple(*this, TargetTriple, *UArgs)); - if (TC.getTriple().isAndroid()) { -llvm::Triple Triple = TC.getTriple(); -StringRef TripleVersionName = Triple.getEnvironmentVersionString(); - -if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "") { - Diags.Report(diag::err_drv_triple_version_invalid) - << TripleVersionName << TC.getTripleString(); - ContainsError = true; -} + // Check if the environment version is valid. + llvm::Triple Triple = TC.getTriple(); + StringRef TripleVersionName = Triple.getEnvironmentVersionString(); + StringRef TripleObjectFormat = Triple.getObjectFormatTypeName(Triple.getObjectFormat()); + + if (Triple.getEnvironmentVersion().empty() && TripleVersionName != "" +&& TripleVersionName != TripleObjectFormat) { +Diags.Report(diag::err_drv_triple_version_invalid) +<< TripleVersionName << TC.getTripleString(); +ContainsError = true; } // Report warning when arm64EC option is overridden by specified target diff --git a/clang/test/CodeGen/fp128_complex.c b/clang/test/CodeGen/fp128_complex.c index 48659d2241684..0e87cbe8ce812 100644 --- a/clang/test/CodeGen/fp128_complex.c +++ b/clang/test/CodeGen/fp128_complex.c @@ -1,4 +1,4 @@ -// RUN: %clang -target aarch64-linux-gnuabi %s -S -emit-llvm -o - | FileCheck %s +// RUN: %clang -target aarch64-linux-gnueabi %s -S -emit-llvm -o - | FileCheck %s _Complex long double a, b, c, d; void test_fp128_compound_assign(void) { diff --git a/clang/test/Driver/mips-features.c b/clang/test/Driver/mips-features.c index fad6009ffb89b..18edcd05ea85c 100644 --- a/clang/test/Driver/mips-features.c +++ b/clang/test/Driver/mips-features.c @@ -400,12 +400,12 @@ // LONG-CALLS-DEF-NOT: "long-calls" // // -mbranch-likely -// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ +// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mbranch-likely 2>&1 \ // RUN: | FileCheck --check-prefix=BRANCH-LIKELY %s // BRANCH-LIKELY: argument unused during compilation: '-mbranch-likely' // // -mno-branch-likely -// RUN: %clang -target -mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ +// RUN: %clang -target mips-mti-linux-gnu -### -c %s -mno-branch-likely 2>&1 \ // RUN: | FileCheck --check-prefix=NO-BRANCH-LIKELY %s // NO-BRANCH-LIKELY: argument unused during compilation: '-mno-branch-likely' diff --git a/clang/test/Frontend/fixed_point_bit_widths.c b/clang/test/Frontend/fixed_point_bit_widths.c index ac8db49ed516a..e56f787e824f2 100644 --- a/clang/test/Frontend/fixed_point_bit_widths.c +++ b/clang/test/Frontend/fixed_point_bit_widths.c @@ -1,7 +1,7 @@ // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - %s | FileCheck %s -// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-ubuntu-fast %s | FileCheck %s +// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4 %s | FileCheck %s // RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=ppc64 %s | FileCheck %s -// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4-windows10pro-fast %s | FileCheck %s +// RUN: %clang -x c -ffixed-point -S -emit-llvm -o - --target=x86_64-scei-ps4 %s | FileCheck %s /* Primary signed _Accum */ diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index 95014a546f724..525ea6df3643c 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -273,7 +273,7 @@ class Triple { Callable, Mesh, Amplification, - +OpenCL, OpenHOS, LastEnvironmentType = OpenHOS diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp index b9971c25
[Lldb-commits] [mlir] [llvm] [lldb] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)
https://github.com/pzread updated https://github.com/llvm/llvm-project/pull/80331 >From 70f54b51bef87bde5e3f5ee067c0f2414d34e915 Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Thu, 1 Feb 2024 19:57:26 + Subject: [PATCH] Add replaceWithZeroTripCheck to LoopLikeOpInterface --- .../mlir/Interfaces/LoopLikeInterface.td | 22 +++ 1 file changed, 22 insertions(+) diff --git a/mlir/include/mlir/Interfaces/LoopLikeInterface.td b/mlir/include/mlir/Interfaces/LoopLikeInterface.td index e2ac85a3f7725..77409cb3a8274 100644 --- a/mlir/include/mlir/Interfaces/LoopLikeInterface.td +++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td @@ -220,6 +220,28 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> { /*defaultImplementation=*/[{ return ::mlir::failure(); }] +>, +InterfaceMethod<[{ +Add a zero-trip-check around the loop to check if the loop body is ever +run and return the new loop inside the check. The loop body is moved +over to the new loop. Returns "failure" if the loop doesn't support +this transformation. + +After the transformation, the ops inserted to the parent region of the +loop are guaranteed to be run only if the loop body runs at least one +iteration. + +Note: Ops in the loop body might be rearranged because of loop rotating +to maintain the semantic. Terminators might be removed/added during this +transformation. + }], + /*retTy=*/"::mlir::FailureOr<::mlir::LoopLikeOpInterface>", + /*methodName=*/"replaceWithZeroTripCheck", + /*args=*/(ins "::mlir::RewriterBase &":$rewriter), + /*methodBody=*/"", + /*defaultImplementation=*/[{ +return ::mlir::failure(); + }] > ]; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [mlir] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)
llvmbot wrote: @llvm/pr-subscribers-mlir Author: Jerry Wu (pzread) Changes Adds a new method `replaceWithZeroTripCheck` to `LoopLikeOpInterface`, to create zero-trip-check around the loop The purpose is to let loop ops (e.g. `scf.while`, `scf.for`) implement their own transformations to add zero-trip-check. The zero-trip-check creates a guard (e.g. `scf.if`) around the loop and the condition will be true only if the loop body will run at least once. An example usage is to hoist resource-intense loop invariants into this guard region so they will only run once but also not run when the loop body won't run at all. The implementation of `scf.while` can be found in the follow-up change: #80349 --- Full diff: https://github.com/llvm/llvm-project/pull/80331.diff 1 Files Affected: - (modified) mlir/include/mlir/Interfaces/LoopLikeInterface.td (+22) ``diff diff --git a/mlir/include/mlir/Interfaces/LoopLikeInterface.td b/mlir/include/mlir/Interfaces/LoopLikeInterface.td index e2ac85a3f7725..77409cb3a8274 100644 --- a/mlir/include/mlir/Interfaces/LoopLikeInterface.td +++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td @@ -220,6 +220,28 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> { /*defaultImplementation=*/[{ return ::mlir::failure(); }] +>, +InterfaceMethod<[{ +Add a zero-trip-check around the loop to check if the loop body is ever +run and return the new loop inside the check. The loop body is moved +over to the new loop. Returns "failure" if the loop doesn't support +this transformation. + +After the transformation, the ops inserted to the parent region of the +loop are guaranteed to be run only if the loop body runs at least one +iteration. + +Note: Ops in the loop body might be rearranged because of loop rotating +to maintain the semantic. Terminators might be removed/added during this +transformation. + }], + /*retTy=*/"::mlir::FailureOr<::mlir::LoopLikeOpInterface>", + /*methodName=*/"replaceWithZeroTripCheck", + /*args=*/(ins "::mlir::RewriterBase &":$rewriter), + /*methodBody=*/"", + /*defaultImplementation=*/[{ +return ::mlir::failure(); + }] > ]; `` https://github.com/llvm/llvm-project/pull/80331 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [mlir] [llvm] [lldb] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)
https://github.com/pzread edited https://github.com/llvm/llvm-project/pull/80331 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [mlir] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)
https://github.com/pzread edited https://github.com/llvm/llvm-project/pull/80331 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [mlir] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)
https://github.com/pzread edited https://github.com/llvm/llvm-project/pull/80331 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -17,7 +17,7 @@ define i16 @test() { ; CHECK-NEXT:[[TMP4:%.*]] = call <2 x i16> @llvm.masked.gather.v2i16.v2p0(<2 x ptr> [[TMP3]], i32 2, <2 x i1> , <2 x i16> poison) ; CHECK-NEXT:[[TMP5:%.*]] = extractelement <2 x i16> [[TMP4]], i32 0 ; CHECK-NEXT:[[TMP6:%.*]] = extractelement <2 x i16> [[TMP4]], i32 1 -; CHECK-NEXT:[[CMP_I178:%.*]] = icmp ult i16 [[TMP6]], [[TMP5]] +; CHECK-NEXT:[[CMP_I178:%.*]] = icmp ult i16 [[TMP5]], [[TMP6]] ; CHECK-NEXT:br label [[WHILE_BODY_I]] ; entry: alexey-bataev wrote: For SLP vectorizer it is not important. https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -30,7 +30,7 @@ define void @test() { ; CHECK-SLP-THRESHOLD: bb: ; CHECK-SLP-THRESHOLD-NEXT:[[TMP0:%.*]] = insertelement <4 x ptr> poison, ptr [[COND_IN_V]], i32 0 ; CHECK-SLP-THRESHOLD-NEXT:[[TMP1:%.*]] = shufflevector <4 x ptr> [[TMP0]], <4 x ptr> poison, <4 x i32> zeroinitializer -; CHECK-SLP-THRESHOLD-NEXT:[[TMP2:%.*]] = getelementptr i64, <4 x ptr> [[TMP1]], <4 x i64> +; CHECK-SLP-THRESHOLD-NEXT:[[TMP2:%.*]] = getelementptr i64, <4 x ptr> [[TMP1]], <4 x i64> alexey-bataev wrote: For X86 target it is supposed as not supported currently, so it just produces masked gather and the order is not important https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -7,7 +7,7 @@ define i32 @test(ptr noalias %p, ptr noalias %addr) { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[TMP0:%.*]] = insertelement <8 x ptr> poison, ptr [[ADDR:%.*]], i32 0 ; CHECK-NEXT:[[TMP1:%.*]] = shufflevector <8 x ptr> [[TMP0]], <8 x ptr> poison, <8 x i32> zeroinitializer -; CHECK-NEXT:[[TMP2:%.*]] = getelementptr i32, <8 x ptr> [[TMP1]], <8 x i32> +; CHECK-NEXT:[[TMP2:%.*]] = getelementptr i32, <8 x ptr> [[TMP1]], <8 x i32> alexey-bataev wrote: Same, TTI for X86 does not support strided loads, so the order is not important https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -397,27 +241,12 @@ define void @test3([48 x float]* %p, float* noalias %s) { ; CHECK-NEXT: entry: ; CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [48 x float], ptr [[P:%.*]], i64 0, i64 0 ; CHECK-NEXT:[[ARRAYIDX2:%.*]] = getelementptr inbounds float, ptr [[S:%.*]], i64 0 -; CHECK-NEXT:[[ARRAYIDX4:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 4 -; CHECK-NEXT:[[ARRAYIDX11:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 8 -; CHECK-NEXT:[[ARRAYIDX18:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 12 -; CHECK-NEXT:[[ARRAYIDX25:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 16 -; CHECK-NEXT:[[ARRAYIDX32:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 20 -; CHECK-NEXT:[[ARRAYIDX39:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 24 -; CHECK-NEXT:[[ARRAYIDX46:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 28 ; CHECK-NEXT:[[ARRAYIDX48:%.*]] = getelementptr inbounds [48 x float], ptr [[P]], i64 0, i64 23 -; CHECK-NEXT:[[TMP0:%.*]] = insertelement <8 x ptr> poison, ptr [[ARRAYIDX]], i32 0 -; CHECK-NEXT:[[TMP1:%.*]] = insertelement <8 x ptr> [[TMP0]], ptr [[ARRAYIDX4]], i32 1 -; CHECK-NEXT:[[TMP2:%.*]] = insertelement <8 x ptr> [[TMP1]], ptr [[ARRAYIDX11]], i32 2 -; CHECK-NEXT:[[TMP3:%.*]] = insertelement <8 x ptr> [[TMP2]], ptr [[ARRAYIDX18]], i32 3 -; CHECK-NEXT:[[TMP4:%.*]] = insertelement <8 x ptr> [[TMP3]], ptr [[ARRAYIDX25]], i32 4 -; CHECK-NEXT:[[TMP5:%.*]] = insertelement <8 x ptr> [[TMP4]], ptr [[ARRAYIDX32]], i32 5 -; CHECK-NEXT:[[TMP6:%.*]] = insertelement <8 x ptr> [[TMP5]], ptr [[ARRAYIDX39]], i32 6 -; CHECK-NEXT:[[TMP7:%.*]] = insertelement <8 x ptr> [[TMP6]], ptr [[ARRAYIDX46]], i32 7 -; CHECK-NEXT:[[TMP8:%.*]] = call <8 x float> @llvm.masked.gather.v8f32.v8p0(<8 x ptr> [[TMP7]], i32 4, <8 x i1> , <8 x float> poison) -; CHECK-NEXT:[[TMP9:%.*]] = load <8 x float>, ptr [[ARRAYIDX48]], align 4 -; CHECK-NEXT:[[TMP10:%.*]] = shufflevector <8 x float> [[TMP9]], <8 x float> poison, <8 x i32> -; CHECK-NEXT:[[TMP11:%.*]] = fsub fast <8 x float> [[TMP10]], [[TMP8]] -; CHECK-NEXT:store <8 x float> [[TMP11]], ptr [[ARRAYIDX2]], align 4 +; CHECK-NEXT:[[TMP0:%.*]] = call <8 x float> @llvm.experimental.vp.strided.load.v8f32.p0.i64(ptr align 4 [[ARRAYIDX]], i64 16, <8 x i1> , i32 8) +; CHECK-NEXT:[[TMP1:%.*]] = load <8 x float>, ptr [[ARRAYIDX48]], align 4 +; CHECK-NEXT:[[TMP2:%.*]] = shufflevector <8 x float> [[TMP1]], <8 x float> poison, <8 x i32> alexey-bataev wrote: It can, planned for the next patch(es), cannot put all the stuff in a single patch https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -3878,6 +3883,130 @@ static Align computeCommonAlignment(ArrayRef VL) { return CommonAlignment; } +/// Check if \p Order represents reverse order. +static bool isReverseOrder(ArrayRef Order) { + unsigned Sz = Order.size(); + return !Order.empty() && all_of(enumerate(Order), [&](const auto &Pair) { +return Pair.value() == Sz || Sz - Pair.index() - 1 == Pair.value(); + }); +} + +/// Checks if the provided list of pointers \p Pointers represents the strided +/// pointers for type ElemTy. If they are not, std::nullopt is returned. +/// Otherwise, if \p Inst is not specified, just initialized optional value is +/// returned to show that the pointers represent strided pointers. If \p Inst +/// specified, the runtime stride is materialized before the given \p Inst. +/// \returns std::nullopt if the pointers are not pointers with the runtime +/// stride, nullptr or actual stride value, otherwise. +static std::optional +calculateRtStride(ArrayRef PointerOps, Type *ElemTy, + const DataLayout &DL, ScalarEvolution &SE, + SmallVectorImpl &SortedIndices, + Instruction *Inst = nullptr) { + SmallVector SCEVs; alexey-bataev wrote: Constant strides covered separately, this one checks for non-constant strides and it does not care about the order, it sorts them properly https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -3930,30 +4065,68 @@ static LoadsState canVectorizeLoads(ArrayRef VL, const Value *VL0, std::optional Diff = getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, DL, SE); // Check that the sorted loads are consecutive. - if (static_cast(*Diff) == VL.size() - 1) + if (static_cast(*Diff) == Sz - 1) return LoadsState::Vectorize; // Simple check if not a strided access - clear order. - IsPossibleStrided = *Diff % (VL.size() - 1) == 0; + bool IsPossibleStrided = *Diff % (Sz - 1) == 0; + // Try to generate strided load node if: + // 1. Target with strided load support is detected. + // 2. The number of loads is greater than MinProfitableStridedLoads, + // or the potential stride <= MaxProfitableLoadStride and the + // potential stride is power-of-2 (to avoid perf regressions for the very + // small number of loads) and max distance > number of loads, or potential + // stride is -1. + // 3. The loads are ordered, or number of unordered loads <= + // MaxProfitableUnorderedLoads, or loads are in reversed order. + // (this check is to avoid extra costs for very expensive shuffles). + if (IsPossibleStrided && (((Sz > MinProfitableStridedLoads || + (static_cast(std::abs(*Diff)) <= + MaxProfitableLoadStride * Sz && + isPowerOf2_32(std::abs(*Diff && + static_cast(std::abs(*Diff)) > Sz) || +*Diff == -(static_cast(Sz) - 1))) { +int Stride = *Diff / static_cast(Sz - 1); +if (*Diff == Stride * static_cast(Sz - 1)) { + if (TTI.isTypeLegal(VecTy) && alexey-bataev wrote: Removed https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
@@ -3930,30 +4065,68 @@ static LoadsState canVectorizeLoads(ArrayRef VL, const Value *VL0, std::optional Diff = getPointersDiff(ScalarTy, Ptr0, ScalarTy, PtrN, DL, SE); // Check that the sorted loads are consecutive. - if (static_cast(*Diff) == VL.size() - 1) + if (static_cast(*Diff) == Sz - 1) return LoadsState::Vectorize; // Simple check if not a strided access - clear order. - IsPossibleStrided = *Diff % (VL.size() - 1) == 0; + bool IsPossibleStrided = *Diff % (Sz - 1) == 0; + // Try to generate strided load node if: + // 1. Target with strided load support is detected. + // 2. The number of loads is greater than MinProfitableStridedLoads, + // or the potential stride <= MaxProfitableLoadStride and the + // potential stride is power-of-2 (to avoid perf regressions for the very + // small number of loads) and max distance > number of loads, or potential + // stride is -1. + // 3. The loads are ordered, or number of unordered loads <= + // MaxProfitableUnorderedLoads, or loads are in reversed order. + // (this check is to avoid extra costs for very expensive shuffles). + if (IsPossibleStrided && (((Sz > MinProfitableStridedLoads || + (static_cast(std::abs(*Diff)) <= + MaxProfitableLoadStride * Sz && + isPowerOf2_32(std::abs(*Diff && + static_cast(std::abs(*Diff)) > Sz) || +*Diff == -(static_cast(Sz) - 1))) { +int Stride = *Diff / static_cast(Sz - 1); alexey-bataev wrote: This is stride in "scalar elements", here the size in bytes is not important, getPointersDiff() handles pointers with different types (sizes). Here we just looking that the pointers have proportional constant distances between them. https://github.com/llvm/llvm-project/pull/80310 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [libcxx] [lldb] [clang] [lld] [libc] [llvm] [mlir] [flang] [openmp] [clang-tools-extra] [SLP]Add support for strided loads. (PR #80310)
https://github.com/alexey-bataev updated https://github.com/llvm/llvm-project/pull/80310 >From 92950afd39034c0184a3c807f8062e0053eead5c Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 1 Feb 2024 17:22:34 + Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- .../llvm/Analysis/TargetTransformInfo.h | 34 ++ .../llvm/Analysis/TargetTransformInfoImpl.h | 13 + llvm/lib/Analysis/TargetTransformInfo.cpp | 14 + .../Target/RISCV/RISCVTargetTransformInfo.cpp | 23 + .../Target/RISCV/RISCVTargetTransformInfo.h | 23 + .../Transforms/Vectorize/SLPVectorizer.cpp| 397 -- .../SLPVectorizer/RISCV/complex-loads.ll | 132 +++--- .../RISCV/strided-loads-vectorized.ll | 209 + .../strided-loads-with-external-use-ptr.ll| 4 +- .../SLPVectorizer/RISCV/strided-loads.ll | 13 +- .../X86/gep-nodes-with-non-gep-inst.ll| 2 +- .../X86/remark_gather-load-redux-cost.ll | 2 +- 12 files changed, 478 insertions(+), 388 deletions(-) diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index 3b615bc700bbb..b0b6dab03fa38 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -781,6 +781,9 @@ class TargetTransformInfo { /// Return true if the target supports masked expand load. bool isLegalMaskedExpandLoad(Type *DataType) const; + /// Return true if the target supports strided load. + bool isLegalStridedLoad(Type *DataType, Align Alignment) const; + /// Return true if this is an alternating opcode pattern that can be lowered /// to a single instruction on the target. In X86 this is for the addsub /// instruction which corrsponds to a Shuffle + Fadd + FSub pattern in IR. @@ -1412,6 +1415,20 @@ class TargetTransformInfo { Align Alignment, TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, const Instruction *I = nullptr) const; + /// \return The cost of strided memory operations. + /// \p Opcode - is a type of memory access Load or Store + /// \p DataTy - a vector type of the data to be loaded or stored + /// \p Ptr - pointer [or vector of pointers] - address[es] in memory + /// \p VariableMask - true when the memory access is predicated with a mask + /// that is not a compile-time constant + /// \p Alignment - alignment of single element + /// \p I - the optional original context instruction, if one exists, e.g. the + ///load/store to transform or the call to the gather/scatter intrinsic + InstructionCost getStridedMemoryOpCost( + unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, + Align Alignment, TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, + const Instruction *I = nullptr) const; + /// \return The cost of the interleaved memory operation. /// \p Opcode is the memory operation code /// \p VecTy is the vector type of the interleaved access. @@ -1848,6 +1865,7 @@ class TargetTransformInfo::Concept { Align Alignment) = 0; virtual bool isLegalMaskedCompressStore(Type *DataType) = 0; virtual bool isLegalMaskedExpandLoad(Type *DataType) = 0; + virtual bool isLegalStridedLoad(Type *DataType, Align Alignment) = 0; virtual bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask) const = 0; @@ -2023,6 +2041,11 @@ class TargetTransformInfo::Concept { bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I = nullptr) = 0; + virtual InstructionCost + getStridedMemoryOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, + bool VariableMask, Align Alignment, + TTI::TargetCostKind CostKind, + const Instruction *I = nullptr) = 0; virtual InstructionCost getInterleavedMemoryOpCost( unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef Indices, @@ -2341,6 +2364,9 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept { bool isLegalMaskedExpandLoad(Type *DataType) override { return Impl.isLegalMaskedExpandLoad(DataType); } + bool isLegalStridedLoad(Type *DataType, Align Alignment) override { +return Impl.isLegalStridedLoad(DataType, Alignment); + } bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask) const override { return Impl.isLegalAltInstr(VecTy, Opcode0, Opcode1, OpcodeMask); @@ -2671,6 +2697,14 @@ class TargetTransformInfo::Model
[Lldb-commits] [libcxx] [flang] [libc] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [AArch64][MachinePipeliner] Add pipeliner support for AArch64 (PR #79589)
https://github.com/ytmukai updated https://github.com/llvm/llvm-project/pull/79589 >From bcdb1e47ce841df96b2916d61cda018503f62358 Mon Sep 17 00:00:00 2001 From: Yuta Mukai Date: Tue, 12 Dec 2023 16:59:09 + Subject: [PATCH] [AArch64][MachinePipeliner] Add pipeliner support for AArch64 Add AArch64 implementations for the interfaces of MachinePipeliner pass. The pass is disabled by default for AArch64. It is enabled by specifying --aarch64-enable-pipeliner. 5 tests in llvm-test-suites show performance improvement by more than 5% on a Neoverse V1 processor. | test | improvement | | | ---:| | MultiSource/Benchmarks/TSVC/Recurrences-dbl/Recurrences-dbl.test | 16% | | MultiSource/Benchmarks/TSVC/Recurrences-dbl/Recurrences-flt.test | 16% | | SingleSource/Benchmarks/Adobe-C++/loop_unroll.test | 14% | | SingleSource/Benchmarks/Misc/flops-5.test| 13% | | SingleSource/Benchmarks/BenchmarkGame/spectral-norm.test | 6% | (base flags: -mcpu=neoverse-v1 -O3 -mrecip, flags for pipelining: -mllvm -aarch64-enable-pipeliner -mllvm -pipeliner-max-stages=100 -mllvm -pipeliner-max-mii=100 -mllvm -pipeliner-enable-copytophi=0) On the other hand, there are cases of significant performance degradation. Algorithm improvements and adding the option/pragma will be needed in the future. --- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 105 ++ llvm/lib/Target/AArch64/AArch64InstrInfo.h| 4 + llvm/lib/Target/AArch64/AArch64Subtarget.cpp | 4 + llvm/lib/Target/AArch64/AArch64Subtarget.h| 3 + .../Target/AArch64/AArch64TargetMachine.cpp | 7 ++ .../CodeGen/AArch64/sms-acceptable-loop1.mir | 78 + .../CodeGen/AArch64/sms-acceptable-loop2.mir | 78 + .../CodeGen/AArch64/sms-acceptable-loop3.mir | 79 + .../CodeGen/AArch64/sms-acceptable-loop4.mir | 79 + .../AArch64/sms-unacceptable-loop1.mir| 77 + .../AArch64/sms-unacceptable-loop2.mir| 80 + .../CodeGen/AArch64/sms-unpipeline-insts1.mir | 87 +++ .../CodeGen/AArch64/sms-unpipeline-insts2.mir | 80 + 13 files changed, 761 insertions(+) create mode 100644 llvm/test/CodeGen/AArch64/sms-acceptable-loop1.mir create mode 100644 llvm/test/CodeGen/AArch64/sms-acceptable-loop2.mir create mode 100644 llvm/test/CodeGen/AArch64/sms-acceptable-loop3.mir create mode 100644 llvm/test/CodeGen/AArch64/sms-acceptable-loop4.mir create mode 100644 llvm/test/CodeGen/AArch64/sms-unacceptable-loop1.mir create mode 100644 llvm/test/CodeGen/AArch64/sms-unacceptable-loop2.mir create mode 100644 llvm/test/CodeGen/AArch64/sms-unpipeline-insts1.mir create mode 100644 llvm/test/CodeGen/AArch64/sms-unpipeline-insts2.mir diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 8e50c16ba0887..809c3415ea234 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -9608,6 +9608,111 @@ AArch64InstrInfo::probedStackAlloc(MachineBasicBlock::iterator MBBI, return ExitMBB->begin(); } +namespace { +class AArch64PipelinerLoopInfo : public TargetInstrInfo::PipelinerLoopInfo { + MachineInstr *PredBranch; + SmallVector Cond; + +public: + AArch64PipelinerLoopInfo(MachineInstr *PredBranch, + const SmallVectorImpl &Cond) + : PredBranch(PredBranch), Cond(Cond.begin(), Cond.end()) {} + + bool shouldIgnoreForPipelining(const MachineInstr *MI) const override { +// Make the instructions for loop control be placed in stage 0. +// The predecessors of PredBranch are considered by the caller. +return MI == PredBranch; + } + + std::optional createTripCountGreaterCondition( + int TC, MachineBasicBlock &MBB, + SmallVectorImpl &CondParam) override { +// A branch instruction will be inserted as "if (Cond) goto epilogue". +// Cond is normalized for such use. +// The predecessors of the branch are assumed to have already been inserted. +CondParam = Cond; +return {}; + } + + void setPreheader(MachineBasicBlock *NewPreheader) override {} + + void adjustTripCount(int TripCountAdjust) override {} + + void disposed() override {} +}; +} // namespace + +static bool isCompareAndBranch(unsigned Opcode) { + switch (Opcode) { + case AArch64::CBZW: + case AArch64::CBZX: + case AArch64::CBNZW: + case AArch64::CBNZX: + case AArch64::TBZW: + case AArch64::TBZX: + case AArch64::TBNZW: + case AArch64::TBNZX: +return true; + } + return false; +} + +std::unique_ptr +AArch64InstrInfo::analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const { + MachineBasicBlock *TBB = nullptr, *FBB = nullptr; + SmallVector Cond; + if (analyzeBranch(*LoopBB, TBB, FBB,
[Lldb-commits] [mlir] [libcxx] [flang] [libc] [clang] [lldb] [llvm] [mlir] Skip invalid test on big endian platform (s390x) (PR #80246)
https://github.com/jpienaar approved this pull request. https://github.com/llvm/llvm-project/pull/80246 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/80368 This patch adds a frame recognizer for Clang's `__builtin_verbose_trap`, which behaves like a `__builtin_trap`, but emits a failure-reason string into debug-info in order for debuggers to display it to a user. The frame recognizer triggers when we encounter a frame with a function name that begins with `__llvm_verbose_trap`, which is the magic prefix Clang emits into debug-info for verbose traps. Once such frame is encountered we display the frame function name as the `Stop Reason` and display that frame to the user. Example output: ``` (lldb) run warning: a.out was compiled with optimization - stepping may behave oddly; variables may not be available. Process 35942 launched: 'a.out' (arm64) Process 35942 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = __llvm_verbose_trap: Function is not implemented frame #1: 0x00013fa4 a.out`main [inlined] Dummy::func(this=) at verbose_trap.cpp:3:5 [opt] 1struct Dummy { 2 void func() { -> 3__builtin_verbose_trap("Function is not implemented"); 4 } 5}; 6 7int main() { (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = __llvm_verbose_trap: Function is not implemented frame #0: 0x00013fa4 a.out`main [inlined] __llvm_verbose_trap: Function is not implemented at verbose_trap.cpp:0 [opt] * frame #1: 0x00013fa4 a.out`main [inlined] Dummy::func(this=) at verbose_trap.cpp:3:5 [opt] frame #2: 0x00013fa4 a.out`main at verbose_trap.cpp:8:13 [opt] frame #3: 0x000189d518b4 dyld`start + 1988 ``` >From 3f3d7aeffe1d156efd4f54cdce6f6c6ca933da75 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Thu, 25 Jan 2024 11:05:02 + Subject: [PATCH] [lldb] Add frame recognizer for __builtin_verbose_trap This patch adds a frame recognizer for Clang's `__builtin_verbose_trap`, which behaves like a `__builtin_trap`, but emits a failure-reason string into debug-info in order for debuggers to display it to a user. The frame recognizer triggers when we encounter a frame with a function name that begins with `__llvm_verbose_trap`, which is the magic prefix Clang emits into debug-info for verbose traps. Once such frame is encountered we display the frame function name as the `Stop Reason` and display that frame to the user. Example output: ``` (lldb) run warning: a.out was compiled with optimization - stepping may behave oddly; variables may not be available. Process 35942 launched: 'a.out' (arm64) Process 35942 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = __llvm_verbose_trap: Function is not implemented frame #1: 0x00013fa4 a.out`main [inlined] Dummy::func(this=) at verbose_trap.cpp:3:5 [opt] 1struct Dummy { 2 void func() { -> 3__builtin_verbose_trap("Function is not implemented"); 4 } 5}; 6 7int main() { (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = __llvm_verbose_trap: Function is not implemented frame #0: 0x00013fa4 a.out`main [inlined] __llvm_verbose_trap: Function is not implemented at verbose_trap.cpp:0 [opt] * frame #1: 0x00013fa4 a.out`main [inlined] Dummy::func(this=) at verbose_trap.cpp:3:5 [opt] frame #2: 0x00013fa4 a.out`main at verbose_trap.cpp:8:13 [opt] frame #3: 0x000189d518b4 dyld`start + 1988 ``` --- .../lldb/Target/VerboseTrapFrameRecognizer.h | 39 + lldb/source/Target/CMakeLists.txt | 1 + lldb/source/Target/Process.cpp| 2 + .../Target/VerboseTrapFrameRecognizer.cpp | 85 +++ .../Shell/Recognizer/Inputs/verbose_trap.cpp | 8 ++ lldb/test/Shell/Recognizer/verbose_trap.test | 9 ++ 6 files changed, 144 insertions(+) create mode 100644 lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h create mode 100644 lldb/source/Target/VerboseTrapFrameRecognizer.cpp create mode 100644 lldb/test/Shell/Recognizer/Inputs/verbose_trap.cpp create mode 100644 lldb/test/Shell/Recognizer/verbose_trap.test diff --git a/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h new file mode 100644 index 0..7e045760a28be --- /dev/null +++ b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h @@ -0,0 +1,39 @@ +#ifndef LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H +#define LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H + +#include "lldb/Target/StackFrameRecognizer.h" + +namespace lldb_private { + +void RegisterVerboseTrapFrameRecognizer(Process &process); + +/// Holds the stack frame that caused the Verbose trap and the inlined stop +/// reason message. +class VerboseTrapRecognizedStackFrame : public RecognizedStackFrame { +public: + VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp, + std::string stop_desc); + + lldb::StackFrameSP Get
[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This patch adds a frame recognizer for Clang's `__builtin_verbose_trap`, which behaves like a `__builtin_trap`, but emits a failure-reason string into debug-info in order for debuggers to display it to a user. The frame recognizer triggers when we encounter a frame with a function name that begins with `__llvm_verbose_trap`, which is the magic prefix Clang emits into debug-info for verbose traps. Once such frame is encountered we display the frame function name as the `Stop Reason` and display that frame to the user. Example output: ``` (lldb) run warning: a.out was compiled with optimization - stepping may behave oddly; variables may not be available. Process 35942 launched: 'a.out' (arm64) Process 35942 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = __llvm_verbose_trap: Function is not implemented frame #1: 0x00013fa4 a.out`main [inlined] Dummy::func(this=) at verbose_trap.cpp:3:5 [opt] 1struct Dummy { 2 void func() { -> 3__builtin_verbose_trap("Function is not implemented"); 4 } 5}; 6 7int main() { (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = __llvm_verbose_trap: Function is not implemented frame #0: 0x00013fa4 a.out`main [inlined] __llvm_verbose_trap: Function is not implemented at verbose_trap.cpp:0 [opt] * frame #1: 0x00013fa4 a.out`main [inlined] Dummy::func(this= ) at verbose_trap.cpp:3:5 [opt] frame #2: 0x00013fa4 a.out`main at verbose_trap.cpp:8:13 [opt] frame #3: 0x000189d518b4 dyld`start + 1988 ``` --- Full diff: https://github.com/llvm/llvm-project/pull/80368.diff 6 Files Affected: - (added) lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h (+39) - (modified) lldb/source/Target/CMakeLists.txt (+1) - (modified) lldb/source/Target/Process.cpp (+2) - (added) lldb/source/Target/VerboseTrapFrameRecognizer.cpp (+85) - (added) lldb/test/Shell/Recognizer/Inputs/verbose_trap.cpp (+8) - (added) lldb/test/Shell/Recognizer/verbose_trap.test (+9) ``diff diff --git a/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h new file mode 100644 index 0..7e045760a28be --- /dev/null +++ b/lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h @@ -0,0 +1,39 @@ +#ifndef LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H +#define LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H + +#include "lldb/Target/StackFrameRecognizer.h" + +namespace lldb_private { + +void RegisterVerboseTrapFrameRecognizer(Process &process); + +/// Holds the stack frame that caused the Verbose trap and the inlined stop +/// reason message. +class VerboseTrapRecognizedStackFrame : public RecognizedStackFrame { +public: + VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp, + std::string stop_desc); + + lldb::StackFrameSP GetMostRelevantFrame() override; + +private: + lldb::StackFrameSP m_most_relevant_frame; +}; + +/// When a thread stops, it checks the current frame contains a +/// Verbose Trap diagnostic. If so, it returns a \a +/// VerboseTrapRecognizedStackFrame holding the diagnostic a stop reason +/// description with and the parent frame as the most relavant frame. +class VerboseTrapFrameRecognizer : public StackFrameRecognizer { +public: + std::string GetName() override { +return "Verbose Trap StackFrame Recognizer"; + } + + lldb::RecognizedStackFrameSP + RecognizeFrame(lldb::StackFrameSP frame) override; +}; + +} // namespace lldb_private + +#endif // LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H diff --git a/lldb/source/Target/CMakeLists.txt b/lldb/source/Target/CMakeLists.txt index cf4818eae3eb8..8186ccbea27d4 100644 --- a/lldb/source/Target/CMakeLists.txt +++ b/lldb/source/Target/CMakeLists.txt @@ -78,6 +78,7 @@ add_lldb_library(lldbTarget UnixSignals.cpp UnwindAssembly.cpp UnwindLLDB.cpp + VerboseTrapFrameRecognizer.cpp LINK_LIBS lldbBreakpoint diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 23a8a66645c02..04b00aaa1fac9 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -63,6 +63,7 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Target/ThreadPlanStack.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Target/VerboseTrapFrameRecognizer.h" #include "lldb/Utility/Event.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" @@ -497,6 +498,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, value_sp->SetValueAs(platform_cache_line_size); RegisterAssertFrameRecognizer(this); + RegisterVerboseTrapFrameRecognizer(*this); } Process::~Process() { diff --git a/lldb/source/Target/VerboseTrapFrameRecognizer.cpp b/lldb/source/Target/VerboseTrapFrameRecognizer.cpp new file mode 10
[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)
jimingham wrote: The patch looks fine to me, but I'm a bit bugged by the fact that it is in Target. In my mind, this is part of the C LanguageRuntime, except we don't yet have a C Language Runtime... https://github.com/llvm/llvm-project/pull/80368 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)
https://github.com/jeffreytan81 created https://github.com/llvm/llvm-project/pull/80375 None >From 59e1499ec0afebb533c4952f079278341b957241 Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Thu, 1 Feb 2024 18:07:51 -0800 Subject: [PATCH] Add commands frequency to statistics dump --- lldb/include/lldb/API/SBCommandInterpreter.h | 9 --- lldb/include/lldb/API/SBStructuredData.h | 1 + .../lldb/Interpreter/CommandInterpreter.h | 15 +-- lldb/source/API/SBCommandInterpreter.cpp | 15 ++- .../source/Commands/CommandObjectCommands.cpp | 10 --- .../source/Interpreter/CommandInterpreter.cpp | 9 ++- lldb/source/Interpreter/CommandObject.cpp | 1 + lldb/source/Target/Statistics.cpp | 4 +++ .../commands/statistics/basic/TestStats.py| 24 + .../stats_api/TestStatisticsAPI.py| 26 +++ 10 files changed, 103 insertions(+), 11 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index b7f5b3bf3396e..b4629a4c2f5a8 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -13,6 +13,7 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" +#include "lldb/API/SBStructuredData.h" namespace lldb_private { class CommandPluginInterfaceImplementation; @@ -246,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList &matches, lldb::SBStringList &descriptions); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -315,6 +316,8 @@ class SBCommandInterpreter { /// and aliases. If successful, result->GetOutput has the full expansion. void ResolveCommand(const char *command_line, SBCommandReturnObject &result); + SBStructuredData GetStatistics(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/include/lldb/API/SBStructuredData.h b/lldb/include/lldb/API/SBStructuredData.h index 35d321eaa7b89..fc6e1ec95c7b8 100644 --- a/lldb/include/lldb/API/SBStructuredData.h +++ b/lldb/include/lldb/API/SBStructuredData.h @@ -122,6 +122,7 @@ class SBStructuredData { friend class SBTrace; friend class lldb_private::python::SWIGBridge; friend class lldb_private::lua::SWIGBridge; + friend class SBCommandInterpreter; SBStructuredData(const lldb_private::StructuredDataImpl &impl); diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 747188a15312f..c46cf0409bab6 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace lldb_private { class CommandInterpreter; @@ -240,7 +241,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -575,7 +576,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { @@ -641,6 +642,12 @@ class CommandInterpreter : public Broadcaster, Status PreprocessCommand(std::string &command); Status PreprocessToken(std::string &token); + void IncreaseCommandUsage(const CommandObject &cmd_obj) { +++m_command_usages[cmd_obj.GetCommandName().str()]; + } + + llvm::json::Value GetStatistics(); + protected: friend class Debugger; @@ -754,6 +761,10 @@ class CommandInterpreter : public Broadcaster, // If the driver is accepts custom exit codes for the 'quit' command. bool m_allow_exit_code = false; + /// Command usage statistics. + typedef std::unordered_map CommandUsageMap; + CommandUsageMap m_command_usages; + StreamString m_transcript_stream; }; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/sou
[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)
https://github.com/jasonmolenda created https://github.com/llvm/llvm-project/pull/80376 debugserver on arm64 devices can manage both Byte Address Select watchpoints (1-8 bytes) and MASK watchpoints (8 bytes-2 gigabytes). This adds a SupportedWatchpointTypes key to the QSupported response from debugserver with a list of these, so lldb can take full advantage of them when creating larger regions with a single hardware watchpoint. Also add documentation for this, and two other lldb extensions, to the lldb-gdb-remote.txt documentation. Re-enable TestLargeWatchpoint.py on Darwin systems when testing with the in-tree built debugserver. I can remove the "in-tree built debugserver" in the future when this new key is handled by an Xcode debugserver. >From 70a518030f2b23ca130a8d0ea667729d7985795c Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Thu, 1 Feb 2024 17:46:03 -0800 Subject: [PATCH] [lldb] Add QSupported key to report watchpoint types supported debugserver on arm64 devices can manage both Byte Address Select watchpoints (1-8 bytes) and MASK watchpoints (8 bytes-2 gigabytes). This adds a SupportedWatchpointTypes key to the QSupported response from debugserver with a list of these, so lldb can take full advantage of them when creating larger regions with a single hardware watchpoint. Also add documentation for this, and two other lldb extensions, to the lldb-gdb-remote.txt documentation. Re-enable TestLargeWatchpoint.py on Darwin systems when testing with the in-tree built debugserver. I can remove the "in-tree built debugserver" in the future when this new key is handled by an Xcode debugserver. --- lldb/docs/lldb-gdb-remote.txt | 37 +++ .../tools/lldb-server/gdbremote_testcase.py | 2 + .../GDBRemoteCommunicationClient.cpp | 21 +++ .../gdb-remote/GDBRemoteCommunicationClient.h | 4 ++ .../Process/gdb-remote/ProcessGDBRemote.cpp | 11 +- .../large-watchpoint/TestLargeWatchpoint.py | 5 --- lldb/tools/debugserver/source/RNBRemote.cpp | 30 --- 7 files changed, 82 insertions(+), 28 deletions(-) diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt index 58269e4c2b688..8db2fbc47b165 100644 --- a/lldb/docs/lldb-gdb-remote.txt +++ b/lldb/docs/lldb-gdb-remote.txt @@ -38,7 +38,44 @@ read packet: + read packet: $OK#9a send packet: + +//-- +// "QSupported" +// +// BRIEF +// Query the GDB remote server for features it supports +// +// PRIORITY TO IMPLEMENT +// Optional. +//-- +QSupported is a standard GDB Remote Serial Protocol packet, but +there are several additions to the response that lldb can parse. +An example exchange: + +send packet: qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+ + +read packet: qXfer:features:read+;PacketSize=2;qEcho+;native-signals+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;SupportedWatchpointTypes =aarch64-mask,aarch64-bas; + +In this example, three lldb extensions are reported: + PacketSize=2 +The base16 maximum packet size that the GDB Remote Serial stub +can handle. + SupportedCompressions= +A list of compression types that the GDB Remote Serial stub can use to +compress packets when the QEnableCompression packet is used to request one +of them. + SupportedWatchpointTypes= +A list of watchpoint types that this GDB Remote Serial stub can manage. +Currently defined names are: +x86_64 64-bit x86-64 watchpoints + (1, 2, 4, 8 byte watchpoints aligned to those amounts) +aarch64-bas AArch64 Byte Address Select watchpoints + (any number of contiguous bytes within a doubleword) +aarch64-mask AArch64 MASK watchpoints + (any power-of-2 region of memory from 8 to 2GB, aligned) + +lldb will default to sending power-of-2 watchpoints up to a pointer size +(void*) in the target process if nothing is specified. //-- // "A" - launch args packet diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 3341b6e54a3bc..75522158b3221 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -921,6 +921,8 @@ def add_qSupported_packets(self, client_features=[]): "qSaveCore", "native-signals", "QNonStop", +"SupportedWatchpointTypes", +"SupportedCompressions", ] def parse_qSupported_response(self, context): diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/
[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changes debugserver on arm64 devices can manage both Byte Address Select watchpoints (1-8 bytes) and MASK watchpoints (8 bytes-2 gigabytes). This adds a SupportedWatchpointTypes key to the QSupported response from debugserver with a list of these, so lldb can take full advantage of them when creating larger regions with a single hardware watchpoint. Also add documentation for this, and two other lldb extensions, to the lldb-gdb-remote.txt documentation. Re-enable TestLargeWatchpoint.py on Darwin systems when testing with the in-tree built debugserver. I can remove the "in-tree built debugserver" in the future when this new key is handled by an Xcode debugserver. --- Full diff: https://github.com/llvm/llvm-project/pull/80376.diff 7 Files Affected: - (modified) lldb/docs/lldb-gdb-remote.txt (+37) - (modified) lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py (+2) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+21) - (modified) lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (+4) - (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+1-10) - (modified) lldb/test/API/functionalities/watchpoint/large-watchpoint/TestLargeWatchpoint.py (-5) - (modified) lldb/tools/debugserver/source/RNBRemote.cpp (+17-13) ``diff diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt index 58269e4c2b688..8db2fbc47b165 100644 --- a/lldb/docs/lldb-gdb-remote.txt +++ b/lldb/docs/lldb-gdb-remote.txt @@ -38,7 +38,44 @@ read packet: + read packet: $OK#9a send packet: + +//-- +// "QSupported" +// +// BRIEF +// Query the GDB remote server for features it supports +// +// PRIORITY TO IMPLEMENT +// Optional. +//-- +QSupported is a standard GDB Remote Serial Protocol packet, but +there are several additions to the response that lldb can parse. +An example exchange: + +send packet: qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+ + +read packet: qXfer:features:read+;PacketSize=2;qEcho+;native-signals+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;SupportedWatchpointTypes =aarch64-mask,aarch64-bas; + +In this example, three lldb extensions are reported: + PacketSize=2 +The base16 maximum packet size that the GDB Remote Serial stub +can handle. + SupportedCompressions= +A list of compression types that the GDB Remote Serial stub can use to +compress packets when the QEnableCompression packet is used to request one +of them. + SupportedWatchpointTypes= +A list of watchpoint types that this GDB Remote Serial stub can manage. +Currently defined names are: +x86_64 64-bit x86-64 watchpoints + (1, 2, 4, 8 byte watchpoints aligned to those amounts) +aarch64-bas AArch64 Byte Address Select watchpoints + (any number of contiguous bytes within a doubleword) +aarch64-mask AArch64 MASK watchpoints + (any power-of-2 region of memory from 8 to 2GB, aligned) + +lldb will default to sending power-of-2 watchpoints up to a pointer size +(void*) in the target process if nothing is specified. //-- // "A" - launch args packet diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index 3341b6e54a3bc..75522158b3221 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -921,6 +921,8 @@ def add_qSupported_packets(self, client_features=[]): "qSaveCore", "native-signals", "QNonStop", +"SupportedWatchpointTypes", +"SupportedCompressions", ] def parse_qSupported_response(self, context): diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 7bb4498418513..c625adc87cbd4 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -403,6 +403,22 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { x.split(compressions, ','); if (!compressions.empty()) MaybeEnableCompression(compressions); + } else if (x.consume_front("SupportedWatchpointTypes=")) { +llvm::SmallVector watchpoint_types; +x.split(watchpoint_types, ','); +m_watchpoint_types = +WatchpointHardwareFeature::eWatc
[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)
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 1f3c30911cc5eee4b42bdc9c6358c689b2f2f223...59e1499ec0afebb533c4952f079278341b957241 lldb/test/API/commands/statistics/basic/TestStats.py lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py `` View the diff from darker here. ``diff --- commands/statistics/basic/TestStats.py 2024-02-02 02:07:51.00 + +++ commands/statistics/basic/TestStats.py 2024-02-02 02:10:41.509153 + @@ -360,20 +360,20 @@ self.assertNotEqual(exe_module, None) self.verify_keys(exe_module, 'module dict for "%s"' % (exe), module_keys) def test_commands(self): """ -Test "statistics dump" and the command information. +Test "statistics dump" and the command information. """ self.build() exe = self.getBuildArtifact("a.out") target = self.createTestTarget(file_path=exe) interp = self.dbg.GetCommandInterpreter() result = lldb.SBCommandReturnObject() -interp.HandleCommand('target list', result) -interp.HandleCommand('target list', result) +interp.HandleCommand("target list", result) +interp.HandleCommand("target list", result) debug_stats = self.get_stats() command_stats = self.get_command_stats(debug_stats) self.assertNotEqual(command_stats, None) --- functionalities/stats_api/TestStatisticsAPI.py 2024-02-02 02:07:51.00 + +++ functionalities/stats_api/TestStatisticsAPI.py 2024-02-02 02:10:41.562490 + @@ -10,11 +10,11 @@ class TestStatsAPI(TestBase): NO_DEBUG_INFO_TESTCASE = True def test_stats_api(self): """ -Test SBTarget::GetStatistics() API. +Test SBTarget::GetStatistics() API. """ self.build() exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) @@ -73,26 +73,26 @@ True, 'Make sure the "failures" key in in "frameVariable" dictionary"', ) def test_command_stats_api(self): -""" -Test GetCommandInterpreter::GetStatistics() API. -""" -self.build() -exe = self.getBuildArtifact("a.out") -lldbutil.run_to_name_breakpoint(self, 'main') +""" +Test GetCommandInterpreter::GetStatistics() API. +""" +self.build() +exe = self.getBuildArtifact("a.out") +lldbutil.run_to_name_breakpoint(self, "main") -interp = self.dbg.GetCommandInterpreter() -result = lldb.SBCommandReturnObject() -interp.HandleCommand('bt', result) +interp = self.dbg.GetCommandInterpreter() +result = lldb.SBCommandReturnObject() +interp.HandleCommand("bt", result) -stream = lldb.SBStream() -res = interp.GetStatistics().GetAsJSON(stream) -command_stats = json.loads(stream.GetData()) +stream = lldb.SBStream() +res = interp.GetStatistics().GetAsJSON(stream) +command_stats = json.loads(stream.GetData()) -# Verify bt command is correctly parsed into final form. -self.assertEqual(command_stats["thread backtrace"], 1) -# Verify original raw command is not duplicatedly captured. -self.assertNotIn('bt', command_stats) -# Verify bt's regex command is not duplicatedly captured. -self.assertNotIn('_regexp-bt', command_stats) +# Verify bt command is correctly parsed into final form. +self.assertEqual(command_stats["thread backtrace"], 1) +# Verify original raw command is not duplicatedly captured. +self.assertNotIn("bt", command_stats) +# Verify bt's regex command is not duplicatedly captured. +self.assertNotIn("_regexp-bt", command_stats) `` https://github.com/llvm/llvm-project/pull/80375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)
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 1f3c30911cc5eee4b42bdc9c6358c689b2f2f223 59e1499ec0afebb533c4952f079278341b957241 -- lldb/include/lldb/API/SBCommandInterpreter.h lldb/include/lldb/API/SBStructuredData.h lldb/include/lldb/Interpreter/CommandInterpreter.h lldb/source/API/SBCommandInterpreter.cpp lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/CommandObject.cpp lldb/source/Target/Statistics.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index c81f56b6f9..c15895dbeb 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1646,8 +1646,9 @@ protected: llvm::Error llvm_error = m_container->LoadUserSubcommand(m_cmd_name, new_cmd_sp, m_overwrite); if (llvm_error) -result.AppendErrorWithFormat("cannot add command: %s", - llvm::toString(std::move(llvm_error)).c_str()); +result.AppendErrorWithFormat( +"cannot add command: %s", +llvm::toString(std::move(llvm_error)).c_str()); } } @@ -1793,9 +1794,9 @@ protected: llvm::Error llvm_error = container->RemoveUserSubcommand(leaf_cmd, /* multiword not okay */ false); if (llvm_error) { - result.AppendErrorWithFormat("could not delete command '%s': %s", - leaf_cmd, - llvm::toString(std::move(llvm_error)).c_str()); + result.AppendErrorWithFormat( + "could not delete command '%s': %s", leaf_cmd, + llvm::toString(std::move(llvm_error)).c_str()); return; } diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 86fbd4..2ff8ae7b73 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -3055,8 +3055,8 @@ void CommandInterpreter::PrintCommandOutput(IOHandler &io_handler, } std::lock_guard guard(io_handler.GetOutputMutex()); - if (had_output && INTERRUPT_REQUESTED(GetDebugger(), -"Interrupted dumping command output")) + if (had_output && + INTERRUPT_REQUESTED(GetDebugger(), "Interrupted dumping command output")) stream->Printf("\n... Interrupted.\n"); stream->Flush(); } @@ -3550,7 +3550,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line, llvm::json::Value CommandInterpreter::GetStatistics() { llvm::json::Object stats; - for (const auto& command_usage : m_command_usages) + for (const auto &command_usage : m_command_usages) stats.try_emplace(command_usage.first, command_usage.second); return stats; } diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp index 7cdee3414d..4699710035 100644 --- a/lldb/source/Target/Statistics.cpp +++ b/lldb/source/Target/Statistics.cpp @@ -311,7 +311,8 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger, {"totalModuleCount", num_modules}, {"totalModuleCountHasDebugInfo", num_modules_has_debug_info}, {"totalModuleCountWithVariableErrors", num_modules_with_variable_errors}, - {"totalModuleCountWithIncompleteTypes", num_modules_with_incomplete_types}, + {"totalModuleCountWithIncompleteTypes", + num_modules_with_incomplete_types}, {"totalDebugInfoEnabled", num_debug_info_enabled_modules}, {"totalSymbolTableStripped", num_stripped_modules}, }; `` https://github.com/llvm/llvm-project/pull/80375 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add commands frequency to statistics dump (PR #80375)
https://github.com/jeffreytan81 updated https://github.com/llvm/llvm-project/pull/80375 >From 59e1499ec0afebb533c4952f079278341b957241 Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Thu, 1 Feb 2024 18:07:51 -0800 Subject: [PATCH 1/2] Add commands frequency to statistics dump --- lldb/include/lldb/API/SBCommandInterpreter.h | 9 --- lldb/include/lldb/API/SBStructuredData.h | 1 + .../lldb/Interpreter/CommandInterpreter.h | 15 +-- lldb/source/API/SBCommandInterpreter.cpp | 15 ++- .../source/Commands/CommandObjectCommands.cpp | 10 --- .../source/Interpreter/CommandInterpreter.cpp | 9 ++- lldb/source/Interpreter/CommandObject.cpp | 1 + lldb/source/Target/Statistics.cpp | 4 +++ .../commands/statistics/basic/TestStats.py| 24 + .../stats_api/TestStatisticsAPI.py| 26 +++ 10 files changed, 103 insertions(+), 11 deletions(-) diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index b7f5b3bf3396e..b4629a4c2f5a8 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -13,6 +13,7 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" +#include "lldb/API/SBStructuredData.h" namespace lldb_private { class CommandPluginInterfaceImplementation; @@ -246,13 +247,13 @@ class SBCommandInterpreter { lldb::SBStringList &matches, lldb::SBStringList &descriptions); - /// Returns whether an interrupt flag was raised either by the SBDebugger - + /// Returns whether an interrupt flag was raised either by the SBDebugger - /// when the function is not running on the RunCommandInterpreter thread, or /// by SBCommandInterpreter::InterruptCommand if it is. If your code is doing - /// interruptible work, check this API periodically, and interrupt if it + /// interruptible work, check this API periodically, and interrupt if it /// returns true. bool WasInterrupted() const; - + /// Interrupts the command currently executing in the RunCommandInterpreter /// thread. /// @@ -315,6 +316,8 @@ class SBCommandInterpreter { /// and aliases. If successful, result->GetOutput has the full expansion. void ResolveCommand(const char *command_line, SBCommandReturnObject &result); + SBStructuredData GetStatistics(); + protected: friend class lldb_private::CommandPluginInterfaceImplementation; diff --git a/lldb/include/lldb/API/SBStructuredData.h b/lldb/include/lldb/API/SBStructuredData.h index 35d321eaa7b89..fc6e1ec95c7b8 100644 --- a/lldb/include/lldb/API/SBStructuredData.h +++ b/lldb/include/lldb/API/SBStructuredData.h @@ -122,6 +122,7 @@ class SBStructuredData { friend class SBTrace; friend class lldb_private::python::SWIGBridge; friend class lldb_private::lua::SWIGBridge; + friend class SBCommandInterpreter; SBStructuredData(const lldb_private::StructuredDataImpl &impl); diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 747188a15312f..c46cf0409bab6 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace lldb_private { class CommandInterpreter; @@ -240,7 +241,7 @@ class CommandInterpreter : public Broadcaster, eCommandTypesAllThem = 0x //< all commands }; - // The CommandAlias and CommandInterpreter both have a hand in + // The CommandAlias and CommandInterpreter both have a hand in // substituting for alias commands. They work by writing special tokens // in the template form of the Alias command, and then detecting them when the // command is executed. These are the special tokens: @@ -575,7 +576,7 @@ class CommandInterpreter : public Broadcaster, void SetEchoCommentCommands(bool enable); bool GetRepeatPreviousCommand() const; - + bool GetRequireCommandOverwrite() const; const CommandObject::CommandMap &GetUserCommands() const { @@ -641,6 +642,12 @@ class CommandInterpreter : public Broadcaster, Status PreprocessCommand(std::string &command); Status PreprocessToken(std::string &token); + void IncreaseCommandUsage(const CommandObject &cmd_obj) { +++m_command_usages[cmd_obj.GetCommandName().str()]; + } + + llvm::json::Value GetStatistics(); + protected: friend class Debugger; @@ -754,6 +761,10 @@ class CommandInterpreter : public Broadcaster, // If the driver is accepts custom exit codes for the 'quit' command. bool m_allow_exit_code = false; + /// Command usage statistics. + typedef std::unordered_map CommandUsageMap; + CommandUsageMap m_command_usages; + StreamString m_transcript_stream; }; diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/sourc
[Lldb-commits] [lldb] [lldb] Add frame recognizer for __builtin_verbose_trap (PR #80368)
clayborg wrote: This almost seems like a compiler runtime plug-in, but C language would be fine. I would rather see this in plug-in somewhere if possible. It might be nice to have these plug-ins register one or more frame regular expression values that point to the plug-in so we can add more things. It would be nice to also add support for C assert() calls that would unwind the stack to the offinding assert function above the 3 or 4 pthread functions that occur when an assertion is hit https://github.com/llvm/llvm-project/pull/80368 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add QSupported key to report watchpoint types supported (PR #80376)
jasonmolenda wrote: The QSupported packet from debugserver also has a "compression minimum size" field it adds (see the change to RNBRemote.cpp) and the QEnableCompression packet accepts that field as well. I must have had a reason for adding this when I added compression to the protocol, but lldb doesn't use this. I'll remove it in a separate patch. https://github.com/llvm/llvm-project/pull/80376 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits