Issue 150389
Summary How can I access DbgValueInst in LLVM Pass written by myself
Labels new issue
Assignees
Reporter enlist12
    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!!!
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to