Given a llvm::AllocaInst, how do I get llvm.dbg.declares that refer to it?

%einfo64 = alloca %struct.exception_table_entry, align 8
call void @llvm.dbg.declare(metadata %struct.exception_table_entry* %einfo64, metadata !28301, metadata !DIExpression()), !dbg !28307

I tried to use AllocaInst.users and found that call llvm.dbg.eclare does not appear in its users list, so I found this question, but the answer has expired. The function FindAllocaDbgDeclare cannot be found in the new version of llvm.

I found a solution:

#include "llvm/IR/DebugInfo.h"

TinyPtrVector<DbgDeclareInst *> DIs = FindDbgDeclareUses(alloca_inst);
for (DbgDeclareInst *ddi: DIs) {
    dbgs() << "dbg inst: " << *ddi << '\n';