Skip to content

Commit fe00905

Browse files
committed
fix valist_size
1 parent 2b0e7b5 commit fe00905

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/device/intrinsics/output.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ end
5050
end
5151
end
5252

53+
function valist_size(dl, param_types)
54+
size = 0
55+
for pty in param_types
56+
ps = sizeof(dl, pty)
57+
if size % ps == 0
58+
size += ps
59+
else
60+
size += (size % ps) + ps
61+
end
62+
end
63+
64+
return size
65+
end
5366

5467
"""
5568
@mtlprintf("%Fmt", args...)
@@ -99,9 +112,8 @@ end
99112
log_type = LLVM.ConstantInt(T_int32, __METAL_OS_LOG_TYPE_DEBUG__)
100113

101114
# compute argsize
102-
argtypes = LLVM.StructType(param_types)
103-
dl = datalayout(mod)
104-
arg_size = LLVM.ConstantInt(T_int64, sizeof(dl, argtypes))
115+
dl = datalayout(mod)
116+
arg_size = LLVM.ConstantInt(T_int64, valist_size(dl, param_types))
105117

106118
alloc = alloca!(builder, T_pint8)
107119
buffer = bitcast!(builder, alloc, T_pint8)

0 commit comments

Comments
 (0)