xref: /llvm-project/llvm/test/Transforms/InstCombine/unreachable-dbg-info-modified.ll (revision f42482def236999b0f7896c09cd714b708861c8b)
1; RUN: opt < %s -passes=instcombine -S | FileCheck %s
2; RUN: opt < %s -passes=instcombine -S --try-experimental-debuginfo-iterators | FileCheck %s
3
4; When removing the llvm.dbg.value intrinsic in the unreachable block
5; InstCombine would incorrectly return a false Modified status.
6
7; CHECK: cond.true:
8; CHECK-NEXT: br label %cond.end
9
10define i32 @foo() !dbg !7 {
11entry:
12  br i1 false, label %cond.true, label %cond.end
13
14cond.true:
15  call void @llvm.dbg.value(metadata i32 undef, metadata !12, metadata !DIExpression()), !dbg !13
16  br label %cond.end
17
18cond.end:
19  ret i32 undef
20}
21
22declare void @llvm.dbg.value(metadata, metadata, metadata) #0
23
24attributes #0 = { nounwind readnone speculatable willreturn }
25
26!llvm.dbg.cu = !{!0}
27!llvm.module.flags = !{!3, !4}
28!llvm.ident = !{!6}
29
30!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
31!1 = !DIFile(filename: "foo.c", directory: "/")
32!2 = !{}
33!3 = !{i32 7, !"Dwarf Version", i32 4}
34!4 = !{i32 2, !"Debug Info Version", i32 3}
35!6 = !{!"clang version 12.0.0"}
36!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
37!8 = !DISubroutineType(types: !9)
38!9 = !{!10}
39!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
40!11 = !{!12, !12}
41!12 = !DILocalVariable(name: "bar", scope: !7, file: !1, line: 1, type: !10)
42!13 = !DILocation(line: 0, scope: !7)
43