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