<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/150389>150389</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
How can I access DbgValueInst in LLVM Pass written by myself
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
enlist12
</td>
</tr>
</table>
<pre>
I try to catch llvm.dbg.value instruction to get some valuable infomation.
The LLVM IR seems like:
```
; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: none, inaccessiblemem: readwrite) uwtable
define dso_local noalias noundef ptr @ttc(i32 noundef %c, i32 noundef %b) local_unnamed_addr #0 !dbg !30 {
entry:
#dbg_value(i32 %c, !34, !DIExpression(), !37)
#dbg_value(i32 %b, !35, !DIExpression(), !37)
%call = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6, !dbg !38
#dbg_value(ptr %call, !36, !DIExpression(), !37)
store i32 %c, ptr %call, align 4, !dbg !39, !tbaa !40
%b1 = getelementptr inbounds nuw i8, ptr %call, i64 4, !dbg !45
store i32 %b, ptr %b1, align 4, !dbg !46, !tbaa !47
ret ptr %call, !dbg !48
}
```
I want to catch #dbg_value(i32 %c, !34, !DIExpression(), !37) and so on.
My code is:
```
for (auto &F : M)
{
if (F.isDeclaration() || F.getName().str() == "store_record" || F.getName().str() == "load_record")
continue;
for (auto &BB : F)
{
for (auto &I : BB)
{
if (I.isTerminator())
{
continue;
}
if (isa<DbgValueInst>(&I))
{
puts("aaaaaaaaaaaaaaaa");
DbgValueInst *DVI = dyn_cast<DbgValueInst>(&I);
Value *V = DVI->getValue();
ValToDbgMap[V] = DVI;
continue;
}
```
However, I didn't get it.
Any help would be appreciated!!!
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVl1v6jgQ_TXmZVQU7ITAQx6gKbqRblerVcUrcuIheNexke2U5d-v7JCWpr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