r212761 - Fix the dtor location issues in PR20038 harder.

Reid Kleckner rnk at google.com
Thu Jul 10 16:51:43 PDT 2014


The PR20038.cpp test isn't passing for me on Windows.

Looks like the windows bots are red for some unrelated reason:
http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/9273/steps/build_clang_tools/logs/stdio


On Thu, Jul 10, 2014 at 1:42 PM, David Blaikie <dblaikie at gmail.com> wrote:

> Author: dblaikie
> Date: Thu Jul 10 15:42:59 2014
> New Revision: 212761
>
> URL: http://llvm.org/viewvc/llvm-project?rev=212761&view=rev
> Log:
> Fix the dtor location issues in PR20038 harder.
>
> Originally committed in r211722, this fixed one case of dtor calls being
> emitted without locations (this causes problems for debug info if the
> call is then inlined), this caught only some of the cases.
>
> Instead of trying to re-enable the location before the cleanup, simply
> re-enable the location immediately after the unconditional branches in
> question using a scoped device to ensure the no-location state doesn't
> leak out arbitrarily.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>     cfe/trunk/lib/CodeGen/CGStmt.cpp
>     cfe/trunk/lib/CodeGen/CodeGenFunction.h
>     cfe/trunk/test/CodeGenCXX/PR20038.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=212761&r1=212760&r2=212761&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jul 10 15:42:59 2014
> @@ -358,10 +358,7 @@ public:
>    Value *VisitExprWithCleanups(ExprWithCleanups *E) {
>      CGF.enterFullExpression(E);
>      CodeGenFunction::RunCleanupsScope Scope(CGF);
> -    auto *V = Visit(E->getSubExpr());
> -    if (CGDebugInfo *DI = CGF.getDebugInfo())
> -      DI->EmitLocation(Builder, E->getLocEnd(), false);
> -    return V;
> +    return Visit(E->getSubExpr());
>    }
>    Value *VisitCXXNewExpr(const CXXNewExpr *E) {
>      return CGF.EmitCXXNewExpr(E);
> @@ -2942,12 +2939,13 @@ Value *ScalarExprEmitter::VisitBinLAnd(c
>    // Reaquire the RHS block, as there may be subblocks inserted.
>    RHSBlock = Builder.GetInsertBlock();
>
> -  // Emit an unconditional branch from this block to ContBlock.  Insert
> an entry
> -  // into the phi node for the edge with the value of RHSCond.
> -  if (CGF.getDebugInfo())
> +  // Emit an unconditional branch from this block to ContBlock.
> +  {
>      // There is no need to emit line number for unconditional branch.
> -    Builder.SetCurrentDebugLocation(llvm::DebugLoc());
> -  CGF.EmitBlock(ContBlock);
> +    SuppressDebugLocation S(Builder);
> +    CGF.EmitBlock(ContBlock);
> +  }
> +  // Insert an entry into the phi node for the edge with the value of
> RHSCond.
>    PN->addIncoming(RHSCond, RHSBlock);
>
>    // ZExt result to int.
>
> Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=212761&r1=212760&r2=212761&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Jul 10 15:42:59 2014
> @@ -524,18 +524,20 @@ void CodeGenFunction::EmitIfStmt(const I
>
>    // Emit the 'else' code if present.
>    if (const Stmt *Else = S.getElse()) {
> -    // There is no need to emit line number for unconditional branch.
> -    if (getDebugInfo())
> -      Builder.SetCurrentDebugLocation(llvm::DebugLoc());
> -    EmitBlock(ElseBlock);
> +    {
> +      // There is no need to emit line number for unconditional branch.
> +      SuppressDebugLocation S(Builder);
> +      EmitBlock(ElseBlock);
> +    }
>      {
>        RunCleanupsScope ElseScope(*this);
>        EmitStmt(Else);
>      }
> -    // There is no need to emit line number for unconditional branch.
> -    if (getDebugInfo())
> -      Builder.SetCurrentDebugLocation(llvm::DebugLoc());
> -    EmitBranch(ContBlock);
> +    {
> +      // There is no need to emit line number for unconditional branch.
> +      SuppressDebugLocation S(Builder);
> +      EmitBranch(ContBlock);
> +    }
>    }
>
>    // Emit the continuation block for code after the if.
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=212761&r1=212760&r2=212761&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Jul 10 15:42:59 2014
> @@ -93,6 +93,19 @@ enum TypeEvaluationKind {
>    TEK_Aggregate
>  };
>
> +class SuppressDebugLocation {
> +  llvm::DebugLoc CurLoc;
> +  llvm::IRBuilderBase &Builder;
> +public:
> +  SuppressDebugLocation(llvm::IRBuilderBase &Builder)
> +      : CurLoc(Builder.getCurrentDebugLocation()), Builder(Builder) {
> +    Builder.SetCurrentDebugLocation(llvm::DebugLoc());
> +  }
> +  ~SuppressDebugLocation() {
> +    Builder.SetCurrentDebugLocation(CurLoc);
> +  }
> +};
> +
>  /// CodeGenFunction - This class organizes the per-function state that is
> used
>  /// while generating LLVM code.
>  class CodeGenFunction : public CodeGenTypeCache {
>
> Modified: cfe/trunk/test/CodeGenCXX/PR20038.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR20038.cpp?rev=212761&r1=212760&r2=212761&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/PR20038.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/PR20038.cpp Thu Jul 10 15:42:59 2014
> @@ -4,8 +4,13 @@ struct C {
>    ~C();
>  };
>  extern bool b;
> -// CHECK: call {{.*}}, !dbg [[DTOR_CALL_LOC:![0-9]*]]
> -// CHECK: [[FUN4:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun4]
> -// CHECK: [[DTOR_CALL_LOC]] = metadata !{i32 [[@LINE+2]], i32 0, metadata
> [[FUN4_BLOCK:.*]], null}
> -// CHECK: [[FUN4_BLOCK]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata
> [[FUN4]],
> -void fun4() { b && (C(), 1); }
> +// CHECK: call {{.*}}, !dbg [[DTOR_CALL1_LOC:![0-9]*]]
> +// CHECK: call {{.*}}, !dbg [[DTOR_CALL2_LOC:![0-9]*]]
> +// CHECK: [[FUN1:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun1]
> +// CHECK: [[FUN2:.*]] = {{.*}}; [ DW_TAG_subprogram ] {{.*}} [def] [fun2]
> +// CHECK: [[DTOR_CALL1_LOC]] = metadata !{i32 [[@LINE+2]], i32 0,
> metadata [[FUN1_BLOCK:.*]], null}
> +// CHECK: [[FUN1_BLOCK]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata
> [[FUN1]],
> +void fun1() { b && (C(), 1); }
> +// CHECK: [[DTOR_CALL2_LOC]] = metadata !{i32 [[@LINE+2]], i32 0,
> metadata [[FUN2_BLOCK1:.*]], null}
> +// CHECK: [[FUN2_BLOCK1]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata
> [[FUN2]],
> +bool fun2() { return (C(), b) && 0; }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140710/44f4053b/attachment.html>


More information about the cfe-commits mailing list