[PATCH] D73481: [DebugInfo] replaceDbgUsesWithUndef after sroa promotes allocas

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 07:53:23 PST 2020


Orlando created this revision.
Orlando added reviewers: vsk, aprantl, djtodoro.
Orlando added projects: LLVM, debug-info.
Herald added subscribers: llvm-commits, hiraditya.

https://reviews.llvm.org/D73481

Files:
  llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
  llvm/test/DebugInfo/X86/sroa-undef-dbg-value-4.ll


Index: llvm/test/DebugInfo/X86/sroa-undef-dbg-value-4.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/sroa-undef-dbg-value-4.ll
@@ -0,0 +1,60 @@
+; RUN: opt -sroa -S %s | FileCheck %s
+; CHECK: call void @llvm.dbg.value(metadata i16* undef, metadata ![[MD_c:[0-9]+]],
+; CHECK: ![[MD_c]] = !DILocalVariable(name: "c",
+
+; clang reduce.c -O0 -g -emit-llvm -S -Xclang -disable-O0-optnone -o -
+; cat reduce.c
+; void a() {
+;   short b = 3;
+;   short *c = &b;
+;   for (;;)
+;     *c = 0;
+; }
+
+define dso_local void @a() !dbg !7 {
+entry:
+  %b = alloca i16, align 2
+  %c = alloca i16*, align 8
+  call void @llvm.dbg.declare(metadata i16* %b, metadata !10, metadata !DIExpression()), !dbg !12
+  store i16 3, i16* %b, align 2, !dbg !12
+  call void @llvm.dbg.declare(metadata i16** %c, metadata !13, metadata !DIExpression()), !dbg !15
+  store i16* %b, i16** %c, align 8, !dbg !15
+  br label %for.cond, !dbg !16
+
+for.cond:                                         ; preds = %for.cond, %entry
+  %0 = load i16*, i16** %c, align 8, !dbg !17
+  store i16 0, i16* %0, align 2, !dbg !20
+  br label %for.cond, !dbg !21, !llvm.loop !22
+}
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "reduce.c", directory: "/")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 10.0.0"}
+!7 = distinct !DISubprogram(name: "a", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 2, type: !11)
+!11 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
+!12 = !DILocation(line: 2, column: 9, scope: !7)
+!13 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 3, type: !14)
+!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
+!15 = !DILocation(line: 3, column: 10, scope: !7)
+!16 = !DILocation(line: 4, column: 3, scope: !7)
+!17 = !DILocation(line: 5, column: 6, scope: !18)
+!18 = distinct !DILexicalBlock(scope: !19, file: !1, line: 4, column: 3)
+!19 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 3)
+!20 = !DILocation(line: 5, column: 8, scope: !18)
+!21 = !DILocation(line: 4, column: 3, scope: !18)
+!22 = distinct !{!22, !23, !24}
+!23 = !DILocation(line: 4, column: 3, scope: !19)
+!24 = !DILocation(line: 5, column: 10, scope: !19)
Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
===================================================================
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -664,6 +664,7 @@
     // tree. Just delete the users now.
     if (!A->use_empty())
       A->replaceAllUsesWith(UndefValue::get(A->getType()));
+    replaceDbgUsesWithUndef(A);
     A->eraseFromParent();
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73481.240587.patch
Type: text/x-patch
Size: 3333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200127/3850b8c6/attachment.bin>


More information about the llvm-commits mailing list