<div dir="ltr">Hi David,<div><br></div><div>This commit introduced a regression for one of my benchmarks, and the failure is an assertion failure.</div><div><br></div><div>The failure point is at </div><div><br></div><div><div>LexicalScope *LexicalScopes::getOrCreateRegularScope(MDNode *Scope) {</div><div> ...... </div><div> if (!Parent) {</div><div> assert(DIDescriptor(Scope).isSubprogram());</div><div> assert(DISubprogram(Scope).describes(MF->getFunction())); // Assertion failure here!</div><div> assert(!CurrentFnLexicalScope);</div><div> CurrentFnLexicalScope = &I->second;</div><div> }</div><div><br></div><div> return &I->second;</div><div>}</div></div><div><br></div><div>And the call stack is like,</div><div><br></div><div><div>8 libLLVMCodeGen.so 0x00007fc17123eb31 llvm::LexicalScopes::getOrCreateRegularScope(llvm::MDNode*) + 305</div><div>9 libLLVMCodeGen.so 0x00007fc17123e986 llvm::LexicalScopes::getOrCreateInlinedScope(llvm::MDNode*, llvm::MDNode*) + 326</div><div>10 libLLVMCodeGen.so 0x00007fc17123e979 llvm::LexicalScopes::getOrCreateInlinedScope(llvm::MDNode*, llvm::MDNode*) + 313</div><div>11 libLLVMCodeGen.so 0x00007fc17123e95a llvm::LexicalScopes::getOrCreateInlinedScope(llvm::MDNode*, llvm::MDNode*) + 282</div><div>12 libLLVMCodeGen.so 0x00007fc17123e979 llvm::LexicalScopes::getOrCreateInlinedScope(llvm::MDNode*, llvm::MDNode*) + 313</div><div>13 libLLVMCodeGen.so 0x00007fc17123de78 llvm::LexicalScopes::extractLexicalScopes(llvm::SmallVectorImpl<std::pair<llvm::MachineInstr const*, llvm::MachineInstr const*> >&, llvm::DenseMap<llvm::MachineInstr const*, llvm::LexicalScope*, llvm::DenseMapInfo<llvm::MachineInstr const*>, llvm::detail::DenseMapPair<llvm::MachineInstr const*, llvm::LexicalScope*> >&) + 1064</div><div>14 libLLVMCodeGen.so 0x00007fc17123d9ee llvm::LexicalScopes::initialize(llvm::MachineFunction const&) + 78</div><div>15 libLLVMCodeGen.so 0x00007fc171240815 llvm::LiveDebugVariables::runOnMachineFunction(llvm::MachineFunction&) + 933</div><div>16 libLLVMCodeGen.so 0x00007fc1712a327c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 124</div><div>17 libLLVMCore.so 0x00007fc17105ac7a llvm::FPPassManager::runOnFunction(llvm::Function&) + 362</div><div>18 libLLVMCore.so 0x00007fc17105af0b llvm::FPPassManager::runOnModule(llvm::Module&) + 43</div><div>19 libLLVMCore.so 0x00007fc17105b4a7 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 999</div><div>20 libclangCodeGen.so 0x00007fc16fe12c4d clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 7741</div><div>21 libclangCodeGen.so 0x00007fc16ff60e85</div><div>22 libclangParse.so 0x00007fc16f847da3 clang::ParseAST(clang::Sema&, bool, bool) + 467</div><div>23 libclangCodeGen.so 0x00007fc16ff5fbbc clang::CodeGenAction::ExecuteAction() + 204</div><div>24 libclangFrontend.so 0x00007fc17047f21e clang::FrontendAction::Execute() + 62</div><div>25 libclangFrontend.so 0x00007fc17044e97c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 892</div><div>26 libclangFrontendTool.so 0x00007fc1703d603a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3050</div><div>27 clang-3.6 0x000000000040cb71 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 577</div><div>28 clang-3.6 0x000000000040ba64 main + 12276</div><div>29 libc.so.6 0x00007fc16cf91de5 __libc_start_main + 245</div><div>30 clang-3.6 0x0000000000408961</div><div><br></div><div>....</div><div>1.<span class="" style="white-space:pre"> </span><eof> parser at end of file<br></div><div>2.<span class="" style="white-space:pre"> </span>Code generation</div><div>3.<span class="" style="white-space:pre"> </span>Running pass 'Function Pass Manager' on module '<a href="http://x.i.cc">x.i.cc</a>'.</div><div>4.<span class="" style="white-space:pre"> </span>Running pass 'Debug Variable Analysis' on function '@__cxx_global_var_init9'</div><div>clang-3.6: error: unable to execute command: Aborted (core dumped)</div><div>clang-3.6: error: clang frontend command failed due to signal (use -v to see invocation)</div></div><div><br></div><div>Since the test case is huge, I'm trying to narrow down to a small test case. But before I can work out that, I want to let you know first, in case you know something about that, and can get it fixed without a test case.</div><div><br></div><div>Thanks,</div><div>-Jiangning</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-01-03 3:55 GMT+08:00 Jeroen Ketema <span dir="ltr"><<a href="mailto:j.ketema@imperial.ac.uk" target="_blank">j.ketema@imperial.ac.uk</a>></span>:<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><span class=""><blockquote type="cite"><div>On 02 Jan 2015, at 20:08, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br><div><br><br style="font-family:Helvetica;font-size:12px;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:12px;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 Wed, Dec 31, 2014 at 2:52 AM, Jeroen Ketema<span> </span><span dir="ltr"><<a href="mailto:j.ketema@imperial.ac.uk" target="_blank">j.ketema@imperial.ac.uk</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">Hi David ,<br><br>This commit is giving me some problems with the code below when compiled with<br><br> clang -Wall -g -gcolumn-info -emit-llvm -c foo.c<br><br>For the first loop the debug information attached to the srem instruction generated for “j % 16” refers to line 10, which is correct. However, for the second loop the debug information refers to line 17 and not to the expected line 18; only the call to __f on line 18 has line 18 attached to it, while the call to __i, the srem instruction, etc. have line 17 attached to it.<br><br>void __i(int);<br>void __f(void);<br><br>#define __fi(X) __f(),__i(X)<br><br>void foo()<br>{<br> <span> </span>for(int j = 0;<br> <span> </span>__f(), __i(0 <= j),<br> <span> </span>__f(), __i((j % 16) == 0), // line 10<br> <span> </span>j < 1600;<br> <span> </span>j += 16)<br> <span> </span>{<br> <span> </span>}<br><br> <span> </span>for(int j = 0;<br> <span> </span>__fi(0 <= j), // line 17<br> <span> </span>__fi((j % 16) == 0), // line 18<br> <span> </span>j < 1600;<br> <span> </span>j += 16)<br> <span> </span>{<br> <span> </span>}<br>}<br><br></blockquote><div><br>Thanks for the report/example/etc. This should be fixed in r225083. Let me know if it isn't or you see any other line info quality issues going forward.<br></div></div></div></blockquote><div><br></div></span><div>Thanks. This indeed fixes things for me.</div><div><br></div><div>---</div><div>Jeroen</div><div><div class="h5"><br><blockquote type="cite"><div><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;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><br>- David<br> </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>Regards,<br><br> <span> </span>Jeroen<br><div><div><br>> On 30 Dec 2014, at 20:39, David Blaikie <dblaikie at<span> </span><a href="http://gmail.com/" target="_blank">gmail.com</a>> wrote:<br>><br>> Author: dblaikie<br>> Date: Tue Dec 30 13:39:33 2014<br>> New Revision: 225000<br>><br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project?rev=225000&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=225000&view=rev</a><br>> Log:<br>> Reapply "DebugInfo: Generalize debug info location handling"<br>><br>> Originally committed in r224385 and reverted in r224441 due to concerns<br>> this change might've introduced a crash. Turns out this change fixes the<br>> crash introduced by one of my earlier more specific location handling<br>> changes (those specific fixes are reverted by this patch, in favor of<br>> the more general solution).<br>><br>> Recommitted in r224941 and reverted in r224970 after it caused a crash<br>> when building compiler-rt. Looks to be due to this change zeroing out<br>> the debug location when emitting default arguments (which were meant to<br>> inherit their outer expression's location) thus creating call<br>> instructions without locations - these create problems for inlining and<br>> must not be created. That is fixed and tested in this version of the<br>> change.<br>><br>> Original commit message:<br>><br>> This is a more scalable (fixed in mostly one place, rather than many<br>> places that will need constant improvement/maintenance) solution to<br>> several commits I've made recently to increase source fidelity for<br>> subexpressions.<br>><br>> This resetting had to be done at the DebugLoc level (not the<br>> SourceLocation level) to preserve scoping information (if the resetting<br>> was done with CGDebugInfo::EmitLocation, it would've caused the tail end<br>> of an expression's codegen to end up in a potentially different scope<br>> than the start, even though it was at the same source location). The<br>> drawback to this is that it might leave CGDebugInfo out of sync. Ideally<br>> CGDebugInfo shouldn't have a duplicate sense of the current<br>> SourceLocation, but for now it seems it does... - I don't think I'm<br>> going to tackle removing that just now.<br>><br>> I expect this'll probably cause some more buildbot fallout & I'll<br>> investigate that as it comes up.<br>><br>> Also these sort of improvements might be starting to show a weakness/bug<br>> in LLVM's line table handling: we don't correctly emit is_stmt for<br>> statements, we just put it on every line table entry. This means one<br>> statement split over multiple lines appears as multiple 'statements' and<br>> two statements on one line (without column info) are treated as one<br>> statement.<br>><br>> I don't think we have any IR representation of statements that would<br>> help us distinguish these cases and identify the beginning of each<br>> statement - so that might be something we need to add (possibly to the<br>> lexical scope chain - a scope for each statement). This does cause some<br>> problems for GDB and possibly other DWARF consumers.<br>><br>> Modified:<br>> cfe/trunk/lib/CodeGen/CGBlocks.cpp<br>> cfe/trunk/lib/CodeGen/CGClass.cpp<br>> cfe/trunk/lib/CodeGen/CGCleanup.cpp<br>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>> cfe/trunk/lib/CodeGen/CGDebugInfo.h<br>> cfe/trunk/lib/CodeGen/CGDecl.cpp<br>> cfe/trunk/lib/CodeGen/CGDeclCXX.cpp<br>> cfe/trunk/lib/CodeGen/CGException.cpp<br>> cfe/trunk/lib/CodeGen/CGExpr.cpp<br>> cfe/trunk/lib/CodeGen/CGExprCXX.cpp<br>> cfe/trunk/lib/CodeGen/CGExprComplex.cpp<br>> cfe/trunk/lib/CodeGen/CGExprScalar.cpp<br>> cfe/trunk/lib/CodeGen/CGStmt.cpp<br>> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp<br>> cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>> cfe/trunk/test/CodeGenCXX/PR20038.cpp<br>> cfe/trunk/test/CodeGenCXX/debug-info-line.cpp<br>> cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Dec 30 13:39:33 2014<br>> @@ -874,7 +874,7 @@ llvm::Value *CodeGenFunction::EmitBlockL<br>> // locations of subexpressions in the initialization.<br>> EmitExprAsInit(&l2r, &blockFieldPseudoVar,<br>> MakeAddrLValue(blockField, type, align),<br>> - /*captured by init*/ false, SourceLocation());<br>> + /*captured by init*/ false);<br>> }<br>><br>> // Activate the cleanup if layout pushed one.<br>> @@ -1175,7 +1175,7 @@ CodeGenFunction::GenerateBlockFunction(G<br>> Alloca->setAlignment(Align);<br>> // Set the DebugLocation to empty, so the store is recognized as a<br>> // frame setup instruction by llvm::DwarfDebug::beginFunction().<br>> - NoLocation NL(*this, Builder);<br>> + ApplyDebugLocation NL(*this);<br>> Builder.CreateAlignedStore(BlockPointer, Alloca, Align);<br>> BlockPointerDbgLoc = Alloca;<br>> }<br>> @@ -1326,9 +1326,9 @@ CodeGenFunction::GenerateCopyHelperFunct<br>> false,<br>> false);<br>> // Create a scope with an artificial location for the body of this function.<br>> - ArtificialLocation AL(*this, Builder);<br>> + ApplyDebugLocation NL(*this);<br>> StartFunction(FD, C.VoidTy, Fn, FI, args);<br>> - AL.Emit();<br>> + ArtificialLocation AL(*this);<br>><br>> llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();<br>><br>> @@ -1497,9 +1497,9 @@ CodeGenFunction::GenerateDestroyHelperFu<br>> nullptr, SC_Static,<br>> false, false);<br>> // Create a scope with an artificial location for the body of this function.<br>> - ArtificialLocation AL(*this, Builder);<br>> + ApplyDebugLocation NL(*this);<br>> StartFunction(FD, C.VoidTy, Fn, FI, args);<br>> - AL.Emit();<br>> + ArtificialLocation AL(*this);<br>><br>> llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();<br>><br>><br>> Modified: cfe/trunk/lib/CodeGen/CGClass.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGClass.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGClass.cpp Tue Dec 30 13:39:33 2014<br>> @@ -544,6 +544,7 @@ static void EmitMemberInitializer(CodeGe<br>> CXXCtorInitializer *MemberInit,<br>> const CXXConstructorDecl *Constructor,<br>> FunctionArgList &Args) {<br>> + ApplyDebugLocation Loc(CGF, MemberInit->getMemberLocation());<br>> assert(MemberInit->isAnyMemberInitializer() &&<br>> "Must have member initializer!");<br>> assert(MemberInit->getInit() && "Must have initializer!");<br>> @@ -597,26 +598,25 @@ static void EmitMemberInitializer(CodeGe<br>> ArrayRef<VarDecl *> ArrayIndexes;<br>> if (MemberInit->getNumArrayIndices())<br>> ArrayIndexes = MemberInit->getArrayIndexes();<br>> - CGF.EmitInitializerForField(Field, LHS, MemberInit->getInit(), ArrayIndexes,<br>> - MemberInit->getMemberLocation());<br>> + ApplyDebugLocation DL(CGF, MemberInit->getMemberLocation());<br>> + CGF.EmitInitializerForField(Field, LHS, MemberInit->getInit(), ArrayIndexes);<br>> }<br>><br>> -void CodeGenFunction::EmitInitializerForField(FieldDecl *Field, LValue LHS,<br>> - Expr *Init,<br>> - ArrayRef<VarDecl *> ArrayIndexes,<br>> - SourceLocation DbgLoc) {<br>> +void CodeGenFunction::EmitInitializerForField(<br>> + FieldDecl *Field, LValue LHS, Expr *Init,<br>> + ArrayRef<VarDecl *> ArrayIndexes) {<br>> QualType FieldType = Field->getType();<br>> switch (getEvaluationKind(FieldType)) {<br>> case TEK_Scalar:<br>> if (LHS.isSimple()) {<br>> - EmitExprAsInit(Init, Field, LHS, false, DbgLoc);<br>> + EmitExprAsInit(Init, Field, LHS, false);<br>> } else {<br>> RValue RHS = RValue::get(EmitScalarExpr(Init));<br>> EmitStoreThroughLValue(RHS, LHS);<br>> }<br>> break;<br>> case TEK_Complex:<br>> - EmitComplexExprIntoLValue(Init, LHS, /*isInit*/ true, DbgLoc);<br>> + EmitComplexExprIntoLValue(Init, LHS, /*isInit*/ true);<br>> break;<br>> case TEK_Aggregate: {<br>> llvm::Value *ArrayIndexVar = nullptr;<br>> @@ -783,8 +783,6 @@ void CodeGenFunction::EmitConstructorBod<br>> // delegation optimization.<br>> if (CtorType == Ctor_Complete && IsConstructorDelegationValid(Ctor) &&<br>> CGM.getTarget().getCXXABI().hasConstructorVariants()) {<br>> - if (CGDebugInfo *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, Ctor->getLocEnd());<br>> EmitDelegateCXXConstructorCall(Ctor, Ctor_Base, Args, Ctor->getLocEnd());<br>> return;<br>> }<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Tue Dec 30 13:39:33 2014<br>> @@ -861,10 +861,7 @@ void CodeGenFunction::PopCleanupBlock(bo<br>><br>> // Emit the EH cleanup if required.<br>> if (RequiresEHCleanup) {<br>> - CGDebugInfo *DI = getDebugInfo();<br>> - SaveAndRestoreLocation AutoRestoreLocation(*this, Builder);<br>> - if (DI)<br>> - DI->EmitLocation(Builder, CurEHLocation);<br>> + ApplyDebugLocation AutoRestoreLocation(*this, CurEHLocation);<br>><br>> CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP();<br>><br>><br>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Dec 30 13:39:33 2014<br>> @@ -52,54 +52,38 @@ CGDebugInfo::~CGDebugInfo() {<br>> "Region stack mismatch, stack not empty!");<br>> }<br>><br>> -SaveAndRestoreLocation::SaveAndRestoreLocation(CodeGenFunction &CGF,<br>> - CGBuilderTy &B)<br>> - : DI(CGF.getDebugInfo()), Builder(B) {<br>> - if (DI) {<br>> - SavedLoc = DI->getLocation();<br>> - DI->CurLoc = SourceLocation();<br>> - }<br>> -}<br>> -<br>> -SaveAndRestoreLocation::~SaveAndRestoreLocation() {<br>> - if (DI)<br>> - DI->EmitLocation(Builder, SavedLoc);<br>> -}<br>> -<br>> -NoLocation::NoLocation(CodeGenFunction &CGF, CGBuilderTy &B)<br>> - : SaveAndRestoreLocation(CGF, B) {<br>> - if (DI)<br>> - Builder.SetCurrentDebugLocation(llvm::DebugLoc());<br>> -}<br>> -<br>> -NoLocation::~NoLocation() {<br>> - if (DI)<br>> - assert(Builder.getCurrentDebugLocation().isUnknown());<br>> -}<br>> -<br>> -ArtificialLocation::ArtificialLocation(CodeGenFunction &CGF, CGBuilderTy &B)<br>> - : SaveAndRestoreLocation(CGF, B) {<br>> - if (DI)<br>> - Builder.SetCurrentDebugLocation(llvm::DebugLoc());<br>> -}<br>> -<br>> -void ArtificialLocation::Emit() {<br>> - if (DI) {<br>> - // Sync the Builder.<br>> - DI->EmitLocation(Builder, SavedLoc);<br>> - DI->CurLoc = SourceLocation();<br>> +ArtificialLocation::ArtificialLocation(CodeGenFunction &CGF)<br>> + : ApplyDebugLocation(CGF) {<br>> + if (auto *DI = CGF.getDebugInfo()) {<br>> // Construct a location that has a valid scope, but no line info.<br>> assert(!DI->LexicalBlockStack.empty());<br>> llvm::DIDescriptor Scope(DI->LexicalBlockStack.back());<br>> - Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, Scope));<br>> + CGF.Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, Scope));<br>> + }<br>> +}<br>> +<br>> +ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF,<br>> + SourceLocation TemporaryLocation,<br>> + bool ForceColumnInfo)<br>> + : CGF(CGF) {<br>> + if (auto *DI = CGF.getDebugInfo()) {<br>> + OriginalLocation = CGF.Builder.getCurrentDebugLocation();<br>> + if (TemporaryLocation.isInvalid())<br>> + CGF.Builder.SetCurrentDebugLocation(llvm::DebugLoc());<br>> + else<br>> + DI->EmitLocation(CGF.Builder, TemporaryLocation, ForceColumnInfo);<br>> }<br>> }<br>><br>> -ArtificialLocation::~ArtificialLocation() {<br>> - if (DI)<br>> - assert(Builder.getCurrentDebugLocation().getLine() == 0);<br>> +ApplyDebugLocation::~ApplyDebugLocation() {<br>> + // Query CGF so the location isn't overwritten when location updates are<br>> + // temporarily disabled (for C++ default function arguments)<br>> + if (CGF.getDebugInfo())<br>> + CGF.Builder.SetCurrentDebugLocation(OriginalLocation);<br>> }<br>><br>> +/// ArtificialLocation - An RAII object that temporarily switches to<br>> +/// an artificial debug location that has a valid scope, but no line<br>> void CGDebugInfo::setLocation(SourceLocation Loc) {<br>> // If the new location isn't valid return.<br>> if (Loc.isInvalid())<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)<br>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Dec 30 13:39:33 2014<br>> @@ -448,27 +448,16 @@ private:<br>> }<br>> };<br>><br>> -/// SaveAndRestoreLocation - An RAII object saves the current location<br>> -/// and automatically restores it to the original value.<br>> -class SaveAndRestoreLocation {<br>> +class ApplyDebugLocation {<br>> protected:<br>> - SourceLocation SavedLoc;<br>> - CGDebugInfo *DI;<br>> - CGBuilderTy &Builder;<br>> -public:<br>> - SaveAndRestoreLocation(CodeGenFunction &CGF, CGBuilderTy &B);<br>> - /// Autorestore everything back to normal.<br>> - ~SaveAndRestoreLocation();<br>> -};<br>> + llvm::DebugLoc OriginalLocation;<br>> + CodeGenFunction &CGF;<br>><br>> -/// NoLocation - An RAII object that temporarily disables debug<br>> -/// locations. This is useful for emitting instructions that should be<br>> -/// counted towards the function prologue.<br>> -class NoLocation : public SaveAndRestoreLocation {<br>> public:<br>> - NoLocation(CodeGenFunction &CGF, CGBuilderTy &B);<br>> - /// Autorestore everything back to normal.<br>> - ~NoLocation();<br>> + ApplyDebugLocation(CodeGenFunction &CGF,<br>> + SourceLocation TemporaryLocation = SourceLocation(),<br>> + bool ForceColumnInfo = false);<br>> + ~ApplyDebugLocation();<br>> };<br>><br>> /// ArtificialLocation - An RAII object that temporarily switches to<br>> @@ -482,16 +471,9 @@ public:<br>> /// This is necessary because passing an empty SourceLocation to<br>> /// CGDebugInfo::setLocation() will result in the last valid location<br>> /// being reused.<br>> -class ArtificialLocation : public SaveAndRestoreLocation {<br>> +class ArtificialLocation : public ApplyDebugLocation {<br>> public:<br>> - ArtificialLocation(CodeGenFunction &CGF, CGBuilderTy &B);<br>> -<br>> - /// Set the current location to line 0, but within the current scope<br>> - /// (= the top of the LexicalBlockStack).<br>> - void Emit();<br>> -<br>> - /// Autorestore everything back to normal.<br>> - ~ArtificialLocation();<br>> + ArtificialLocation(CodeGenFunction &CGF);<br>> };<br>><br>><br>><br>> Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Dec 30 13:39:33 2014<br>> @@ -597,14 +597,13 @@ static void drillIntoBlockVariable(CodeG<br>> }<br>><br>> void CodeGenFunction::EmitScalarInit(const Expr *init, const ValueDecl *D,<br>> - LValue lvalue, bool capturedByInit,<br>> - SourceLocation DbgLoc) {<br>> + LValue lvalue, bool capturedByInit) {<br>> Qualifiers::ObjCLifetime lifetime = lvalue.getObjCLifetime();<br>> if (!lifetime) {<br>> llvm::Value *value = EmitScalarExpr(init);<br>> if (capturedByInit)<br>> drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D));<br>> - EmitStoreThroughLValue(RValue::get(value), lvalue, true, DbgLoc);<br>> + EmitStoreThroughLValue(RValue::get(value), lvalue, true);<br>> return;<br>> }<br>><br>> @@ -1088,6 +1087,7 @@ void CodeGenFunction::EmitAutoVarInit(co<br>> if (emission.wasEmittedAsGlobal()) return;<br>><br>> const VarDecl &D = *emission.Variable;<br>> + ApplyDebugLocation DL(*this, D.getLocation());<br>> QualType type = D.getType();<br>><br>> // If this local has an initializer, emit it now.<br>> @@ -1126,7 +1126,7 @@ void CodeGenFunction::EmitAutoVarInit(co<br>> if (!constant) {<br>> LValue lv = MakeAddrLValue(Loc, type, alignment);<br>> lv.setNonGC(true);<br>> - return EmitExprAsInit(Init, &D, lv, capturedByInit, D.getLocation());<br>> + return EmitExprAsInit(Init, &D, lv, capturedByInit);<br>> }<br>><br>> if (!emission.IsConstantAggregate) {<br>> @@ -1192,26 +1192,25 @@ void CodeGenFunction::EmitAutoVarInit(co<br>> /// \param capturedByInit true if the variable is a __block variable<br>> /// whose address is potentially changed by the initializer<br>> void CodeGenFunction::EmitExprAsInit(const Expr *init, const ValueDecl *D,<br>> - LValue lvalue, bool capturedByInit,<br>> - SourceLocation DbgLoc) {<br>> + LValue lvalue, bool capturedByInit) {<br>> QualType type = D->getType();<br>><br>> if (type->isReferenceType()) {<br>> RValue rvalue = EmitReferenceBindingToExpr(init);<br>> if (capturedByInit)<br>> drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D));<br>> - EmitStoreThroughLValue(rvalue, lvalue, true, DbgLoc);<br>> + EmitStoreThroughLValue(rvalue, lvalue, true);<br>> return;<br>> }<br>> switch (getEvaluationKind(type)) {<br>> case TEK_Scalar:<br>> - EmitScalarInit(init, D, lvalue, capturedByInit, DbgLoc);<br>> + EmitScalarInit(init, D, lvalue, capturedByInit);<br>> return;<br>> case TEK_Complex: {<br>> ComplexPairTy complex = EmitComplexExpr(init);<br>> if (capturedByInit)<br>> drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D));<br>> - EmitStoreOfComplex(complex, lvalue, /*init*/ true, DbgLoc);<br>> + EmitStoreOfComplex(complex, lvalue, /*init*/ true);<br>> return;<br>> }<br>> case TEK_Aggregate:<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Tue Dec 30 13:39:33 2014<br>> @@ -474,11 +474,11 @@ CodeGenFunction::GenerateCXXGlobalInitFu<br>> ArrayRef<llvm::Function *> Decls,<br>> llvm::GlobalVariable *Guard) {<br>> {<br>> - ArtificialLocation AL(*this, Builder);<br>> + ApplyDebugLocation NL(*this);<br>> StartFunction(GlobalDecl(), getContext().VoidTy, Fn,<br>> getTypes().arrangeNullaryFunction(), FunctionArgList());<br>> // Emit an artificial location for this function.<br>> - AL.Emit();<br>> + ArtificialLocation AL(*this);<br>><br>> llvm::BasicBlock *ExitBlock = nullptr;<br>> if (Guard) {<br>> @@ -525,11 +525,11 @@ void CodeGenFunction::GenerateCXXGlobalD<br>> const std::vector<std::pair<llvm::WeakVH, llvm::Constant*> ><br>> &DtorsAndObjects) {<br>> {<br>> - ArtificialLocation AL(*this, Builder);<br>> + ApplyDebugLocation NL(*this);<br>> StartFunction(GlobalDecl(), getContext().VoidTy, Fn,<br>> getTypes().arrangeNullaryFunction(), FunctionArgList());<br>> // Emit an artificial location for this function.<br>> - AL.Emit();<br>> + ArtificialLocation AL(*this);<br>><br>> // Emit the dtors, in reverse order from construction.<br>> for (unsigned i = 0, e = DtorsAndObjects.size(); i != e; ++i) {<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGException.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGException.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Dec 30 13:39:33 2014<br>> @@ -734,9 +734,7 @@ llvm::BasicBlock *CodeGenFunction::EmitL<br>><br>> // Save the current IR generation state.<br>> CGBuilderTy::InsertPoint savedIP = Builder.saveAndClearIP();<br>> - SaveAndRestoreLocation AutoRestoreLocation(*this, Builder);<br>> - if (CGDebugInfo *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, CurEHLocation);<br>> + ApplyDebugLocation AutoRestoreLocation(*this, CurEHLocation);<br>><br>> const EHPersonality &personality = EHPersonality::get(CGM);<br>><br>><br>> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Dec 30 13:39:33 2014<br>> @@ -1438,11 +1438,7 @@ RValue CodeGenFunction::EmitLoadOfGlobal<br>> /// lvalue, where both are guaranteed to the have the same type, and that type<br>> /// is 'Ty'.<br>> void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,<br>> - bool isInit,<br>> - SourceLocation DbgLoc) {<br>> - if (auto *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, DbgLoc);<br>> -<br>> + bool isInit) {<br>> if (!Dst.isSimple()) {<br>> if (Dst.isVectorElt()) {<br>> // Read/modify/write the vector, inserting the new element.<br>> @@ -2408,9 +2404,6 @@ LValue CodeGenFunction::EmitArraySubscri<br>> // The element count here is the total number of non-VLA elements.<br>> llvm::Value *numElements = getVLASize(vla).first;<br>><br>> - if (auto *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, E->getLocStart());<br>> -<br>> // Effectively, the multiply by the VLA size is part of the GEP.<br>> // GEP indexes are signed, and scaling an index isn't permitted to<br>> // signed-overflow, so we use the same semantics for our explicit<br>> @@ -2456,9 +2449,6 @@ LValue CodeGenFunction::EmitArraySubscri<br>> // Propagate the alignment from the array itself to the result.<br>> ArrayAlignment = ArrayLV.getAlignment();<br>><br>> - if (auto *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, E->getLocStart());<br>> -<br>> if (getLangOpts().isSignedOverflowDefined())<br>> Address = Builder.CreateGEP(ArrayPtr, Args, "arrayidx");<br>> else<br>> @@ -2466,8 +2456,6 @@ LValue CodeGenFunction::EmitArraySubscri<br>> } else {<br>> // The base must be a pointer, which is not an aggregate. Emit it.<br>> llvm::Value *Base = EmitScalarExpr(E->getBase());<br>> - if (auto *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, E->getLocStart());<br>> if (getLangOpts().isSignedOverflowDefined())<br>> Address = Builder.CreateGEP(Base, Idx, "arrayidx");<br>> else<br>> @@ -3024,18 +3012,15 @@ RValue CodeGenFunction::EmitRValueForFie<br>><br>> RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,<br>> ReturnValueSlot ReturnValue) {<br>> - if (CGDebugInfo *DI = getDebugInfo()) {<br>> - SourceLocation Loc = E->getLocStart();<br>> - // Force column info to be generated so we can differentiate<br>> - // multiple call sites on the same line in the debug info.<br>> - // FIXME: This is insufficient. Two calls coming from the same macro<br>> - // expansion will still get the same line/column and break debug info. It's<br>> - // possible that LLVM can be fixed to not rely on this uniqueness, at which<br>> - // point this workaround can be removed.<br>> - const FunctionDecl* Callee = E->getDirectCallee();<br>> - bool ForceColumnInfo = Callee && Callee->isInlineSpecified();<br>> - DI->EmitLocation(Builder, Loc, ForceColumnInfo);<br>> - }<br>> + // Force column info to be generated so we can differentiate<br>> + // multiple call sites on the same line in the debug info.<br>> + // FIXME: This is insufficient. Two calls coming from the same macro<br>> + // expansion will still get the same line/column and break debug info. It's<br>> + // possible that LLVM can be fixed to not rely on this uniqueness, at which<br>> + // point this workaround can be removed.<br>> + ApplyDebugLocation DL(*this, E->getLocStart(),<br>> + E->getDirectCallee() &&<br>> + E->getDirectCallee()->isInlineSpecified());<br>><br>> // Builtins never have block type.<br>> if (E->getCallee()->getType()->isBlockPointerType())<br>> @@ -3151,8 +3136,6 @@ LValue CodeGenFunction::EmitBinaryOperat<br>><br>> RValue RV = EmitAnyExpr(E->getRHS());<br>> LValue LV = EmitCheckedLValue(E->getLHS(), TCK_Store);<br>> - if (CGDebugInfo *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, E->getLocStart());<br>> EmitStoreThroughLValue(RV, LV);<br>> return LV;<br>> }<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Dec 30 13:39:33 2014<br>> @@ -187,8 +187,6 @@ RValue CodeGenFunction::EmitCXXMemberOrO<br>> unsigned ArgsToSkip = isa<CXXOperatorCallExpr>(CE) ? 1 : 0;<br>> llvm::Value *RHS =<br>> EmitLValue(*(CE->arg_begin() + ArgsToSkip)).getAddress();<br>> - if (auto *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, CE->getLocStart());<br>> EmitAggregateAssign(This, RHS, CE->getType());<br>> return RValue::get(This);<br>> }<br>> @@ -754,15 +752,13 @@ static llvm::Value *EmitCXXNewAllocSize(<br>> }<br>><br>> static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const Expr *Init,<br>> - QualType AllocType, llvm::Value *NewPtr,<br>> - SourceLocation DbgLoc = SourceLocation()) {<br>> + QualType AllocType, llvm::Value *NewPtr) {<br>> // FIXME: Refactor with EmitExprAsInit.<br>> CharUnits Alignment = CGF.getContext().getTypeAlignInChars(AllocType);<br>> switch (CGF.getEvaluationKind(AllocType)) {<br>> case TEK_Scalar:<br>> CGF.EmitScalarInit(Init, nullptr,<br>> - CGF.MakeAddrLValue(NewPtr, AllocType, Alignment), false,<br>> - DbgLoc);<br>> + CGF.MakeAddrLValue(NewPtr, AllocType, Alignment), false);<br>> return;<br>> case TEK_Complex:<br>> CGF.EmitComplexExprIntoLValue(Init, CGF.MakeAddrLValue(NewPtr, AllocType,<br>> @@ -1020,12 +1016,12 @@ static void EmitNewInitializer(CodeGenFu<br>> llvm::Value *NewPtr,<br>> llvm::Value *NumElements,<br>> llvm::Value *AllocSizeWithoutCookie) {<br>> + ApplyDebugLocation DL(CGF, E->getStartLoc());<br>> if (E->isArray())<br>> CGF.EmitNewArrayInitializer(E, ElementType, NewPtr, NumElements,<br>> AllocSizeWithoutCookie);<br>> else if (const Expr *Init = E->getInitializer())<br>> - StoreAnyExprIntoOneUnit(CGF, Init, E->getAllocatedType(), NewPtr,<br>> - E->getStartLoc());<br>> + StoreAnyExprIntoOneUnit(CGF, Init, E->getAllocatedType(), NewPtr);<br>> }<br>><br>> /// Emit a call to an operator new or operator delete function, as implicitly<br>> @@ -1269,9 +1265,6 @@ llvm::Value *CodeGenFunction::EmitCXXNew<br>> E->placement_arg_end(), /* CalleeDecl */ nullptr,<br>> /*ParamsToSkip*/ 1);<br>><br>> - if (auto *DI = getDebugInfo())<br>> - DI->EmitLocation(Builder, E->getLocStart());<br>> -<br>> // Emit the allocation call. If the allocator is a global placement<br>> // operator, just "inline" it directly.<br>> RValue RV;<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Tue Dec 30 13:39:33 2014<br>> @@ -81,8 +81,7 @@ public:<br>><br>> /// EmitStoreOfComplex - Store the specified real/imag parts into the<br>> /// specified value pointer.<br>> - void EmitStoreOfComplex(ComplexPairTy Val, LValue LV, bool isInit,<br>> - SourceLocation DbgLoc);<br>> + void EmitStoreOfComplex(ComplexPairTy Val, LValue LV, bool isInit);<br>><br>> /// EmitComplexToComplexCast - Emit a cast from complex value Val to DestType.<br>> ComplexPairTy EmitComplexToComplexCast(ComplexPairTy Val, QualType SrcType,<br>> @@ -335,11 +334,7 @@ ComplexPairTy ComplexExprEmitter::EmitLo<br>> /// EmitStoreOfComplex - Store the specified real/imag parts into the<br>> /// specified value pointer.<br>> void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy Val, LValue lvalue,<br>> - bool isInit,<br>> - SourceLocation DbgLoc) {<br>> - if (auto *DI = CGF.getDebugInfo())<br>> - DI->EmitLocation(CGF.Builder, DbgLoc);<br>> -<br>> + bool isInit) {<br>> if (lvalue.getType()->isAtomicType())<br>> return CGF.EmitAtomicStore(RValue::getComplex(Val), lvalue, isInit);<br>><br>> @@ -869,7 +864,7 @@ EmitCompoundAssignLValue(const CompoundA<br>> // Truncate the result and store it into the LHS lvalue.<br>> if (LHSTy->isAnyComplexType()) {<br>> ComplexPairTy ResVal = EmitComplexToComplexCast(Result, OpInfo.Ty, LHSTy);<br>> - EmitStoreOfComplex(ResVal, LHS, /*isInit*/ false, E->getLocStart());<br>> + EmitStoreOfComplex(ResVal, LHS, /*isInit*/ false);<br>> Val = RValue::getComplex(ResVal);<br>> } else {<br>> llvm::Value *ResVal =<br>> @@ -914,7 +909,7 @@ LValue ComplexExprEmitter::EmitBinAssign<br>> LValue LHS = CGF.EmitLValue(E->getLHS());<br>><br>> // Store the result value into the LHS lvalue.<br>> - EmitStoreOfComplex(Val, LHS, /*isInit*/ false, E->getLocStart());<br>> + EmitStoreOfComplex(Val, LHS, /*isInit*/ false);<br>><br>> return LHS;<br>> }<br>> @@ -1042,19 +1037,18 @@ ComplexPairTy CodeGenFunction::EmitCompl<br>> }<br>><br>> void CodeGenFunction::EmitComplexExprIntoLValue(const Expr *E, LValue dest,<br>> - bool isInit,<br>> - SourceLocation DbgLoc) {<br>> + bool isInit) {<br>> assert(E && getComplexType(E->getType()) &&<br>> "Invalid complex expression to emit");<br>> ComplexExprEmitter Emitter(*this);<br>> ComplexPairTy Val = Emitter.Visit(const_cast<Expr*>(E));<br>> - Emitter.EmitStoreOfComplex(Val, dest, isInit, DbgLoc);<br>> + Emitter.EmitStoreOfComplex(Val, dest, isInit);<br>> }<br>><br>> /// EmitStoreOfComplex - Store a complex number into the specified l-value.<br>> void CodeGenFunction::EmitStoreOfComplex(ComplexPairTy V, LValue dest,<br>> - bool isInit, SourceLocation DbgLoc) {<br>> - ComplexExprEmitter(*this).EmitStoreOfComplex(V, dest, isInit, DbgLoc);<br>> + bool isInit) {<br>> + ComplexExprEmitter(*this).EmitStoreOfComplex(V, dest, isInit);<br>> }<br>><br>> /// EmitLoadOfComplex - Load a complex number from the specified address.<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Dec 30 13:39:33 2014<br>> @@ -196,6 +196,7 @@ public:<br>> //===--------------------------------------------------------------------===//<br>><br>> Value *Visit(Expr *E) {<br>> + ApplyDebugLocation DL(CGF, E->getLocStart());<br>> return StmtVisitor<ScalarExprEmitter, Value*>::Visit(E);<br>> }<br>><br>> @@ -3042,7 +3043,7 @@ Value *ScalarExprEmitter::VisitBinLAnd(c<br>> // Emit an unconditional branch from this block to ContBlock.<br>> {<br>> // There is no need to emit line number for unconditional branch.<br>> - SuppressDebugLocation S(Builder);<br>> + ApplyDebugLocation DL(CGF);<br>> CGF.EmitBlock(ContBlock);<br>> }<br>> // Insert an entry into the phi node for the edge with the value of RHSCond.<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Dec 30 13:39:33 2014<br>> @@ -565,7 +565,7 @@ void CodeGenFunction::EmitIfStmt(const I<br>> if (const Stmt *Else = S.getElse()) {<br>> {<br>> // There is no need to emit line number for unconditional branch.<br>> - SuppressDebugLocation S(Builder);<br>> + ApplyDebugLocation DL(*this);<br>> EmitBlock(ElseBlock);<br>> }<br>> {<br>> @@ -574,7 +574,7 @@ void CodeGenFunction::EmitIfStmt(const I<br>> }<br>> {<br>> // There is no need to emit line number for unconditional branch.<br>> - SuppressDebugLocation S(Builder);<br>> + ApplyDebugLocation DL(*this);<br>> EmitBranch(ContBlock);<br>> }<br>> }<br>><br>> Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)<br>> +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue Dec 30 13:39:33 2014<br>> @@ -86,13 +86,13 @@ static void EmitOMPIfClause(CodeGenFunct<br>> // Emit the 'else' code if present.<br>> {<br>> // There is no need to emit line number for unconditional branch.<br>> - SuppressDebugLocation SDL(CGF.Builder);<br>> + ApplyDebugLocation DL(CGF);<br>> CGF.EmitBlock(ElseBlock);<br>> }<br>> CodeGen(/*ThenBlock*/ false);<br>> {<br>> // There is no need to emit line number for unconditional branch.<br>> - SuppressDebugLocation SDL(CGF.Builder);<br>> + ApplyDebugLocation DL(CGF);<br>> CGF.EmitBranch(ContBlock);<br>> }<br>> // Emit the continuation block for code after the if.<br>><br>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)<br>> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Dec 30 13:39:33 2014<br>> @@ -93,19 +93,6 @@ enum TypeEvaluationKind {<br>> TEK_Aggregate<br>> };<br>><br>> -class SuppressDebugLocation {<br>> - llvm::DebugLoc CurLoc;<br>> - llvm::IRBuilderBase &Builder;<br>> -public:<br>> - SuppressDebugLocation(llvm::IRBuilderBase &Builder)<br>> - : CurLoc(Builder.getCurrentDebugLocation()), Builder(Builder) {<br>> - Builder.SetCurrentDebugLocation(llvm::DebugLoc());<br>> - }<br>> - ~SuppressDebugLocation() {<br>> - Builder.SetCurrentDebugLocation(CurLoc);<br>> - }<br>> -};<br>> -<br>> /// CodeGenFunction - This class organizes the per-function state that is used<br>> /// while generating LLVM code.<br>> class CodeGenFunction : public CodeGenTypeCache {<br>> @@ -1300,8 +1287,7 @@ public:<br>> FunctionArgList &Args);<br>><br>> void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init,<br>> - ArrayRef<VarDecl *> ArrayIndexes,<br>> - SourceLocation DbgLoc = SourceLocation());<br>> + ArrayRef<VarDecl *> ArrayIndexes);<br>><br>> /// InitializeVTablePointer - Initialize the vtable pointer of the given<br>> /// subobject.<br>> @@ -1546,7 +1532,7 @@ public:<br>> /// EmitExprAsInit - Emits the code necessary to initialize a<br>> /// location in memory with the given initializer.<br>> void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue,<br>> - bool capturedByInit, SourceLocation DbgLoc);<br>> + bool capturedByInit);<br>><br>> /// hasVolatileMember - returns true if aggregate type has a volatile<br>> /// member.<br>> @@ -1833,8 +1819,7 @@ public:<br>> void EmitVarDecl(const VarDecl &D);<br>><br>> void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue,<br>> - bool capturedByInit,<br>> - SourceLocation DbgLoc = SourceLocation());<br>> + bool capturedByInit);<br>> void EmitScalarInit(llvm::Value *init, LValue lvalue);<br>><br>> typedef void SpecialInitFn(CodeGenFunction &Init, const VarDecl &D,<br>> @@ -2164,8 +2149,7 @@ public:<br>> /// EmitStoreThroughLValue - Store the specified rvalue into the specified<br>> /// lvalue, where both are guaranteed to the have the same type, and that type<br>> /// is 'Ty'.<br>> - void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit = false,<br>> - SourceLocation DbgLoc = SourceLocation());<br>> + void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit = false);<br>> void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst);<br>> void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst);<br>><br>> @@ -2537,12 +2521,10 @@ public:<br>><br>> /// EmitComplexExprIntoLValue - Emit the given expression of complex<br>> /// type and place its result into the specified l-value.<br>> - void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit,<br>> - SourceLocation DbgLoc = SourceLocation());<br>> + void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit);<br>><br>> /// EmitStoreOfComplex - Store a complex number into the specified l-value.<br>> - void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit,<br>> - SourceLocation DbgLoc = SourceLocation());<br>> + void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit);<br>><br>> /// EmitLoadOfComplex - Load a complex number from the specified l-value.<br>> ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc);<br>><br>> Modified: cfe/trunk/test/CodeGenCXX/PR20038.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR20038.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR20038.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/test/CodeGenCXX/PR20038.cpp (original)<br>> +++ cfe/trunk/test/CodeGenCXX/PR20038.cpp Tue Dec 30 13:39:33 2014<br>> @@ -1,4 +1,4 @@<br>> -// RUN: %clang_cc1 -triple %itanium_abi_triple -g -emit-llvm %s -o - | FileCheck %s<br>> +// RUN: %clang_cc1 -triple %itanium_abi_triple -g -mllvm -no-discriminators -emit-llvm %s -o - | FileCheck %s<br>><br>> struct C {<br>> ~C();<br>> @@ -8,9 +8,7 @@ extern bool b;<br>> // CHECK: call {{.*}}, !dbg [[DTOR_CALL2_LOC:![0-9]*]]<br>> // CHECK: [[FUN1:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun1]<br>> // CHECK: [[FUN2:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun2]<br>> -// CHECK: [[DTOR_CALL1_LOC]] = !{i32 [[@LINE+2]], i32 0, [[FUN1_BLOCK:.*]], null}<br>> -// CHECK: [[FUN1_BLOCK]] = !{!"0xb{{[^,]*}}", {{[^,]*}}, [[FUN1]]}<br>> +// CHECK: [[DTOR_CALL1_LOC]] = !{i32 [[@LINE+1]], i32 0, [[FUN1]], null}<br>> void fun1() { b && (C(), 1); }<br>> -// CHECK: [[DTOR_CALL2_LOC]] = !{i32 [[@LINE+2]], i32 0, [[FUN2_BLOCK1:.*]], null}<br>> -// CHECK: [[FUN2_BLOCK1]] = !{!"0xb{{[^,]*}}", {{[^,]*}}, [[FUN2]]}<br>> +// CHECK: [[DTOR_CALL2_LOC]] = !{i32 [[@LINE+1]], i32 0, [[FUN2]], null}<br>> bool fun2() { return (C(), b) && 0; }<br>><br>> Modified: cfe/trunk/test/CodeGenCXX/debug-info-line.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/test/CodeGenCXX/debug-info-line.cpp (original)<br>> +++ cfe/trunk/test/CodeGenCXX/debug-info-line.cpp Tue Dec 30 13:39:33 2014<br>> @@ -1,4 +1,5 @@<br>> // RUN: %clang_cc1 -g -std=c++11 -S -emit-llvm %s -o - | FileCheck %s<br>> +// RUN: %clang_cc1 -triple i686-linux-gnu -g -std=c++11 -S -emit-llvm %s -o - | FileCheck %s<br>><br>> int &src();<br>> int *sink();<br>> @@ -110,6 +111,23 @@ void f10() {<br>> new (void_src()) int(src()));<br>> }<br>><br>> +// CHECK-LABEL: define<br>> +__complex double f11() {<br>> + __complex double f;<br>> +// CHECK: store {{.*}} !dbg [[DBG_F11:!.*]]<br>> +#line 1200<br>> + return f;<br>> +}<br>> +<br>> +// CHECK-LABEL: define<br>> +void f12() {<br>> + int f12_1();<br>> + void f12_2(int = f12_1());<br>> +// CHECK: call i32 {{.*}} !dbg [[DBG_F12:!.*]]<br>> +#line 1300<br>> + f12_2();<br>> +}<br>> +<br>> // CHECK: [[DBG_F1]] = !{i32 100,<br>> // CHECK: [[DBG_FOO_VALUE]] = !{i32 200,<br>> // CHECK: [[DBG_FOO_REF]] = !{i32 202,<br>> @@ -124,3 +142,5 @@ void f10() {<br>> // CHECK: [[DBG_F9]] = !{i32 1000,<br>> // CHECK: [[DBG_F10_ICMP]] = !{i32 1100,<br>> // CHECK: [[DBG_F10_STORE]] = !{i32 1100,<br>> +// CHECK: [[DBG_F11]] = !{i32 1200,<br>> +// CHECK: [[DBG_F12]] = !{i32 1300,<br>><br>> Modified: cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp<br>> URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp?rev=225000&r1=224999&r2=225000&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp?rev=225000&r1=224999&r2=225000&view=diff</a><br>> ==============================================================================<br>> --- cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp (original)<br>> +++ cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp Tue Dec 30 13:39:33 2014<br>> @@ -36,12 +36,12 @@ void func() {<br>> // CHECK: = !{!"0x100\00{{.*}}", [[FOR:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE+2]]]<br>> // CHECK: [[FOR]] = !{!"0xb\00[[@LINE+1]]\00{{.*}}", !{{.*}}} ; [ DW_TAG_lexical_block ]<br>> for (int i = 0; i != 10; ++i) {<br>> - // FIXME: Do not include scopes that have only other scopes (and no variables<br>> - // or using declarations) as direct children, they just waste<br>> - // space/relocations/etc.<br>> - // CHECK: = !{!"0x100\00{{.*}}", [[FOR_COMPOUND:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [b] [line [[@LINE+3]]]<br>> - // CHECK: [[FOR_COMPOUND]] = !{!"0xb\00[[@LINE-5]]\00{{.*}}", !{{[0-9]+}}, [[FOR_BODY:![0-9]+]]} ; [ DW_TAG_lexical_block ]<br>> - // CHECK: [[FOR_BODY]] = !{!"0xb\00[[@LINE-6]]\00{{.*}}", !{{[0-9]+}}, [[FOR]]} ; [ DW_TAG_lexical_block ]<br>> + // FIXME: Do not include scopes that have only other scopes (and no variables<br>> + // or using declarations) as direct children, they just waste<br>> + // space/relocations/etc.<br>> + // CHECK: [[FOR_LOOP_INCLUDING_COND:!.*]] = !{!"0xb\00[[@LINE-4]]\00{{.*}}", !{{[0-9]+}}, [[FOR]]} ; [ DW_TAG_lexical_block ]<br>> + // CHECK: = !{!"0x100\00{{.*}}", [[FOR_COMPOUND:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [b] [line [[@LINE+2]]]<br>> + // CHECK: [[FOR_COMPOUND]] = !{!"0xb\00[[@LINE-6]]\00{{.*}}", !{{[0-9]+}}, [[FOR_LOOP_INCLUDING_COND]]} ; [ DW_TAG_lexical_block ]<br>> bool b = i % 2;<br>> }<br>></div></div></blockquote></div></div></blockquote></div></div></div><br></div><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>