<div dir="ltr"><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">Thanks! It works. </span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">One sub-question: How do we analyze the
member dereferenced struct variables as dbg.declares only has the
declaration info as inside the function the struct variable types could have
members dereferenced as well. </span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">Example:</span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><a href="https://godbolt.org/z/zaeYn9do7">https://godbolt.org/z/zaeYn9do7</a></span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif">







</p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">dbg.declares have use_var info, i would like
to fetch <a href="http://address.id">address.id</a> as well.</span></p><div><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><br></p></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 20, 2021 at 12:25 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">You'd have to analyze the dbg.declares and track that they refer to the same thing as the geps/loads you're interested in - from the dbg.declares (& dbg.values) you can follow those to find the variables they refer to.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 20, 2021 at 12:18 PM Bella V via cfe-users <<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">Hello All,</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">I read the documentation and I was able to fetch the variable names and source locations attached to metadata for call instructions (@llvm.dbg.declare) using dyn_cast<DbgVariableIntrinsic>. I wanted to check if we could fetch the variable names in the load/gep instructors using debugInfo. I want to collect the use variable object details within the function.</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif"> </span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">I could only fetch the source locations (not the variable names) using !dbg attached to the load instructions. Any pointers if that is allowed.</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif"><br><b>C code:</b> </span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">int foo (bar_t *b, int len)</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">{</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">    if (b == (bar_t *)NULL) {</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">        return 0;</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">    }</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">    return -1;</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">}</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif"> </span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><b><span style="font-size:10pt;font-family:Arial,sans-serif">IR optimised code through LTO:</span></b><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">; Function Attrs: noinline nounwind optnone uwtable</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">define i32 @foo(%struct.bar_t*, i32) #0 !dbg !10 {</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  %3 = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  %4 = add i64 %3, 1</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  %5 = alloca i32, align 4</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  %6 = alloca % struct.bar_t*, align 8</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  %7 = alloca i32, align 4</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  store % struct.bar_t* %0, % struct.bar_t** %6, align 8</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  call void @llvm.dbg.declare(metadata % struct.bar_t** %6, metadata !11, metadata !DIExpression()), !dbg !12</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  store i32 %1, i32* %7, align 4</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  call void @llvm.dbg.declare(metadata i32* %7, metadata !12, metadata !DIExpression()), !dbg !14</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  %8 = load % struct.bar_t*, % struct.bar_t** %6, align 8, !dbg !15</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  %9 = icmp eq % struct.bar_t* %8, null, !dbg !16</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">  br i1 %9, label %10, label %11, !dbg !17</span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif"> </span><span style="font-family:Arial,sans-serif"></span></p><p class="MsoNormal" style="margin:0cm;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;vertical-align:baseline;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Arial,sans-serif">Many Thanks.</span></p></div>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div>
</blockquote></div>