<div dir="ltr">The PR20038.cpp test isn't passing for me on Windows.<div><br></div><div>Looks like the windows bots are red for some unrelated reason:</div><div><a href="http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/9273/steps/build_clang_tools/logs/stdio">http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/9273/steps/build_clang_tools/logs/stdio</a><br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 10, 2014 at 1:42 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Thu Jul 10 15:42:59 2014<br>
New Revision: 212761<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=212761&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=212761&view=rev</a><br>
Log:<br>
Fix the dtor location issues in PR20038 harder.<br>
<br>
Originally committed in r211722, this fixed one case of dtor calls being<br>
emitted without locations (this causes problems for debug info if the<br>
call is then inlined), this caught only some of the cases.<br>
<br>
Instead of trying to re-enable the location before the cleanup, simply<br>
re-enable the location immediately after the unconditional branches in<br>
question using a scoped device to ensure the no-location state doesn't<br>
leak out arbitrarily.<br>
<br>
Modified:<br>
cfe/trunk/lib/CodeGen/CGExprScalar.cpp<br>
cfe/trunk/lib/CodeGen/CGStmt.cpp<br>
cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>
cfe/trunk/test/CodeGenCXX/PR20038.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=212761&r1=212760&r2=212761&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=212761&r1=212760&r2=212761&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jul 10 15:42:59 2014<br>
@@ -358,10 +358,7 @@ public:<br>
Value *VisitExprWithCleanups(ExprWithCleanups *E) {<br>
CGF.enterFullExpression(E);<br>
CodeGenFunction::RunCleanupsScope Scope(CGF);<br>
- auto *V = Visit(E->getSubExpr());<br>
- if (CGDebugInfo *DI = CGF.getDebugInfo())<br>
- DI->EmitLocation(Builder, E->getLocEnd(), false);<br>
- return V;<br>
+ return Visit(E->getSubExpr());<br>
}<br>
Value *VisitCXXNewExpr(const CXXNewExpr *E) {<br>
return CGF.EmitCXXNewExpr(E);<br>
@@ -2942,12 +2939,13 @@ Value *ScalarExprEmitter::VisitBinLAnd(c<br>
// Reaquire the RHS block, as there may be subblocks inserted.<br>
RHSBlock = Builder.GetInsertBlock();<br>
<br>
- // Emit an unconditional branch from this block to ContBlock. Insert an entry<br>
- // into the phi node for the edge with the value of RHSCond.<br>
- if (CGF.getDebugInfo())<br>
+ // Emit an unconditional branch from this block to ContBlock.<br>
+ {<br>
// There is no need to emit line number for unconditional branch.<br>
- Builder.SetCurrentDebugLocation(llvm::DebugLoc());<br>
- CGF.EmitBlock(ContBlock);<br>
+ SuppressDebugLocation S(Builder);<br>
+ CGF.EmitBlock(ContBlock);<br>
+ }<br>
+ // Insert an entry into the phi node for the edge with the value of RHSCond.<br>
PN->addIncoming(RHSCond, RHSBlock);<br>
<br>
// ZExt result to int.<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=212761&r1=212760&r2=212761&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=212761&r1=212760&r2=212761&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 10 15:42:59 2014<br>
@@ -524,18 +524,20 @@ void CodeGenFunction::EmitIfStmt(const I<br>
<br>
// Emit the 'else' code if present.<br>
if (const Stmt *Else = S.getElse()) {<br>
- // There is no need to emit line number for unconditional branch.<br>
- if (getDebugInfo())<br>
- Builder.SetCurrentDebugLocation(llvm::DebugLoc());<br>
- EmitBlock(ElseBlock);<br>
+ {<br>
+ // There is no need to emit line number for unconditional branch.<br>
+ SuppressDebugLocation S(Builder);<br>
+ EmitBlock(ElseBlock);<br>
+ }<br>
{<br>
RunCleanupsScope ElseScope(*this);<br>
EmitStmt(Else);<br>
}<br>
- // There is no need to emit line number for unconditional branch.<br>
- if (getDebugInfo())<br>
- Builder.SetCurrentDebugLocation(llvm::DebugLoc());<br>
- EmitBranch(ContBlock);<br>
+ {<br>
+ // There is no need to emit line number for unconditional branch.<br>
+ SuppressDebugLocation S(Builder);<br>
+ EmitBranch(ContBlock);<br>
+ }<br>
}<br>
<br>
// Emit the continuation block for code after the if.<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=212761&r1=212760&r2=212761&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=212761&r1=212760&r2=212761&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Jul 10 15:42:59 2014<br>
@@ -93,6 +93,19 @@ 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>
<br>
Modified: cfe/trunk/test/CodeGenCXX/PR20038.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR20038.cpp?rev=212761&r1=212760&r2=212761&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR20038.cpp?rev=212761&r1=212760&r2=212761&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/PR20038.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/PR20038.cpp Thu Jul 10 15:42:59 2014<br>
@@ -4,8 +4,13 @@ struct C {<br>
~C();<br>
};<br>
extern bool b;<br>
-// CHECK: call {{.*}}, !dbg [[DTOR_CALL_LOC:![0-9]*]]<br>
-// CHECK: [[FUN4:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun4]<br>
-// CHECK: [[DTOR_CALL_LOC]] = metadata !{i32 [[@LINE+2]], i32 0, metadata [[FUN4_BLOCK:.*]], null}<br>
-// CHECK: [[FUN4_BLOCK]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata [[FUN4]],<br>
-void fun4() { b && (C(), 1); }<br>
+// CHECK: call {{.*}}, !dbg [[DTOR_CALL1_LOC:![0-9]*]]<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]] = metadata !{i32 [[@LINE+2]], i32 0, metadata [[FUN1_BLOCK:.*]], null}<br>
+// CHECK: [[FUN1_BLOCK]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata [[FUN1]],<br>
+void fun1() { b && (C(), 1); }<br>
+// CHECK: [[DTOR_CALL2_LOC]] = metadata !{i32 [[@LINE+2]], i32 0, metadata [[FUN2_BLOCK1:.*]], null}<br>
+// CHECK: [[FUN2_BLOCK1]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata [[FUN2]],<br>
+bool fun2() { return (C(), b) && 0; }<br>
<br>
<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>
</blockquote></div><br></div>