[PATCH] D73479: [DebugInfo] replaceDbgUsesWithUndef when sroa promotes an alloca

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


Orlando created this revision.
Orlando added reviewers: vsk, aprantl, djtodoro.
Orlando added a project: LLVM.
Herald added subscribers: llvm-commits, hiraditya.

...used in a single block only.


https://reviews.llvm.org/D73479

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


Index: llvm/test/DebugInfo/X86/sroa-undef-dbg-value-3.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/sroa-undef-dbg-value-3.ll
@@ -0,0 +1,47 @@
+; RUN: opt -sroa -S %s | FileCheck %s
+; CHECK: call void @llvm.dbg.value(metadata i32** 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() {   int *b = 0;   int **c = &b;   *c = 0; }
+
+define dso_local void @a() !dbg !7 {
+entry:
+  %b = alloca i32*, align 8
+  %c = alloca i32**, align 8
+  call void @llvm.dbg.declare(metadata i32** %b, metadata !10, metadata !DIExpression()), !dbg !13
+  store i32* null, i32** %b, align 8, !dbg !13
+  call void @llvm.dbg.declare(metadata i32*** %c, metadata !14, metadata !DIExpression()), !dbg !16
+  store i32** %b, i32*** %c, align 8, !dbg !16
+  %0 = load i32**, i32*** %c, align 8, !dbg !17
+  store i32* null, i32** %0, align 8, !dbg !18
+  ret void, !dbg !19
+}
+
+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: 1, type: !11)
+!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !DILocation(line: 1, column: 19, scope: !7)
+!14 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 1, type: !15)
+!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
+!16 = !DILocation(line: 1, column: 34, scope: !7)
+!17 = !DILocation(line: 1, column: 45, scope: !7)
+!18 = !DILocation(line: 1, column: 47, scope: !7)
+!19 = !DILocation(line: 1, column: 52, scope: !7)
Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
===================================================================
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -518,6 +518,7 @@
     LBI.deleteValue(SI);
   }
 
+  replaceDbgUsesWithUndef(AI);
   AI->eraseFromParent();
 
   // The alloca's debuginfo can be removed as well.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73479.240583.patch
Type: text/x-patch
Size: 2872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200127/d2946a5f/attachment.bin>


More information about the llvm-commits mailing list