I suppose I was hoping that, one day, the compiler would be in a
"mode-agnostic" state when outside the top-level push_cfun/pop_cfun
pair, except for explicit exceptions like TARGET_CPU_CPP_BUILTINS.
However, that would mean deferring backend_init until the first call
to your new hook, which would probably be even more work than what
you've done so far. Even then, the compiler would not be in a
mode-agnostic state between a top-level pop_cfun and the next
push_cfun. I suppose that day will only come "when" (= if) all
mode-specific data is in an easily-switchable struct.
From the segfault you describe, it sounds like we currently assume that
calling this hook is a no-op until the first time we pass a function
with attributes. (Or at least, it sounds like that rule would avoid the
situations where things go wrong.) If so, I think we should mention
that in the tm.texi documentation.