Skip to content

Conversation

gitoleg
Copy link
Collaborator

@gitoleg gitoleg commented Nov 12, 2024

This PR adds a support for one more case of passing structs by value, with memcpy emitted.

First of all, don't worry - despite the PR seems big, it's basically consist of helpers + refactoring. Also, there is a minor change in the CIRBaseBuilder - I made static the getBestAllocaInsertPoint method in order to call it from lowering - we discussed once - and I here we just need it (or copy-paste the code, which doesn't seem good).

I will add several comments in order to simplify review.

Copy link

github-actions bot commented Nov 12, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

auto tmp = createTmpAlloca(CGF, Src.getLoc(), SrcTy);
CGF.getRewriter().create<StoreOp>(Src.getLoc(), Src, tmp);
auto len = createUInt64(CGF, Src.getLoc(), DstSize.getFixedValue());
createMemCpy(CGF, tmp, Dst, len);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here are the changes for the title - we emit a temp alloca (basically that's why we need the changes in the CIRBaseBuilder - we don't have any hint here where to insert it. Thus, we insert it as LLVM does - in the function start

@bcardosolopes bcardosolopes merged commit 7787e7c into llvm:main Nov 13, 2024
6 checks passed
lanza pushed a commit that referenced this pull request Mar 18, 2025
…ry (#1111)

This PR adds a support for one more case of passing structs by value,
with `memcpy` emitted.

First of all, don't worry - despite the PR seems big, it's basically
consist of helpers + refactoring. Also, there is a minor change in the
`CIRBaseBuilder` - I made static the `getBestAllocaInsertPoint` method
in order to call it from lowering - we discussed once - and I here we
just need it (or copy-paste the code, which doesn't seem good).

I will add several comments in order to simplify review.
terapines-osc-cir pushed a commit to Terapines/clangir that referenced this pull request Sep 2, 2025
…ry (llvm#1111)

This PR adds a support for one more case of passing structs by value,
with `memcpy` emitted.

First of all, don't worry - despite the PR seems big, it's basically
consist of helpers + refactoring. Also, there is a minor change in the
`CIRBaseBuilder` - I made static the `getBestAllocaInsertPoint` method
in order to call it from lowering - we discussed once - and I here we
just need it (or copy-paste the code, which doesn't seem good).

I will add several comments in order to simplify review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants