if (!TLI->has(LibFunc::strlen))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[2];
AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
B.getInt8PtrTy(),
NULL);
CallInst *CI = B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen");
- if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(StrLen->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
return CI;
}
if (!TLI->has(LibFunc::strnlen))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[2];
AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
TD->getIntPtrType(Context),
NULL);
CallInst *CI = B.CreateCall2(StrNLen, CastToCStr(Ptr, B), MaxLen, "strnlen");
- if (const Function *F = dyn_cast<Function>(StrNLen->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(StrNLen->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
return CI;
}
if (!TLI->has(LibFunc::strchr))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AttributeSet AS =
AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
I8Ptr, I8Ptr, I32Ty, NULL);
CallInst *CI = B.CreateCall2(StrChr, CastToCStr(Ptr, B),
ConstantInt::get(I32Ty, C), "strchr");
- if (const Function *F = dyn_cast<Function>(StrChr->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(StrChr->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}
if (!TLI->has(LibFunc::strncmp))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[3];
AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
AS[1] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
CallInst *CI = B.CreateCall3(StrNCmp, CastToCStr(Ptr1, B),
CastToCStr(Ptr2, B), Len, "strncmp");
- if (const Function *F = dyn_cast<Function>(StrNCmp->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(StrNCmp->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
return CI;
}
if (!TLI->has(LibFunc::strcpy))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[2];
AS[0] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
I8Ptr, I8Ptr, I8Ptr, NULL);
CallInst *CI = B.CreateCall2(StrCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
Name);
- if (const Function *F = dyn_cast<Function>(StrCpy->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(StrCpy->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}
if (!TLI->has(LibFunc::strncpy))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[2];
AS[0] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
Len->getType(), NULL);
CallInst *CI = B.CreateCall3(StrNCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
Len, "strncpy");
- if (const Function *F = dyn_cast<Function>(StrNCpy->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(StrNCpy->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}
if (!TLI->has(LibFunc::memcpy_chk))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS;
AS = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
Attribute::NoUnwind);
Dst = CastToCStr(Dst, B);
Src = CastToCStr(Src, B);
CallInst *CI = B.CreateCall4(MemCpy, Dst, Src, Len, ObjSize);
- if (const Function *F = dyn_cast<Function>(MemCpy->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(MemCpy->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}
if (!TLI->has(LibFunc::memchr))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS;
Attribute::AttrKind AVs[2] = { Attribute::ReadOnly, Attribute::NoUnwind };
AS = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
NULL);
CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr");
- if (const Function *F = dyn_cast<Function>(MemChr->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(MemChr->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
return CI;
}
if (!TLI->has(LibFunc::memcmp))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[3];
AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
AS[1] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B),
Len, "memcmp");
- if (const Function *F = dyn_cast<Function>(MemCmp->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(MemCmp->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
return CI;
}
SmallString<20> NameBuffer;
AppendTypeSuffix(Op, Name, NameBuffer);
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
Value *Callee = M->getOrInsertFunction(Name, Op->getType(),
Op->getType(), NULL);
CallInst *CI = B.CreateCall(Callee, Op, Name);
CI->setAttributes(Attrs);
- if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(Callee->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
return CI;
}
SmallString<20> NameBuffer;
AppendTypeSuffix(Op1, Name, NameBuffer);
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
Value *Callee = M->getOrInsertFunction(Name, Op1->getType(),
Op1->getType(), Op2->getType(), NULL);
CallInst *CI = B.CreateCall2(Callee, Op1, Op2, Name);
CI->setAttributes(Attrs);
- if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(Callee->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
return CI;
}
if (!TLI->has(LibFunc::putchar))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
Value *PutChar = M->getOrInsertFunction("putchar", B.getInt32Ty(),
B.getInt32Ty(), NULL);
CallInst *CI = B.CreateCall(PutChar,
"chari"),
"putchar");
- if (const Function *F = dyn_cast<Function>(PutChar->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(PutChar->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}
if (!TLI->has(LibFunc::puts))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[2];
AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
B.getInt8PtrTy(),
NULL);
CallInst *CI = B.CreateCall(PutS, CastToCStr(Str, B), "puts");
- if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts()))
- CI->setCallingConv(F->getCallingConv());
+ if (Function *F = dyn_cast<Function>(PutS->stripPointerCasts())) {
+ CallingConv::ID CC = F->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ F->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}
if (!TLI->has(LibFunc::fputc))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[2];
AS[0] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
AS[1] = AttributeSet::get(M->getContext(), AttributeSet::FunctionIndex,
"chari");
CallInst *CI = B.CreateCall2(F, Char, File, "fputc");
- if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
- CI->setCallingConv(Fn->getCallingConv());
+ if (Function *Fn = dyn_cast<Function>(F->stripPointerCasts())) {
+ CallingConv::ID CC = Fn->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ Fn->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}
if (!TLI->has(LibFunc::fputs))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[3];
AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
AS[1] = AttributeSet::get(M->getContext(), 2, Attribute::NoCapture);
File->getType(), NULL);
CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs");
- if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
- CI->setCallingConv(Fn->getCallingConv());
+ if (Function *Fn = dyn_cast<Function>(F->stripPointerCasts())) {
+ CallingConv::ID CC = Fn->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ Fn->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}
if (!TLI->has(LibFunc::fwrite))
return 0;
- Module *M = B.GetInsertBlock()->getParent()->getParent();
+ Function *CallerF = B.GetInsertBlock()->getParent();
+ Module *M = CallerF->getParent();
AttributeSet AS[3];
AS[0] = AttributeSet::get(M->getContext(), 1, Attribute::NoCapture);
AS[1] = AttributeSet::get(M->getContext(), 4, Attribute::NoCapture);
CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size,
ConstantInt::get(TD->getIntPtrType(Context), 1), File);
- if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
- CI->setCallingConv(Fn->getCallingConv());
+ if (Function *Fn = dyn_cast<Function>(F->stripPointerCasts())) {
+ CallingConv::ID CC = Fn->getCallingConv();
+ CallingConv::ID CallerCC = CallerF->getCallingConv();
+ if (CC == CallingConv::C && CallingConv::isARMTargetCC(CallerCC)) {
+ // If caller is using ARM target specific CC such as AAPCS-VFP,
+ // make sure the call uses it or it would introduce a calling
+ // convention mismatch.
+ CI->setCallingConv(CallerCC);
+ Fn->setCallingConv(CallerCC);
+ } else
+ CI->setCallingConv(CC);
+ }
+
return CI;
}