Is the check for volatility on both the return type of the function --
TREE_TYPE (TREE_TYPE (fndecl)) -- and on the RESULT_DECL -- TREE_TYPE
(r)) -- necessary?
I would expect that checking the volatility of the function return type
is sufficient; that's the language issue. If, for whatever reason, the
compiler were to make the RESULT_DECL volatile, for a function with a
non-volatile return, I believe that the NRV would still be valid.
Would you please test removing the check on the RESULT_DECL from your patch?