@@ -285,14 +285,19 @@ end
285285function execute_ir (N, n_outs, fn)
286286 ptr = sizeof (Int) == sizeof (Int64) ? " i64" : " i32"
287287 cint = sizeof (Cint) == sizeof (Int64) ? " i64" : " i32"
288- res = """ define { [$n_outs x $ptr ], [$n_outs x $ptr ], i8 } @f($ptr %exec, [$N x $ptr ] %inps, [$N x i8] %donated) alwaysinline {
288+ args = N > 0 ? " , [$N x $ptr ] %inps, [$N x i8] %donated" : " "
289+ stores = N > 0 ? """
290+ store [$N x $ptr ] %inps, [$N x $ptr ]* %inpa
291+ store [$N x i8] %donated, [$N x i8]* %dona
292+ """ : " "
293+
294+ res = """ define { [$n_outs x $ptr ], [$n_outs x $ptr ], i8 } @f($ptr %exec $args ) alwaysinline {
289295entry:
290296 %inpa = alloca [$N x $ptr ]
297+ %dona = alloca [$N x i8]
291298 %outa = alloca [$n_outs x $ptr ]
292299 %futpa = alloca [$n_outs x $ptr ]
293- store [$N x $ptr ] %inps, [$N x $ptr ]* %inpa
294- %dona = alloca [$N x i8]
295- store [$N x i8] %donated, [$N x i8]* %dona
300+ $stores
296301 %futa = alloca i8
297302 call void inttoptr ($ptr $fn to void ($ptr , $cint , [$N x $ptr ]*, [$N x i8]*, $cint , [$n_outs x $ptr ]*, i8*, [$n_outs x $ptr ]*)*)($ptr %exec, $cint $N , [$N x $ptr ]* nocapture readonly %inpa, [$N x i8]* nocapture readonly %dona, $cint $n_outs , [$n_outs x $ptr ]* nocapture writeonly %outa, i8* nocapture writeonly %futa, [$n_outs x $ptr ]* nocapture writeonly %futpa)
298303 %out = load [$n_outs x $ptr ], [$n_outs x $ptr ]* %outa
@@ -323,17 +328,19 @@ end
323328 :(AsyncBuffer (Buffer (outputs[$ i]), future ? Future (future_res[$ i]) : nothing )),
324329 )
325330 end
331+
332+ args_type = N > 0 ? (Ptr{Cvoid}, NTuple{N,Ptr{Cvoid}}, NTuple{N,UInt8}) : (Ptr{Cvoid},)
333+ args = N > 0 ? (:inputs , :donated_args ) : ()
326334 return quote
327335 Base. @_inline_meta
328336 exec = exec. exec
329337 GC. @preserve exec begin
330338 outputs, future_res, future = Base. llvmcall (
331339 ($ ir, " f" ),
332340 Tuple{NTuple{n_outs,Ptr{Cvoid}},NTuple{n_outs,Ptr{Cvoid}},Bool},
333- Tuple{Ptr{Cvoid},NTuple{N,Ptr{Cvoid}},NTuple{N,UInt8} },
341+ Tuple{$ args_type ... },
334342 exec,
335- inputs,
336- donated_args,
343+ $ (args... ),
337344 )
338345 end
339346 return ($ (results... ),)
0 commit comments