<div dir="ltr"><div dir="ltr"><div dir="ltr">I wanted to start a migration from dbg.declare to dbg.addr, but never finished it. For your purposes, they are probably equivalent. The slight semantic difference is that dbg.declare cannot be mixed with dbg.value to create a variable that is sometimes in memory and sometimes a pure value.<div><br></div><div>To distinguish between two inlined copies of the same variable, look at the inlinedAt location of the location of the dbg intrinsic. The inlinedAt location will be distinct for every inlined call site. You can see how it is used in CodeGen/AsmPrinter/Dwarf* by looking for uses of InlinedEntity:</div><div><div>  using InlinedEntity = std::pair<const DINode *, const DILocation *>;</div></div><div>...</div><div><br></div><div><div>  for (const auto &VI : Asm->MF->getVariableDbgInfo()) {</div><div>    if (!VI.Var)</div><div>      continue;</div><div>    assert(VI.Var->isValidLocationForIntrinsic(VI.Loc) &&</div><div>           "Expected inlined-at fields to agree");</div><div><br></div><div>    InlinedEntity Var(VI.Var, VI.Loc->getInlinedAt());</div></div><div>...</div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Sep 17, 2018 at 7:00 AM Alexander Potapenko <<a href="mailto:glider@google.com">glider@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(I think I've asked a similar question off-list a couple of times, but<br>
never got an answer)<br>
<br>
Hi folks,<br>
<br>
For [K]MSAN we need to figure out which inlined function a local var<br>
originally belonged to in the source file.<br>
E.g. when a local buffer %buf is declared in @bar(), but @bar() is<br>
inlined into @foo(), then there's a local %buf.i in @foo(), but we<br>
need to determine that the local came from @bar(). In the case of<br>
nested inline functions we need the deepest one.<br>
<br>
Is there any existing code for that? If not, which debug info<br>
constructs do we need to look up to get this information?<br>
<br>
<a href="https://llvm.org/docs/SourceLevelDebugging.html" rel="noreferrer" target="_blank">https://llvm.org/docs/SourceLevelDebugging.html</a> mentions<br>
@llvm.dbg.addr as the source of information about a local var, but the<br>
ToT Clang doesn't emit it. There're calls to @llvm.debug.declare in<br>
the IR, but it's said to be deprecated, so I'm not sure if it's ok to<br>
use it.<br>
<br>
Thanks in advance,<br>
-- <br>
Alexander Potapenko<br>
Software Engineer<br>
<br>
Google Germany GmbH<br>
Erika-Mann-Straße, 33<br>
80636 München<br>
<br>
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado<br>
Registergericht und -nummer: Hamburg, HRB 86891<br>
Sitz der Gesellschaft: Hamburg<br>
</blockquote></div>