|
@@ -723,7 +723,7 @@ Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL,
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
|
Constant *StrLen = M->getOrInsertFunction("strlen", DL.getIntPtrType(Context),
|
|
Constant *StrLen = M->getOrInsertFunction("strlen", DL.getIntPtrType(Context),
|
|
- B.getInt8PtrTy(), nullptr);
|
|
|
|
|
|
+ B.getInt8PtrTy());
|
|
inferLibFuncAttributes(*M->getFunction("strlen"), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction("strlen"), *TLI);
|
|
CallInst *CI = B.CreateCall(StrLen, castToCStr(Ptr, B), "strlen");
|
|
CallInst *CI = B.CreateCall(StrLen, castToCStr(Ptr, B), "strlen");
|
|
if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts()))
|
|
if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts()))
|
|
@@ -741,7 +741,7 @@ Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B,
|
|
Type *I8Ptr = B.getInt8PtrTy();
|
|
Type *I8Ptr = B.getInt8PtrTy();
|
|
Type *I32Ty = B.getInt32Ty();
|
|
Type *I32Ty = B.getInt32Ty();
|
|
Constant *StrChr =
|
|
Constant *StrChr =
|
|
- M->getOrInsertFunction("strchr", I8Ptr, I8Ptr, I32Ty, nullptr);
|
|
|
|
|
|
+ M->getOrInsertFunction("strchr", I8Ptr, I8Ptr, I32Ty);
|
|
inferLibFuncAttributes(*M->getFunction("strchr"), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction("strchr"), *TLI);
|
|
CallInst *CI = B.CreateCall(
|
|
CallInst *CI = B.CreateCall(
|
|
StrChr, {castToCStr(Ptr, B), ConstantInt::get(I32Ty, C)}, "strchr");
|
|
StrChr, {castToCStr(Ptr, B), ConstantInt::get(I32Ty, C)}, "strchr");
|
|
@@ -759,7 +759,7 @@ Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B,
|
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
|
Value *StrNCmp = M->getOrInsertFunction("strncmp", B.getInt32Ty(),
|
|
Value *StrNCmp = M->getOrInsertFunction("strncmp", B.getInt32Ty(),
|
|
B.getInt8PtrTy(), B.getInt8PtrTy(),
|
|
B.getInt8PtrTy(), B.getInt8PtrTy(),
|
|
- DL.getIntPtrType(Context), nullptr);
|
|
|
|
|
|
+ DL.getIntPtrType(Context));
|
|
inferLibFuncAttributes(*M->getFunction("strncmp"), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction("strncmp"), *TLI);
|
|
CallInst *CI = B.CreateCall(
|
|
CallInst *CI = B.CreateCall(
|
|
StrNCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, "strncmp");
|
|
StrNCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, "strncmp");
|
|
@@ -777,7 +777,7 @@ Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
|
|
|
|
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Type *I8Ptr = B.getInt8PtrTy();
|
|
Type *I8Ptr = B.getInt8PtrTy();
|
|
- Value *StrCpy = M->getOrInsertFunction(Name, I8Ptr, I8Ptr, I8Ptr, nullptr);
|
|
|
|
|
|
+ Value *StrCpy = M->getOrInsertFunction(Name, I8Ptr, I8Ptr, I8Ptr);
|
|
inferLibFuncAttributes(*M->getFunction(Name), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction(Name), *TLI);
|
|
CallInst *CI =
|
|
CallInst *CI =
|
|
B.CreateCall(StrCpy, {castToCStr(Dst, B), castToCStr(Src, B)}, Name);
|
|
B.CreateCall(StrCpy, {castToCStr(Dst, B), castToCStr(Src, B)}, Name);
|
|
@@ -794,7 +794,7 @@ Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B,
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Type *I8Ptr = B.getInt8PtrTy();
|
|
Type *I8Ptr = B.getInt8PtrTy();
|
|
Value *StrNCpy = M->getOrInsertFunction(Name, I8Ptr, I8Ptr, I8Ptr,
|
|
Value *StrNCpy = M->getOrInsertFunction(Name, I8Ptr, I8Ptr, I8Ptr,
|
|
- Len->getType(), nullptr);
|
|
|
|
|
|
+ Len->getType());
|
|
inferLibFuncAttributes(*M->getFunction(Name), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction(Name), *TLI);
|
|
CallInst *CI = B.CreateCall(
|
|
CallInst *CI = B.CreateCall(
|
|
StrNCpy, {castToCStr(Dst, B), castToCStr(Src, B), Len}, "strncpy");
|
|
StrNCpy, {castToCStr(Dst, B), castToCStr(Src, B), Len}, "strncpy");
|
|
@@ -817,7 +817,7 @@ Value *llvm::emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
|
|
Value *MemCpy = M->getOrInsertFunction(
|
|
Value *MemCpy = M->getOrInsertFunction(
|
|
"__memcpy_chk", AttributeList::get(M->getContext(), AS), B.getInt8PtrTy(),
|
|
"__memcpy_chk", AttributeList::get(M->getContext(), AS), B.getInt8PtrTy(),
|
|
B.getInt8PtrTy(), B.getInt8PtrTy(), DL.getIntPtrType(Context),
|
|
B.getInt8PtrTy(), B.getInt8PtrTy(), DL.getIntPtrType(Context),
|
|
- DL.getIntPtrType(Context), nullptr);
|
|
|
|
|
|
+ DL.getIntPtrType(Context));
|
|
Dst = castToCStr(Dst, B);
|
|
Dst = castToCStr(Dst, B);
|
|
Src = castToCStr(Src, B);
|
|
Src = castToCStr(Src, B);
|
|
CallInst *CI = B.CreateCall(MemCpy, {Dst, Src, Len, ObjSize});
|
|
CallInst *CI = B.CreateCall(MemCpy, {Dst, Src, Len, ObjSize});
|
|
@@ -835,7 +835,7 @@ Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B,
|
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
|
Value *MemChr = M->getOrInsertFunction("memchr", B.getInt8PtrTy(),
|
|
Value *MemChr = M->getOrInsertFunction("memchr", B.getInt8PtrTy(),
|
|
B.getInt8PtrTy(), B.getInt32Ty(),
|
|
B.getInt8PtrTy(), B.getInt32Ty(),
|
|
- DL.getIntPtrType(Context), nullptr);
|
|
|
|
|
|
+ DL.getIntPtrType(Context));
|
|
inferLibFuncAttributes(*M->getFunction("memchr"), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction("memchr"), *TLI);
|
|
CallInst *CI = B.CreateCall(MemChr, {castToCStr(Ptr, B), Val, Len}, "memchr");
|
|
CallInst *CI = B.CreateCall(MemChr, {castToCStr(Ptr, B), Val, Len}, "memchr");
|
|
|
|
|
|
@@ -854,7 +854,7 @@ Value *llvm::emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B,
|
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
|
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
|
Value *MemCmp = M->getOrInsertFunction("memcmp", B.getInt32Ty(),
|
|
Value *MemCmp = M->getOrInsertFunction("memcmp", B.getInt32Ty(),
|
|
B.getInt8PtrTy(), B.getInt8PtrTy(),
|
|
B.getInt8PtrTy(), B.getInt8PtrTy(),
|
|
- DL.getIntPtrType(Context), nullptr);
|
|
|
|
|
|
+ DL.getIntPtrType(Context));
|
|
inferLibFuncAttributes(*M->getFunction("memcmp"), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction("memcmp"), *TLI);
|
|
CallInst *CI = B.CreateCall(
|
|
CallInst *CI = B.CreateCall(
|
|
MemCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, "memcmp");
|
|
MemCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, "memcmp");
|
|
@@ -887,7 +887,7 @@ Value *llvm::emitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B,
|
|
|
|
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Value *Callee = M->getOrInsertFunction(Name, Op->getType(),
|
|
Value *Callee = M->getOrInsertFunction(Name, Op->getType(),
|
|
- Op->getType(), nullptr);
|
|
|
|
|
|
+ Op->getType());
|
|
CallInst *CI = B.CreateCall(Callee, Op, Name);
|
|
CallInst *CI = B.CreateCall(Callee, Op, Name);
|
|
CI->setAttributes(Attrs);
|
|
CI->setAttributes(Attrs);
|
|
if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts()))
|
|
if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts()))
|
|
@@ -903,7 +903,7 @@ Value *llvm::emitBinaryFloatFnCall(Value *Op1, Value *Op2, StringRef Name,
|
|
|
|
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Value *Callee = M->getOrInsertFunction(Name, Op1->getType(), Op1->getType(),
|
|
Value *Callee = M->getOrInsertFunction(Name, Op1->getType(), Op1->getType(),
|
|
- Op2->getType(), nullptr);
|
|
|
|
|
|
+ Op2->getType());
|
|
CallInst *CI = B.CreateCall(Callee, {Op1, Op2}, Name);
|
|
CallInst *CI = B.CreateCall(Callee, {Op1, Op2}, Name);
|
|
CI->setAttributes(Attrs);
|
|
CI->setAttributes(Attrs);
|
|
if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts()))
|
|
if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts()))
|
|
@@ -918,8 +918,7 @@ Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B,
|
|
return nullptr;
|
|
return nullptr;
|
|
|
|
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
- Value *PutChar = M->getOrInsertFunction("putchar", B.getInt32Ty(),
|
|
|
|
- B.getInt32Ty(), nullptr);
|
|
|
|
|
|
+ Value *PutChar = M->getOrInsertFunction("putchar", B.getInt32Ty(), B.getInt32Ty());
|
|
inferLibFuncAttributes(*M->getFunction("putchar"), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction("putchar"), *TLI);
|
|
CallInst *CI = B.CreateCall(PutChar,
|
|
CallInst *CI = B.CreateCall(PutChar,
|
|
B.CreateIntCast(Char,
|
|
B.CreateIntCast(Char,
|
|
@@ -940,7 +939,7 @@ Value *llvm::emitPutS(Value *Str, IRBuilder<> &B,
|
|
|
|
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Value *PutS =
|
|
Value *PutS =
|
|
- M->getOrInsertFunction("puts", B.getInt32Ty(), B.getInt8PtrTy(), nullptr);
|
|
|
|
|
|
+ M->getOrInsertFunction("puts", B.getInt32Ty(), B.getInt8PtrTy());
|
|
inferLibFuncAttributes(*M->getFunction("puts"), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction("puts"), *TLI);
|
|
CallInst *CI = B.CreateCall(PutS, castToCStr(Str, B), "puts");
|
|
CallInst *CI = B.CreateCall(PutS, castToCStr(Str, B), "puts");
|
|
if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts()))
|
|
if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts()))
|
|
@@ -955,7 +954,7 @@ Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B,
|
|
|
|
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Constant *F = M->getOrInsertFunction("fputc", B.getInt32Ty(), B.getInt32Ty(),
|
|
Constant *F = M->getOrInsertFunction("fputc", B.getInt32Ty(), B.getInt32Ty(),
|
|
- File->getType(), nullptr);
|
|
|
|
|
|
+ File->getType());
|
|
if (File->getType()->isPointerTy())
|
|
if (File->getType()->isPointerTy())
|
|
inferLibFuncAttributes(*M->getFunction("fputc"), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction("fputc"), *TLI);
|
|
Char = B.CreateIntCast(Char, B.getInt32Ty(), /*isSigned*/true,
|
|
Char = B.CreateIntCast(Char, B.getInt32Ty(), /*isSigned*/true,
|
|
@@ -975,7 +974,7 @@ Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B,
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
Module *M = B.GetInsertBlock()->getModule();
|
|
StringRef FPutsName = TLI->getName(LibFunc_fputs);
|
|
StringRef FPutsName = TLI->getName(LibFunc_fputs);
|
|
Constant *F = M->getOrInsertFunction(
|
|
Constant *F = M->getOrInsertFunction(
|
|
- FPutsName, B.getInt32Ty(), B.getInt8PtrTy(), File->getType(), nullptr);
|
|
|
|
|
|
+ FPutsName, B.getInt32Ty(), B.getInt8PtrTy(), File->getType());
|
|
if (File->getType()->isPointerTy())
|
|
if (File->getType()->isPointerTy())
|
|
inferLibFuncAttributes(*M->getFunction(FPutsName), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction(FPutsName), *TLI);
|
|
CallInst *CI = B.CreateCall(F, {castToCStr(Str, B), File}, "fputs");
|
|
CallInst *CI = B.CreateCall(F, {castToCStr(Str, B), File}, "fputs");
|
|
@@ -995,8 +994,8 @@ Value *llvm::emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B,
|
|
StringRef FWriteName = TLI->getName(LibFunc_fwrite);
|
|
StringRef FWriteName = TLI->getName(LibFunc_fwrite);
|
|
Constant *F = M->getOrInsertFunction(
|
|
Constant *F = M->getOrInsertFunction(
|
|
FWriteName, DL.getIntPtrType(Context), B.getInt8PtrTy(),
|
|
FWriteName, DL.getIntPtrType(Context), B.getInt8PtrTy(),
|
|
- DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType(),
|
|
|
|
- nullptr);
|
|
|
|
|
|
+ DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType());
|
|
|
|
+
|
|
if (File->getType()->isPointerTy())
|
|
if (File->getType()->isPointerTy())
|
|
inferLibFuncAttributes(*M->getFunction(FWriteName), *TLI);
|
|
inferLibFuncAttributes(*M->getFunction(FWriteName), *TLI);
|
|
CallInst *CI =
|
|
CallInst *CI =
|