25 changes: 25 additions & 0 deletions libc/src/string/memset_explicit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- Implementation of memset_explicit ---------------------------------===//
//
// 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 "src/string/memset_explicit.h"
#include "src/__support/common.h"
#include "src/string/memory_utils/inline_memset.h"

namespace LIBC_NAMESPACE {

[[gnu::noinline]] LLVM_LIBC_FUNCTION(void *, memset_explicit,
(void *dst, int value, size_t count)) {
// Use the inline memset function to set the memory.
inline_memset(dst, static_cast<uint8_t>(value), count);
// avoid dead store elimination
// The asm itself should also be sufficient to behave as a compiler barrier.
asm("" : : "r"(dst) : "memory");
return dst;
}

} // namespace LIBC_NAMESPACE
20 changes: 20 additions & 0 deletions libc/src/string/memset_explicit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for memset_explicit ---------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_STRING_MEMSET_EXPLICIT_H
#define LLVM_LIBC_SRC_STRING_MEMSET_EXPLICIT_H

#include <stddef.h> // size_t

namespace LIBC_NAMESPACE {

[[gnu::noinline]] void *memset_explicit(void *ptr, int value, size_t count);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_STRING_MEMSET_EXPLICIT_H
1 change: 1 addition & 0 deletions libc/test/UnitTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ add_header_library(
DEPENDS
libc.src.__support.CPP.string
libc.src.__support.CPP.type_traits
libc.src.__support.uint
)

add_unittest_framework_library(
Expand Down
3 changes: 2 additions & 1 deletion libc/test/UnitTest/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

#include "src/__support/CPP/string.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/UInt.h"

namespace LIBC_NAMESPACE {

// Return the first N hex digits of an integer as a string in upper case.
template <typename T>
cpp::enable_if_t<cpp::is_integral_v<T>, cpp::string>
cpp::enable_if_t<cpp::is_integral_v<T> || cpp::is_big_int_v<T>, cpp::string>
int_to_hex(T value, size_t length = sizeof(T) * 2) {
cpp::string s(length, '0');

Expand Down
2 changes: 2 additions & 0 deletions libc/test/src/__support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ add_libc_test(
SRCS
math_extras_test.cpp
DEPENDS
libc.src.__support.integer_literals
libc.src.__support.math_extras
libc.src.__support.uint128
)

add_libc_test(
Expand Down
69 changes: 47 additions & 22 deletions libc/test/src/__support/math_extras_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,59 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/UInt128.h" // UInt128
#include "src/__support/integer_literals.h"
#include "src/__support/math_extras.h"
#include "test/UnitTest/Test.h"

namespace LIBC_NAMESPACE {

TEST(LlvmLibcBlockMathExtrasTest, mask_trailing_ones) {
EXPECT_EQ(uint8_t(0), (mask_leading_ones<uint8_t, 0>()));
EXPECT_EQ(uint8_t(0), (mask_trailing_ones<uint8_t, 0>()));
EXPECT_EQ(uint16_t(0), (mask_leading_ones<uint16_t, 0>()));
EXPECT_EQ(uint16_t(0), (mask_trailing_ones<uint16_t, 0>()));
EXPECT_EQ(uint32_t(0), (mask_leading_ones<uint32_t, 0>()));
EXPECT_EQ(uint32_t(0), (mask_trailing_ones<uint32_t, 0>()));
EXPECT_EQ(uint64_t(0), (mask_leading_ones<uint64_t, 0>()));
EXPECT_EQ(uint64_t(0), (mask_trailing_ones<uint64_t, 0>()));

EXPECT_EQ(uint32_t(0x00000003), (mask_trailing_ones<uint32_t, 2>()));
EXPECT_EQ(uint32_t(0xC0000000), (mask_leading_ones<uint32_t, 2>()));

EXPECT_EQ(uint32_t(0x000007FF), (mask_trailing_ones<uint32_t, 11>()));
EXPECT_EQ(uint32_t(0xFFE00000), (mask_leading_ones<uint32_t, 11>()));

EXPECT_EQ(uint32_t(0xFFFFFFFF), (mask_trailing_ones<uint32_t, 32>()));
EXPECT_EQ(uint32_t(0xFFFFFFFF), (mask_leading_ones<uint32_t, 32>()));
EXPECT_EQ(uint64_t(0xFFFFFFFFFFFFFFFF), (mask_trailing_ones<uint64_t, 64>()));
EXPECT_EQ(uint64_t(0xFFFFFFFFFFFFFFFF), (mask_leading_ones<uint64_t, 64>()));

EXPECT_EQ(uint64_t(0x0000FFFFFFFFFFFF), (mask_trailing_ones<uint64_t, 48>()));
EXPECT_EQ(uint64_t(0xFFFFFFFFFFFF0000), (mask_leading_ones<uint64_t, 48>()));
EXPECT_EQ(0_u8, (mask_leading_ones<uint8_t, 0>()));
EXPECT_EQ(0_u8, (mask_trailing_ones<uint8_t, 0>()));
EXPECT_EQ(0_u16, (mask_leading_ones<uint16_t, 0>()));
EXPECT_EQ(0_u16, (mask_trailing_ones<uint16_t, 0>()));
EXPECT_EQ(0_u32, (mask_leading_ones<uint32_t, 0>()));
EXPECT_EQ(0_u32, (mask_trailing_ones<uint32_t, 0>()));
EXPECT_EQ(0_u64, (mask_leading_ones<uint64_t, 0>()));
EXPECT_EQ(0_u64, (mask_trailing_ones<uint64_t, 0>()));

EXPECT_EQ(0x00000003_u32, (mask_trailing_ones<uint32_t, 2>()));
EXPECT_EQ(0xC0000000_u32, (mask_leading_ones<uint32_t, 2>()));

EXPECT_EQ(0x000007FF_u32, (mask_trailing_ones<uint32_t, 11>()));
EXPECT_EQ(0xFFE00000_u32, (mask_leading_ones<uint32_t, 11>()));

EXPECT_EQ(0xFFFFFFFF_u32, (mask_trailing_ones<uint32_t, 32>()));
EXPECT_EQ(0xFFFFFFFF_u32, (mask_leading_ones<uint32_t, 32>()));
EXPECT_EQ(0xFFFFFFFFFFFFFFFF_u64, (mask_trailing_ones<uint64_t, 64>()));
EXPECT_EQ(0xFFFFFFFFFFFFFFFF_u64, (mask_leading_ones<uint64_t, 64>()));

EXPECT_EQ(0x0000FFFFFFFFFFFF_u64, (mask_trailing_ones<uint64_t, 48>()));
EXPECT_EQ(0xFFFFFFFFFFFF0000_u64, (mask_leading_ones<uint64_t, 48>()));

EXPECT_EQ(0_u128, (mask_trailing_ones<UInt128, 0>()));
EXPECT_EQ(0_u128, (mask_leading_ones<UInt128, 0>()));

EXPECT_EQ(0x00000000000000007FFFFFFFFFFFFFFF_u128,
(mask_trailing_ones<UInt128, 63>()));
EXPECT_EQ(0xFFFFFFFFFFFFFFFE0000000000000000_u128,
(mask_leading_ones<UInt128, 63>()));

EXPECT_EQ(0x0000000000000000FFFFFFFFFFFFFFFF_u128,
(mask_trailing_ones<UInt128, 64>()));
EXPECT_EQ(0xFFFFFFFFFFFFFFFF0000000000000000_u128,
(mask_leading_ones<UInt128, 64>()));

EXPECT_EQ(0x0000000000000001FFFFFFFFFFFFFFFF_u128,
(mask_trailing_ones<UInt128, 65>()));
EXPECT_EQ(0xFFFFFFFFFFFFFFFF8000000000000000_u128,
(mask_leading_ones<UInt128, 65>()));

EXPECT_EQ(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_u128,
(mask_trailing_ones<UInt128, 128>()));
EXPECT_EQ(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_u128,
(mask_leading_ones<UInt128, 128>()));
}

} // namespace LIBC_NAMESPACE
10 changes: 10 additions & 0 deletions libc/test/src/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,16 @@ add_libc_test(
libc.src.string.strxfrm
)

add_libc_test(
memset_explicit_test
SUITE
libc-string-tests
SRCS
memset_explicit_test.cpp
DEPENDS
libc.src.string.memset_explicit
)

# Tests all implementations that can run on the target CPU.
function(add_libc_multi_impl_test name)
get_property(fq_implementations GLOBAL PROPERTY ${name}_implementations)
Expand Down
31 changes: 31 additions & 0 deletions libc/test/src/string/memset_explicit_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//===-- Unittests for memset_explicit -------------------------------------===//
//
// 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 "memory_utils/memory_check_utils.h"
#include "src/string/memset_explicit.h"
#include "test/UnitTest/Test.h"

namespace LIBC_NAMESPACE {

// Apply the same tests as memset

static inline void Adaptor(cpp::span<char> p1, uint8_t value, size_t size) {
LIBC_NAMESPACE::memset_explicit(p1.begin(), value, size);
}

TEST(LlvmLibcmemsetExplicitTest, SizeSweep) {
static constexpr size_t kMaxSize = 400;
Buffer DstBuffer(kMaxSize);
for (size_t size = 0; size < kMaxSize; ++size) {
const char value = size % 10;
auto dst = DstBuffer.span().subspan(0, size);
ASSERT_TRUE((CheckMemset<Adaptor>(dst, value, size)));
}
}

} // namespace LIBC_NAMESPACE
7 changes: 3 additions & 4 deletions libcxx/include/__availability
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@
# endif
#endif

// Availability markup is disabled when building the library, or when the compiler
// Availability markup is disabled when building the library, or when a non-Clang
// compiler is used because only Clang supports the necessary attributes.
// doesn't support the proper attributes.
#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || \
!__has_feature(attribute_availability_with_strict) || !__has_feature(attribute_availability_in_templates) || \
!__has_extension(pragma_clang_attribute_external_declaration)
#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)
# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
# endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

// REQUIRES: stdlib=apple-libc++

// Test that using -pedantic-errors doesn't turn off availability annotations.
// This used to be the case because we used __has_extension(...) to enable the
// availability annotations, and -pedantic-errors changes the behavior of
// __has_extension(...) in an incompatible way.

// ADDITIONAL_COMPILE_FLAGS: -pedantic-errors

#include <__availability>

#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
# error Availability annotations should be enabled on Apple platforms in the system configuration!
#endif
10 changes: 5 additions & 5 deletions lldb/include/lldb/Core/ValueObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class ValueObject {
/// Returns a unique id for this ValueObject.
lldb::user_id_t GetID() const { return m_id.GetID(); }

virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx,
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx,
bool can_create = true);

// The method always creates missing children in the path, if necessary.
Expand All @@ -476,7 +476,7 @@ class ValueObject {

virtual size_t GetIndexOfChildWithName(llvm::StringRef name);

size_t GetNumChildren(uint32_t max = UINT32_MAX);
uint32_t GetNumChildren(uint32_t max = UINT32_MAX);

const Value &GetValue() const { return m_value; }

Expand Down Expand Up @@ -791,7 +791,7 @@ class ValueObject {
return (m_children.find(idx) != m_children.end());
}

ValueObject *GetChildAtIndex(size_t idx) {
ValueObject *GetChildAtIndex(uint32_t idx) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
const auto iter = m_children.find(idx);
return ((iter == m_children.end()) ? nullptr : iter->second);
Expand Down Expand Up @@ -958,9 +958,9 @@ class ValueObject {
int32_t synthetic_index);

/// Should only be called by ValueObject::GetNumChildren().
virtual size_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0;
virtual uint32_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0;

void SetNumChildren(size_t num_children);
void SetNumChildren(uint32_t num_children);

void SetValueDidChange(bool value_changed) {
m_flags.m_value_did_change = value_changed;
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/ValueObjectCast.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ValueObjectCast : public ValueObject {

std::optional<uint64_t> GetByteSize() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

lldb::ValueType GetValueType() const override;

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/ValueObjectChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ValueObjectChild : public ValueObject {

lldb::ValueType GetValueType() const override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

ConstString GetTypeName() override;

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/ValueObjectConstResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ValueObjectConstResult : public ValueObject {

lldb::ValueType GetValueType() const override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

ConstString GetTypeName() override;

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/ValueObjectDynamicValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ValueObjectDynamicValue : public ValueObject {

ConstString GetDisplayTypeName() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

lldb::ValueType GetValueType() const override;

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/ValueObjectMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ValueObjectMemory : public ValueObject {

ConstString GetDisplayTypeName() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

lldb::ValueType GetValueType() const override;

Expand Down
4 changes: 2 additions & 2 deletions lldb/include/lldb/Core/ValueObjectRegister.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ValueObjectRegisterSet : public ValueObject {

ConstString GetQualifiedTypeName() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
int32_t synthetic_index) override;
Expand Down Expand Up @@ -95,7 +95,7 @@ class ValueObjectRegister : public ValueObject {

ConstString GetTypeName() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

bool SetValueFromCString(const char *value_str, Status &error) override;

Expand Down
4 changes: 2 additions & 2 deletions lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class ValueObjectSynthetic : public ValueObject {

bool MightHaveChildren() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

lldb::ValueType GetValueType() const override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx,
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx,
bool can_create = true) override;

lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/ValueObjectVTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ValueObjectVTable : public ValueObject {

std::optional<uint64_t> GetByteSize() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
int32_t synthetic_index) override;
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Core/ValueObjectVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ValueObjectVariable : public ValueObject {

ConstString GetDisplayTypeName() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

lldb::ValueType GetValueType() const override;

Expand Down
20 changes: 10 additions & 10 deletions lldb/include/lldb/DataFormatters/TypeSynthetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class SyntheticChildrenFrontEnd {

virtual ~SyntheticChildrenFrontEnd() = default;

virtual size_t CalculateNumChildren() = 0;
virtual uint32_t CalculateNumChildren() = 0;

virtual size_t CalculateNumChildren(uint32_t max) {
virtual uint32_t CalculateNumChildren(uint32_t max) {
auto count = CalculateNumChildren();
return count <= max ? count : max;
}

virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx) = 0;
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) = 0;

virtual size_t GetIndexOfChildWithName(ConstString name) = 0;

Expand Down Expand Up @@ -109,9 +109,9 @@ class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd {

~SyntheticValueProviderFrontEnd() override = default;

size_t CalculateNumChildren() override { return 0; }
uint32_t CalculateNumChildren() override { return 0; }

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override { return nullptr; }
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { return nullptr; }

size_t GetIndexOfChildWithName(ConstString name) override {
return UINT32_MAX;
Expand Down Expand Up @@ -322,9 +322,9 @@ class TypeFilterImpl : public SyntheticChildren {

~FrontEnd() override = default;

size_t CalculateNumChildren() override { return filter->GetCount(); }
uint32_t CalculateNumChildren() override { return filter->GetCount(); }

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
if (idx >= filter->GetCount())
return lldb::ValueObjectSP();
return m_backend.GetSyntheticExpressionPathChild(
Expand Down Expand Up @@ -426,11 +426,11 @@ class ScriptedSyntheticChildren : public SyntheticChildren {

bool IsValid();

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

size_t CalculateNumChildren(uint32_t max) override;
uint32_t CalculateNumChildren(uint32_t max) override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down
4 changes: 2 additions & 2 deletions lldb/include/lldb/DataFormatters/VectorIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
VectorIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp,
llvm::ArrayRef<ConstString> item_names);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Target/StackFrameRecognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject {
m_value = m_parent->GetValue();
return true;
}
size_t CalculateNumChildren(uint32_t max = UINT32_MAX) override {
uint32_t CalculateNumChildren(uint32_t max = UINT32_MAX) override {
return m_parent->GetNumChildren(max);
}
CompilerType GetCompilerTypeImpl() override {
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Core/ValueObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ bool ValueObject::IsLogicalTrue(Status &error) {
return ret;
}

ValueObjectSP ValueObject::GetChildAtIndex(size_t idx, bool can_create) {
ValueObjectSP ValueObject::GetChildAtIndex(uint32_t idx, bool can_create) {
ValueObjectSP child_sp;
// We may need to update our value if we are dynamic
if (IsPossibleDynamicType())
Expand Down Expand Up @@ -440,7 +440,7 @@ ValueObjectSP ValueObject::GetChildMemberWithName(llvm::StringRef name,
return child_sp;
}

size_t ValueObject::GetNumChildren(uint32_t max) {
uint32_t ValueObject::GetNumChildren(uint32_t max) {
UpdateValueIfNeeded();

if (max < UINT32_MAX) {
Expand Down Expand Up @@ -470,7 +470,7 @@ bool ValueObject::MightHaveChildren() {
}

// Should only be called by ValueObject::GetNumChildren()
void ValueObject::SetNumChildren(size_t num_children) {
void ValueObject::SetNumChildren(uint32_t num_children) {
m_flags.m_children_count_valid = true;
m_children.SetChildrenCount(num_children);
}
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/ValueObjectCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ValueObjectCast::~ValueObjectCast() = default;

CompilerType ValueObjectCast::GetCompilerTypeImpl() { return m_cast_type; }

size_t ValueObjectCast::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectCast::CalculateNumChildren(uint32_t max) {
ExecutionContext exe_ctx(GetExecutionContextRef());
auto children_count = GetCompilerType().GetNumChildren(
true, &exe_ctx);
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/ValueObjectChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ lldb::ValueType ValueObjectChild::GetValueType() const {
return m_parent->GetValueType();
}

size_t ValueObjectChild::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectChild::CalculateNumChildren(uint32_t max) {
ExecutionContext exe_ctx(GetExecutionContextRef());
auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
return children_count <= max ? children_count : max;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/ValueObjectConstResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ std::optional<uint64_t> ValueObjectConstResult::GetByteSize() {

void ValueObjectConstResult::SetByteSize(size_t size) { m_byte_size = size; }

size_t ValueObjectConstResult::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectConstResult::CalculateNumChildren(uint32_t max) {
ExecutionContext exe_ctx(GetExecutionContextRef());
auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
return children_count <= max ? children_count : max;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/ValueObjectDynamicValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ConstString ValueObjectDynamicValue::GetDisplayTypeName() {
return m_parent->GetDisplayTypeName();
}

size_t ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) {
const bool success = UpdateValueIfNeeded(false);
if (success && m_dynamic_type_info.HasType()) {
ExecutionContext exe_ctx(GetExecutionContextRef());
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/ValueObjectMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ConstString ValueObjectMemory::GetDisplayTypeName() {
return m_compiler_type.GetDisplayTypeName();
}

size_t ValueObjectMemory::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectMemory::CalculateNumChildren(uint32_t max) {
if (m_type_sp) {
auto child_count = m_type_sp->GetNumChildren(true);
return child_count <= max ? child_count : max;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Core/ValueObjectRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ConstString ValueObjectRegisterSet::GetQualifiedTypeName() {
return ConstString();
}

size_t ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) {
const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
if (reg_set) {
auto reg_count = reg_set->num_registers;
Expand Down Expand Up @@ -220,7 +220,7 @@ ConstString ValueObjectRegister::GetTypeName() {
return m_type_name;
}

size_t ValueObjectRegister::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectRegister::CalculateNumChildren(uint32_t max) {
ExecutionContext exe_ctx(GetExecutionContextRef());
auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx);
return children_count <= max ? children_count : max;
Expand Down
18 changes: 9 additions & 9 deletions lldb/source/Core/ValueObjectSyntheticFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class DummySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
DummySyntheticFrontEnd(ValueObject &backend)
: SyntheticChildrenFrontEnd(backend) {}

size_t CalculateNumChildren() override { return m_backend.GetNumChildren(); }
uint32_t CalculateNumChildren() override { return m_backend.GetNumChildren(); }

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
return m_backend.GetChildAtIndex(idx);
}

Expand Down Expand Up @@ -84,7 +84,7 @@ ConstString ValueObjectSynthetic::GetDisplayTypeName() {
return m_parent->GetDisplayTypeName();
}

size_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) {
Log *log = GetLog(LLDBLog::DataFormatters);

UpdateValueIfNeeded();
Expand Down Expand Up @@ -236,13 +236,13 @@ bool ValueObjectSynthetic::UpdateValue() {
return true;
}

lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(uint32_t idx,
bool can_create) {
Log *log = GetLog(LLDBLog::DataFormatters);

LLDB_LOGF(log,
"[ValueObjectSynthetic::GetChildAtIndex] name=%s, retrieving "
"child at index %zu",
"child at index %u",
GetName().AsCString(), idx);

UpdateValueIfNeeded();
Expand All @@ -261,15 +261,15 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
if (can_create && m_synth_filter_up != nullptr) {
LLDB_LOGF(log,
"[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
"index %zu not cached and will be created",
"index %u not cached and will be created",
GetName().AsCString(), idx);

lldb::ValueObjectSP synth_guy = m_synth_filter_up->GetChildAtIndex(idx);

LLDB_LOGF(
log,
"[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index "
"%zu created as %p (is "
"%u created as %p (is "
"synthetic: %s)",
GetName().AsCString(), idx, static_cast<void *>(synth_guy.get()),
synth_guy.get()
Expand All @@ -291,7 +291,7 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
} else {
LLDB_LOGF(log,
"[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
"index %zu not cached and cannot "
"index %u not cached and cannot "
"be created (can_create = %s, synth_filter = %p)",
GetName().AsCString(), idx, can_create ? "yes" : "no",
static_cast<void *>(m_synth_filter_up.get()));
Expand All @@ -301,7 +301,7 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
} else {
LLDB_LOGF(log,
"[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
"index %zu cached as %p",
"index %u cached as %p",
GetName().AsCString(), idx, static_cast<void *>(valobj));

return valobj->GetSP();
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Core/ValueObjectVTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ValueObjectVTableChild : public ValueObject {

std::optional<uint64_t> GetByteSize() override { return m_addr_size; };

size_t CalculateNumChildren(uint32_t max) override { return 0; };
uint32_t CalculateNumChildren(uint32_t max) override { return 0; };

ValueType GetValueType() const override { return eValueTypeVTableEntry; };

Expand Down Expand Up @@ -159,7 +159,7 @@ std::optional<uint64_t> ValueObjectVTable::GetByteSize() {
return std::nullopt;
}

size_t ValueObjectVTable::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectVTable::CalculateNumChildren(uint32_t max) {
if (UpdateValueIfNeeded(false))
return m_num_vtable_entries <= max ? m_num_vtable_entries : max;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/ValueObjectVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ ConstString ValueObjectVariable::GetQualifiedTypeName() {
return ConstString();
}

size_t ValueObjectVariable::CalculateNumChildren(uint32_t max) {
uint32_t ValueObjectVariable::CalculateNumChildren(uint32_t max) {
CompilerType type(GetCompilerType());

if (!type.IsValid())
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/DataFormatters/TypeSynthetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ ScriptedSyntheticChildren::FrontEnd::FrontEnd(std::string pclass,
ScriptedSyntheticChildren::FrontEnd::~FrontEnd() = default;

lldb::ValueObjectSP
ScriptedSyntheticChildren::FrontEnd::GetChildAtIndex(size_t idx) {
ScriptedSyntheticChildren::FrontEnd::GetChildAtIndex(uint32_t idx) {
if (!m_wrapper_sp || !m_interpreter)
return lldb::ValueObjectSP();

Expand All @@ -178,13 +178,13 @@ bool ScriptedSyntheticChildren::FrontEnd::IsValid() {
return (m_wrapper_sp && m_wrapper_sp->IsValid() && m_interpreter);
}

size_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren() {
uint32_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren() {
if (!m_wrapper_sp || m_interpreter == nullptr)
return 0;
return m_interpreter->CalculateNumChildren(m_wrapper_sp, UINT32_MAX);
}

size_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) {
uint32_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) {
if (!m_wrapper_sp || m_interpreter == nullptr)
return 0;
return m_interpreter->CalculateNumChildren(m_wrapper_sp, max);
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/DataFormatters/VectorType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~VectorTypeSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override { return m_num_children; }
uint32_t CalculateNumChildren() override { return m_num_children; }

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
if (idx >= CalculateNumChildren())
return {};
std::optional<uint64_t> size = m_child_type.GetByteSize(nullptr);
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~BlockPointerSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override {
uint32_t CalculateNumChildren() override {
const bool omit_empty_base_classes = false;
return m_block_struct_type.GetNumChildren(omit_empty_base_classes, nullptr);
}

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
if (!m_block_struct_type.IsValid()) {
return lldb::ValueObjectSP();
}
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
~StdlibCoroutineHandleSyntheticFrontEnd() = default;

size_t lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
uint32_t lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
CalculateNumChildren() {
if (!m_resume_ptr_sp || !m_destroy_ptr_sp)
return 0;
Expand All @@ -113,7 +113,7 @@ size_t lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
}

lldb::ValueObjectSP lldb_private::formatters::
StdlibCoroutineHandleSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
StdlibCoroutineHandleSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
switch (idx) {
case 0:
return m_resume_ptr_sp;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class StdlibCoroutineHandleSyntheticFrontEnd

~StdlibCoroutineHandleSyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd {

bool MightHaveChildren() override { return true; }
lldb::ChildCacheState Update() override;
size_t CalculateNumChildren() override { return m_elements.size(); }
ValueObjectSP GetChildAtIndex(size_t idx) override;
uint32_t CalculateNumChildren() override { return m_elements.size(); }
ValueObjectSP GetChildAtIndex(uint32_t idx) override;

private:
llvm::StringRef GetDataContainerMemberName();
Expand Down Expand Up @@ -97,7 +97,7 @@ lldb::ChildCacheState GenericBitsetFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
}

ValueObjectSP GenericBitsetFrontEnd::GetChildAtIndex(size_t idx) {
ValueObjectSP GenericBitsetFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx >= m_elements.size() || !m_first)
return ValueObjectSP();

Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class GenericOptionalFrontend : public SyntheticChildrenFrontEnd {
}

bool MightHaveChildren() override { return true; }
size_t CalculateNumChildren() override { return m_has_value ? 1U : 0U; }
uint32_t CalculateNumChildren() override { return m_has_value ? 1U : 0U; }

ValueObjectSP GetChildAtIndex(size_t idx) override;
ValueObjectSP GetChildAtIndex(uint32_t idx) override;
lldb::ChildCacheState Update() override;

private:
Expand Down Expand Up @@ -81,7 +81,7 @@ lldb::ChildCacheState GenericOptionalFrontend::Update() {
return lldb::ChildCacheState::eRefetch;
}

ValueObjectSP GenericOptionalFrontend::GetChildAtIndex(size_t _idx) {
ValueObjectSP GenericOptionalFrontend::GetChildAtIndex(uint32_t _idx) {
if (!m_has_value)
return ValueObjectSP();

Expand Down
16 changes: 8 additions & 8 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,14 @@ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
}

size_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
CalculateNumChildren() {
return 2;
}

lldb::ValueObjectSP
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (m_pair_ptr)
return m_pair_ptr->GetChildAtIndex(idx);
if (m_pair_sp)
Expand Down Expand Up @@ -509,13 +509,13 @@ lldb::ChildCacheState lldb_private::formatters::
return lldb::ChildCacheState::eRefetch;
}

size_t lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::
CalculateNumChildren() {
return 2;
}

lldb::ValueObjectSP lldb_private::formatters::
LibCxxUnorderedMapIteratorSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
LibCxxUnorderedMapIteratorSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
if (m_pair_sp)
return m_pair_sp->GetChildAtIndex(idx);
return lldb::ValueObjectSP();
Expand Down Expand Up @@ -566,14 +566,14 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
Update();
}

size_t lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
CalculateNumChildren() {
return (m_cntrl ? 1 : 0);
}

lldb::ValueObjectSP
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (!m_cntrl)
return lldb::ValueObjectSP();

Expand Down Expand Up @@ -661,7 +661,7 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator(
: nullptr);
}

size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
CalculateNumChildren() {
if (m_value_ptr_sp)
return m_deleter_sp ? 2 : 1;
Expand All @@ -670,7 +670,7 @@ size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::

lldb::ValueObjectSP
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (!m_value_ptr_sp)
return lldb::ValueObjectSP();

Expand Down
16 changes: 8 additions & 8 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class LibCxxMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -135,9 +135,9 @@ class LibCxxUnorderedMapIteratorSyntheticFrontEnd

~LibCxxUnorderedMapIteratorSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -166,9 +166,9 @@ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand All @@ -186,9 +186,9 @@ class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class LibcxxStdAtomicSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~LibcxxStdAtomicSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -124,14 +124,14 @@ bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
return true;
}

size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
CalculateNumChildren() {
return m_real_child ? 1 : 0;
}

lldb::ValueObjectSP
lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (idx == 0)
return m_real_child->GetSP()->Clone(ConstString("Value"));
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class LibcxxInitializerListSyntheticFrontEnd

~LibcxxInitializerListSyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -59,7 +59,7 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
// delete m_start;
}

size_t lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
CalculateNumChildren() {
m_num_elements = 0;
ValueObjectSP size_sp(m_backend.GetChildMemberWithName("__size_"));
Expand All @@ -69,7 +69,7 @@ size_t lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
}

lldb::ValueObjectSP lldb_private::formatters::
LibcxxInitializerListSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
LibcxxInitializerListSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
if (!m_start)
return lldb::ValueObjectSP();

Expand Down
16 changes: 8 additions & 8 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class ForwardListFrontEnd : public AbstractListFrontEnd {
public:
ForwardListFrontEnd(ValueObject &valobj);

size_t CalculateNumChildren() override;
ValueObjectSP GetChildAtIndex(size_t idx) override;
uint32_t CalculateNumChildren() override;
ValueObjectSP GetChildAtIndex(uint32_t idx) override;
lldb::ChildCacheState Update() override;
};

Expand All @@ -147,9 +147,9 @@ class ListFrontEnd : public AbstractListFrontEnd {

~ListFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -240,7 +240,7 @@ ForwardListFrontEnd::ForwardListFrontEnd(ValueObject &valobj)
Update();
}

size_t ForwardListFrontEnd::CalculateNumChildren() {
uint32_t ForwardListFrontEnd::CalculateNumChildren() {
if (m_count != UINT32_MAX)
return m_count;

Expand All @@ -253,7 +253,7 @@ size_t ForwardListFrontEnd::CalculateNumChildren() {
return m_count;
}

ValueObjectSP ForwardListFrontEnd::GetChildAtIndex(size_t idx) {
ValueObjectSP ForwardListFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx >= CalculateNumChildren())
return nullptr;

Expand Down Expand Up @@ -308,7 +308,7 @@ ListFrontEnd::ListFrontEnd(lldb::ValueObjectSP valobj_sp)
Update();
}

size_t ListFrontEnd::CalculateNumChildren() {
uint32_t ListFrontEnd::CalculateNumChildren() {
if (m_count != UINT32_MAX)
return m_count;
if (!m_head || !m_tail || m_node_address == 0)
Expand Down Expand Up @@ -343,7 +343,7 @@ size_t ListFrontEnd::CalculateNumChildren() {
}
}

lldb::ValueObjectSP ListFrontEnd::GetChildAtIndex(size_t idx) {
lldb::ValueObjectSP ListFrontEnd::GetChildAtIndex(uint32_t idx) {
static ConstString g_value("__value_");
static ConstString g_next("__next_");

Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ class LibcxxStdMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~LibcxxStdMapSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -209,7 +209,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
Update();
}

size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
CalculateNumChildren() {
if (m_count != UINT32_MAX)
return m_count;
Expand Down Expand Up @@ -308,7 +308,7 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset(

lldb::ValueObjectSP
lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
static ConstString g_cc_("__cc_"), g_cc("__cc");
static ConstString g_nc("__nc");

Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class QueueFrontEnd : public SyntheticChildrenFrontEnd {
bool MightHaveChildren() override { return true; }
lldb::ChildCacheState Update() override;

size_t CalculateNumChildren() override {
uint32_t CalculateNumChildren() override {
return m_container_sp ? m_container_sp->GetNumChildren() : 0;
}

ValueObjectSP GetChildAtIndex(size_t idx) override {
ValueObjectSP GetChildAtIndex(uint32_t idx) override {
return m_container_sp ? m_container_sp->GetChildAtIndex(idx)
: nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class LibcxxStdRangesRefViewSyntheticFrontEnd

~LibcxxStdRangesRefViewSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override {
uint32_t CalculateNumChildren() override {
// __range_ will be the sole child of this type
return 1;
}

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
// Since we only have a single child, return it
assert(idx == 0);
return m_range_sp;
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class LibcxxStdSpanSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~LibcxxStdSpanSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

/// Determines properties of the std::span<> associated with this object
//
Expand Down Expand Up @@ -73,14 +73,14 @@ lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::
Update();
}

size_t lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::
CalculateNumChildren() {
return m_num_elements;
}

lldb::ValueObjectSP
lldb_private::formatters::LibcxxStdSpanSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (!m_start)
return {};

Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class TupleFrontEnd: public SyntheticChildrenFrontEnd {

bool MightHaveChildren() override { return true; }
lldb::ChildCacheState Update() override;
size_t CalculateNumChildren() override { return m_elements.size(); }
ValueObjectSP GetChildAtIndex(size_t idx) override;
uint32_t CalculateNumChildren() override { return m_elements.size(); }
ValueObjectSP GetChildAtIndex(uint32_t idx) override;

private:
// The lifetime of a ValueObject and all its derivative ValueObjects
Expand Down Expand Up @@ -58,7 +58,7 @@ lldb::ChildCacheState TupleFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
}

ValueObjectSP TupleFrontEnd::GetChildAtIndex(size_t idx) {
ValueObjectSP TupleFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx >= m_elements.size())
return ValueObjectSP();
if (!m_base)
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class LibcxxStdUnorderedMapSyntheticFrontEnd

~LibcxxStdUnorderedMapSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand All @@ -62,7 +62,7 @@ lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
Update();
}

size_t lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
CalculateNumChildren() {
return m_num_elements;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ static bool isUnorderedMap(ConstString type_name) {
}

lldb::ValueObjectSP lldb_private::formatters::
LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx >= CalculateNumChildren())
return lldb::ValueObjectSP();
if (m_tree == nullptr)
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class LibcxxStdValarraySyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~LibcxxStdValarraySyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -63,7 +63,7 @@ lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::
// delete m_finish;
}

size_t lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::
CalculateNumChildren() {
if (!m_start || !m_finish)
return 0;
Expand All @@ -84,7 +84,7 @@ size_t lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::

lldb::ValueObjectSP
lldb_private::formatters::LibcxxStdValarraySyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (!m_start || !m_finish)
return lldb::ValueObjectSP();

Expand Down
6 changes: 3 additions & 3 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ class VariantFrontEnd : public SyntheticChildrenFrontEnd {

bool MightHaveChildren() override { return true; }
lldb::ChildCacheState Update() override;
size_t CalculateNumChildren() override { return m_size; }
ValueObjectSP GetChildAtIndex(size_t idx) override;
uint32_t CalculateNumChildren() override { return m_size; }
ValueObjectSP GetChildAtIndex(uint32_t idx) override;

private:
size_t m_size = 0;
Expand All @@ -233,7 +233,7 @@ lldb::ChildCacheState VariantFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
}

ValueObjectSP VariantFrontEnd::GetChildAtIndex(size_t idx) {
ValueObjectSP VariantFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx >= m_size)
return {};

Expand Down
16 changes: 8 additions & 8 deletions lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class LibcxxStdVectorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~LibcxxStdVectorSyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand All @@ -46,9 +46,9 @@ class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -82,7 +82,7 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
// delete m_finish;
}

size_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
CalculateNumChildren() {
if (!m_start || !m_finish)
return 0;
Expand All @@ -103,7 +103,7 @@ size_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::

lldb::ValueObjectSP
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (!m_start || !m_finish)
return lldb::ValueObjectSP();

Expand Down Expand Up @@ -165,14 +165,14 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
}
}

size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
uint32_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
CalculateNumChildren() {
return m_count;
}

lldb::ValueObjectSP
lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
auto iter = m_children.find(idx), end = m_children.end();
if (iter != end)
return iter->second;
Expand Down
20 changes: 10 additions & 10 deletions lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class LibstdcppMapIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
explicit LibstdcppMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand All @@ -64,9 +64,9 @@ class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
explicit LibStdcppSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -132,12 +132,12 @@ lldb::ChildCacheState LibstdcppMapIteratorSyntheticFrontEnd::Update() {
return lldb::ChildCacheState::eReuse;
}

size_t LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() {
uint32_t LibstdcppMapIteratorSyntheticFrontEnd::CalculateNumChildren() {
return 2;
}

lldb::ValueObjectSP
LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
if (m_pair_address != 0 && m_pair_type) {
if (!m_pair_sp)
m_pair_sp = CreateValueObjectFromAddress("pair", m_pair_address,
Expand Down Expand Up @@ -219,10 +219,10 @@ lldb::ChildCacheState VectorIteratorSyntheticFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
}

size_t VectorIteratorSyntheticFrontEnd::CalculateNumChildren() { return 1; }
uint32_t VectorIteratorSyntheticFrontEnd::CalculateNumChildren() { return 1; }

lldb::ValueObjectSP
VectorIteratorSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
VectorIteratorSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx == 0)
return m_item_sp;
return lldb::ValueObjectSP();
Expand Down Expand Up @@ -371,10 +371,10 @@ LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd(
Update();
}

size_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { return 1; }
uint32_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { return 1; }

lldb::ValueObjectSP
LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
LibStdcppSharedPtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx == 0)
return m_ptr_obj->GetSP();
if (idx == 1) {
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class LibStdcppTupleSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
explicit LibStdcppTupleSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -89,13 +89,13 @@ lldb::ChildCacheState LibStdcppTupleSyntheticFrontEnd::Update() {
bool LibStdcppTupleSyntheticFrontEnd::MightHaveChildren() { return true; }

lldb::ValueObjectSP
LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
LibStdcppTupleSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx < m_members.size() && m_members[idx])
return m_members[idx]->GetSP();
return lldb::ValueObjectSP();
}

size_t LibStdcppTupleSyntheticFrontEnd::CalculateNumChildren() {
uint32_t LibStdcppTupleSyntheticFrontEnd::CalculateNumChildren() {
return m_members.size();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class LibStdcppUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
explicit LibStdcppUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -116,7 +116,7 @@ lldb::ChildCacheState LibStdcppUniquePtrSyntheticFrontEnd::Update() {
bool LibStdcppUniquePtrSyntheticFrontEnd::MightHaveChildren() { return true; }

lldb::ValueObjectSP
LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
if (idx == 0 && m_ptr_obj)
return m_ptr_obj->GetSP();
if (idx == 1 && m_del_obj)
Expand All @@ -135,7 +135,7 @@ LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
return lldb::ValueObjectSP();
}

size_t LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() {
uint32_t LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() {
if (m_del_obj)
return 2;
return 1;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/ObjC/Cocoa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,9 @@ class ObjCClassSyntheticChildrenFrontEnd : public SyntheticChildrenFrontEnd {

~ObjCClassSyntheticChildrenFrontEnd() override = default;

size_t CalculateNumChildren() override { return 0; }
uint32_t CalculateNumChildren() override { return 0; }

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
return lldb::ValueObjectSP();
}

Expand Down
34 changes: 17 additions & 17 deletions lldb/source/Plugins/Language/ObjC/NSArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class NSArrayMSyntheticFrontEndBase : public SyntheticChildrenFrontEnd {

~NSArrayMSyntheticFrontEndBase() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override = 0;

Expand Down Expand Up @@ -214,9 +214,9 @@ class GenericNSArrayISyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~GenericNSArrayISyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -302,9 +302,9 @@ class NSArray0SyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~NSArray0SyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand All @@ -319,9 +319,9 @@ class NSArray1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~NSArray1SyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -477,14 +477,14 @@ lldb_private::formatters::
: NSArrayMSyntheticFrontEndBase(valobj_sp), m_data_32(nullptr),
m_data_64(nullptr) {}

size_t
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::CalculateNumChildren() {
uint32_t lldb_private::formatters::NSArrayMSyntheticFrontEndBase::
CalculateNumChildren() {
return GetUsedCount();
}

lldb::ValueObjectSP
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (idx >= CalculateNumChildren())
return lldb::ValueObjectSP();
lldb::addr_t object_at_idx = GetDataAddress();
Expand Down Expand Up @@ -634,7 +634,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
}

template <typename D32, typename D64, bool Inline>
size_t
uint32_t
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
CalculateNumChildren() {
return m_data_32 ? m_data_32->used : m_data_64->used;
Expand Down Expand Up @@ -684,7 +684,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
template <typename D32, typename D64, bool Inline>
lldb::ValueObjectSP
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
GetChildAtIndex(size_t idx) {
GetChildAtIndex(uint32_t idx) {
if (idx >= CalculateNumChildren())
return lldb::ValueObjectSP();
lldb::addr_t object_at_idx;
Expand Down Expand Up @@ -719,7 +719,7 @@ lldb_private::formatters::NSArray0SyntheticFrontEnd::GetIndexOfChildWithName(
return UINT32_MAX;
}

size_t
uint32_t
lldb_private::formatters::NSArray0SyntheticFrontEnd::CalculateNumChildren() {
return 0;
}
Expand All @@ -735,7 +735,7 @@ bool lldb_private::formatters::NSArray0SyntheticFrontEnd::MightHaveChildren() {

lldb::ValueObjectSP
lldb_private::formatters::NSArray0SyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
return lldb::ValueObjectSP();
}

Expand All @@ -754,7 +754,7 @@ lldb_private::formatters::NSArray1SyntheticFrontEnd::GetIndexOfChildWithName(
return UINT32_MAX;
}

size_t
uint32_t
lldb_private::formatters::NSArray1SyntheticFrontEnd::CalculateNumChildren() {
return 1;
}
Expand All @@ -770,7 +770,7 @@ bool lldb_private::formatters::NSArray1SyntheticFrontEnd::MightHaveChildren() {

lldb::ValueObjectSP
lldb_private::formatters::NSArray1SyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
static const ConstString g_zero("[0]");

if (idx == 0) {
Expand Down
48 changes: 24 additions & 24 deletions lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class NSDictionaryISyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~NSDictionaryISyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -144,9 +144,9 @@ class NSConstantDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
NSConstantDictionarySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -176,9 +176,9 @@ class NSCFDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
NSCFDictionarySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -209,9 +209,9 @@ class NSDictionary1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~NSDictionary1SyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand All @@ -230,9 +230,9 @@ class GenericNSDictionaryMSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~GenericNSDictionaryMSyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -263,9 +263,9 @@ namespace Foundation1100 {

~NSDictionaryMSyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -606,7 +606,7 @@ size_t lldb_private::formatters::NSDictionaryISyntheticFrontEnd::
return idx;
}

size_t lldb_private::formatters::NSDictionaryISyntheticFrontEnd::
uint32_t lldb_private::formatters::NSDictionaryISyntheticFrontEnd::
CalculateNumChildren() {
if (!m_data_32 && !m_data_64)
return 0;
Expand Down Expand Up @@ -655,7 +655,7 @@ bool lldb_private::formatters::NSDictionaryISyntheticFrontEnd::

lldb::ValueObjectSP
lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
uint32_t num_children = CalculateNumChildren();

if (idx >= num_children)
Expand Down Expand Up @@ -744,7 +744,7 @@ size_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
return idx;
}

size_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
uint32_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
CalculateNumChildren() {
if (!m_hashtable.IsValid())
return 0;
Expand Down Expand Up @@ -777,7 +777,7 @@ bool lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::

lldb::ValueObjectSP
lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
lldb::addr_t m_keys_ptr = m_hashtable.GetKeyPointer();
lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer();

Expand Down Expand Up @@ -880,7 +880,7 @@ size_t lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::
return idx;
}

size_t lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::
uint32_t lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::
CalculateNumChildren() {
return m_size;
}
Expand Down Expand Up @@ -920,7 +920,7 @@ bool lldb_private::formatters::NSConstantDictionarySyntheticFrontEnd::
}

lldb::ValueObjectSP lldb_private::formatters::
NSConstantDictionarySyntheticFrontEnd::GetChildAtIndex(size_t idx) {
NSConstantDictionarySyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
uint32_t num_children = CalculateNumChildren();

if (idx >= num_children)
Expand Down Expand Up @@ -994,7 +994,7 @@ size_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
return name == g_zero ? 0 : UINT32_MAX;
}

size_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
uint32_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
CalculateNumChildren() {
return 1;
}
Expand All @@ -1012,7 +1012,7 @@ bool lldb_private::formatters::NSDictionary1SyntheticFrontEnd::

lldb::ValueObjectSP
lldb_private::formatters::NSDictionary1SyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
if (idx != 0)
return lldb::ValueObjectSP();

Expand Down Expand Up @@ -1087,7 +1087,7 @@ size_t lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
}

template <typename D32, typename D64>
size_t
uint32_t
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::CalculateNumChildren() {
if (!m_data_32 && !m_data_64)
return 0;
Expand Down Expand Up @@ -1140,7 +1140,7 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
template <typename D32, typename D64>
lldb::ValueObjectSP
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
D32, D64>::GetChildAtIndex(size_t idx) {
D32, D64>::GetChildAtIndex(uint32_t idx) {
lldb::addr_t m_keys_ptr;
lldb::addr_t m_values_ptr;
if (m_data_32) {
Expand Down Expand Up @@ -1250,7 +1250,7 @@ lldb_private::formatters::Foundation1100::
return idx;
}

size_t
uint32_t
lldb_private::formatters::Foundation1100::
NSDictionaryMSyntheticFrontEnd::CalculateNumChildren() {
if (!m_data_32 && !m_data_64)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ lldb_private::formatters::Foundation1100::

lldb::ValueObjectSP
lldb_private::formatters::Foundation1100::
NSDictionaryMSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
NSDictionaryMSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) {
lldb::addr_t m_keys_ptr =
(m_data_32 ? m_data_32->_keys_addr : m_data_64->_keys_addr);
lldb::addr_t m_values_ptr =
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/ObjC/NSError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ class NSErrorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
// no need to delete m_child_ptr - it's kept alive by the cluster manager on
// our behalf

size_t CalculateNumChildren() override {
uint32_t CalculateNumChildren() override {
if (m_child_ptr)
return 1;
if (m_child_sp)
return 1;
return 0;
}

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
if (idx != 0)
return lldb::ValueObjectSP();

Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/ObjC/NSException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ class NSExceptionSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~NSExceptionSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override {
uint32_t CalculateNumChildren() override {
return 4;
}

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
switch (idx) {
case 0: return m_name_sp;
case 1: return m_reason_sp;
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class NSIndexPathSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~NSIndexPathSyntheticFrontEnd() override = default;

size_t CalculateNumChildren() override { return m_impl.GetNumIndexes(); }
uint32_t CalculateNumChildren() override { return m_impl.GetNumIndexes(); }

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
return m_impl.GetIndexAtIndex(idx, m_uint_star_type);
}

Expand Down
29 changes: 15 additions & 14 deletions lldb/source/Plugins/Language/ObjC/NSSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class NSSetISyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~NSSetISyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -84,9 +84,9 @@ class NSCFSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
NSCFSetSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -117,9 +117,9 @@ class GenericNSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~GenericNSSetMSyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -233,9 +233,9 @@ class NSSetCodeRunningSyntheticFrontEnd : public SyntheticChildrenFrontEnd {

~NSSetCodeRunningSyntheticFrontEnd() override;

size_t CalculateNumChildren() override;
uint32_t CalculateNumChildren() override;

lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override;

lldb::ChildCacheState Update() override;

Expand Down Expand Up @@ -419,7 +419,7 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetIndexOfChildWithName(
return idx;
}

size_t
uint32_t
lldb_private::formatters::NSSetISyntheticFrontEnd::CalculateNumChildren() {
if (!m_data_32 && !m_data_64)
return 0;
Expand Down Expand Up @@ -466,7 +466,8 @@ bool lldb_private::formatters::NSSetISyntheticFrontEnd::MightHaveChildren() {
}

lldb::ValueObjectSP
lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex(size_t idx) {
lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex(
uint32_t idx) {
uint32_t num_children = CalculateNumChildren();

if (idx >= num_children)
Expand Down Expand Up @@ -555,7 +556,7 @@ lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetIndexOfChildWithName(
return idx;
}

size_t
uint32_t
lldb_private::formatters::NSCFSetSyntheticFrontEnd::CalculateNumChildren() {
if (!m_hashtable.IsValid())
return 0;
Expand Down Expand Up @@ -587,7 +588,7 @@ bool lldb_private::formatters::NSCFSetSyntheticFrontEnd::MightHaveChildren() {

lldb::ValueObjectSP
lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
uint32_t idx) {
lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer();

const uint32_t num_children = CalculateNumChildren();
Expand Down Expand Up @@ -696,7 +697,7 @@ lldb_private::formatters::
}

template <typename D32, typename D64>
size_t
uint32_t
lldb_private::formatters::
GenericNSSetMSyntheticFrontEnd<D32, D64>::CalculateNumChildren() {
if (!m_data_32 && !m_data_64)
Expand Down Expand Up @@ -748,7 +749,7 @@ lldb_private::formatters::
template <typename D32, typename D64>
lldb::ValueObjectSP
lldb_private::formatters::
GenericNSSetMSyntheticFrontEnd<D32, D64>::GetChildAtIndex(size_t idx) {
GenericNSSetMSyntheticFrontEnd<D32, D64>::GetChildAtIndex(uint32_t idx) {
lldb::addr_t m_objs_addr =
(m_data_32 ? m_data_32->_objs_addr : m_data_64->_objs_addr);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//===--- VTuneSupportPlugin.h -- Support for VTune profiler ---*- 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
//
//===----------------------------------------------------------------------===//
//
// Handles support for registering code with VIntel Tune's Amplifier JIT API.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGGING_VTUNESUPPORT_H
#define LLVM_EXECUTIONENGINE_ORC_DEBUGGING_VTUNESUPPORT_H

#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
#include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"
#include "llvm/ExecutionEngine/Orc/Shared/VTuneSharedStructs.h"

namespace llvm {

namespace orc {

class VTuneSupportPlugin : public ObjectLinkingLayer::Plugin {
public:
VTuneSupportPlugin(ExecutorProcessControl &EPC, ExecutorAddr RegisterImplAddr,
ExecutorAddr UnregisterImplAddr, bool EmitDebugInfo)
: EPC(EPC), RegisterVTuneImplAddr(RegisterImplAddr),
UnregisterVTuneImplAddr(UnregisterImplAddr),
EmitDebugInfo(EmitDebugInfo) {}

void modifyPassConfig(MaterializationResponsibility &MR,
jitlink::LinkGraph &G,
jitlink::PassConfiguration &Config) override;

Error notifyEmitted(MaterializationResponsibility &MR) override;
Error notifyFailed(MaterializationResponsibility &MR) override;
Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override;
void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey,
ResourceKey SrcKey) override;

static Expected<std::unique_ptr<VTuneSupportPlugin>>
Create(ExecutorProcessControl &EPC, JITDylib &JD, bool EmitDebugInfo,
bool TestMode = false);

private:
ExecutorProcessControl &EPC;
ExecutorAddr RegisterVTuneImplAddr;
ExecutorAddr UnregisterVTuneImplAddr;
std::mutex PluginMutex;
uint64_t NextMethodID = 0;
DenseMap<MaterializationResponsibility *, std::pair<uint64_t, uint64_t>>
PendingMethodIDs;
DenseMap<ResourceKey, SmallVector<std::pair<uint64_t, uint64_t>>>
LoadedMethodIDs;
bool EmitDebugInfo;
};

} // end namespace orc

} // end namespace llvm

#endif
102 changes: 102 additions & 0 deletions llvm/include/llvm/ExecutionEngine/Orc/Shared/VTuneSharedStructs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//===-------------------- VTuneSharedStructs.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
//
//===----------------------------------------------------------------------===//
//
// Structs and serialization to share VTune-related information
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H
#define LLVM_EXECUTIONENGINE_ORC_SHARED_VTUNESHAREDSTRUCTS_H

namespace llvm {
namespace orc {

using VTuneLineTable = std::vector<std::pair<unsigned, unsigned>>;

// SI = String Index, 1-indexed into the VTuneMethodBatch::Strings table.
// SI == 0 means replace with nullptr.

// MI = Method Index, 1-indexed into the VTuneMethodBatch::Methods table.
// MI == 0 means this is a parent method and was not inlined.

struct VTuneMethodInfo {
VTuneLineTable LineTable;
ExecutorAddr LoadAddr;
uint64_t LoadSize;
uint64_t MethodID;
uint32_t NameSI;
uint32_t ClassFileSI;
uint32_t SourceFileSI;
uint32_t ParentMI;
};

using VTuneMethodTable = std::vector<VTuneMethodInfo>;
using VTuneStringTable = std::vector<std::string>;

struct VTuneMethodBatch {
VTuneMethodTable Methods;
VTuneStringTable Strings;
};

using VTuneUnloadedMethodIDs = SmallVector<std::pair<uint64_t, uint64_t>>;

namespace shared {

using SPSVTuneLineTable = SPSSequence<SPSTuple<uint32_t, uint32_t>>;
using SPSVTuneMethodInfo =
SPSTuple<SPSVTuneLineTable, SPSExecutorAddr, uint64_t, uint64_t, uint32_t,
uint32_t, uint32_t, uint32_t>;
using SPSVTuneMethodTable = SPSSequence<SPSVTuneMethodInfo>;
using SPSVTuneStringTable = SPSSequence<SPSString>;
using SPSVTuneMethodBatch = SPSTuple<SPSVTuneMethodTable, SPSVTuneStringTable>;
using SPSVTuneUnloadedMethodIDs = SPSSequence<SPSTuple<uint64_t, uint64_t>>;

template <> class SPSSerializationTraits<SPSVTuneMethodInfo, VTuneMethodInfo> {
public:
static size_t size(const VTuneMethodInfo &MI) {
return SPSVTuneMethodInfo::AsArgList::size(
MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
}

static bool deserialize(SPSInputBuffer &IB, VTuneMethodInfo &MI) {
return SPSVTuneMethodInfo::AsArgList::deserialize(
IB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
}

static bool serialize(SPSOutputBuffer &OB, const VTuneMethodInfo &MI) {
return SPSVTuneMethodInfo::AsArgList::serialize(
OB, MI.LineTable, MI.LoadAddr, MI.LoadSize, MI.MethodID, MI.NameSI,
MI.ClassFileSI, MI.SourceFileSI, MI.ParentMI);
}
};

template <>
class SPSSerializationTraits<SPSVTuneMethodBatch, VTuneMethodBatch> {
public:
static size_t size(const VTuneMethodBatch &MB) {
return SPSVTuneMethodBatch::AsArgList::size(MB.Methods, MB.Strings);
}

static bool deserialize(SPSInputBuffer &IB, VTuneMethodBatch &MB) {
return SPSVTuneMethodBatch::AsArgList::deserialize(IB, MB.Methods,
MB.Strings);
}

static bool serialize(SPSOutputBuffer &OB, const VTuneMethodBatch &MB) {
return SPSVTuneMethodBatch::AsArgList::serialize(OB, MB.Methods,
MB.Strings);
}
};

} // end namespace shared
} // end namespace orc
} // end namespace llvm

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

//===------ JITLoaderVTune.h --- Register profiler objects ------*- 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
//
//===----------------------------------------------------------------------===//
//
// Register objects for access by profilers via the perf JIT interface.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_JITLOADERVTUNE_H
#define LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_JITLOADERVTUNE_H

#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
#include <cstdint>

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerVTuneImpl(const char *Data, uint64_t Size);

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_unregisterVTuneImpl(const char *Data, uint64_t Size);

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_test_registerVTuneImpl(const char *Data, uint64_t Size);

#endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_JITLOADERVTUNE_H


6 changes: 6 additions & 0 deletions llvm/lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,12 @@ static void computeKnownBitsFromOperator(const Operator *I,
if (RV->getType() == I->getType()) {
computeKnownBits(RV, Known2, Depth + 1, Q);
Known = Known.unionWith(Known2);
// If the function doesn't return properly for all input values
// (e.g. unreachable exits) then there might be conflicts between the
// argument value and the range metadata. Simply discard the known bits
// in case of conflicts.
if (Known.hasConflict())
Known.resetAll();
}
}
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,7 @@ MachineInstrBuilder MachineIRBuilder::buildShuffleSplat(const DstOp &Res,

MachineInstrBuilder MachineIRBuilder::buildSplatVector(const DstOp &Res,
const SrcOp &Src) {
LLT DstTy = Res.getLLTTy(*getMRI());
assert(Src.getLLTTy(*getMRI()) == DstTy.getElementType() &&
assert(Src.getLLTTy(*getMRI()) == Res.getLLTTy(*getMRI()).getElementType() &&
"Expected Src to match Dst elt ty");
return buildInstr(TargetOpcode::G_SPLAT_VECTOR, Res, Src);
}
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/ExecutionEngine/Orc/Debugging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_llvm_component_library(LLVMOrcDebugging
DebuggerSupportPlugin.cpp
LLJITUtilsCBindings.cpp
PerfSupportPlugin.cpp
VTuneSupportPlugin.cpp

ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/ExecutionEngine/Orc/Debugging/
Expand Down
185 changes: 185 additions & 0 deletions llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
//===--- VTuneSupportPlugin.cpp -- Support for VTune profiler --*- 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
//
//===----------------------------------------------------------------------===//
//
// Handles support for registering code with VIntel Tune's Amplfiier JIT API.
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/ExecutionEngine/Orc/Debugging/DebugInfoSupport.h"

using namespace llvm;
using namespace llvm::orc;
using namespace llvm::jitlink;

static constexpr StringRef RegisterVTuneImplName = "llvm_orc_registerVTuneImpl";
static constexpr StringRef UnregisterVTuneImplName =
"llvm_orc_unregisterVTuneImpl";
static constexpr StringRef RegisterTestVTuneImplName =
"llvm_orc_test_registerVTuneImpl";

static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo) {
VTuneMethodBatch Batch;
std::unique_ptr<DWARFContext> DC;
StringMap<std::unique_ptr<MemoryBuffer>> DCBacking;
if (EmitDebugInfo) {
auto EDC = createDWARFContext(G);
if (!EDC) {
EmitDebugInfo = false;
} else {
DC = std::move(EDC->first);
DCBacking = std::move(EDC->second);
}
}

auto GetStringIdx = [Deduplicator = StringMap<uint32_t>(),
&Batch](StringRef S) mutable {
auto I = Deduplicator.find(S);
if (I != Deduplicator.end())
return I->second;

Batch.Strings.push_back(S.str());
return Deduplicator[S] = Batch.Strings.size();
};
for (auto Sym : G.defined_symbols()) {
if (!Sym->isCallable())
continue;

Batch.Methods.push_back(VTuneMethodInfo());
auto &Method = Batch.Methods.back();
Method.MethodID = 0;
Method.ParentMI = 0;
Method.LoadAddr = Sym->getAddress();
Method.LoadSize = Sym->getSize();
Method.NameSI = GetStringIdx(Sym->getName());
Method.ClassFileSI = 0;
Method.SourceFileSI = 0;

if (!EmitDebugInfo)
continue;

auto &Section = Sym->getBlock().getSection();
auto Addr = Sym->getAddress();
auto SAddr =
object::SectionedAddress{Addr.getValue(), Section.getOrdinal()};
DILineInfoTable LinesInfo = DC->getLineInfoForAddressRange(
SAddr, Sym->getSize(),
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath);
Method.SourceFileSI = Batch.Strings.size();
Batch.Strings.push_back(DC->getLineInfoForAddress(SAddr).FileName);
for (auto &LInfo : LinesInfo) {
Method.LineTable.push_back(
std::pair<unsigned, unsigned>{/*unsigned*/ Sym->getOffset(),
/*DILineInfo*/ LInfo.second.Line});
}
}
return Batch;
}

void VTuneSupportPlugin::modifyPassConfig(MaterializationResponsibility &MR,
LinkGraph &G,
PassConfiguration &Config) {
Config.PostFixupPasses.push_back([this, MR = &MR](LinkGraph &G) {
// the object file is generated but not linked yet
auto Batch = getMethodBatch(G, EmitDebugInfo);
if (Batch.Methods.empty()) {
return Error::success();
}
{
std::lock_guard<std::mutex> Lock(PluginMutex);
uint64_t Allocated = Batch.Methods.size();
uint64_t Start = NextMethodID;
NextMethodID += Allocated;
for (size_t i = Start; i < NextMethodID; ++i) {
Batch.Methods[i - Start].MethodID = i;
}
this->PendingMethodIDs[MR] = {Start, Allocated};
}
G.allocActions().push_back(
{cantFail(shared::WrapperFunctionCall::Create<
shared::SPSArgList<shared::SPSVTuneMethodBatch>>(
RegisterVTuneImplAddr, Batch)),
{}});
return Error::success();
});
}

Error VTuneSupportPlugin::notifyEmitted(MaterializationResponsibility &MR) {
if (auto Err = MR.withResourceKeyDo([this, MR = &MR](ResourceKey K) {
std::lock_guard<std::mutex> Lock(PluginMutex);
auto I = PendingMethodIDs.find(MR);
if (I == PendingMethodIDs.end())
return;

LoadedMethodIDs[K].push_back(I->second);
PendingMethodIDs.erase(I);
})) {
return Err;
}
return Error::success();
}

Error VTuneSupportPlugin::notifyFailed(MaterializationResponsibility &MR) {
std::lock_guard<std::mutex> Lock(PluginMutex);
PendingMethodIDs.erase(&MR);
return Error::success();
}

Error VTuneSupportPlugin::notifyRemovingResources(JITDylib &JD, ResourceKey K) {
// Unregistration not required if not provided
if (!UnregisterVTuneImplAddr) {
return Error::success();
}
VTuneUnloadedMethodIDs UnloadedIDs;
{
std::lock_guard<std::mutex> Lock(PluginMutex);
auto I = LoadedMethodIDs.find(K);
if (I == LoadedMethodIDs.end())
return Error::success();

UnloadedIDs = std::move(I->second);
LoadedMethodIDs.erase(I);
}
if (auto Err = EPC.callSPSWrapper<void(shared::SPSVTuneUnloadedMethodIDs)>(
UnregisterVTuneImplAddr, UnloadedIDs))
return Err;

return Error::success();
}

void VTuneSupportPlugin::notifyTransferringResources(JITDylib &JD,
ResourceKey DstKey,
ResourceKey SrcKey) {
std::lock_guard<std::mutex> Lock(PluginMutex);
auto I = LoadedMethodIDs.find(SrcKey);
if (I == LoadedMethodIDs.end())
return;

auto &Dest = LoadedMethodIDs[DstKey];
Dest.insert(Dest.end(), I->second.begin(), I->second.end());
LoadedMethodIDs.erase(SrcKey);
}

Expected<std::unique_ptr<VTuneSupportPlugin>>
VTuneSupportPlugin::Create(ExecutorProcessControl &EPC, JITDylib &JD,
bool EmitDebugInfo, bool TestMode) {
auto &ES = EPC.getExecutionSession();
auto RegisterImplName =
ES.intern(TestMode ? RegisterTestVTuneImplName : RegisterVTuneImplName);
auto UnregisterImplName = ES.intern(UnregisterVTuneImplName);
SymbolLookupSet SLS{RegisterImplName, UnregisterImplName};
auto Res = ES.lookup(makeJITDylibSearchOrder({&JD}), std::move(SLS));
if (!Res)
return Res.takeError();
ExecutorAddr RegisterImplAddr(
Res->find(RegisterImplName)->second.getAddress());
ExecutorAddr UnregisterImplAddr(
Res->find(UnregisterImplName)->second.getAddress());
return std::make_unique<VTuneSupportPlugin>(
EPC, RegisterImplAddr, UnregisterImplAddr, EmitDebugInfo);
}
7 changes: 4 additions & 3 deletions llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,10 @@ class ObjectLinkingLayerJITLinkContext final : public JITLinkContext {
ProcessSymbol(Sym);

// Attempt to claim all weak defs that we're not already responsible for.
// This cannot fail -- any clashes will just result in rejection of our
// claim, at which point we'll externalize that symbol.
cantFail(MR->defineMaterializing(std::move(NewSymbolsToClaim)));
// This may fail if the resource tracker has become defunct, but should
// always succeed otherwise.
if (auto Err = MR->defineMaterializing(std::move(NewSymbolsToClaim)))
return Err;

// Walk the list of symbols that we just tried to claim. Symbols that we're
// responsible for are marked live. Symbols that we're not responsible for
Expand Down
9 changes: 9 additions & 0 deletions llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ if( CMAKE_HOST_UNIX AND HAVE_LIBRT )
set(rt_lib rt)
endif()

set(intel_jit_profiling )
if( LLVM_USE_INTEL_JITEVENTS )
set(intel_jit_profiling IntelJITProfiling)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../IntelJITProfiling)
include_directories(${PROJECT_BINARY_DIR}/ittapi/include/ )
endif()

add_llvm_component_library(LLVMOrcTargetProcess
ExecutorSharedMemoryMapperService.cpp
JITLoaderGDB.cpp
JITLoaderPerf.cpp
JITLoaderVTune.cpp
OrcRTBootstrap.cpp
RegisterEHFrames.cpp
SimpleExecutorDylibManager.cpp
Expand All @@ -21,6 +29,7 @@ add_llvm_component_library(LLVMOrcTargetProcess
${rt_lib}

LINK_COMPONENTS
${intel_jit_profiling}
OrcShared
Support
TargetParser
Expand Down
224 changes: 224 additions & 0 deletions llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderVTune.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
//===------- JITLoaderVTune.cpp - Register profiler objects -----*- 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
//
//===----------------------------------------------------------------------===//
//
// Register objects for access by profilers via the VTune JIT interface.
//===----------------------------------------------------------------------===//

#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderVTune.h"
#include "llvm/ExecutionEngine/Orc/Shared/VTuneSharedStructs.h"
#include <map>

#if LLVM_USE_INTEL_JITEVENTS
#include "IntelJITEventsWrapper.h"
#include "ittnotify.h"

using namespace llvm;
using namespace llvm::orc;

namespace {
class JITEventWrapper {
public:
static std::unique_ptr<IntelJITEventsWrapper> Wrapper;
};
std::unique_ptr<IntelJITEventsWrapper> JITEventWrapper::Wrapper;
} // namespace

static Error registerJITLoaderVTuneRegisterImpl(const VTuneMethodBatch &MB) {
const size_t StringsSize = MB.Strings.size();

for (const auto &MethodInfo : MB.Methods) {
iJIT_Method_Load MethodMessage;
memset(&MethodMessage, 0, sizeof(iJIT_Method_Load));

MethodMessage.method_id = MethodInfo.MethodID;
if (MethodInfo.NameSI != 0 && MethodInfo.NameSI < StringsSize) {
MethodMessage.method_name =
const_cast<char *>(MB.Strings.at(MethodInfo.NameSI).data());
} else {
MethodMessage.method_name = NULL;
}
if (MethodInfo.ClassFileSI != 0 && MethodInfo.ClassFileSI < StringsSize) {
MethodMessage.class_file_name =
const_cast<char *>(MB.Strings.at(MethodInfo.ClassFileSI).data());
} else {
MethodMessage.class_file_name = NULL;
}
if (MethodInfo.SourceFileSI != 0 && MethodInfo.SourceFileSI < StringsSize) {
MethodMessage.source_file_name =
const_cast<char *>(MB.Strings.at(MethodInfo.SourceFileSI).data());
} else {
MethodMessage.source_file_name = NULL;
}

MethodMessage.method_load_address = MethodInfo.LoadAddr.toPtr<void *>();
MethodMessage.method_size = MethodInfo.LoadSize;
MethodMessage.class_id = 0;

MethodMessage.user_data = NULL;
MethodMessage.user_data_size = 0;
MethodMessage.env = iJDE_JittingAPI;

std::vector<LineNumberInfo> LineInfo;
for (const auto &LInfo : MethodInfo.LineTable) {
LineInfo.push_back(LineNumberInfo{LInfo.first, LInfo.second});
}

if (LineInfo.size() == 0) {
MethodMessage.line_number_size = 0;
MethodMessage.line_number_table = 0;
} else {
MethodMessage.line_number_size = LineInfo.size();
MethodMessage.line_number_table = &*LineInfo.begin();
}
JITEventWrapper::Wrapper->iJIT_NotifyEvent(
iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &MethodMessage);
}

return Error::success();
}

static void registerJITLoaderVTuneUnregisterImpl(
const std::vector<std::pair<uint64_t, uint64_t>> &UM) {
for (auto &Method : UM) {
JITEventWrapper::Wrapper->iJIT_NotifyEvent(
iJVM_EVENT_TYPE_METHOD_UNLOAD_START,
const_cast<unsigned long *>(&Method.first));
}
}

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerVTuneImpl(const char *Data, uint64_t Size) {
using namespace orc::shared;
if (!JITEventWrapper::Wrapper)
JITEventWrapper::Wrapper.reset(new IntelJITEventsWrapper);

return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
Data, Size, registerJITLoaderVTuneRegisterImpl)
.release();
}

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_unregisterVTuneImpl(const char *Data, uint64_t Size) {
using namespace orc::shared;
return WrapperFunction<void(SPSVTuneUnloadedMethodIDs)>::handle(
Data, Size, registerJITLoaderVTuneUnregisterImpl)
.release();
}

// For Testing: following code comes from llvm-jitlistener.cpp in llvm tools
namespace {
using SourceLocations = std::vector<std::pair<std::string, unsigned int>>;
using NativeCodeMap = std::map<uint64_t, SourceLocations>;
NativeCodeMap ReportedDebugFuncs;
} // namespace

static int NotifyEvent(iJIT_JVM_EVENT EventType, void *EventSpecificData) {
switch (EventType) {
case iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED: {
if (!EventSpecificData) {
errs() << "Error: The JIT event listener did not provide a event data.";
return -1;
}
iJIT_Method_Load *msg = static_cast<iJIT_Method_Load *>(EventSpecificData);

ReportedDebugFuncs[msg->method_id];

outs() << "Method load [" << msg->method_id << "]: " << msg->method_name
<< ", Size = " << msg->method_size << "\n";

for (unsigned int i = 0; i < msg->line_number_size; ++i) {
if (!msg->line_number_table) {
errs() << "A function with a non-zero line count had no line table.";
return -1;
}
std::pair<std::string, unsigned int> loc(
std::string(msg->source_file_name),
msg->line_number_table[i].LineNumber);
ReportedDebugFuncs[msg->method_id].push_back(loc);
outs() << " Line info @ " << msg->line_number_table[i].Offset << ": "
<< msg->source_file_name << ", line "
<< msg->line_number_table[i].LineNumber << "\n";
}
outs() << "\n";
} break;
case iJVM_EVENT_TYPE_METHOD_UNLOAD_START: {
if (!EventSpecificData) {
errs() << "Error: The JIT event listener did not provide a event data.";
return -1;
}
unsigned int UnloadId =
*reinterpret_cast<unsigned int *>(EventSpecificData);
assert(1 == ReportedDebugFuncs.erase(UnloadId));
outs() << "Method unload [" << UnloadId << "]\n";
} break;
default:
break;
}
return 0;
}

static iJIT_IsProfilingActiveFlags IsProfilingActive(void) {
// for testing, pretend we have an Intel Parallel Amplifier XE 2011
// instance attached
return iJIT_SAMPLING_ON;
}

static unsigned int GetNewMethodID(void) {
static unsigned int id = 0;
return ++id;
}

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_test_registerVTuneImpl(const char *Data, uint64_t Size) {
using namespace orc::shared;
JITEventWrapper::Wrapper.reset(new IntelJITEventsWrapper(
NotifyEvent, NULL, NULL, IsProfilingActive, 0, 0, GetNewMethodID));
return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
Data, Size, registerJITLoaderVTuneRegisterImpl)
.release();
}

#else

using namespace llvm;
using namespace llvm::orc;

static Error unsupportedBatch(const VTuneMethodBatch &MB) {
return llvm::make_error<StringError>("unsupported for Intel VTune",
inconvertibleErrorCode());
}

static void unsuppported(const std::vector<std::pair<uint64_t, uint64_t>> &UM) {

}

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerVTuneImpl(const char *Data, uint64_t Size) {
using namespace orc::shared;
return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
Data, Size, unsupportedBatch)
.release();
}

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_unregisterVTuneImpl(const char *Data, uint64_t Size) {
using namespace orc::shared;
return WrapperFunction<void(SPSVTuneUnloadedMethodIDs)>::handle(Data, Size,
unsuppported)
.release();
}

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_test_registerVTuneImpl(const char *Data, uint64_t Size) {
using namespace orc::shared;
return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
Data, Size, unsupportedBatch)
.release();
}

#endif
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/VOP3Instructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ let SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0 in {
defm V_MINIMUMMAXIMUM_F16 : VOP3Inst<"v_minimummaximum_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>>;
} // End SubtargetPredicate = isGFX12Plus, ReadsModeReg = 0

let SubtargetPredicate = HasDot9Insts, IsDOT=1 in {
let OtherPredicates = [HasDot9Insts], IsDOT=1 in {
defm V_DOT2_F16_F16 : VOP3Inst<"v_dot2_f16_f16", VOP3_DOT_Profile<VOP_F16_V2F16_V2F16_F16>, int_amdgcn_fdot2_f16_f16>;
defm V_DOT2_BF16_BF16 : VOP3Inst<"v_dot2_bf16_bf16", VOP3_DOT_Profile<VOP_BF16_V2BF16_V2BF16_BF16>, int_amdgcn_fdot2_bf16_bf16>;
}
Expand Down
63 changes: 63 additions & 0 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53441,6 +53441,69 @@ static SDValue combineSetCC(SDNode *N, SelectionDAG &DAG,
truncateAVX512SetCCNoBWI(VT, OpVT, LHS, RHS, CC, DL, DAG, Subtarget))
return R;

// In the middle end transforms:
// `(or (icmp eq X, C), (icmp eq X, C+1))`
// -> `(icmp ult (add x, -C), 2)`
// Likewise inverted cases with `ugt`.
//
// Since x86, pre avx512, doesn't have unsigned vector compares, this results
// in worse codegen. So, undo the middle-end transform and go back to `(or
// (icmp eq), (icmp eq))` form.
// Also skip AVX1 with ymm vectors, as the umin approach combines better than
// the xmm approach.
//
// NB: We don't handle the similiar simplication of `(and (icmp ne), (icmp
// ne))` as it doesn't end up instruction positive.
// TODO: We might want to do this for avx512 as well if we `sext` the result.
if (VT.isVector() && OpVT.isVector() && OpVT.isInteger() &&
ISD::isUnsignedIntSetCC(CC) && LHS.getOpcode() == ISD::ADD &&
!Subtarget.hasAVX512() &&
(OpVT.getSizeInBits() <= 128 || !Subtarget.hasAVX() ||
Subtarget.hasAVX2()) &&
LHS.hasOneUse()) {

APInt CmpC;
SDValue AddC = LHS.getOperand(1);
if (ISD::isConstantSplatVector(RHS.getNode(), CmpC) &&
DAG.isConstantIntBuildVectorOrConstantInt(AddC)) {
// See which form we have depending on the constant/condition.
SDValue C0 = SDValue();
SDValue C1 = SDValue();

// If we had `(add x, -1)` and can lower with `umin`, don't transform as
// we will end up generating an additional constant. Keeping in the
// current form has a slight latency cost, but it probably worth saving a
// constant.
if (ISD::isConstantSplatVectorAllOnes(AddC.getNode()) &&
DAG.getTargetLoweringInfo().isOperationLegal(ISD::UMIN, OpVT)) {
// Pass
}
// Normal Cases
else if ((CC == ISD::SETULT && CmpC == 2) ||
(CC == ISD::SETULE && CmpC == 1)) {
// These will constant fold.
C0 = DAG.getNegative(AddC, DL, OpVT);
C1 = DAG.getNode(ISD::SUB, DL, OpVT, C0,
DAG.getAllOnesConstant(DL, OpVT));
}
// Inverted Cases
else if ((CC == ISD::SETUGT && (-CmpC) == 3) ||
(CC == ISD::SETUGE && (-CmpC) == 2)) {
// These will constant fold.
C0 = DAG.getNOT(DL, AddC, OpVT);
C1 = DAG.getNode(ISD::ADD, DL, OpVT, C0,
DAG.getAllOnesConstant(DL, OpVT));
}
if (C0 && C1) {
SDValue NewLHS =
DAG.getSetCC(DL, VT, LHS.getOperand(0), C0, ISD::SETEQ);
SDValue NewRHS =
DAG.getSetCC(DL, VT, LHS.getOperand(0), C1, ISD::SETEQ);
return DAG.getNode(ISD::OR, DL, VT, NewLHS, NewRHS);
}
}
}

// For an SSE1-only target, lower a comparison of v4f32 to X86ISD::CMPP early
// to avoid scalarization via legalization because v4i32 is not a legal type.
if (Subtarget.hasSSE1() && !Subtarget.hasSSE2() && VT == MVT::v4i32 &&
Expand Down
Loading