1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -O3 -S | FileCheck %s
3 ; RUN: opt < %s -passes='default<O3>' -S | FileCheck %s
5 ; This is based on the following most basic C++ code:
44 ; There are no inttoptr casts in the original source code, nor should there be any in the optimized IR.
46 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
48 %0 = type { ptr, i32, i32, i32 }
50 define dso_local void @_Z3gen1S(ptr noalias sret(%0) align 8 %arg, ptr byval(%0) align 8 %arg1) {
51 ; CHECK-LABEL: @_Z3gen1S(
53 ; CHECK-NEXT: [[I2:%.*]] = load ptr, ptr [[ARG1:%.*]], align 8
54 ; CHECK-NEXT: store ptr [[I2]], ptr [[ARG:%.*]], align 8
55 ; CHECK-NEXT: ret void
58 %i2 = load ptr, ptr %arg1, align 8
59 store ptr %i2, ptr %arg, align 8
63 define dso_local ptr @_Z3foo1S(ptr byval(%0) align 8 %arg) {
64 ; CHECK-LABEL: @_Z3foo1S(
66 ; CHECK-NEXT: [[I2:%.*]] = alloca [[TMP0:%.*]], align 8
67 ; CHECK-NEXT: [[I1_SROA_0_0_COPYLOAD:%.*]] = load ptr, ptr [[ARG:%.*]], align 8
68 ; CHECK-NEXT: store ptr [[I1_SROA_0_0_COPYLOAD]], ptr [[I2]], align 8
69 ; CHECK-NEXT: tail call void @_Z7escape01S(ptr nonnull byval([[TMP0]]) align 8 [[I2]])
70 ; CHECK-NEXT: ret ptr [[I1_SROA_0_0_COPYLOAD]]
73 %i = alloca %0, align 8
74 %i1 = alloca %0, align 8
75 %i2 = alloca %0, align 8
76 call void @llvm.lifetime.start.p0(i64 24, ptr %i)
77 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %i1, ptr align 8 %arg, i64 24, i1 false)
78 call void @_Z3gen1S(ptr sret(%0) align 8 %i, ptr byval(%0) align 8 %i1)
79 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %i2, ptr align 8 %i, i64 24, i1 false)
80 call void @_Z7escape01S(ptr byval(%0) align 8 %i2)
81 %i9 = load ptr, ptr %i, align 8
82 call void @llvm.lifetime.end.p0(i64 24, ptr %i)
86 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
88 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)
90 declare dso_local void @_Z7escape01S(ptr byval(%0) align 8)
92 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
94 define dso_local ptr @_Z3bar1S(ptr byval(%0) align 8 %arg) {
95 ; CHECK-LABEL: @_Z3bar1S(
97 ; CHECK-NEXT: [[I1_SROA_0_0_COPYLOAD:%.*]] = load ptr, ptr [[ARG:%.*]], align 8
98 ; CHECK-NEXT: [[I5:%.*]] = tail call i32 @_Z4condv()
99 ; CHECK-NEXT: [[I6_NOT:%.*]] = icmp eq i32 [[I5]], 0
100 ; CHECK-NEXT: br i1 [[I6_NOT]], label [[BB10:%.*]], label [[BB7:%.*]]
102 ; CHECK-NEXT: tail call void @_Z5sync0v()
103 ; CHECK-NEXT: tail call void @_Z7escape0Pi(ptr [[I1_SROA_0_0_COPYLOAD]])
104 ; CHECK-NEXT: br label [[BB13:%.*]]
106 ; CHECK-NEXT: tail call void @_Z5sync1v()
107 ; CHECK-NEXT: tail call void @_Z7escape1Pi(ptr [[I1_SROA_0_0_COPYLOAD]])
108 ; CHECK-NEXT: br label [[BB13]]
110 ; CHECK-NEXT: ret ptr [[I1_SROA_0_0_COPYLOAD]]
113 %i = alloca %0, align 8
114 %i1 = alloca %0, align 8
115 call void @llvm.lifetime.start.p0(i64 24, ptr %i)
116 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %i1, ptr align 8 %arg, i64 24, i1 false)
117 call void @_Z3gen1S(ptr sret(%0) align 8 %i, ptr byval(%0) align 8 %i1)
118 %i5 = call i32 @_Z4condv()
119 %i6 = icmp ne i32 %i5, 0
120 br i1 %i6, label %bb7, label %bb10
123 call void @_Z5sync0v()
124 %i9 = load ptr, ptr %i, align 8
125 call void @_Z7escape0Pi(ptr %i9)
129 call void @_Z5sync1v()
130 %i12 = load ptr, ptr %i, align 8
131 call void @_Z7escape1Pi(ptr %i12)
135 %i15 = load ptr, ptr %i, align 8
136 call void @llvm.lifetime.end.p0(i64 24, ptr %i)
140 declare dso_local i32 @_Z4condv()
141 declare dso_local void @_Z5sync0v()
142 declare dso_local void @_Z7escape0Pi(ptr)
143 declare dso_local void @_Z5sync1v()
144 declare dso_local void @_Z7escape1Pi(ptr)