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
Diff Detail
- Repository
- rC Clang
Event Timeline
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–1119 | I think this cast isn't necessary. |
Yes, it's possible to do this for all C structs. It removes lots of alloca and memcpy instructions in the IR.
Wow, the IR improvements here are amazing.
lib/CodeGen/CGDecl.cpp | ||
---|---|---|
1119 | 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. |
I think this cast isn't necessary.