c++: Avoid duplicate trivial_abi cleanup in cdtor clones [PR125066]
Prevents redundant cleanup operations for trivial_abi parameters in C++ constructor/destructor clones.
Constructor and destructor clones in the C++ frontend were applying parameter cleanups redundantly. Since these clones already incorporate a generic copy of the original function body, including necessary parameter cleanups, this commit modifies store_parm_decls to avoid registering another front-end CLEANUP_STMT for trivial_abi parameters when processing a clone. A new test case, attr-trivial_abi10.C, has been added to verify this fix.
In Details
This commit addresses a bug in the C++ frontend related to handling trivial_abi constructors and destructors, specifically concerning cloned functions generated for them. Constructor/destructor clones already receive a genericized copy of the original function's body, which includes parameter cleanup logic. The change prevents the store_parm_decls function from re-registering trivial_abi parameter cleanups for these cloned functions, thus avoiding redundant cleanup statements and ensuring correctness, as verified by PR125066.
- trivial_abi
- A C++ function attribute that suggests the function's calling convention has minimal overhead, often allowing for more aggressive optimizations like inlining or direct register passing of parameters. It implies that normal C++ ABI-specific cleanup actions might not be necessary.
- cdtor clones
- Refers to cloned functions created by the compiler for constructors and destructors. These clones are often generated to handle specific ABI requirements or optimizations, such as the
trivial_abiattribute. - CLEANUP_STMT
- A statement or construct within the compiler's intermediate representation (IR) that signifies a cleanup action, such as releasing resources or destructing objects, typically generated at the end of a scope or function.
- store_parm_decls
- A function within the GCC C++ frontend responsible for processing and storing the declarations of function parameters.
- PR125066
- A problem report (PR) filed against the GCC compiler, identifying a specific bug related to C++ trivial_abi handling in constructor/destructor clones.