[llvm] r219215 - DebugInfo: Ensure that all debug location scope chains from instructions within a function, lead to the function itself.

Adam Nemet anemet at apple.com
Tue Oct 14 09:59:35 PDT 2014


Great.  Thanks to both of you.

Adam

On Oct 14, 2014, at 9:55 AM, David Blaikie <dblaikie at gmail.com> wrote:

> 
> 
> On Fri, Oct 10, 2014 at 12:01 PM, Adam Nemet <anemet at apple.com> wrote:
> Thanks, David and hoping the tale will have a happy ending :)
> 
> Perhaps, perhaps. Fixed a fairly innocuous bug in Clang (r219690) that was causing this particular issue. Just chatting to Lang now about whether there's a good way for me to reproduce your whole test-suite run to have some confidence there's nothing else lurking in that level of testing before I submit again.
>  
> 
> On Oct 10, 2014, at 11:57 AM, David Blaikie <dblaikie at gmail.com> wrote:
> 
>> I can confirm the reproduction and have reverted this patch in r219523 while I investigate (I assume it'll be a frontend (clang) fix, but we'll see).
>> 
>> On Fri, Oct 10, 2014 at 11:43 AM, Adam Nemet <anemet at apple.com> wrote:
>> 
>> On Oct 10, 2014, at 11:28 AM, David Blaikie <dblaikie at gmail.com> wrote:
>> 
>>> 
>>> 
>>> On Fri, Oct 10, 2014 at 11:07 AM, Adam Nemet <anemet at apple.com> wrote:
>>> 
>>> On Oct 7, 2014, at 9:56 AM, David Blaikie <dblaikie at gmail.com> wrote:
>>> 
>>> > Author: dblaikie
>>> > Date: Tue Oct  7 11:56:20 2014
>>> > New Revision: 219215
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=219215&view=rev
>>> > Log:
>>> > DebugInfo: Ensure that all debug location scope chains from instructions within a function, lead to the function itself.
>>> >
>>> > Let me tell you a tale...
>>> >
>>> > Originally committed in r211723 after discovering a nasty case of weird
>>> > scoping due to inlining, this was reverted in r211724 after it fired in
>>> > ASan/compiler-rt.
>>> >
>>> > (minor diversion where I accidentally committed/reverted again in
>>> > r211871/r211873)
>>> >
>>> > After further testing and fixing bugs in ArgumentPromotion (r211872) and
>>> > Inlining (r212065) it was recommitted in r212085. Reverted in r212089
>>> > after the sanitizer buildbots still showed problems.
>>> >
>>> > Fixed another bug in ArgumentPromotion (r212128) found by this
>>> > assertion.
>>> >
>>> > Recommitted in r212205, reverted in r212226 after it crashed some more
>>> > on sanitizer buildbots.
>>> >
>>> > Fix clang some more in r212761.
>>> >
>>> > Recommitted in r212776, reverted in r212793. ASan failures.
>>> > Recommitted in r213391, reverted in r213432, trying to reproduce flakey
>>> > ASan build failure.
>>> >
>>> > Fixed bugs in r213805 (ArgPromo + DebugInfo), r213952
>>> > (LiveDebugVariables strips dbg_value intrinsics in functions not
>>> > described by debug info).
>>> >
>>> > Recommitted in r214761, reverted in r214999, flakey failure on Windows
>>> > buildbot.
>>> >
>>> > Fixed DeadArgElimination + DebugInfo bug in r219210.
>>> >
>>> > Recommitting and hoping that's the last of it.
>>> >
>>> > [That one burned down, fell over, then sank into the swamp.]
>>> 
>>> Hi David,
>>> 
>>> Unfortunately, this may not be the end of the tale yet...  We’re seeing the new assert triggered with test-suite/SingleSource/UnitTests/ObjC++/property-reference-object.mm using -O0 -g on x86_64:
>>> 
>>> /org/llvm/build$ ./Debug+Asserts/bin/clang++ /org/test-suite/SingleSource/UnitTests/ObjC++/property-reference-object.mm -O0 -g -arch x86_64 -m64 -fomit-frame-pointer -mdynamic-no-pic -c
>>> Assertion failed: (DISubprogram(Scope).describes(MF->getFunction())), function getOrCreateRegularScope, file /Users/anemet/proj/org/llvm/lib/CodeGen/LexicalScopes.cpp, line 179.
>>> 0  clang                    0x000000010b8ee19e llvm::sys::PrintStackTrace(__sFILE*) + 46
>>> 1  clang                    0x000000010b8ee4ab PrintStackTraceSignalHandler(void*) + 27
>>> 2  clang                    0x000000010b8ee8c1 SignalHandler(int) + 561
>>> 3  libsystem_platform.dylib 0x00007fff8a7da5aa _sigtramp + 26
>>> 4  clang                    0x000000010be8fc0c std::__1::piecewise_construct + 0
>>> 5  clang                    0x000000010b8ee4db raise + 27
>>> 6  clang                    0x000000010b8ee592 abort + 18
>>> 7  clang                    0x000000010b8ee571 __assert_rtn + 129
>>> 8  clang                    0x000000010ac4b9e6 llvm::LexicalScopes::getOrCreateRegularScope(llvm::MDNode*) + 2854
>>> 9  clang                    0x000000010ac48f9c llvm::LexicalScopes::getOrCreateLexicalScope(llvm::DebugLoc) + 188
>>> 10 clang                    0x000000010ac489df llvm::LexicalScopes::extractLexicalScopes(llvm::SmallVectorImpl<std::__1::pair<llvm::MachineInstr const*, llvm::MachineInstr const*> >&, llvm::DenseMap<llvm::MachineInstr const*, llvm::LexicalScope*, llvm::DenseMapInfo<llvm::MachineInstr const*> >&) + 607
>>> 11 clang                    0x000000010ac486f6 llvm::LexicalScopes::initialize(llvm::MachineFunction const&) + 118
>>> 12 clang                    0x000000010ab2b7dc llvm::DwarfDebug::beginFunction(llvm::MachineFunction const*) + 252
>>> 13 clang                    0x000000010aadff16 llvm::AsmPrinter::EmitFunctionHeader() + 1302
>>> 14 clang                    0x000000010a697a46 llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) + 262
>>> 15 clang                    0x000000010ad00a2e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 110
>>> 16 clang                    0x000000010b80891f llvm::FPPassManager::runOnFunction(llvm::Function&) + 431
>>> 17 clang                    0x000000010b808c08 llvm::FPPassManager::runOnModule(llvm::Module&) + 104
>>> 18 clang                    0x000000010b8095d6 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) + 1350
>>> 19 clang                    0x000000010b808ebe llvm::legacy::PassManagerImpl::run(llvm::Module&) + 302
>>> 20 clang                    0x000000010b809d21 llvm::legacy::PassManager::run(llvm::Module&) + 33
>>> 21 clang                    0x0000000107ceef51 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, llvm::raw_ostream*) + 1601
>>> 22 clang                    0x0000000107cee702 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 114
>>> 23 clang                    0x0000000107ee2d65 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1733
>>> 24 clang                    0x00000001080327b4 clang::ParseAST(clang::Sema&, bool, bool) + 1268
>>> 25 clang                    0x0000000107a1d98a clang::ASTFrontendAction::ExecuteAction() + 522
>>> 26 clang                    0x0000000107ee0d09 clang::CodeGenAction::ExecuteAction() + 3785
>>> 27 clang                    0x0000000107a1cef8 clang::FrontendAction::Execute() + 120
>>> 28 clang                    0x00000001079b136f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1007
>>> 29 clang                    0x00000001078d8ec0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3136
>>> 30 clang                    0x00000001078ba79b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 2395
>>> 31 clang                    0x00000001078ceea6 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) + 198
>>> 32 clang                    0x00000001078ce4a8 main + 1288
>>> 33 libdyld.dylib            0x00007fff8ffe95fd start + 1
>>> 
>>> As expected reverting the commit fixes the assert.  Can you please take a look?
>>> 
>>> Sure - could you provide the crash results (the crash handler should specify two temporary files that contain the semi-preprocessed source and the -cc1 command line in a shell file)?
>> 
>> Sent off-list.
>> 
>> Adam
>> 
>>> - David
>>>  
>>> 
>>> Thanks,
>>> Adam
>>> 
>>> 
>>> >
>>> > Modified:
>>> >    llvm/trunk/lib/CodeGen/LexicalScopes.cpp
>>> >    llvm/trunk/lib/IR/DebugInfo.cpp
>>> >
>>> > Modified: llvm/trunk/lib/CodeGen/LexicalScopes.cpp
>>> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LexicalScopes.cpp?rev=219215&r1=219214&r2=219215&view=diff
>>> > ==============================================================================
>>> > --- llvm/trunk/lib/CodeGen/LexicalScopes.cpp (original)
>>> > +++ llvm/trunk/lib/CodeGen/LexicalScopes.cpp Tue Oct  7 11:56:20 2014
>>> > @@ -137,6 +137,8 @@ LexicalScope *LexicalScopes::findLexical
>>> > /// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
>>> > /// not available then create new lexical scope.
>>> > LexicalScope *LexicalScopes::getOrCreateLexicalScope(DebugLoc DL) {
>>> > +  if (DL.isUnknown())
>>> > +    return nullptr;
>>> >   MDNode *Scope = nullptr;
>>> >   MDNode *InlinedAt = nullptr;
>>> >   DL.getScopeAndInlinedAt(Scope, InlinedAt, MF->getFunction()->getContext());
>>> > @@ -172,9 +174,12 @@ LexicalScope *LexicalScopes::getOrCreate
>>> >                               std::make_tuple(Parent, DIDescriptor(Scope),
>>> >                                               nullptr, false)).first;
>>> >
>>> > -  if (!Parent && DIDescriptor(Scope).isSubprogram() &&
>>> > -      DISubprogram(Scope).describes(MF->getFunction()))
>>> > +  if (!Parent) {
>>> > +    assert(DIDescriptor(Scope).isSubprogram());
>>> > +    assert(DISubprogram(Scope).describes(MF->getFunction()));
>>> > +    assert(!CurrentFnLexicalScope);
>>> >     CurrentFnLexicalScope = &I->second;
>>> > +  }
>>> >
>>> >   return &I->second;
>>> > }
>>> >
>>> > Modified: llvm/trunk/lib/IR/DebugInfo.cpp
>>> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=219215&r1=219214&r2=219215&view=diff
>>> > ==============================================================================
>>> > --- llvm/trunk/lib/IR/DebugInfo.cpp (original)
>>> > +++ llvm/trunk/lib/IR/DebugInfo.cpp Tue Oct  7 11:56:20 2014
>>> > @@ -568,6 +568,34 @@ bool DISubprogram::Verify() const {
>>> >   if (isLValueReference() && isRValueReference())
>>> >     return false;
>>> >
>>> > +  // If a DISubprogram has an llvm::Function*, then scope chains from all
>>> > +  // instructions within the function should lead to this DISubprogram.
>>> > +  if (auto *F = getFunction()) {
>>> > +    LLVMContext &Ctxt = F->getContext();
>>> > +    for (auto &BB : *F) {
>>> > +      for (auto &I : BB) {
>>> > +        DebugLoc DL = I.getDebugLoc();
>>> > +        if (DL.isUnknown())
>>> > +          continue;
>>> > +
>>> > +        MDNode *Scope = nullptr;
>>> > +        MDNode *IA = nullptr;
>>> > +        // walk the inlined-at scopes
>>> > +        while (DL.getScopeAndInlinedAt(Scope, IA, F->getContext()), IA)
>>> > +          DL = DebugLoc::getFromDILocation(IA);
>>> > +        DL.getScopeAndInlinedAt(Scope, IA, Ctxt);
>>> > +        assert(!IA);
>>> > +        while (!DIDescriptor(Scope).isSubprogram()) {
>>> > +          DILexicalBlockFile D(Scope);
>>> > +          Scope = D.isLexicalBlockFile()
>>> > +                      ? D.getScope()
>>> > +                      : DebugLoc::getFromDILexicalBlock(Scope).getScope(Ctxt);
>>> > +        }
>>> > +        if (!DISubprogram(Scope).describes(F))
>>> > +          return false;
>>> > +      }
>>> > +    }
>>> > +  }
>>> >   return DbgNode->getNumOperands() == 9 && getNumHeaderFields() == 12;
>>> > }
>>> >
>>> >
>>> >
>>> > _______________________________________________
>>> > llvm-commits mailing list
>>> > llvm-commits at cs.uiuc.edu
>>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> 
>> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141014/5610d381/attachment.html>


More information about the llvm-commits mailing list