1 ; RUN: opt -S -passes=hipstdpar-interpose-alloc %s | FileCheck %s
3 %"struct.std::nothrow_t" = type { i8 }
5 @_ZSt7nothrow = external global %"struct.std::nothrow_t", align 1
7 declare ptr @__hipstdpar_aligned_alloc(i64, i64)
9 declare ptr @__hipstdpar_malloc(i64)
11 declare ptr @__hipstdpar_calloc(i64, i64)
13 declare i32 @__hipstdpar_posix_aligned_alloc(ptr, i64, i64)
15 declare void @__hipstdpar_hidden_free(ptr)
17 declare ptr @__hipstdpar_realloc(ptr, i64)
19 declare ptr @__hipstdpar_realloc_array(ptr, i64, i64)
21 declare void @__hipstdpar_free(ptr)
23 declare ptr @__hipstdpar_operator_new_aligned(i64, i64)
25 declare ptr @__hipstdpar_operator_new(i64)
27 declare ptr @__hipstdpar_operator_new_nothrow(i64, %"struct.std::nothrow_t")
29 declare ptr @__hipstdpar_operator_new_aligned_nothrow(i64, i64, %"struct.std::nothrow_t")
31 declare void @__hipstdpar_operator_delete_aligned_sized(ptr, i64, i64)
33 declare void @__hipstdpar_operator_delete(ptr)
35 declare void @__hipstdpar_operator_delete_aligned(ptr, i64)
37 declare void @__hipstdpar_operator_delete_sized(ptr, i64)
39 define dso_local noundef i32 @allocs() {
40 ; CHECK: %1 = call noalias align 8 ptr @__hipstdpar_aligned_alloc(i64 noundef 8, i64 noundef 42)
41 %1 = call noalias align 8 ptr @aligned_alloc(i64 noundef 8, i64 noundef 42)
42 ; CHECK: call void @__hipstdpar_free(ptr noundef %1)
43 call void @free(ptr noundef %1)
45 ; CHECK: %2 = call noalias ptr @__hipstdpar_calloc(i64 noundef 1, i64 noundef 42)
46 %2 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 42)
47 ; CHECK: call void @__hipstdpar_free(ptr noundef %2)
48 call void @free(ptr noundef %2)
50 ; CHECK: %3 = call noalias ptr @__hipstdpar_malloc(i64 noundef 42)
51 %3 = call noalias ptr @malloc(i64 noundef 42)
52 ; CHECK: call void @__hipstdpar_free(ptr noundef %3)
53 call void @free(ptr noundef %3)
55 ; CHECK: %4 = call noalias align 8 ptr @__hipstdpar_aligned_alloc(i64 noundef 8, i64 noundef 42)
56 %4 = call noalias align 8 ptr @memalign(i64 noundef 8, i64 noundef 42)
57 ; CHECK: call void @__hipstdpar_free(ptr noundef %4)
58 call void @free(ptr noundef %4)
60 %tmp = alloca ptr, align 8
61 ; CHECK: %5 = call i32 @__hipstdpar_posix_aligned_alloc(ptr noundef %tmp, i64 noundef 8, i64 noundef 42)
62 %5 = call i32 @posix_memalign(ptr noundef %tmp, i64 noundef 8, i64 noundef 42)
63 ; CHECK: call void @__hipstdpar_free(ptr noundef %tmp)
64 call void @free(ptr noundef %tmp)
66 ; CHECK: %6 = call noalias ptr @__hipstdpar_malloc(i64 noundef 42)
67 %6 = call noalias ptr @malloc(i64 noundef 42)
68 ; CHECK: %7 = call ptr @__hipstdpar_realloc(ptr noundef %6, i64 noundef 42)
69 %7 = call ptr @realloc(ptr noundef %6, i64 noundef 42)
70 ; CHECK: call void @__hipstdpar_free(ptr noundef %7)
71 call void @free(ptr noundef %7)
73 ; CHECK: %8 = call noalias ptr @__hipstdpar_calloc(i64 noundef 1, i64 noundef 42)
74 %8 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 42)
75 ; CHECK: %9 = call ptr @__hipstdpar_realloc_array(ptr noundef %8, i64 noundef 1, i64 noundef 42)
76 %9 = call ptr @reallocarray(ptr noundef %8, i64 noundef 1, i64 noundef 42)
77 ; CHECK: call void @__hipstdpar_free(ptr noundef %9)
78 call void @free(ptr noundef %9)
80 ; CHECK: %10 = call noalias noundef nonnull ptr @__hipstdpar_operator_new(i64 noundef 1)
81 %10 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 1)
82 ; CHECK: call void @__hipstdpar_operator_delete(ptr noundef %10)
83 call void @_ZdlPv(ptr noundef %10)
85 ; CHECK: %11 = call noalias noundef nonnull align 8 ptr @__hipstdpar_operator_new_aligned(i64 noundef 1, i64 noundef 8)
86 %11 = call noalias noundef nonnull align 8 ptr @_ZnwmSt11align_val_t(i64 noundef 1, i64 noundef 8)
87 ; CHECK: call void @__hipstdpar_operator_delete_aligned(ptr noundef %11, i64 noundef 8)
88 call void @_ZdlPvSt11align_val_t(ptr noundef %11, i64 noundef 8)
90 ; CHECK: %12 = call noalias noundef ptr @__hipstdpar_operator_new_nothrow(i64 noundef 1, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
91 %12 = call noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 noundef 1, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
92 ; CHECK: call void @__hipstdpar_operator_delete(ptr noundef %12)
93 call void @_ZdlPv(ptr noundef %12)
95 ; CHECK: %13 = call noalias noundef align 8 ptr @__hipstdpar_operator_new_aligned_nothrow(i64 noundef 1, i64 noundef 8, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
96 %13 = call noalias noundef align 8 ptr @_ZnwmSt11align_val_tRKSt9nothrow_t(i64 noundef 1, i64 noundef 8, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
97 ; CHECK: call void @__hipstdpar_operator_delete_aligned(ptr noundef %13, i64 noundef 8)
98 call void @_ZdlPvSt11align_val_t(ptr noundef %13, i64 noundef 8)
100 ; CHECK: %14 = call noalias noundef nonnull ptr @__hipstdpar_operator_new(i64 noundef 42)
101 %14 = call noalias noundef nonnull ptr @_Znam(i64 noundef 42)
102 ; CHECK: call void @__hipstdpar_operator_delete(ptr noundef %14)
103 call void @_ZdaPv(ptr noundef %14)
105 ; CHECK: %15 = call noalias noundef nonnull align 8 ptr @__hipstdpar_operator_new_aligned(i64 noundef 42, i64 noundef 8)
106 %15 = call noalias noundef nonnull align 8 ptr @_ZnamSt11align_val_t(i64 noundef 42, i64 noundef 8)
107 ; CHECK: call void @__hipstdpar_operator_delete_aligned(ptr noundef %15, i64 noundef 8)
108 call void @_ZdaPvSt11align_val_t(ptr noundef %15, i64 noundef 8)
110 ; CHECK: %16 = call noalias noundef ptr @__hipstdpar_operator_new_nothrow(i64 noundef 42, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
111 %16 = call noalias noundef ptr @_ZnamRKSt9nothrow_t(i64 noundef 42, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
112 ; CHECK: call void @__hipstdpar_operator_delete(ptr noundef %16)
113 call void @_ZdaPv(ptr noundef %16)
115 ; CHECK: %17 = call noalias noundef align 8 ptr @__hipstdpar_operator_new_aligned_nothrow(i64 noundef 42, i64 noundef 8, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
116 %17 = call noalias noundef align 8 ptr @_ZnamSt11align_val_tRKSt9nothrow_t(i64 noundef 42, i64 noundef 8, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
117 ; CHECK: call void @__hipstdpar_operator_delete_aligned(ptr noundef %17, i64 noundef 8)
118 call void @_ZdaPvSt11align_val_t(ptr noundef %17, i64 noundef 8)
120 ; CHECK: %18 = call ptr @__hipstdpar_calloc(i64 noundef 1, i64 noundef 42)
121 %18 = call ptr @calloc(i64 noundef 1, i64 noundef 42)
122 ; CHECK: call void @__hipstdpar_free(ptr noundef %18)
123 call void @free(ptr noundef %18)
125 ; CHECK: %19 = call ptr @__hipstdpar_malloc(i64 noundef 42)
126 %19 = call ptr @malloc(i64 noundef 42)
127 ; CHECK: call void @__hipstdpar_free(ptr noundef %19)
128 call void @free(ptr noundef %19)
130 ; CHECK: %20 = call noalias noundef nonnull ptr @__hipstdpar_operator_new(i64 noundef 42)
131 %20 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 42)
132 ; CHECK: call void @__hipstdpar_operator_delete(ptr noundef %20)
133 call void @_ZdlPv(ptr noundef %20)
135 ; CHECK: %21 = call noalias noundef nonnull align 8 ptr @__hipstdpar_operator_new_aligned(i64 noundef 42, i64 noundef 8)
136 %21 = call noalias noundef nonnull align 8 ptr @_ZnwmSt11align_val_t(i64 noundef 42, i64 noundef 8)
137 ; CHECK: call void @__hipstdpar_operator_delete_aligned(ptr noundef %21, i64 noundef 8)
138 call void @_ZdlPvSt11align_val_t(ptr noundef %21, i64 noundef 8)
140 ; CHECK: %22 = call noalias noundef ptr @__hipstdpar_operator_new_nothrow(i64 noundef 42, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
141 %22 = call noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 noundef 42, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
142 ; CHECK: call void @__hipstdpar_operator_delete(ptr noundef %22)
143 call void @_ZdlPv(ptr noundef %22)
145 ; CHECK: %23 = call noalias noundef align 8 ptr @__hipstdpar_operator_new_aligned_nothrow(i64 noundef 42, i64 noundef 8, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
146 %23 = call noalias noundef align 8 ptr @_ZnwmSt11align_val_tRKSt9nothrow_t(i64 noundef 42, i64 noundef 8, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow)
147 ; CHECK: call void @__hipstdpar_operator_delete_aligned(ptr noundef %23, i64 noundef 8)
148 call void @_ZdlPvSt11align_val_t(ptr noundef %23, i64 noundef 8)
150 ; CHECK: %24 = call ptr @__hipstdpar_malloc(i64 noundef 42)
151 %24 = call ptr @malloc(i64 noundef 42)
152 ; CHECK: %25 = call ptr @__hipstdpar_realloc(ptr noundef %24, i64 noundef 41)
153 %25 = call ptr @realloc(ptr noundef %24, i64 noundef 41)
154 ; CHECK: call void @__hipstdpar_free(ptr noundef %25)
155 call void @free(ptr noundef %25)
157 ; CHECK: %26 = call ptr @__hipstdpar_calloc(i64 noundef 1, i64 noundef 42)
158 %26 = call ptr @__libc_calloc(i64 noundef 1, i64 noundef 42)
159 ; CHECK: call void @__hipstdpar_free(ptr noundef %26)
160 call void @__libc_free(ptr noundef %26)
162 ; CHECK: %27 = call ptr @__hipstdpar_malloc(i64 noundef 42)
163 %27 = call ptr @__libc_malloc(i64 noundef 42)
164 ; CHECK: call void @__hipstdpar_free(ptr noundef %27)
165 call void @__libc_free(ptr noundef %27)
167 ; CHECK: %28 = call ptr @__hipstdpar_aligned_alloc(i64 noundef 8, i64 noundef 42)
168 %28 = call ptr @__libc_memalign(i64 noundef 8, i64 noundef 42)
169 ; CHECK: call void @__hipstdpar_free(ptr noundef %28)
170 call void @__libc_free(ptr noundef %28)
175 declare noalias ptr @aligned_alloc(i64 noundef, i64 noundef)
177 declare void @free(ptr noundef)
179 declare noalias ptr @calloc(i64 noundef, i64 noundef)
181 declare noalias ptr @malloc(i64 noundef)
183 declare noalias ptr @memalign(i64 noundef, i64 noundef)
185 declare i32 @posix_memalign(ptr noundef, i64 noundef, i64 noundef)
187 declare ptr @realloc(ptr noundef, i64 noundef)
189 declare ptr @reallocarray(ptr noundef, i64 noundef, i64 noundef)
191 declare noundef nonnull ptr @_Znwm(i64 noundef)
193 declare void @_ZdlPv(ptr noundef)
195 declare noalias noundef nonnull ptr @_ZnwmSt11align_val_t(i64 noundef, i64 noundef)
197 declare void @_ZdlPvSt11align_val_t(ptr noundef, i64 noundef)
199 declare noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1))
201 declare noalias noundef ptr @_ZnwmSt11align_val_tRKSt9nothrow_t(i64 noundef, i64 noundef, ptr noundef nonnull align 1 dereferenceable(1))
203 declare noundef nonnull ptr @_Znam(i64 noundef)
205 declare void @_ZdaPv(ptr noundef)
207 declare noalias noundef nonnull ptr @_ZnamSt11align_val_t(i64 noundef, i64 noundef)
209 declare void @_ZdaPvSt11align_val_t(ptr noundef, i64 noundef)
211 declare noalias noundef ptr @_ZnamRKSt9nothrow_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1))
213 declare noalias noundef ptr @_ZnamSt11align_val_tRKSt9nothrow_t(i64 noundef, i64 noundef, ptr noundef nonnull align 1 dereferenceable(1))
215 declare ptr @__libc_calloc(i64 noundef, i64 noundef)
217 declare void @__libc_free(ptr noundef)
219 declare ptr @__libc_malloc(i64 noundef)
221 declare ptr @__libc_memalign(i64 noundef, i64 noundef)