Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/ComputeCxx/Comparison/LayoutDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ bool compare_existential_values(const swift::existential_type_metadata &type, co
}

ValueLayout wrapped_layout = fetch(reinterpret_cast<const swift::metadata &>(type), options, 0);
ValueLayout layout = wrapped_layout == ValueLayoutTrivial ? nullptr : layout;
ValueLayout layout = wrapped_layout == ValueLayoutTrivial ? nullptr : wrapped_layout;

return compare(layout, lhs_value, rhs_value, type.vw_size(), options);
}
Expand Down
4 changes: 0 additions & 4 deletions Sources/ComputeCxx/Graph/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ Graph::Context *Graph::primary_context() const {
Info info = {nullptr, UINT64_MAX};
_contexts_by_id.for_each(
[](const uint64_t context_id, Context *const context, void *info_ref) {
auto typed_info_ref = (std::pair<Context *, uint64_t> *)info_ref;
if (context_id < ((Info *)info_ref)->context_id) {
((Info *)info_ref)->context = context;
((Info *)info_ref)->context_id = context_id;
Expand Down Expand Up @@ -872,7 +871,6 @@ void Graph::indirect_attribute_set(data::ptr<IndirectNode> indirect_node, Attrib

OffsetAttributeID resolved_source = source.resolve(TraversalOptions::SkipMutableReference);
source = resolved_source.attribute();
uint32_t offset = resolved_source.offset();

AttributeID old_source = indirect_node->source().identifier();
if (source == old_source) {
Expand Down Expand Up @@ -2052,8 +2050,6 @@ CFStringRef Graph::all_copy_trace_path() {
}

void Graph::trace_assertion_failure(bool all_stop_tracing, const char *format, ...) {
char *message = nullptr;

va_list args;
va_start(args, format);

Expand Down
2 changes: 0 additions & 2 deletions Sources/ComputeCxx/Graph/Graph.mm
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ int trap_cycles() {
data::ptr<Graph::TreeElement> tree = tree_stack.top();
tree_stack.pop();

uint64_t tree_element_index;
auto found_tree_element = tree_element_indices.find(tree);
if (found_tree_element != tree_element_indices.end()) {
auto index = trees.size();
Expand Down Expand Up @@ -939,7 +938,6 @@ int trap_cycles() {

int frame_count = 0;
for (auto update = current_update(); update != nullptr; update = update.get()->next()) {
auto &frames = update.get()->frames();
for (auto &frame : std::ranges::reverse_view(update.get()->frames())) {
[nodes addObject:[NSNumber numberWithUnsignedInt:frame.attribute.offset()]];

Expand Down
32 changes: 19 additions & 13 deletions Sources/ComputeCxx/Swift/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ bool metadata::visit(metadata_visitor &visitor) const {
}
case ::swift::MetadataKind::Enum:
case ::swift::MetadataKind::Optional: {
auto enum_type = reinterpret_cast<const ::swift::EnumMetadata *>(this);
auto context = descriptor();
if (context && ::swift::EnumDescriptor::classof(context)) {
auto enum_context = reinterpret_cast<const ::swift::EnumDescriptor *>(context);
Expand Down Expand Up @@ -737,27 +736,34 @@ bool metadata::visit_heap_class(metadata_visitor &visitor) const {

bool metadata::visit_heap_locals(metadata_visitor &visitor) const {
auto local_type = reinterpret_cast<const ::swift::HeapLocalVariableMetadata *>(this);
if (!local_type->CaptureDescription || local_type->CaptureDescription[1] != '\0' ||
local_type->OffsetToFirstCapture == 0) {
if (!local_type->CaptureDescription) {
return visitor.unknown_result();
}

auto descriptor = reinterpret_cast<const ::swift::reflection::CaptureDescriptor *>(local_type->CaptureDescription);
if (descriptor->NumMetadataSources != 0) {
return visitor.unknown_result();
}

size_t offset = local_type->OffsetToFirstCapture;
if (offset == 0) {
return visitor.unknown_result();
}

if (descriptor->NumBindings) {
size_t offset = local_type->OffsetToFirstCapture;
// Builtin.RawPointer, see https://github.com/swiftlang/swift/blob/main/docs/ABI/Mangling.rst
static const metadata *pointer_type = mangled_type_name_ref("Bp", true, nullptr);
if (pointer_type == nullptr) {
return visitor.unknown_result();
}
for (unsigned i = 0; i < descriptor->NumBindings; ++i) {
// Builtin.RawPointer, see https://github.com/swiftlang/swift/blob/main/docs/ABI/Mangling.rst
static const metadata *pointer_type = mangled_type_name_ref("Bp", true, nullptr);
if (pointer_type == nullptr) {
return visitor.unknown_result();
if (!visitor.visit_element(*pointer_type, metadata::ref_kind::unmanaged, offset, vw_size())) {
return false;
}
visitor.visit_element(*pointer_type, metadata::ref_kind::unmanaged, offset, vw_size());
offset += sizeof(void *);
}
}

size_t offset = local_type->OffsetToFirstCapture;
for (auto capture_type_record = descriptor->capture_begin(), end = descriptor->capture_end();
capture_type_record != end; ++capture_type_record) {
const char *mangled_name = nullptr;
Expand All @@ -772,13 +778,13 @@ bool metadata::visit_heap_locals(metadata_visitor &visitor) const {

size_t size = element_type->vw_size();
size_t alignment_mask = element_type->getValueWitnesses()->getAlignmentMask();
size_t offset = (offset + alignment_mask) & ~alignment_mask;
size_t aligned_offset = (offset + alignment_mask) & ~alignment_mask;

if (!visitor.visit_element(*element_type, kind, offset, size)) {
if (!visitor.visit_element(*element_type, kind, aligned_offset, size)) {
return false;
}

offset += size;
offset = aligned_offset + size;
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Platform/MachOFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ void MachOFile::forEachLoadCommand(/* Diagnostics& diag, */ void (^callback)(con
} else if (hasMachOBigEndianMagic()) {
return; // can't process big endian mach-o
} else {
const uint32_t *h = (uint32_t *)this;
/* diag.error("file does not start with MH_MAGIC[_64]: 0x%08X 0x%08X", h[0], h[1]); */
/* const uint32_t *h = (uint32_t *)this;
diag.error("file does not start with MH_MAGIC[_64]: 0x%08X 0x%08X", h[0], h[1]); */
return; // not a mach-o file
}
const load_command *const cmdsEnd = (load_command *)((char *)startCmds + this->sizeofcmds);
Expand Down
2 changes: 0 additions & 2 deletions Sources/Utilities/HashTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ bool UntypedTable::insert(key_type key, value_type value) {
this->create_buckets();
}

void *result;

uint64_t hash_value = _hash(key);
HashNode *node = _buckets[hash_value & _bucket_mask];

Expand Down
1 change: 0 additions & 1 deletion Sources/Utilities/include/Utilities/List.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ template <typename T> void ForwardList<T>::pop_front() {
}

Node *next = _front->next;
T value = _front->value;

_front->next = _spare;
_spare = _front;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,18 @@ struct PrefetchCompareValuesTests {

let types: [Any.Type] = [Int.self, Double.self, Float.self]
for type in types {
let layout0 = prefetchCompareValues(of: type, options: ComparisonOptions(mode: .bitwise), priority: 0)
let layout0 = prefetchCompareValues(
of: type,
options: ComparisonOptions(mode: .bitwise),
priority: 0
)
#expect(layout0 == .trivial)

let layout1 = prefetchCompareValues(of: type, options: ComparisonOptions(mode: .indirect), priority: 0)
let layout1 = prefetchCompareValues(
of: type,
options: ComparisonOptions(mode: .indirect),
priority: 0
)
#expect(layout1 == .trivial)

let layout2 = prefetchCompareValues(
Expand Down