coderkalyan / coderkalyan/femtoc

air, codegen: copy elision

Open
#64 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Zig
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Currently, air supports any type (including aggregates) as temporaries. Codegen lowers all aggregates to the stack, which results in some redundant intermediates being created.

For example, the code `let mut slice = array[start..end]` creates two allocas: the first one is the temporary to store the slicing result of array[start..end], and the second is the mutable stack slot for the `slice` variable. The backend then generates a copy (unrolled gep + load + store for slices, memcpy for arrays) between the two allocas. This problem doesn't currently happen when `slice` is constant, because no stack slot is created. However, for mut slices, we should find a way to elide the copy, and intialize the rvalue directly into the mut variable.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.