I don't think there's currently an easier way. There used to be a global metadata node that collected all function metadata entries (llvm.dbg.sp
) but it was removed a while ago in favor of llvm.dbg.cu
which reflects the DWARF structure more closely.
I suppose that the common uses of debug metadata don't require by-function lookup, and any extra information that could be removed, was removed, because saving space is important and metadata in IR is already way too big.