mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 17:11:44 +03:00
Refactor and fix intrinsics for variadic functions
I.e., va_start(), va_copy() and va_arg().
This commit is contained in:
parent
dfbb6c5b08
commit
82005009e7
9 changed files with 92 additions and 99 deletions
|
@ -971,13 +971,14 @@ void DtoDefineFunction(FuncDeclaration *fd) {
|
|||
// D varargs: prepare _argptr and _arguments
|
||||
if (f->linkage == LINKd && f->varargs == 1) {
|
||||
// allocate _argptr (of type core.stdc.stdarg.va_list)
|
||||
LLValue *argptrmem = DtoAlloca(
|
||||
Type::tvalist->semantic(fd->loc, fd->_scope), "_argptr_mem");
|
||||
irFunc->_argptr = argptrmem;
|
||||
Type *const argptrType = Type::tvalist->semantic(fd->loc, fd->_scope);
|
||||
LLValue *argptrMem = DtoAlloca(argptrType, "_argptr_mem");
|
||||
irFunc->_argptr = argptrMem;
|
||||
|
||||
// initialize _argptr with a call to the va_start intrinsic
|
||||
LLValue *vaStartArg = gABI->prepareVaStart(argptrmem);
|
||||
llvm::CallInst::Create(GET_INTRINSIC_DECL(vastart), vaStartArg, "",
|
||||
DLValue argptrVal(argptrType, argptrMem);
|
||||
LLValue *llAp = gABI->prepareVaStart(&argptrVal);
|
||||
llvm::CallInst::Create(GET_INTRINSIC_DECL(vastart), llAp, "",
|
||||
gIR->scopebb());
|
||||
|
||||
// copy _arguments to a memory location
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue