I was a puzzled by src/backend/utils/fmgr/README and fmgr.h's descriptions of fcinfo->flinfo->fn_extra (FmgrInfo.fn_extra) as they seem to conflict with actual usage.
The docs suggest that fl_extra is for the use of function call handlers, but in practice it's also used heavily by function implementations as a cache space.
For example, SQL functions use fn_extra in init_sql_fcache, plpgsql uses it in plpgsql_compile, but also most of the array functions use it for a type cache.
I'm inclined to change the docs to say that functions called directly by the fmgr may also use fn_extra (per existing practice). Handlers that wrap functions usually called directly by the fmgr must save and restore fn_extra or leave it untouched.