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