mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-23 23:23:13 +01:00
Finally fix the _d_invariant declaration on x86.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "gen/logger.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "ir/irtype.h"
|
||||
#include "ir/irtypefunction.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
@@ -94,6 +95,7 @@ llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name
|
||||
LLFunctionType* fnty = fn->getFunctionType();
|
||||
LLFunction* resfn = llvm::cast<llvm::Function>(target->getOrInsertFunction(name, fnty));
|
||||
resfn->setAttributes(fn->getAttributes());
|
||||
resfn->setCallingConv(fn->getCallingConv());
|
||||
return resfn;
|
||||
}
|
||||
|
||||
@@ -902,10 +904,23 @@ static void LLVM_D_BuildRuntimeModule()
|
||||
|
||||
// void invariant._d_invariant(Object o)
|
||||
{
|
||||
// KLUDGE: _d_invariant is actually extern(D) in the upstream runtime, possibly
|
||||
// for more efficient parameter passing on x86. This complicates our code here
|
||||
// quite a bit, though.
|
||||
llvm::StringRef fname("_D9invariant12_d_invariantFC6ObjectZv");
|
||||
LLType *types[] = { objectTy };
|
||||
LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false);
|
||||
llvm::Function* fn = llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M);
|
||||
Parameters* params = new Parameters();
|
||||
params->push(new Parameter(STCin, ClassDeclaration::object->type, NULL, NULL));
|
||||
TypeFunction* dty = new TypeFunction(params, Type::tvoid, 0, LINKd);
|
||||
llvm::Function* fn = llvm::Function::Create(llvm::cast<llvm::FunctionType>(DtoType(dty)),
|
||||
llvm::GlobalValue::ExternalLinkage, fname, M);
|
||||
gABI->newFunctionType(dty);
|
||||
gABI->rewriteFunctionType(dty);
|
||||
gABI->doneWithFunctionType();
|
||||
#if LDC_LLVM_VER < 303
|
||||
fn->addAttribute(1, dty->fty.args[0]->attrs);
|
||||
#else
|
||||
fn->addAttributes(1, llvm::AttributeSet::get(gIR->context(), 1, dty->fty.args[0]->attrs));
|
||||
#endif
|
||||
fn->setCallingConv(gABI->callingConv(LINKd));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user