// call. The way we make this work is to cast to the exact type
// of the promoted arguments.
if (isa<FunctionNoProtoType>(FnType) &&
- !getTargetHooks().isNoProtoCallVariadic(FnType->getCallConv())) {
+ !getTargetHooks().isNoProtoCallVariadic(FnInfo)) {
assert(cast<llvm::FunctionType>(Callee->getType()->getContainedType(0))
->isVarArg());
llvm::Type *CalleeTy = getTypes().GetFunctionType(FnInfo, false);
return 32;
}
-bool TargetCodeGenInfo::isNoProtoCallVariadic(CallingConv CC) const {
+bool TargetCodeGenInfo::isNoProtoCallVariadic(
+ const CodeGen::CGFunctionInfo &) const {
// The following conventions are known to require this to be false:
// x86_stdcall
// MIPS
return X86AdjustInlineAsmType(CGF, Constraint, Ty);
}
- bool isNoProtoCallVariadic(CallingConv CC) const {
+ bool isNoProtoCallVariadic(const CodeGen::CGFunctionInfo &FI) const {
// The default CC on x86-64 sets %al to the number of SSA
// registers used, and GCC sets this when calling an unprototyped
- // function, so we override the default behavior.
- if (CC == CC_Default || CC == CC_C) return true;
+ // function, so we override the default behavior. However, don't do
+ // that when AVX types are involved.
+ if (FI.getCallingConvention() == llvm::CallingConv::C) {
+ bool HasAVXType = false;
+ for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
+ ie = FI.arg_end();
+ it != ie; ++it) {
+ if (it->info.isDirect()) {
+ llvm::Type *Ty = it->info.getCoerceToType();
+ if (llvm::VectorType *VTy = dyn_cast_or_null<llvm::VectorType>(Ty)) {
+ if (VTy->getBitWidth() > 128) {
+ HasAVXType = true;
+ break;
+ }
+ }
+ }
+ }
+ if (!HasAVXType)
+ return true;
+ }
- return TargetCodeGenInfo::isNoProtoCallVariadic(CC);
+ return TargetCodeGenInfo::isNoProtoCallVariadic(FI);
}
};
namespace CodeGen {
class CodeGenModule;
class CodeGenFunction;
+ class CGFunctionInfo;
}
/// TargetCodeGenInfo - This class organizes various target-specific
/// same way and some out-of-band information is passed for the
/// benefit of variadic callees, as is the case for x86-64.
/// In this case the ABI should be consulted.
- virtual bool isNoProtoCallVariadic(CallingConv CC) const;
+ virtual bool isNoProtoCallVariadic(const CodeGen::CGFunctionInfo &) const;
};
}