1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=dse -S | FileCheck %s
3 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=dse -S | FileCheck %s
5 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7 %struct.Village = type { [4 x ptr], ptr, %struct.List, %struct.Hosp, i32, i64 }
8 %struct.List = type { ptr, ptr, ptr }
9 %struct.Patient = type { i32, i32, i32, ptr }
10 %struct.Hosp = type { i32, i32, i32, %struct.List, %struct.List, %struct.List, %struct.List }
12 declare ptr @alloc(ptr)
14 define ptr @alloc_tree() {
15 ; CHECK-LABEL: @alloc_tree(
17 ; CHECK-NEXT: [[FVAL:%.*]] = alloca [4 x ptr], align 16
18 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 32, ptr nonnull [[FVAL]])
19 ; CHECK-NEXT: [[CALL:%.*]] = tail call dereferenceable_or_null(192) ptr @malloc(i64 192)
20 ; CHECK-NEXT: [[CALL3:%.*]] = tail call ptr @alloc(ptr [[CALL]])
21 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [4 x ptr], ptr [[FVAL]], i64 0, i64 3
22 ; CHECK-NEXT: store ptr [[CALL3]], ptr [[ARRAYIDX]], align 8
23 ; CHECK-NEXT: [[CALL3_1:%.*]] = tail call ptr @alloc(ptr [[CALL]])
24 ; CHECK-NEXT: [[ARRAYIDX_1:%.*]] = getelementptr inbounds [4 x ptr], ptr [[FVAL]], i64 0, i64 2
25 ; CHECK-NEXT: store ptr [[CALL3_1]], ptr [[ARRAYIDX_1]], align 16
26 ; CHECK-NEXT: [[CALL3_2:%.*]] = tail call ptr @alloc(ptr [[CALL]])
27 ; CHECK-NEXT: [[ARRAYIDX_2:%.*]] = getelementptr inbounds [4 x ptr], ptr [[FVAL]], i64 0, i64 1
28 ; CHECK-NEXT: store ptr [[CALL3_2]], ptr [[ARRAYIDX_2]], align 8
29 ; CHECK-NEXT: [[CALL3_3:%.*]] = tail call ptr @alloc(ptr [[CALL]])
30 ; CHECK-NEXT: store ptr [[CALL3_3]], ptr [[FVAL]], align 16
31 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(32) [[CALL]], ptr nonnull align 16 dereferenceable(32) [[FVAL]], i64 32, i1 false)
32 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 32, ptr nonnull [[FVAL]])
33 ; CHECK-NEXT: ret ptr [[CALL]]
36 %fval = alloca [4 x ptr], align 16
37 call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %fval) #7
38 %call = tail call dereferenceable_or_null(192) ptr @malloc(i64 192) #8
39 %call3 = tail call ptr @alloc(ptr %call)
40 %arrayidx = getelementptr inbounds [4 x ptr], ptr %fval, i64 0, i64 3
41 store ptr %call3, ptr %arrayidx, align 8
42 %call3.1 = tail call ptr @alloc(ptr %call)
43 %arrayidx.1 = getelementptr inbounds [4 x ptr], ptr %fval, i64 0, i64 2
44 store ptr %call3.1, ptr %arrayidx.1, align 16
45 %call3.2 = tail call ptr @alloc(ptr %call)
46 %arrayidx.2 = getelementptr inbounds [4 x ptr], ptr %fval, i64 0, i64 1
47 store ptr %call3.2, ptr %arrayidx.2, align 8
48 %call3.3 = tail call ptr @alloc(ptr %call)
49 store ptr %call3.3, ptr %fval, align 16
50 call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(32) %call, ptr nonnull align 16 dereferenceable(32) %fval, i64 32, i1 false)
51 call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %fval) #7
55 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
56 declare noalias ptr @malloc(i64)
57 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
58 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)