Use cast<> instead of unchecked dyn_cast
DebugInfo: Simplify subprogram declaration creation/references and accidentally refix PR11300.

Also simplifies the linkage name handling a little too.