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