mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 09:00:33 +03:00
Fixed forward reference problem in struct methods on x86-64.
This commit is contained in:
parent
e61562033d
commit
740cdaa588
3 changed files with 27 additions and 0 deletions
|
@ -303,6 +303,16 @@ void DtoResolveFunction(FuncDeclaration* fdecl)
|
|||
return; // ignore declaration completely
|
||||
}
|
||||
|
||||
if (AggregateDeclaration* ad = fdecl->isMember())
|
||||
{
|
||||
ad->codegen(Type::sir);
|
||||
if (ad->isStructDeclaration() && llvm::isa<llvm::OpaqueType>(DtoType(ad->type)))
|
||||
{
|
||||
ad->ir.irStruct->structFuncs.push_back(fdecl);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//printf("resolve function: %s\n", fdecl->toPrettyChars());
|
||||
|
||||
if (fdecl->parent)
|
||||
|
@ -434,6 +444,8 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
|
|||
|
||||
void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||
{
|
||||
DtoResolveFunction(fdecl);
|
||||
|
||||
if (fdecl->ir.declared) return;
|
||||
fdecl->ir.declared = true;
|
||||
|
||||
|
@ -478,6 +490,9 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
|||
if (!func)
|
||||
func = llvm::Function::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module);
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "func = " << *func << std::endl;
|
||||
|
||||
// add func to IRFunc
|
||||
fdecl->ir.irFunc->func = func;
|
||||
|
||||
|
@ -594,6 +609,8 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
|||
|
||||
void DtoDefineFunction(FuncDeclaration* fd)
|
||||
{
|
||||
DtoDeclareFunction(fd);
|
||||
|
||||
if (fd->ir.defined) return;
|
||||
fd->ir.defined = true;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue