[PATCH] D73478: [DebugInfo] replaceDbgUsesWithUndef before removing single store alloca

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


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

https://reviews.llvm.org/D73478

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


Index: llvm/test/DebugInfo/X86/sroa-undef-dbg-value-2.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/sroa-undef-dbg-value-2.ll
@@ -0,0 +1,53 @@
+; 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
+; int *d;
+; void a() {
+;   int **b = &d;
+;   int ***c = &b;
+; }
+
+ at d = common dso_local global i32* null, align 8, !dbg !0
+
+define dso_local void @a() !dbg !12 {
+entry:
+  %b = alloca i32**, align 8
+  %c = alloca i32***, align 8
+  call void @llvm.dbg.declare(metadata i32*** %b, metadata !15, metadata !DIExpression()), !dbg !17
+  store i32** @d, i32*** %b, align 8, !dbg !17
+  call void @llvm.dbg.declare(metadata i32**** %c, metadata !18, metadata !DIExpression()), !dbg !20
+  store i32*** %b, i32**** %c, align 8, !dbg !20
+  ret void, !dbg !21
+}
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!8, !9, !10}
+!llvm.ident = !{!11}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "d", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "reduce.c", directory: "/")
+!4 = !{}
+!5 = !{!0}
+!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
+!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!8 = !{i32 7, !"Dwarf Version", i32 4}
+!9 = !{i32 2, !"Debug Info Version", i32 3}
+!10 = !{i32 1, !"wchar_size", i32 4}
+!11 = !{!"clang version 10.0.0"}
+!12 = distinct !DISubprogram(name: "a", scope: !3, file: !3, line: 2, type: !13, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!13 = !DISubroutineType(types: !14)
+!14 = !{null}
+!15 = !DILocalVariable(name: "b", scope: !12, file: !3, line: 3, type: !16)
+!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
+!17 = !DILocation(line: 3, column: 10, scope: !12)
+!18 = !DILocalVariable(name: "c", scope: !12, file: !3, line: 4, type: !19)
+!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)
+!20 = !DILocation(line: 4, column: 11, scope: !12)
+!21 = !DILocation(line: 5, column: 1, scope: !12)
Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
===================================================================
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -421,6 +421,7 @@
   Info.OnlyStore->eraseFromParent();
   LBI.deleteValue(Info.OnlyStore);
 
+  replaceDbgUsesWithUndef(AI);
   AI->eraseFromParent();
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73478.240576.patch
Type: text/x-patch
Size: 3055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200127/687ef145/attachment.bin>


More information about the llvm-commits mailing list