[llvm] r315279 - Ignore all duplicate frame index expression

Björn Steinbrink via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 09:52:52 PDT 2017


Can you check what kind of conflict is this? Two non-fragment
expressions, or a non-fragment expression conflicting with a fragment
expression?

2017-10-12 15:25 GMT+02:00 Daniel Jasper <djasper at google.com>:
> With this change, we are actually running into the assertion "conflicting
> locations for variable". I have re-instantiated the previous detection logic
> in r315576.
> What would lead to such two variables conflicting?
> Reid, can you help generate a test case? I'll forward repro instructions of
> internal tests to you.
>
> On Tue, Oct 10, 2017 at 8:46 AM, Bjorn Steinbrink via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: bsteinbr
>> Date: Tue Oct 10 00:46:17 2017
>> New Revision: 315279
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315279&view=rev
>> Log:
>> Ignore all duplicate frame index expression
>>
>> Some passes might duplicate calls to llvm.dbg.declare creating
>> duplicate frame index expression which currently trigger an assertion
>> which is meant to catch erroneous, overlapping fragment declarations.
>> But identical frame index expressions are just redundant and don't
>> actually conflict with each other, so we can be more lenient and just
>> ignore the duplicates.
>>
>> Reviewers: aprantl, rnk
>>
>> Subscribers: llvm-commits, JDevlieghere
>>
>> Differential Revision: https://reviews.llvm.org/D38540
>>
>> Modified:
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=315279&r1=315278&r2=315279&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Oct 10 00:46:17
>> 2017
>> @@ -220,9 +220,34 @@ ArrayRef<DbgVariable::FrameIndexExpr> Db
>>                return A.Expr->getFragmentInfo()->OffsetInBits <
>>                       B.Expr->getFragmentInfo()->OffsetInBits;
>>              });
>> +
>>    return FrameIndexExprs;
>>  }
>>
>> +void DbgVariable::addMMIEntry(const DbgVariable &V) {
>> +  assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
>> +  assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
>> +  assert(V.Var == Var && "conflicting variable");
>> +  assert(V.IA == IA && "conflicting inlined-at location");
>> +
>> +  assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
>> +  assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
>> +
>> +  for (const auto &FIE : V.FrameIndexExprs)
>> +    // Ignore duplicate entries.
>> +    if (llvm::none_of(FrameIndexExprs, [&](const FrameIndexExpr &Other) {
>> +          return FIE.FI == Other.FI && FIE.Expr == Other.Expr;
>> +        }))
>> +      FrameIndexExprs.push_back(FIE);
>> +
>> +  assert((FrameIndexExprs.size() == 1 ||
>> +          llvm::all_of(FrameIndexExprs,
>> +                       [](FrameIndexExpr &FIE) {
>> +                         return FIE.Expr && FIE.Expr->isFragment();
>> +                       })) &&
>> +         "conflicting locations for variable");
>> +}
>> +
>>  static const DwarfAccelTable::Atom TypeAtoms[] = {
>>      DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
>> dwarf::DW_FORM_data4),
>>      DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=315279&r1=315278&r2=315279&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Oct 10 00:46:17
>> 2017
>> @@ -138,30 +138,7 @@ public:
>>    /// Get the FI entries, sorted by fragment offset.
>>    ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
>>    bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
>> -
>> -  void addMMIEntry(const DbgVariable &V) {
>> -    assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
>> -    assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
>> -    assert(V.Var == Var && "conflicting variable");
>> -    assert(V.IA == IA && "conflicting inlined-at location");
>> -
>> -    assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
>> -    assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
>> -
>> -    if (FrameIndexExprs.size()) {
>> -      auto *Expr = FrameIndexExprs.back().Expr;
>> -      // Get rid of duplicate non-fragment entries. More than one
>> non-fragment
>> -      // dbg.declare makes no sense so ignore all but the first.
>> -      if (!Expr || !Expr->isFragment())
>> -        return;
>> -    }
>> -    FrameIndexExprs.append(V.FrameIndexExprs.begin(),
>> V.FrameIndexExprs.end());
>> -    assert(llvm::all_of(FrameIndexExprs,
>> -                        [](FrameIndexExpr &FIE) {
>> -                          return FIE.Expr && FIE.Expr->isFragment();
>> -                        }) &&
>> -           "conflicting locations for variable");
>> -  }
>> +  void addMMIEntry(const DbgVariable &V);
>>
>>    // Translate tag to proper Dwarf tag.
>>    dwarf::Tag getTag() const {
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>


More information about the llvm-commits mailing list