[PATCH] D46738: [DebugInfo] Fix PR37395.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 20:01:53 PDT 2018


HsiangKai created this revision.
HsiangKai added reviewers: davide, aprantl.
Herald added subscribers: llvm-commits, JDevlieghere.

Do not assume DbgInfoIntrinsic has an address as its first operand.

Fix https://bugs.llvm.org/show_bug.cgi?id=37395


Repository:
  rL LLVM

https://reviews.llvm.org/D46738

Files:
  lib/IR/IntrinsicInst.cpp
  test/DebugInfo/Generic/PR37395.ll


Index: test/DebugInfo/Generic/PR37395.ll
===================================================================
--- /dev/null
+++ test/DebugInfo/Generic/PR37395.ll
@@ -0,0 +1,65 @@
+; RUN: opt -O1 -S %s | FileCheck %s
+; CHECK: DILabel
+;
+source_filename = "small.c"
+
+ at a = common dso_local global i32 0, align 4, !dbg !0
+
+; Function Attrs: nounwind uwtable
+define dso_local void @f() !dbg !11 {
+entry:
+  br label %for.cond, !dbg !18
+
+for.cond:                                         ; preds = %for.inc, %entry
+  %0 = load i32, i32* @a, align 4, !dbg !19
+  %tobool = icmp ne i32 %0, 0, !dbg !20
+  br i1 %tobool, label %for.body, label %for.end, !dbg !20
+
+for.body:                                         ; preds = %for.cond
+  br label %L, !dbg !20
+
+L:                                                ; preds = %for.body
+  call void @llvm.dbg.label(metadata !15), !dbg !21
+  br label %for.inc, !dbg !20
+
+for.inc:                                          ; preds = %L
+  %1 = load i32, i32* @a, align 4, !dbg !22
+  %inc = add nsw i32 %1, 1, !dbg !22
+  store i32 %inc, i32* @a, align 4, !dbg !22
+  br label %for.cond, !dbg !23, !llvm.loop !24
+
+for.end:                                          ; preds = %for.cond
+  ret void, !dbg !26
+}
+
+declare void @llvm.dbg.label(metadata)
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!7, !8, !9}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
+!3 = !DIFile(filename: "small.c", directory: "./")
+!4 = !{}
+!5 = !{!0}
+!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!7 = !{i32 2, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{i32 1, !"wchar_size", i32 4}
+!11 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true, scopeLine: 4, isOptimized: true, unit: !2, retainedNodes: !14)
+!12 = !DISubroutineType(types: !13)
+!13 = !{null}
+!14 = !{!15}
+!15 = !DILabel(scope: !16, name: "L", file: !3, line: 6)
+!16 = distinct !DILexicalBlock(scope: !17, file: !3, line: 5, column: 3)
+!17 = distinct !DILexicalBlock(scope: !11, file: !3, line: 5, column: 3)
+!18 = !DILocation(line: 5, column: 3, scope: !11)
+!19 = !DILocation(line: 5, column: 10, scope: !16)
+!20 = !DILocation(line: 5, column: 3, scope: !17)
+!21 = !DILocation(line: 6, column: 3, scope: !16)
+!22 = !DILocation(line: 5, column: 14, scope: !16)
+!23 = !DILocation(line: 5, column: 3, scope: !16)
+!24 = distinct !{!24, !20, !25}
+!25 = !DILocation(line: 6, column: 5, scope: !17)
+!26 = !DILocation(line: 7, column: 1, scope: !11)
Index: lib/IR/IntrinsicInst.cpp
===================================================================
--- lib/IR/IntrinsicInst.cpp
+++ lib/IR/IntrinsicInst.cpp
@@ -43,8 +43,6 @@
   if (auto *V = dyn_cast<ValueAsMetadata>(MD))
     return V->getValue();
 
-  // When the value goes to null, it gets replaced by an empty MDNode.
-  assert(!cast<MDNode>(MD)->getNumOperands() && "Expected an empty MDNode");
   return nullptr;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46738.146271.patch
Type: text/x-patch
Size: 3319 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180511/269dccec/attachment.bin>


More information about the llvm-commits mailing list