llvm/test/Transforms/SimplifyCFG/branch-fold-dbg.ll
Duncan P. N. Exon Smith 1ef70ff39b IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly.  These
are the matching assembly changes for the metadata/value split in
r223802.

  - Only use the `metadata` type when referencing metadata from a call
    intrinsic -- i.e., only when it's used as a `Value`.

  - Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
    when referencing it from call intrinsics.

So, assembly like this:

    define @foo(i32 %v) {
      call void @llvm.foo(metadata !{i32 %v}, metadata !0)
      call void @llvm.foo(metadata !{i32 7}, metadata !0)
      call void @llvm.foo(metadata !1, metadata !0)
      call void @llvm.foo(metadata !3, metadata !0)
      call void @llvm.foo(metadata !{metadata !3}, metadata !0)
      ret void, !bar !2
    }
    !0 = metadata !{metadata !2}
    !1 = metadata !{i32* @global}
    !2 = metadata !{metadata !3}
    !3 = metadata !{}

turns into this:

    define @foo(i32 %v) {
      call void @llvm.foo(metadata i32 %v, metadata !0)
      call void @llvm.foo(metadata i32 7, metadata !0)
      call void @llvm.foo(metadata i32* @global, metadata !0)
      call void @llvm.foo(metadata !3, metadata !0)
      call void @llvm.foo(metadata !{!3}, metadata !0)
      ret void, !bar !2
    }
    !0 = !{!2}
    !1 = !{i32* @global}
    !2 = !{!3}
    !3 = !{}

I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines).  I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.

This is part of PR21532.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00

60 lines
2.3 KiB
LLVM

; RUN: opt -simplifycfg -S < %s | FileCheck %s
%0 = type { i32*, i32* }
@0 = external hidden constant [5 x %0], align 4
define void @foo(i32) nounwind ssp {
Entry:
%1 = icmp slt i32 %0, 0, !dbg !5
br i1 %1, label %BB5, label %BB1, !dbg !5
BB1: ; preds = %Entry
%2 = icmp sgt i32 %0, 4, !dbg !5
br i1 %2, label %BB5, label %BB2, !dbg !5
BB2: ; preds = %BB1
%3 = shl i32 1, %0, !dbg !5
%4 = and i32 %3, 31, !dbg !5
%5 = icmp eq i32 %4, 0, !dbg !5
br i1 %5, label %BB5, label %BB3, !dbg !5
;CHECK: icmp eq
;CHECK-NEXT: getelementptr
;CHECK-NEXT: icmp eq
BB3: ; preds = %BB2
%6 = getelementptr inbounds [5 x %0]* @0, i32 0, i32 %0, !dbg !6
call void @llvm.dbg.value(metadata %0* %6, i64 0, metadata !7, metadata !{}), !dbg !12
%7 = icmp eq %0* %6, null, !dbg !13
br i1 %7, label %BB5, label %BB4, !dbg !13
BB4: ; preds = %BB3
%8 = icmp slt i32 %0, 0, !dbg !5
ret void, !dbg !14
BB5: ; preds = %BB3, %BB2, %BB1, %Entry
ret void, !dbg !14
}
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
!llvm.dbg.sp = !{!0}
!0 = !{!"0x2e\00foo\00foo\00\00231\000\001\000\006\00256\000\000", !15, !1, !3, null, void (i32)* @foo, null, null, null} ; [ DW_TAG_subprogram ] [line 231] [def] [scope 0] [foo]
!1 = !{!"0x29", !15} ; [ DW_TAG_file_type ]
!2 = !{!"0x11\0012\00clang (trunk 129006)\001\00\000\00\000", !15, !4, !4, null, null, null} ; [ DW_TAG_compile_unit ]
!3 = !{!"0x15\00\000\000\000\000\000\000", !15, !1, null, !4, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!4 = !{null}
!5 = !{i32 131, i32 2, !0, null}
!6 = !{i32 134, i32 2, !0, null}
!7 = !{!"0x100\00bar\00232\000", !8, !1, !9} ; [ DW_TAG_auto_variable ]
!8 = !{!"0xb\00231\001\003", !15, !0} ; [ DW_TAG_lexical_block ]
!9 = !{!"0xf\00\000\0032\0032\000\000", null, !2, !10} ; [ DW_TAG_pointer_type ]
!10 = !{!"0x26\00\000\000\000\000\000", null, !2, !11} ; [ DW_TAG_const_type ]
!11 = !{!"0x24\00unsigned int\000\0032\0032\000\000\007", null, !2} ; [ DW_TAG_base_type ]
!12 = !{i32 232, i32 40, !8, null}
!13 = !{i32 234, i32 2, !8, null}
!14 = !{i32 274, i32 1, !8, null}
!15 = !{!"a.c", !"/private/tmp"}