]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/MemCpyOpt/merge-into-memset.ll
Vendor import of llvm trunk r321414:
[FreeBSD/FreeBSD.git] / test / Transforms / MemCpyOpt / merge-into-memset.ll
1 ; RUN: opt < %s -memcpyopt -S | FileCheck %s
2 ; Update cached non-local dependence information when merging stores into memset.
3
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5
6 ; Don't delete the memcpy in %if.then, even though it depends on an instruction
7 ; which will be deleted.
8
9 ; CHECK-LABEL: @foo
10 define void @foo(i1 %c, i8* %d, i8* %e, i8* %f) {
11 entry:
12   %tmp = alloca [50 x i8], align 8
13   %tmp4 = bitcast [50 x i8]* %tmp to i8*
14   %tmp1 = getelementptr inbounds i8, i8* %tmp4, i64 1
15   call void @llvm.memset.p0i8.i64(i8* nonnull %d, i8 0, i64 10, i32 1, i1 false), !dbg !5
16   store i8 0, i8* %tmp4, align 8, !dbg !5
17 ; CHECK: call void @llvm.memset.p0i8.i64(i8* nonnull %d, i8 0, i64 10, i32 1, i1 false), !dbg !5
18   call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull %tmp1, i8* nonnull %d, i64 10, i32 1, i1 false)
19   br i1 %c, label %if.then, label %exit
20
21 if.then:
22 ; CHECK: if.then:
23 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %f, i8* nonnull %tmp4, i64 30, i32 8, i1 false)
24   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %f, i8* nonnull %tmp4, i64 30, i32 8, i1 false)
25   br label %exit
26
27 exit:
28   ret void
29 }
30
31 declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1)
32 declare void @llvm.memset.p0i8.i64(i8*, i8, i64, i32, i1)
33
34 !llvm.dbg.cu = !{!0}
35 !llvm.module.flags = !{!3, !4}
36
37 !0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
38 !1 = !DIFile(filename: "t.rs", directory: "/tmp")
39 !2 = !{}
40 !3 = !{i32 2, !"Dwarf Version", i32 4}
41 !4 = !{i32 2, !"Debug Info Version", i32 3}
42 !5 = !DILocation(line: 8, column: 5, scope: !6)
43 !6 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 5, type: !7, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
44 !7 = !DISubroutineType(types: !8)
45 !8 = !{null}