[PATCH] Avoid empty .debug_loc entries and lists

David Blaikie dblaikie at gmail.com
Thu Jun 4 16:36:01 PDT 2015


On Thu, Jun 4, 2015 at 4:28 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:

>
> > On 2015 Jun 4, at 16:09, David Blaikie <dblaikie at gmail.com> wrote:
> >
> > Judging by the code, does this cause us not to create a variable if it
> has no locations? That's probably not quite right - even if we have no
> locations, it's probably a good idea/correct to describe the variable so
> shadowing, etc, works correctly (if someone tries to print the variable the
> compiler still finds the right variable but just reports that it doesn't
> know the location)
>
> So the code here already has an early return if there are no ranges:
>
>     for (const auto &I : DbgValues) {
>       InlinedVariable IV = I.first;
>       if (Processed.count(IV))
>         continue;
>
>       // Instruction ranges, specifying where IV is accessible.
>       const auto &Ranges = I.second;
>       if (Ranges.empty())
>         continue;
>
> My patch effectively hits this `continue` more often.  The difference
> is cases where we *thought* we knew how to emit ranges, but in fact
> didn't know how.
>
> I suppose I assumed the intended behaviour was "don't emit the
> variable if we don't have any ranges for it" since that's what was
> going on, but are you saying this `continue` is a bug?  (Or am I
> totally missing your point?)
>

How do we end up with an empty range list here? That seems strange - I
assume we're just lazily creating the rang lists in
calculateDbgValueHistory... (I could sort of understand empty entries in a
range list - when it turns out the dbg_value intrinsic describes no
instructions due to things being optimized away, hoisted here or there,
etc).


>
> > On 2015 Jun 4, at 16:13, Adrian Prantl <aprantl at apple.com> wrote:
> >
> > Even worse, when it is a function argument, omitting the variable will
> effectively change the function signature. (Yes, there is also the
> subroutine type...).
>
> No, there's a separate loop that guarantees all the function arguments
> get created.
>
>     // Collect info for variables that were optimized out.
>     for (const DILocalVariable *DV : SP->getVariables()) {
>       if (!Processed.insert(InlinedVariable(DV, nullptr)).second)
>         continue;
>       if (LexicalScope *Scope = LScopes.findLexicalScope(DV->getScope())) {
>         ensureAbstractVariableIsCreatedIfScoped(InlinedVariable(DV,
> nullptr),
>                                                 Scope->getScopeNode());
>         ConcreteVariables.push_back(make_unique<DbgVariable>(
>             DV, /* IA */ nullptr, /* Expr */ nullptr, this));
>         InfoHolder.addScopeVariable(Scope, ConcreteVariables.back().get());
>       }
>     }
>
> I haven't touched this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150604/34ee8e1a/attachment.html>


More information about the llvm-commits mailing list