I ended up trying lots of stuff, checking llvm ir from different c programs with variadic functions, clever chat gpt prompts and managed to fix the issue by appenind , i32 128
at the %.va_list
:
The working println
function code is:
define void @println(i8* %a, ...) {
entry:
%.va_list = alloca i8, i32 128 ; here is the appended alignment
call void @llvm.va_start(i8* %.va_list)
call void @vprintf(i8* %a, i8* %.va_list)
call void @printf(i8* @.str_3)
call void @llvm.va_end(i8* %.va_list)
ret void
}
ChatGPT thread that helped me: https://chatgpt.com/share/6738f7c5-3994-800e-90ab-5af879464fa8