89 lines · plain
1; RUN: opt < %s -S -passes='speculative-execution' | FileCheck %s2 3%class.B = type { ptr }4 5; Testing that two bitcasts are not hoisted to the first BB6define ptr @foo(ptr readonly %b) {7; CHECK-LABEL: foo8; CHECK-LABEL: entry9; CHECK-NEXT: %i = icmp eq ptr %b, null10; CHECK-NEXT: br i1 %i, label %end, label %notnull11entry:12 %i = icmp eq ptr %b, null13 br i1 %i, label %end, label %notnull14 15; CHECK-LABEL: notnull:16notnull: ; preds = %entry17 %vtable = load ptr, ptr %b, align 818 %i2 = getelementptr inbounds i32, ptr %vtable, i64 -219 %offset.to.top = load i32, ptr %i2, align 420 %i4 = sext i32 %offset.to.top to i6421 %i5 = getelementptr inbounds i8, ptr %b, i64 %i422 br label %end23 24end: ; preds = %notnull, %entry25 %i6 = phi ptr [ %i5, %notnull ], [ null, %entry ]26 ret ptr %i627}28 29define void @f(i32 %i, i1 %arg) {30entry:31; CHECK-LABEL: @f(32; CHECK: %a2 = add i32 %i, 033 br i1 %arg, label %land.rhs, label %land.end34 35land.rhs: ; preds = %entry36; CHECK: land.rhs:37; CHECK-NEXT: #dbg_label38; CHECK-NEXT: %y = alloca i32, align 439; CHECK-NEXT: #dbg_declare(ptr %y40; CHECK-NEXT: %a0 = load i32, ptr undef, align 141; CHECK-NEXT: #dbg_value(i32 %a042; CHECK-NEXT: #dbg_label43; CHECK-NEXT: #dbg_value(i32 %a244 call void @llvm.dbg.label(metadata !11), !dbg !1045 %y = alloca i32, align 446 call void @llvm.dbg.declare(metadata ptr %y, metadata !14, metadata !DIExpression()), !dbg !1047 48 %a0 = load i32, ptr undef, align 149 call void @llvm.dbg.value(metadata i32 %a0, metadata !9, metadata !DIExpression()), !dbg !1050 ;; RemoveDIs: Check a label that is attached to a hoisted instruction51 ;; gets left behind (match intrinsic-style debug info behaviour).52 call void @llvm.dbg.label(metadata !15), !dbg !1053 54 %a2 = add i32 %i, 055 call void @llvm.dbg.value(metadata i32 %a2, metadata !13, metadata !DIExpression()), !dbg !1056 57 br label %land.end58 59land.end: ; preds = %land.rhs, %entry60 ret void61}62 63; Function Attrs: nounwind readnone speculatable willreturn64declare void @llvm.dbg.value(metadata, metadata, metadata) #165declare void @llvm.dbg.label(metadata)66declare void @llvm.dbg.declare(metadata, metadata, metadata)67 68attributes #1 = { nounwind readnone speculatable willreturn }69 70!llvm.dbg.cu = !{!0}71!llvm.module.flags = !{!5}72 73!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)74!1 = !DIFile(filename: "foo.c", directory: "/bar")75!2 = !{}76!3 = !{!4}77!4 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)78!5 = !{i32 2, !"Debug Info Version", i32 3}79!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !7, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)80!7 = !DISubroutineType(types: !8)81!8 = !{null}82!9 = !DILocalVariable(name: "a0", scope: !6, file: !1, line: 3, type: !4)83!10 = !DILocation(line: 0, scope: !6)84!11 = !DILabel(scope: !6, name: "label", file: !1, line: 1)85!12 = !DILocalVariable(name: "x", scope: !6, file: !1, line: 3, type: !4)86!13 = !DILocalVariable(name: "a2", scope: !6, file: !1, line: 3, type: !4)87!14 = !DILocalVariable(name: "y", scope: !6, file: !1, line: 3, type: !4)88!15 = !DILabel(scope: !6, name: "label2", file: !1, line: 2)89