summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG
diff options
context:
space:
mode:
authorstozer <stephen.tozer@sony.com>2019-12-04 09:44:02 +0000
committerstozer <stephen.tozer@sony.com>2019-12-04 16:01:49 +0000
commit72ce759928e6dfee6a9efa310b966c19722352ba (patch)
tree7ca2b21eabffe17458b139055ff7f56bdfc51a85 /llvm/test/Transforms/SimplifyCFG
parentb3b37783034cab31db2d60cf79d0c1c82a8c3419 (diff)
downloadbcm5719-llvm-72ce759928e6dfee6a9efa310b966c19722352ba.tar.gz
bcm5719-llvm-72ce759928e6dfee6a9efa310b966c19722352ba.zip
[DebugInfo] Recover debug intrinsics when killing duplicated/empty basic blocks
When basic blocks are killed, either due to being empty or to being an if.then or if.else block whose complement contains identical instructions, some of the debug intrinsics in that block are lost. This patch sinks those intrinsics into the single successor block, setting them Undef if necessary to prevent debug info from falling out-of-date. Differential Revision: https://reviews.llvm.org/D70318
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG')
-rw-r--r--llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-else.ll67
-rw-r--r--llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-empty.ll71
2 files changed, 138 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-else.ll b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-else.ll
new file mode 100644
index 00000000000..32962886be5
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-else.ll
@@ -0,0 +1,67 @@
+; RUN: opt -simplifycfg -S < %s | FileCheck %s
+; Checks that when the if.then and if.else blocks are both eliminated by
+; SimplifyCFG, as the common code is hoisted out, the variables with a
+; dbg.value in either of those blocks are set undef just before the
+; conditional branch instruction.
+
+define i32 @"?fn@@YAHH@Z"(i32 %foo) !dbg !8 {
+; CHECK-LABEL: entry:
+entry:
+ call void @llvm.dbg.value(metadata i32 %foo, metadata !13, metadata !DIExpression()), !dbg !16
+ call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression()), !dbg !16
+ call void @llvm.dbg.value(metadata i32 0, metadata !15, metadata !DIExpression()), !dbg !16
+ %cmp = icmp eq i32 %foo, 4, !dbg !17
+; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata [[BEARDS:![0-9]+]]
+; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata [[BIRDS:![0-9]+]]
+ br i1 %cmp, label %if.then, label %if.else, !dbg !17
+
+if.then: ; preds = %entry
+ call void @llvm.dbg.value(metadata i32 8, metadata !14, metadata !DIExpression()), !dbg !16
+ br label %if.end, !dbg !18
+
+if.else: ; preds = %entry
+ call void @llvm.dbg.value(metadata i32 4, metadata !14, metadata !DIExpression()), !dbg !16
+ call void @llvm.dbg.value(metadata i32 8, metadata !15, metadata !DIExpression()), !dbg !16
+ br label %if.end, !dbg !21
+
+if.end: ; preds = %if.else, %if.then
+ %beards.0 = phi i32 [ 8, %if.then ], [ 4, %if.else ], !dbg !23
+ call void @llvm.dbg.value(metadata i32 %beards.0, metadata !14, metadata !DIExpression()), !dbg !16
+ ret i32 %beards.0, !dbg !24
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+; CHECK-LABEL: }
+; CHECK: [[BEARDS]] = !DILocalVariable(name: "beards"
+; CHECK: [[BIRDS]] = !DILocalVariable(name: "birds"
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "test.cpp", directory: "C:\5Cdev\5Cllvm-project", checksumkind: CSK_MD5, checksum: "64604a72fdf5b6db8aa2328236bedd6b")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 2}
+!6 = !{i32 7, !"PIC Level", i32 2}
+!7 = !{!"clang version 10.0.0 "}
+!8 = distinct !DISubprogram(name: "fn", linkageName: "?fn@@YAHH@Z", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11, !11}
+!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!12 = !{!13, !14, !15}
+!13 = !DILocalVariable(name: "foo", arg: 1, scope: !8, file: !1, line: 1, type: !11)
+!14 = !DILocalVariable(name: "beards", scope: !8, file: !1, line: 2, type: !11)
+!15 = !DILocalVariable(name: "birds", scope: !8, file: !1, line: 3, type: !11)
+!16 = !DILocation(line: 0, scope: !8)
+!17 = !DILocation(line: 5, scope: !8)
+!18 = !DILocation(line: 8, scope: !19)
+!19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 5)
+!20 = distinct !DILexicalBlock(scope: !8, file: !1, line: 5)
+!21 = !DILocation(line: 11, scope: !22)
+!22 = distinct !DILexicalBlock(scope: !20, file: !1, line: 8)
+!23 = !DILocation(line: 0, scope: !20)
+!24 = !DILocation(line: 13, scope: !8)
diff --git a/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-empty.ll b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-empty.ll
new file mode 100644
index 00000000000..7d5e32a2d65
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/hoist-dbgvalue-empty.ll
@@ -0,0 +1,71 @@
+; RUN: opt -simplifycfg -S < %s | FileCheck %s
+; Checks that when the if.then block is eliminated due to containing no
+; instructions, the debug intrinsics are hoisted out of the block before its
+; deletion. The hoisted intrinsics should have undef values as the branch
+; behaviour is unknown to the intrinsics after hoisting.
+
+define dso_local i32 @"?fn@@YAHH@Z"(i32 %foo) local_unnamed_addr !dbg !8 {
+entry:
+ call void @llvm.dbg.value(metadata i32 %foo, metadata !13, metadata !DIExpression()), !dbg !16
+ call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression()), !dbg !16
+ call void @llvm.dbg.value(metadata i32 0, metadata !15, metadata !DIExpression()), !dbg !16
+ %cmp = icmp eq i32 %foo, 4, !dbg !17
+ br i1 %cmp, label %if.then, label %if.else, !dbg !17
+
+if.then: ; preds = %entry
+ call void @llvm.dbg.value(metadata i32 8, metadata !14, metadata !DIExpression()), !dbg !16
+ call void @llvm.dbg.value(metadata i32 3, metadata !15, metadata !DIExpression()), !dbg !16
+ br label %if.end, !dbg !18
+
+if.else: ; preds = %entry
+ call void @"?side@@YAXXZ"(), !dbg !21
+ call void @llvm.dbg.value(metadata i32 4, metadata !14, metadata !DIExpression()), !dbg !16
+ call void @llvm.dbg.value(metadata i32 6, metadata !15, metadata !DIExpression()), !dbg !16
+ br label %if.end, !dbg !23
+
+; CHECK-LABEL: if.end:
+if.end: ; preds = %if.else, %if.then
+; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata [[BEARDS:![0-9]+]]
+; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata [[BIRDS:![0-9]+]]
+ %beards.0 = phi i32 [ 8, %if.then ], [ 4, %if.else ], !dbg !24
+ call void @llvm.dbg.value(metadata i32 %beards.0, metadata !14, metadata !DIExpression()), !dbg !16
+ ret i32 %beards.0, !dbg !25
+}
+
+declare dso_local void @"?side@@YAXXZ"() local_unnamed_addr
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6}
+!llvm.ident = !{!7}
+
+; CHECK: [[BEARDS]] = !DILocalVariable(name: "beards"
+; CHECK: [[BIRDS]] = !DILocalVariable(name: "birds"
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "test2.cpp", directory: "C:\5Cdev\5Cllvm-project", checksumkind: CSK_MD5, checksum: "8ac5d40fcc9914d6479c1a770dfdc176")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 2}
+!6 = !{i32 7, !"PIC Level", i32 2}
+!7 = !{!"clang version 10.0.0 "}
+!8 = distinct !DISubprogram(name: "fn", linkageName: "?fn@@YAHH@Z", scope: !1, file: !1, line: 3, type: !9, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11, !11}
+!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!12 = !{!13, !14, !15}
+!13 = !DILocalVariable(name: "foo", arg: 1, scope: !8, file: !1, line: 3, type: !11)
+!14 = !DILocalVariable(name: "beards", scope: !8, file: !1, line: 4, type: !11)
+!15 = !DILocalVariable(name: "birds", scope: !8, file: !1, line: 5, type: !11)
+!16 = !DILocation(line: 0, scope: !8)
+!17 = !DILocation(line: 7, scope: !8)
+!18 = !DILocation(line: 10, scope: !19)
+!19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 7)
+!20 = distinct !DILexicalBlock(scope: !8, file: !1, line: 7)
+!21 = !DILocation(line: 11, scope: !22)
+!22 = distinct !DILexicalBlock(scope: !20, file: !1, line: 10)
+!23 = !DILocation(line: 14, scope: !22)
+!24 = !DILocation(line: 0, scope: !20)
+!25 = !DILocation(line: 16, scope: !8)
OpenPOWER on IntegriCloud