1 ; RUN: opt < %s -S -passes='speculative-execution' | FileCheck %s
2 ; RUN: opt --try-experimental-debuginfo-iterators < %s -S -passes='speculative-execution' | FileCheck %s
4 %class.B = type { ptr }
6 ; Testing that two bitcasts are not hoisted to the first BB
7 define ptr @foo(ptr readonly %b) {
10 ; CHECK-NEXT: %i = icmp eq ptr %b, null
11 ; CHECK-NEXT: br i1 %i, label %end, label %notnull
13 %i = icmp eq ptr %b, null
14 br i1 %i, label %end, label %notnull
16 ; CHECK-LABEL: notnull:
17 notnull: ; preds = %entry
18 %vtable = load ptr, ptr %b, align 8
19 %i2 = getelementptr inbounds i32, ptr %vtable, i64 -2
20 %offset.to.top = load i32, ptr %i2, align 4
21 %i4 = sext i32 %offset.to.top to i64
22 %i5 = getelementptr inbounds i8, ptr %b, i64 %i4
25 end: ; preds = %notnull, %entry
26 %i6 = phi ptr [ %i5, %notnull ], [ null, %entry ]
30 define void @f(i32 %i, i1 %arg) {
33 ; CHECK: %a2 = add i32 %i, 0
34 br i1 %arg, label %land.rhs, label %land.end
36 land.rhs: ; preds = %entry
38 ; CHECK-NEXT: #dbg_label
39 ; CHECK-NEXT: %y = alloca i32, align 4
40 ; CHECK-NEXT: #dbg_declare(ptr %y
41 ; CHECK-NEXT: %a0 = load i32, ptr undef, align 1
42 ; CHECK-NEXT: #dbg_value(i32 %a0
43 ; CHECK-NEXT: #dbg_label
44 ; CHECK-NEXT: #dbg_value(i32 %a2
45 call void @llvm.dbg.label(metadata !11), !dbg !10
46 %y = alloca i32, align 4
47 call void @llvm.dbg.declare(metadata ptr %y, metadata !14, metadata !DIExpression()), !dbg !10
49 %a0 = load i32, ptr undef, align 1
50 call void @llvm.dbg.value(metadata i32 %a0, metadata !9, metadata !DIExpression()), !dbg !10
51 ;; RemoveDIs: Check a label that is attached to a hoisted instruction
52 ;; gets left behind (match intrinsic-style debug info behaviour).
53 call void @llvm.dbg.label(metadata !15), !dbg !10
56 call void @llvm.dbg.value(metadata i32 %a2, metadata !13, metadata !DIExpression()), !dbg !10
60 land.end: ; preds = %land.rhs, %entry
64 ; Function Attrs: nounwind readnone speculatable willreturn
65 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
66 declare void @llvm.dbg.label(metadata)
67 declare void @llvm.dbg.declare(metadata, metadata, metadata)
69 attributes #1 = { nounwind readnone speculatable willreturn }
72 !llvm.module.flags = !{!5}
74 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None)
75 !1 = !DIFile(filename: "foo.c", directory: "/bar")
78 !4 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
79 !5 = !{i32 2, !"Debug Info Version", i32 3}
80 !6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !7, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
81 !7 = !DISubroutineType(types: !8)
83 !9 = !DILocalVariable(name: "a0", scope: !6, file: !1, line: 3, type: !4)
84 !10 = !DILocation(line: 0, scope: !6)
85 !11 = !DILabel(scope: !6, name: "label", file: !1, line: 1)
86 !12 = !DILocalVariable(name: "x", scope: !6, file: !1, line: 3, type: !4)
87 !13 = !DILocalVariable(name: "a2", scope: !6, file: !1, line: 3, type: !4)
88 !14 = !DILocalVariable(name: "y", scope: !6, file: !1, line: 3, type: !4)
89 !15 = !DILabel(scope: !6, name: "label2", file: !1, line: 2)