mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-12 05:47:11 +03:00
Merge branch 'master' into merge-2.067
This commit is contained in:
commit
4b6bd7ab52
13 changed files with 26 additions and 105 deletions
|
@ -61,7 +61,6 @@ env:
|
||||||
- LLVM_PACKAGE="llvm-3.7 llvm-3.7-dev libedit2 libedit-dev"
|
- LLVM_PACKAGE="llvm-3.7 llvm-3.7-dev libedit2 libedit-dev"
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- env: LLVM_PACKAGE="llvm-3.6 llvm-3.6-dev libedit2 libedit-dev" OPTS="-DMULTILIB=ON" TEST_BITNESS=32
|
|
||||||
- env: LLVM_PACKAGE="llvm-3.7 llvm-3.7-dev libedit2 libedit-dev" TEST_DEBUG=1
|
- env: LLVM_PACKAGE="llvm-3.7 llvm-3.7-dev libedit2 libedit-dev" TEST_DEBUG=1
|
||||||
- env: LLVM_PACKAGE="llvm-3.7 llvm-3.7-dev libedit2 libedit-dev"
|
- env: LLVM_PACKAGE="llvm-3.7 llvm-3.7-dev libedit2 libedit-dev"
|
||||||
script:
|
script:
|
||||||
|
|
|
@ -28,22 +28,6 @@ struct MIPS64TargetABI : TargetABI {
|
||||||
MIPS64TargetABI(const bool Is64Bit) : Is64Bit(Is64Bit)
|
MIPS64TargetABI(const bool Is64Bit) : Is64Bit(Is64Bit)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
llvm::CallingConv::ID callingConv(LINK l)
|
|
||||||
{
|
|
||||||
switch (l)
|
|
||||||
{
|
|
||||||
case LINKc:
|
|
||||||
case LINKcpp:
|
|
||||||
case LINKpascal:
|
|
||||||
case LINKwindows:
|
|
||||||
case LINKd:
|
|
||||||
case LINKdefault:
|
|
||||||
return llvm::CallingConv::C;
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unhandled D linkage type.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool returnInArg(TypeFunction* tf)
|
bool returnInArg(TypeFunction* tf)
|
||||||
{
|
{
|
||||||
if (tf->isref)
|
if (tf->isref)
|
||||||
|
|
|
@ -28,22 +28,6 @@ struct PPC64TargetABI : TargetABI {
|
||||||
PPC64TargetABI(const bool Is64Bit) : Is64Bit(Is64Bit)
|
PPC64TargetABI(const bool Is64Bit) : Is64Bit(Is64Bit)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
llvm::CallingConv::ID callingConv(LINK l)
|
|
||||||
{
|
|
||||||
switch (l)
|
|
||||||
{
|
|
||||||
case LINKc:
|
|
||||||
case LINKcpp:
|
|
||||||
case LINKpascal:
|
|
||||||
case LINKwindows:
|
|
||||||
case LINKd:
|
|
||||||
case LINKdefault:
|
|
||||||
return llvm::CallingConv::C;
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unhandled D linkage type.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool returnInArg(TypeFunction* tf)
|
bool returnInArg(TypeFunction* tf)
|
||||||
{
|
{
|
||||||
if (tf->isref)
|
if (tf->isref)
|
||||||
|
|
|
@ -36,8 +36,6 @@ struct Win64TargetABI : TargetABI
|
||||||
ExplicitByvalRewrite byvalRewrite;
|
ExplicitByvalRewrite byvalRewrite;
|
||||||
IntegerRewrite integerRewrite;
|
IntegerRewrite integerRewrite;
|
||||||
|
|
||||||
llvm::CallingConv::ID callingConv(LINK l);
|
|
||||||
|
|
||||||
bool returnInArg(TypeFunction* tf);
|
bool returnInArg(TypeFunction* tf);
|
||||||
|
|
||||||
bool passByVal(Type* t);
|
bool passByVal(Type* t);
|
||||||
|
@ -95,23 +93,6 @@ TargetABI* getWin64TargetABI()
|
||||||
return new Win64TargetABI;
|
return new Win64TargetABI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
llvm::CallingConv::ID Win64TargetABI::callingConv(LINK l)
|
|
||||||
{
|
|
||||||
switch (l)
|
|
||||||
{
|
|
||||||
case LINKc:
|
|
||||||
case LINKcpp:
|
|
||||||
case LINKpascal:
|
|
||||||
case LINKd:
|
|
||||||
case LINKdefault:
|
|
||||||
case LINKwindows:
|
|
||||||
return llvm::CallingConv::C;
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unhandled D linkage type.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Win64TargetABI::returnInArg(TypeFunction* tf)
|
bool Win64TargetABI::returnInArg(TypeFunction* tf)
|
||||||
{
|
{
|
||||||
if (tf->isref)
|
if (tf->isref)
|
||||||
|
|
|
@ -219,8 +219,6 @@ struct X86_64TargetABI : TargetABI {
|
||||||
X86_64_C_struct_rewrite struct_rewrite;
|
X86_64_C_struct_rewrite struct_rewrite;
|
||||||
ImplicitByvalRewrite byvalRewrite;
|
ImplicitByvalRewrite byvalRewrite;
|
||||||
|
|
||||||
llvm::CallingConv::ID callingConv(LINK l);
|
|
||||||
|
|
||||||
bool returnInArg(TypeFunction* tf);
|
bool returnInArg(TypeFunction* tf);
|
||||||
|
|
||||||
bool passByVal(Type* t);
|
bool passByVal(Type* t);
|
||||||
|
@ -249,21 +247,6 @@ TargetABI* getX86_64TargetABI() {
|
||||||
return new X86_64TargetABI;
|
return new X86_64TargetABI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
llvm::CallingConv::ID X86_64TargetABI::callingConv(LINK l) {
|
|
||||||
switch (l) {
|
|
||||||
case LINKc:
|
|
||||||
case LINKcpp:
|
|
||||||
case LINKpascal:
|
|
||||||
case LINKwindows: // Doesn't really make sense, user should use Win64 target.
|
|
||||||
case LINKd:
|
|
||||||
case LINKdefault:
|
|
||||||
return llvm::CallingConv::C;
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unhandled D linkage type.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool X86_64TargetABI::returnInArg(TypeFunction* tf) {
|
bool X86_64TargetABI::returnInArg(TypeFunction* tf) {
|
||||||
if (tf->isref)
|
if (tf->isref)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -24,7 +24,7 @@ struct X86TargetABI : TargetABI
|
||||||
{
|
{
|
||||||
IntegerRewrite integerRewrite;
|
IntegerRewrite integerRewrite;
|
||||||
|
|
||||||
llvm::CallingConv::ID callingConv(LINK l)
|
llvm::CallingConv::ID callingConv(llvm::FunctionType* ft, LINK l)
|
||||||
{
|
{
|
||||||
switch (l)
|
switch (l)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ struct X86TargetABI : TargetABI
|
||||||
case LINKdefault:
|
case LINKdefault:
|
||||||
case LINKpascal:
|
case LINKpascal:
|
||||||
case LINKwindows:
|
case LINKwindows:
|
||||||
return llvm::CallingConv::X86_StdCall;
|
return ft->isVarArg() ? llvm::CallingConv::C : llvm::CallingConv::X86_StdCall;
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("Unhandled D linkage type.");
|
llvm_unreachable("Unhandled D linkage type.");
|
||||||
}
|
}
|
||||||
|
|
22
gen/abi.cpp
22
gen/abi.cpp
|
@ -152,23 +152,6 @@ Type* TargetABI::vaListType()
|
||||||
// Some reasonable defaults for when we don't know what ABI to use.
|
// Some reasonable defaults for when we don't know what ABI to use.
|
||||||
struct UnknownTargetABI : TargetABI
|
struct UnknownTargetABI : TargetABI
|
||||||
{
|
{
|
||||||
llvm::CallingConv::ID callingConv(LINK l)
|
|
||||||
{
|
|
||||||
switch (l)
|
|
||||||
{
|
|
||||||
case LINKc:
|
|
||||||
case LINKcpp:
|
|
||||||
case LINKpascal:
|
|
||||||
case LINKwindows:
|
|
||||||
return llvm::CallingConv::C;
|
|
||||||
case LINKd:
|
|
||||||
case LINKdefault:
|
|
||||||
return llvm::CallingConv::Fast;
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unhandled D linkage type.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool returnInArg(TypeFunction* tf)
|
bool returnInArg(TypeFunction* tf)
|
||||||
{
|
{
|
||||||
if (tf->isref)
|
if (tf->isref)
|
||||||
|
@ -240,11 +223,6 @@ struct IntrinsicABI : TargetABI
|
||||||
{
|
{
|
||||||
RemoveStructPadding remove_padding;
|
RemoveStructPadding remove_padding;
|
||||||
|
|
||||||
llvm::CallingConv::ID callingConv(LINK l)
|
|
||||||
{
|
|
||||||
return llvm::CallingConv::C;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool returnInArg(TypeFunction* tf)
|
bool returnInArg(TypeFunction* tf)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace llvm
|
||||||
{
|
{
|
||||||
class Type;
|
class Type;
|
||||||
class Value;
|
class Value;
|
||||||
|
class FunctionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return rewrite rule
|
// return rewrite rule
|
||||||
|
@ -87,8 +88,11 @@ struct TargetABI
|
||||||
static TargetABI* getIntrinsic();
|
static TargetABI* getIntrinsic();
|
||||||
|
|
||||||
/// Returns the LLVM calling convention to be used for the given D linkage
|
/// Returns the LLVM calling convention to be used for the given D linkage
|
||||||
/// type on the target.
|
/// type on the target. Defaults to the C calling convention.
|
||||||
virtual llvm::CallingConv::ID callingConv(LINK l) = 0;
|
virtual llvm::CallingConv::ID callingConv(llvm::FunctionType* ft, LINK l)
|
||||||
|
{
|
||||||
|
return llvm::CallingConv::C;
|
||||||
|
}
|
||||||
|
|
||||||
/// Applies any rewrites that might be required to accurately reproduce the
|
/// Applies any rewrites that might be required to accurately reproduce the
|
||||||
/// passed function name on LLVM given a specific calling convention.
|
/// passed function name on LLVM given a specific calling convention.
|
||||||
|
|
|
@ -839,7 +839,12 @@ void ldc::DIBuilder::EmitStopPoint(Loc& loc)
|
||||||
// If we already have a location set and the current loc is invalid
|
// If we already have a location set and the current loc is invalid
|
||||||
// (line 0), then we can just ignore it (see GitHub issue #998 for why we
|
// (line 0), then we can just ignore it (see GitHub issue #998 for why we
|
||||||
// cannot do this in all cases).
|
// cannot do this in all cases).
|
||||||
if (!loc.linnum && !IR->ir->getCurrentDebugLocation().isUnknown())
|
if (!loc.linnum &&
|
||||||
|
!IR->ir->getCurrentDebugLocation()
|
||||||
|
#if LDC_LLVM_VER < 307
|
||||||
|
.isUnknown()
|
||||||
|
#endif
|
||||||
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Logger::println("D to dwarf stoppoint at line %u, column %u", loc.linnum, loc.charnum);
|
Logger::println("D to dwarf stoppoint at line %u, column %u", loc.linnum, loc.charnum);
|
||||||
|
|
|
@ -501,7 +501,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||||
fatal();
|
fatal();
|
||||||
}
|
}
|
||||||
|
|
||||||
func->setCallingConv(gABI->callingConv(link));
|
func->setCallingConv(gABI->callingConv(func->getFunctionType(), link));
|
||||||
|
|
||||||
IF_LOG Logger::cout() << "func = " << *func << std::endl;
|
IF_LOG Logger::cout() << "func = " << *func << std::endl;
|
||||||
|
|
||||||
|
|
|
@ -198,13 +198,13 @@ static llvm::Function* build_module_function(const std::string &name, const std:
|
||||||
assert(gIR->module.getFunction(symbolName) == NULL);
|
assert(gIR->module.getFunction(symbolName) == NULL);
|
||||||
llvm::Function* fn = llvm::Function::Create(fnTy,
|
llvm::Function* fn = llvm::Function::Create(fnTy,
|
||||||
llvm::GlobalValue::InternalLinkage, symbolName, &gIR->module);
|
llvm::GlobalValue::InternalLinkage, symbolName, &gIR->module);
|
||||||
fn->setCallingConv(gABI->callingConv(LINKd));
|
fn->setCallingConv(gABI->callingConv(fn->getFunctionType(), LINKd));
|
||||||
|
|
||||||
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "", fn);
|
llvm::BasicBlock* bb = llvm::BasicBlock::Create(gIR->context(), "", fn);
|
||||||
IRBuilder<> builder(bb);
|
IRBuilder<> builder(bb);
|
||||||
|
|
||||||
// debug info
|
// debug info
|
||||||
llvm::DISubprogram dis = gIR->DBuilder.EmitModuleCTor(fn, name.c_str());
|
ldc::DISubprogram dis = gIR->DBuilder.EmitModuleCTor(fn, name.c_str());
|
||||||
if (global.params.symdebug) {
|
if (global.params.symdebug) {
|
||||||
// Need _some_ debug info to avoid inliner bug, see GitHub issue #998.
|
// Need _some_ debug info to avoid inliner bug, see GitHub issue #998.
|
||||||
builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, dis));
|
builder.SetCurrentDebugLocation(llvm::DebugLoc::get(0, 0, dis));
|
||||||
|
@ -219,7 +219,11 @@ static llvm::Function* build_module_function(const std::string &name, const std:
|
||||||
#else
|
#else
|
||||||
llvm::CallInst* call = builder.CreateCall(f, "");
|
llvm::CallInst* call = builder.CreateCall(f, "");
|
||||||
#endif
|
#endif
|
||||||
call->setCallingConv(gABI->callingConv(LINKd));
|
call->setCallingConv(gABI->callingConv(call->
|
||||||
|
#if LDC_LLVM_VER < 307
|
||||||
|
getCalledFunction()->
|
||||||
|
#endif
|
||||||
|
getFunctionType(), LINKd));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment vgate's
|
// Increment vgate's
|
||||||
|
@ -666,7 +670,7 @@ static void addCoverageAnalysis(Module* m)
|
||||||
|
|
||||||
LLFunctionType* ctorTy = LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector<LLType*>(), false);
|
LLFunctionType* ctorTy = LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector<LLType*>(), false);
|
||||||
ctor = LLFunction::Create(ctorTy, LLGlobalValue::InternalLinkage, ctorname, &gIR->module);
|
ctor = LLFunction::Create(ctorTy, LLGlobalValue::InternalLinkage, ctorname, &gIR->module);
|
||||||
ctor->setCallingConv(gABI->callingConv(LINKd));
|
ctor->setCallingConv(gABI->callingConv(ctor->getFunctionType(), LINKd));
|
||||||
// Set function attributes. See functions.cpp:DtoDefineFunction()
|
// Set function attributes. See functions.cpp:DtoDefineFunction()
|
||||||
if (global.params.targetTriple.getArch() == llvm::Triple::x86_64)
|
if (global.params.targetTriple.getArch() == llvm::Triple::x86_64)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1006,7 +1006,7 @@ static void LLVM_D_BuildRuntimeModule()
|
||||||
#else
|
#else
|
||||||
fn->addAttribute(1, irFty.args[0]->attrs.attrs);
|
fn->addAttribute(1, irFty.args[0]->attrs.attrs);
|
||||||
#endif
|
#endif
|
||||||
fn->setCallingConv(gABI->callingConv(LINKd));
|
fn->setCallingConv(gABI->callingConv(fn->getFunctionType(), LINKd));
|
||||||
}
|
}
|
||||||
|
|
||||||
// void _d_hidden_func(Object o)
|
// void _d_hidden_func(Object o)
|
||||||
|
@ -1048,6 +1048,6 @@ static void LLVM_D_BuildRuntimeModule()
|
||||||
|
|
||||||
LLFunctionType* fty = LLFunctionType::get(voidTy, params, false);
|
LLFunctionType* fty = LLFunctionType::get(voidTy, params, false);
|
||||||
llvm::Function* fn = LLFunction::Create(fty, LLGlobalValue::ExternalLinkage, fname, M);
|
llvm::Function* fn = LLFunction::Create(fty, LLGlobalValue::ExternalLinkage, fname, M);
|
||||||
fn->setCallingConv(gABI->callingConv(LINKc));
|
fn->setCallingConv(gABI->callingConv(fn->getFunctionType(), LINKc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,12 +277,11 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
||||||
bool nestedcall = irFty.arg_nest;
|
bool nestedcall = irFty.arg_nest;
|
||||||
bool dvarargs = irFty.arg_arguments;
|
bool dvarargs = irFty.arg_arguments;
|
||||||
|
|
||||||
llvm::CallingConv::ID callconv = gABI->callingConv(tf->linkage);
|
|
||||||
|
|
||||||
// get callee llvm value
|
// get callee llvm value
|
||||||
LLValue* callable = DtoCallableValue(fnval);
|
LLValue* callable = DtoCallableValue(fnval);
|
||||||
LLFunctionType* callableTy = DtoExtractFunctionType(callable->getType());
|
LLFunctionType* callableTy = DtoExtractFunctionType(callable->getType());
|
||||||
assert(callableTy);
|
assert(callableTy);
|
||||||
|
llvm::CallingConv::ID callconv = gABI->callingConv(callableTy, tf->linkage);
|
||||||
|
|
||||||
// IF_LOG Logger::cout() << "callable: " << *callable << '\n';
|
// IF_LOG Logger::cout() << "callable: " << *callable << '\n';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue