r326307 and r327870 made changes that allowed using non-trivial C
structs with fields qualified with strong or weak. This commit generalizes NRVO, which could only be applied to C++ structs, to cover non-trivial C structs.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
Is it possible to just do this for all structs? I don't think it hurts anything to do it for structs that are trivial and returned indirectly, and it would certainly be nice to construct C return values in-place even if they're guilty of nothing more than being, y'know, really really big.
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1116 ↗ | (On Diff #140034) | I think this cast isn't necessary. |
Comment Actions
Yes, it's possible to do this for all C structs. It removes lots of alloca and memcpy instructions in the IR.
Comment Actions
Wow, the IR improvements here are amazing.
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1119 ↗ | (On Diff #140119) | This should be isNonTrivialToPrimitiveDestroy(), I think. The dynamic NRVO flag is specifically tied to whether we should destroy the local variable in its normal cleanup. |