[PATCH] D57444: [DebugInfo] LLVM ERROR: Broken function found, while removing Debug Intrinsics

Carlos Alberto Enciso via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 05:18:32 PST 2019


CarlosAlbertoEnciso updated this revision to Diff 184487.
CarlosAlbertoEnciso added a comment.

Updated patch to remove the negative CHECK. Thanks for your feedback.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57444/new/

https://reviews.llvm.org/D57444

Files:
  include/llvm/Transforms/Utils/Local.h
  lib/Transforms/Utils/Local.cpp
  test/CodeGen/X86/bbi-23595.ll


Index: test/CodeGen/X86/bbi-23595.ll
===================================================================
--- test/CodeGen/X86/bbi-23595.ll
+++ test/CodeGen/X86/bbi-23595.ll
@@ -0,0 +1,51 @@
+; RUN: opt < %s -S -simplifycfg | FileCheck %s
+
+; Note: This patch is a complement to pr38762.
+;
+; The new issue has been submitted as:
+;   https://bugs.llvm.org/show_bug.cgi?id=40523
+;
+; For the given test case, the verifier complains with the error message:
+;
+;   LLVM ERROR: Broken function found, compilation aborted!
+;
+; The issue was introduced at https://reviews.llvm.org/rL345250.
+
+; CHECK-LABEL: _Z7test_itv()
+; CHECK:       entry:
+; CHECK-NEXT:    %retval.0 = select i1 undef, i16 1, i16 0
+; CHECK-NEXT:    ret i16 0
+
+define i16 @_Z7test_itv() {
+entry:
+  br label %sw.bb
+
+sw.bb:                                            ; preds = %entry
+  br i1 undef, label %W, label %cleanup4
+
+W:                                                ; preds = %sw.bb
+  call void @llvm.dbg.label(metadata !1), !dbg !8
+  br label %cleanup4
+
+cleanup4:                                         ; preds = %W, %sw.bb
+  %retval.0 = phi i16 [ 1, %W ], [ 0, %sw.bb ]
+  ret i16 0
+}
+
+; Function Attrs: nounwind readnone speculatable
+declare void @llvm.dbg.label(metadata) #0
+
+attributes #0 = { nounwind readnone speculatable }
+
+!llvm.dbg.cu = !{}
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = !DILabel(scope: !2, name: "W", file: !3, line: 47)
+!2 = distinct !DILexicalBlock(scope: !4, file: !3, line: 40, column: 3)
+!3 = !DIFile(filename: "foo.c", directory: "./")
+!4 = distinct !DISubprogram(name: "test_it", scope: !3, file: !3, line: 35, type: !5, scopeLine: 36, unit: !7)
+!5 = !DISubroutineType(types: !6)
+!6 = !{}
+!7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!8 = !DILocation(line: 47, column: 2, scope: !2)
Index: lib/Transforms/Utils/Local.cpp
===================================================================
--- lib/Transforms/Utils/Local.cpp
+++ lib/Transforms/Utils/Local.cpp
@@ -2529,13 +2529,13 @@
                                     BasicBlock *BB) {
   // Since we are moving the instructions out of its basic block, we do not
   // retain their original debug locations (DILocations) and debug intrinsic
-  // instructions (dbg.values).
+  // instructions.
   //
   // Doing so would degrade the debugging experience and adversely affect the
   // accuracy of profiling information.
   //
   // Currently, when hoisting the instructions, we take the following actions:
-  // - Remove their dbg.values.
+  // - Remove their debug intrinsic instructions.
   // - Set their debug locations to the values from the insertion point.
   //
   // As per PR39141 (comment #8), the more fundamental reason why the dbg.values
@@ -2553,7 +2553,7 @@
     I->dropUnknownNonDebugMetadata();
     if (I->isUsedByMetadata())
       dropDebugUsers(*I);
-    if (isa<DbgVariableIntrinsic>(I)) {
+    if (isa<DbgInfoIntrinsic>(I)) {
       // Remove DbgInfo Intrinsics.
       II = I->eraseFromParent();
       continue;
Index: include/llvm/Transforms/Utils/Local.h
===================================================================
--- include/llvm/Transforms/Utils/Local.h
+++ include/llvm/Transforms/Utils/Local.h
@@ -455,8 +455,7 @@
 /// \p DomBlock, by moving its instructions to the insertion point \p InsertPt.
 ///
 /// The moved instructions receive the insertion point debug location values
-/// (DILocations) and their debug intrinsic instructions (dbg.values) are
-/// removed.
+/// (DILocations) and their debug intrinsic instructions are removed.
 void hoistAllInstructionsInto(BasicBlock *DomBlock, Instruction *InsertPt,
                               BasicBlock *BB);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57444.184487.patch
Type: text/x-patch
Size: 3845 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/589b07c0/attachment.bin>


More information about the llvm-commits mailing list