brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 6e28811 Raw
88 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=memcpyopt -S -verify-memoryssa | FileCheck %s3 4target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"5target triple = "x86_64-apple-macosx10.8.0"6 7%struct.foo = type { i8, [7 x i8], i32 }8 9; Check that the memcpy is removed.10define i32 @test1(ptr nocapture %foobie) nounwind noinline ssp uwtable {11; CHECK-LABEL: @test1(12; CHECK-NEXT:    [[BLETCH_SROA_1:%.*]] = alloca [7 x i8], align 113; CHECK-NEXT:    store i8 98, ptr [[FOOBIE:%.*]], align 414; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr inbounds [[STRUCT_FOO:%.*]], ptr [[FOOBIE]], i64 0, i32 1, i64 015; CHECK-NEXT:    [[TMP2:%.*]] = getelementptr inbounds [[STRUCT_FOO]], ptr [[FOOBIE]], i64 0, i32 216; CHECK-NEXT:    store i32 20, ptr [[TMP2]], align 417; CHECK-NEXT:    ret i32 undef18;19  %bletch.sroa.1 = alloca [7 x i8], align 120  store i8 98, ptr %foobie, align 421  %1 = getelementptr inbounds %struct.foo, ptr %foobie, i64 0, i32 1, i64 022  call void @llvm.memcpy.p0.p0.i64(ptr %1, ptr %bletch.sroa.1, i64 7, i1 false)23  %2 = getelementptr inbounds %struct.foo, ptr %foobie, i64 0, i32 224  store i32 20, ptr %2, align 425  ret i32 undef26}27 28; Check that the memcpy is removed.29define void @test2(ptr sret(i8) noalias nocapture %out) nounwind noinline ssp uwtable {30; CHECK-LABEL: @test2(31; CHECK-NEXT:    [[IN:%.*]] = alloca i64, align 832; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr [[IN]])33; CHECK-NEXT:    ret void34;35  %in = alloca i6436  call void @llvm.lifetime.start.p0(ptr %in)37  call void @llvm.memcpy.p0.p0.i64(ptr %out, ptr %in, i64 8, i1 false)38  ret void39}40 41; Check that the memcpy is not removed.42define void @test_lifetime_may_alias(ptr %src, ptr %dst) {43; CHECK-LABEL: @test_lifetime_may_alias(44; CHECK-NEXT:    [[LIFETIME:%.*]] = alloca i64, align 845; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr [[LIFETIME]])46; CHECK-NEXT:    call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 8, i1 false)47; CHECK-NEXT:    ret void48;49  %lifetime = alloca i6450  call void @llvm.lifetime.start.p0(ptr %lifetime)51  call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 8, i1 false)52  ret void53}54 55; lifetime.start on full alloca size, copy in range.56define void @test_lifetime_partial_alias_1(ptr noalias %dst) {57; CHECK-LABEL: @test_lifetime_partial_alias_1(58; CHECK-NEXT:    [[A:%.*]] = alloca [16 x i8], align 159; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr [[A]])60; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 861; CHECK-NEXT:    ret void62;63  %a = alloca [16 x i8]64  call void @llvm.lifetime.start.p0(ptr %a)65  %gep = getelementptr i8, ptr %a, i64 866  call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %gep, i64 8, i1 false)67  ret void68}69 70; lifetime.start on full alloca size, copy out of range.71define void @test_lifetime_partial_alias_2(ptr noalias %dst) {72; CHECK-LABEL: @test_lifetime_partial_alias_2(73; CHECK-NEXT:    [[A:%.*]] = alloca [16 x i8], align 174; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr [[A]])75; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[A]], i64 876; CHECK-NEXT:    ret void77;78  %a = alloca [16 x i8]79  call void @llvm.lifetime.start.p0(ptr %a)80  %gep = getelementptr i8, ptr %a, i64 881  call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %gep, i64 16, i1 false)82  ret void83}84 85declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind86 87declare void @llvm.lifetime.start.p0(ptr nocapture) nounwind88