1 ; RUN: opt < %s -S -passes='speculative-execution' | FileCheck %s
3 %class.B = type { ptr }
5 ; Testing that two bitcasts are not hoisted to the first BB
6 define ptr @foo(ptr readonly %b) {
9 ; CHECK-NEXT: %i = icmp eq ptr %b, null
10 ; CHECK-NEXT: br i1 %i, label %end, label %notnull
12 %i = icmp eq ptr %b, null
13 br i1 %i, label %end, label %notnull
15 ; CHECK-LABEL: notnull:
16 notnull: ; preds = %entry
17 %vtable = load ptr, ptr %b, align 8
18 %i2 = getelementptr inbounds i32, ptr %vtable, i64 -2
19 %offset.to.top = load i32, ptr %i2, align 4
20 %i4 = sext i32 %offset.to.top to i64
21 %i5 = getelementptr inbounds i8, ptr %b, i64 %i4
24 end: ; preds = %notnull, %entry
25 %i6 = phi ptr [ %i5, %notnull ], [ null, %entry ]
29 define void @f(i32 %i) {
32 ; CHECK: %a2 = add i32 %i, 0
33 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %a2
34 br i1 undef, label %land.rhs, label %land.end
36 land.rhs: ; preds = %entry
38 ; CHECK-NEXT: call void @llvm.dbg.label
39 ; CHECK-NEXT: %y = alloca i32, align 4
40 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %y
41 ; CHECK-NEXT: %a0 = load i32, ptr undef, align 1
42 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %a0
43 call void @llvm.dbg.label(metadata !11), !dbg !10
44 %y = alloca i32, align 4
45 call void @llvm.dbg.declare(metadata ptr %y, metadata !14, metadata !DIExpression()), !dbg !10
47 %a0 = load i32, ptr undef, align 1
48 call void @llvm.dbg.value(metadata i32 %a0, metadata !9, metadata !DIExpression()), !dbg !10
51 call void @llvm.dbg.value(metadata i32 %a2, metadata !13, metadata !DIExpression()), !dbg !10
55 land.end: ; preds = %land.rhs, %entry
59 ; Function Attrs: nounwind readnone speculatable willreturn
60 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
61 declare void @llvm.dbg.label(metadata)
62 declare void @llvm.dbg.declare(metadata, metadata, metadata)
64 attributes #1 = { nounwind readnone speculatable willreturn }
67 !llvm.module.flags = !{!5}
69 !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)
70 !1 = !DIFile(filename: "foo.c", directory: "/bar")
73 !4 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
74 !5 = !{i32 2, !"Debug Info Version", i32 3}
75 !6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !7, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
76 !7 = !DISubroutineType(types: !8)
78 !9 = !DILocalVariable(name: "a0", scope: !6, file: !1, line: 3, type: !4)
79 !10 = !DILocation(line: 0, scope: !6)
80 !11 = !DILabel(scope: !6, name: "label", file: !1, line: 1)
81 !12 = !DILocalVariable(name: "x", scope: !6, file: !1, line: 3, type: !4)
82 !13 = !DILocalVariable(name: "a2", scope: !6, file: !1, line: 3, type: !4)
83 !14 = !DILocalVariable(name: "y", scope: !6, file: !1, line: 3, type: !4)