llvm.org GIT mirror llvm / e14048c
Reapply "DebugInfo: Ensure that all debug location scope chains from instructions within a function, lead to the function itself." Committed in r212205 and reverted in r212226 due to msan self-hosting failure, I believe I've got that fixed by r212761 to Clang. Original commit message: "Originally committed in r211723, reverted in r211724 due to failure cases found and fixed (ArgumentPromotion: r211872, Inlining: r212065), committed again in r212085 and reverted again in r212089 after fixing some other cases, such as debug info subprogram lists not keeping track of the function they represent (r212128) and then short-circuiting things like LiveDebugVariables that build LexicalScopes for functions that might not have full debug info. And again, I believe the invariant actually holds for some reasonable amount of code (but I'll keep an eye on the buildbots and see what happens... ). Original commit message: PR20038: DebugInfo: Inlined call sites where the caller has debug info but the call itself has no debug location. This situation does bad things when inlined, so I've fixed Clang not to produce inlinable call sites without locations when the caller has debug info (in the one case where I could find that this occurred). This updates the PR20038 test case to be what clang now produces, and readds the assertion that had to be removed due to this bug. I've also beefed up the debug info verifier to help diagnose these issues in the future, and I hope to add checks to the inliner to just assert-fail if it encounters this situation. If, in the future, we decide we have to cope with this situation, the right thing to do is probably to just remove all the DebugLocs from the inlined instructions." git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212776 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 6 years ago
3 changed file(s) with 34 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
787787 for (const auto &Var : ConcreteVariables) {
788788 DIE *VariableDie = Var->getDIE();
789789 // FIXME: There shouldn't be any variables without DIEs.
790 if (!VariableDie)
791 continue;
790 assert(VariableDie);
792791 // FIXME: Consider the time-space tradeoff of just storing the unit pointer
793792 // in the ConcreteVariables list, rather than looking it up again here.
794793 // DIE::getUnit isn't simple - it walks parent pointers, etc.
136136 /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
137137 /// not available then create new lexical scope.
138138 LexicalScope *LexicalScopes::getOrCreateLexicalScope(DebugLoc DL) {
139 if (DL.isUnknown())
140 return nullptr;
139141 MDNode *Scope = nullptr;
140142 MDNode *InlinedAt = nullptr;
141143 DL.getScopeAndInlinedAt(Scope, InlinedAt, MF->getFunction()->getContext());
171173 std::make_tuple(Parent, DIDescriptor(Scope),
172174 nullptr, false)).first;
173175
174 if (!Parent && DIDescriptor(Scope).isSubprogram() &&
175 DISubprogram(Scope).describes(MF->getFunction()))
176 if (!Parent) {
177 assert(DIDescriptor(Scope).isSubprogram());
178 assert(DISubprogram(Scope).describes(MF->getFunction()));
179 assert(!CurrentFnLexicalScope);
176180 CurrentFnLexicalScope = &I->second;
181 }
177182
178183 return &I->second;
179184 }
537537 if (isLValueReference() && isRValueReference())
538538 return false;
539539
540 if (auto *F = getFunction()) {
541 LLVMContext &Ctxt = F->getContext();
542 for (auto &BB : *F) {
543 for (auto &I : BB) {
544 DebugLoc DL = I.getDebugLoc();
545 if (DL.isUnknown())
546 continue;
547
548 MDNode *Scope = nullptr;
549 MDNode *IA = nullptr;
550 // walk the inlined-at scopes
551 while (DL.getScopeAndInlinedAt(Scope, IA, F->getContext()), IA)
552 DL = DebugLoc::getFromDILocation(IA);
553 DL.getScopeAndInlinedAt(Scope, IA, Ctxt);
554 assert(!IA);
555 while (!DIDescriptor(Scope).isSubprogram()) {
556 DILexicalBlockFile D(Scope);
557 Scope = D.isLexicalBlockFile()
558 ? D.getScope()
559 : DebugLoc::getFromDILexicalBlock(Scope).getScope(Ctxt);
560 }
561 if (!DISubprogram(Scope).describes(F))
562 return false;
563 }
564 }
565 }
540566 return DbgNode->getNumOperands() == 20;
541567 }
542568