[PATCH] D42551: [Debug] Add dbg.value intrinsics for PHIs created during LCSSA.

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 15:10:44 PST 2018


vsk added a comment.

I think we hit a snafu:

http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/8260

  The unwind destination does not have an exception handling instruction!
    %call.i84 = invoke i32 %14(%"class.std::__1::basic_streambuf"* nonnull %10)
            to label %invoke.cont9 unwind label %lpad6, !dbg !11517
  LandingPadInst not the first non-PHI instruction in the block.
    %18 = landingpad { i8*, i32 }
            catch i8* null, !dbg !11530
  The unwind destination does not have an exception handling instruction!
    %call.i89 = invoke i32 %13(%"class.std::__1::basic_streambuf"* nonnull %9)
            to label %invoke.cont6 unwind label %lpad3, !dbg !11918
  LandingPadInst not the first non-PHI instruction in the block.
    %17 = landingpad { i8*, i32 }
            catch i8* null, !dbg !11933
  The unwind destination does not have an exception handling instruction!
    %call.i86 = invoke i32 %14(%"class.std::__1::basic_streambuf.4"* nonnull %10)
            to label %invoke.cont9 unwind label %lpad6, !dbg !15662
  LandingPadInst not the first non-PHI instruction in the block.
    %18 = landingpad { i8*, i32 }
            catch i8* null, !dbg !15673
  The unwind destination does not have an exception handling instruction!
    %call.i91 = invoke i32 %13(%"class.std::__1::basic_streambuf.4"* nonnull %9)
            to label %invoke.cont6 unwind label %lpad3, !dbg !16044
  LandingPadInst not the first non-PHI instruction in the block.
    %17 = landingpad { i8*, i32 }
            catch i8* null, !dbg !16057
  LLVM ERROR: Broken module found, compilation aborted!

Candidate fix:

  diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
  index a7eaffd1a7a..05194a1aed5 100644
  --- a/lib/Transforms/Utils/Local.cpp
  +++ b/lib/Transforms/Utils/Local.cpp
  @@ -1373,7 +1373,7 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB,
           auto PhiMAV = MetadataAsValue::get(C, ValueAsMetadata::get(PHI));
           NewDbgII->setOperand(0, PhiMAV);
           BasicBlock *Parent = PHI->getParent();
  -        NewDbgII->insertBefore(Parent->getFirstNonPHIOrDbgOrLifetime());
  +        NewDbgII->insertAfter(Parent->getFirstNonPHIOrDbgOrLifetime());
         }
       }
     }
  diff --git a/test/Transforms/LCSSA/basictest.ll b/test/Transforms/LCSSA/basictest.ll
  index 284de862eec..7c6df70e1db 100644
  --- a/test/Transforms/LCSSA/basictest.ll
  +++ b/test/Transforms/LCSSA/basictest.ll
  @@ -19,8 +19,9 @@ post.if:		; preds = %if.false, %if.true
   	br i1 %S2, label %loop.exit, label %loop.interior
   loop.exit:		; preds = %post.if
   ; CHECK: %X3.lcssa = phi i32
  -; CHECK2: call void @llvm.dbg.value(metadata i32 %X3.lcssa, metadata !11, metadata !DIExpression()), !dbg !19
   ; CHECK: %X4 = add i32 3, %X3.lcssa
  +; CHECK2: add i32 3, %X3.lcssa
  +; CHECK2: call void @llvm.dbg.value(metadata i32 %X3.lcssa, metadata !11, metadata !DIExpression()), !dbg !19
   	%X4 = add i32 3, %X3		; <i32> [#uses=0]
   	ret void
   }


Repository:
  rL LLVM

https://reviews.llvm.org/D42551





More information about the llvm-commits mailing list