forked from OSchip/llvm-project
Use nullptr instead of NULL for variadic sentinels
Windows defines NULL to 0, which when used as an argument to a variadic function, is not a null pointer constant. As a result, Clang's -Wsentinel fires on this code. Using '0' would be wrong on most 64-bit platforms, but both MSVC and Clang make it work on Windows. Sidestep the issue with nullptr. llvm-svn: 221940
This commit is contained in:
parent
8716b58583
commit
971c3ea67b
|
@ -144,7 +144,7 @@ namespace {
|
||||||
LLVMContext &C = F.getContext();
|
LLVMContext &C = F.getContext();
|
||||||
BasicBlock *CleanupBB = BasicBlock::Create(C, CleanupBBName, &F);
|
BasicBlock *CleanupBB = BasicBlock::Create(C, CleanupBBName, &F);
|
||||||
Type *ExnTy = StructType::get(Type::getInt8PtrTy(C),
|
Type *ExnTy = StructType::get(Type::getInt8PtrTy(C),
|
||||||
Type::getInt32Ty(C), NULL);
|
Type::getInt32Ty(C), nullptr);
|
||||||
Constant *PersFn =
|
Constant *PersFn =
|
||||||
F.getParent()->
|
F.getParent()->
|
||||||
getOrInsertFunction("__gcc_personality_v0",
|
getOrInsertFunction("__gcc_personality_v0",
|
||||||
|
|
|
@ -99,7 +99,7 @@ bool SjLjEHPrepare::doInitialization(Module &M) {
|
||||||
VoidPtrTy, // __personality
|
VoidPtrTy, // __personality
|
||||||
VoidPtrTy, // __lsda
|
VoidPtrTy, // __lsda
|
||||||
ArrayType::get(VoidPtrTy, 5), // __jbuf
|
ArrayType::get(VoidPtrTy, 5), // __jbuf
|
||||||
NULL);
|
nullptr);
|
||||||
RegisterFn = M.getOrInsertFunction(
|
RegisterFn = M.getOrInsertFunction(
|
||||||
"_Unwind_SjLj_Register", Type::getVoidTy(M.getContext()),
|
"_Unwind_SjLj_Register", Type::getVoidTy(M.getContext()),
|
||||||
PointerType::getUnqual(FunctionContextTy), (Type *)nullptr);
|
PointerType::getUnqual(FunctionContextTy), (Type *)nullptr);
|
||||||
|
|
|
@ -480,12 +480,12 @@ BasicBlock *StackProtector::CreateFailBB() {
|
||||||
if (Trip.getOS() == llvm::Triple::OpenBSD) {
|
if (Trip.getOS() == llvm::Triple::OpenBSD) {
|
||||||
Constant *StackChkFail = M->getOrInsertFunction(
|
Constant *StackChkFail = M->getOrInsertFunction(
|
||||||
"__stack_smash_handler", Type::getVoidTy(Context),
|
"__stack_smash_handler", Type::getVoidTy(Context),
|
||||||
Type::getInt8PtrTy(Context), NULL);
|
Type::getInt8PtrTy(Context), nullptr);
|
||||||
|
|
||||||
B.CreateCall(StackChkFail, B.CreateGlobalStringPtr(F->getName(), "SSH"));
|
B.CreateCall(StackChkFail, B.CreateGlobalStringPtr(F->getName(), "SSH"));
|
||||||
} else {
|
} else {
|
||||||
Constant *StackChkFail = M->getOrInsertFunction(
|
Constant *StackChkFail = M->getOrInsertFunction(
|
||||||
"__stack_chk_fail", Type::getVoidTy(Context), NULL);
|
"__stack_chk_fail", Type::getVoidTy(Context), nullptr);
|
||||||
B.CreateCall(StackChkFail);
|
B.CreateCall(StackChkFail);
|
||||||
}
|
}
|
||||||
B.CreateUnreachable();
|
B.CreateUnreachable();
|
||||||
|
|
|
@ -1919,7 +1919,7 @@ Constant *ConstantExpr::getAlignOf(Type* Ty) {
|
||||||
// alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1
|
// alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1
|
||||||
// Note that a non-inbounds gep is used, as null isn't within any object.
|
// Note that a non-inbounds gep is used, as null isn't within any object.
|
||||||
Type *AligningTy =
|
Type *AligningTy =
|
||||||
StructType::get(Type::getInt1Ty(Ty->getContext()), Ty, NULL);
|
StructType::get(Type::getInt1Ty(Ty->getContext()), Ty, nullptr);
|
||||||
Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo(0));
|
Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo(0));
|
||||||
Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0);
|
Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0);
|
||||||
Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
|
Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
|
||||||
|
@ -2712,7 +2712,7 @@ bool ConstantDataSequential::isCString() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getSplatValue - If this is a splat constant, meaning that all of the
|
/// getSplatValue - If this is a splat constant, meaning that all of the
|
||||||
/// elements have the same value, return that value. Otherwise return NULL.
|
/// elements have the same value, return that value. Otherwise return nullptr.
|
||||||
Constant *ConstantDataVector::getSplatValue() const {
|
Constant *ConstantDataVector::getSplatValue() const {
|
||||||
const char *Base = getRawDataValues().data();
|
const char *Base = getRawDataValues().data();
|
||||||
|
|
||||||
|
|
|
@ -364,7 +364,7 @@ bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
|
||||||
|
|
||||||
/// IsConstantOne - Return true only if val is constant int 1
|
/// IsConstantOne - Return true only if val is constant int 1
|
||||||
static bool IsConstantOne(Value *val) {
|
static bool IsConstantOne(Value *val) {
|
||||||
assert(val && "IsConstantOne does not work with NULL val");
|
assert(val && "IsConstantOne does not work with nullptr val");
|
||||||
const ConstantInt *CVal = dyn_cast<ConstantInt>(val);
|
const ConstantInt *CVal = dyn_cast<ConstantInt>(val);
|
||||||
return CVal && CVal->isOne();
|
return CVal && CVal->isOne();
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ static Instruction *createMalloc(Instruction *InsertBefore,
|
||||||
Value *MallocFunc = MallocF;
|
Value *MallocFunc = MallocF;
|
||||||
if (!MallocFunc)
|
if (!MallocFunc)
|
||||||
// prototype malloc as "void *malloc(size_t)"
|
// prototype malloc as "void *malloc(size_t)"
|
||||||
MallocFunc = M->getOrInsertFunction("malloc", BPTy, IntPtrTy, NULL);
|
MallocFunc = M->getOrInsertFunction("malloc", BPTy, IntPtrTy, nullptr);
|
||||||
PointerType *AllocPtrType = PointerType::getUnqual(AllocTy);
|
PointerType *AllocPtrType = PointerType::getUnqual(AllocTy);
|
||||||
CallInst *MCall = nullptr;
|
CallInst *MCall = nullptr;
|
||||||
Instruction *Result = nullptr;
|
Instruction *Result = nullptr;
|
||||||
|
@ -492,7 +492,7 @@ static Instruction* createFree(Value* Source, Instruction *InsertBefore,
|
||||||
Type *VoidTy = Type::getVoidTy(M->getContext());
|
Type *VoidTy = Type::getVoidTy(M->getContext());
|
||||||
Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
|
Type *IntPtrTy = Type::getInt8PtrTy(M->getContext());
|
||||||
// prototype free as "void free(void*)"
|
// prototype free as "void free(void*)"
|
||||||
Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, NULL);
|
Value *FreeFunc = M->getOrInsertFunction("free", VoidTy, IntPtrTy, nullptr);
|
||||||
CallInst* Result = nullptr;
|
CallInst* Result = nullptr;
|
||||||
Value *PtrCast = Source;
|
Value *PtrCast = Source;
|
||||||
if (InsertBefore) {
|
if (InsertBefore) {
|
||||||
|
|
|
@ -654,7 +654,7 @@ void AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If I is an interesting memory access, return the PointerOperand
|
// If I is an interesting memory access, return the PointerOperand
|
||||||
// and set IsWrite/Alignment. Otherwise return NULL.
|
// and set IsWrite/Alignment. Otherwise return nullptr.
|
||||||
static Value *isInterestingMemoryAccess(Instruction *I, bool *IsWrite,
|
static Value *isInterestingMemoryAccess(Instruction *I, bool *IsWrite,
|
||||||
unsigned *Alignment) {
|
unsigned *Alignment) {
|
||||||
// Skip memory accesses inserted by another instrumentation.
|
// Skip memory accesses inserted by another instrumentation.
|
||||||
|
@ -1001,19 +1001,19 @@ void AddressSanitizerModule::initializeCallbacks(Module &M) {
|
||||||
IRBuilder<> IRB(*C);
|
IRBuilder<> IRB(*C);
|
||||||
// Declare our poisoning and unpoisoning functions.
|
// Declare our poisoning and unpoisoning functions.
|
||||||
AsanPoisonGlobals = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanPoisonGlobals = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanPoisonGlobalsName, IRB.getVoidTy(), IntptrTy, NULL));
|
kAsanPoisonGlobalsName, IRB.getVoidTy(), IntptrTy, nullptr));
|
||||||
AsanPoisonGlobals->setLinkage(Function::ExternalLinkage);
|
AsanPoisonGlobals->setLinkage(Function::ExternalLinkage);
|
||||||
AsanUnpoisonGlobals = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanUnpoisonGlobals = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanUnpoisonGlobalsName, IRB.getVoidTy(), NULL));
|
kAsanUnpoisonGlobalsName, IRB.getVoidTy(), nullptr));
|
||||||
AsanUnpoisonGlobals->setLinkage(Function::ExternalLinkage);
|
AsanUnpoisonGlobals->setLinkage(Function::ExternalLinkage);
|
||||||
// Declare functions that register/unregister globals.
|
// Declare functions that register/unregister globals.
|
||||||
AsanRegisterGlobals = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanRegisterGlobals = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanRegisterGlobalsName, IRB.getVoidTy(),
|
kAsanRegisterGlobalsName, IRB.getVoidTy(),
|
||||||
IntptrTy, IntptrTy, NULL));
|
IntptrTy, IntptrTy, nullptr));
|
||||||
AsanRegisterGlobals->setLinkage(Function::ExternalLinkage);
|
AsanRegisterGlobals->setLinkage(Function::ExternalLinkage);
|
||||||
AsanUnregisterGlobals = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanUnregisterGlobals = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanUnregisterGlobalsName,
|
kAsanUnregisterGlobalsName,
|
||||||
IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
AsanUnregisterGlobals->setLinkage(Function::ExternalLinkage);
|
AsanUnregisterGlobals->setLinkage(Function::ExternalLinkage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1044,7 +1044,7 @@ bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M) {
|
||||||
// We initialize an array of such structures and pass it to a run-time call.
|
// We initialize an array of such structures and pass it to a run-time call.
|
||||||
StructType *GlobalStructTy =
|
StructType *GlobalStructTy =
|
||||||
StructType::get(IntptrTy, IntptrTy, IntptrTy, IntptrTy, IntptrTy,
|
StructType::get(IntptrTy, IntptrTy, IntptrTy, IntptrTy, IntptrTy,
|
||||||
IntptrTy, IntptrTy, NULL);
|
IntptrTy, IntptrTy, nullptr);
|
||||||
SmallVector<Constant *, 16> Initializers(n);
|
SmallVector<Constant *, 16> Initializers(n);
|
||||||
|
|
||||||
bool HasDynamicallyInitializedGlobals = false;
|
bool HasDynamicallyInitializedGlobals = false;
|
||||||
|
@ -1081,10 +1081,10 @@ bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M) {
|
||||||
assert(((RightRedzoneSize + SizeInBytes) % MinRZ) == 0);
|
assert(((RightRedzoneSize + SizeInBytes) % MinRZ) == 0);
|
||||||
Type *RightRedZoneTy = ArrayType::get(IRB.getInt8Ty(), RightRedzoneSize);
|
Type *RightRedZoneTy = ArrayType::get(IRB.getInt8Ty(), RightRedzoneSize);
|
||||||
|
|
||||||
StructType *NewTy = StructType::get(Ty, RightRedZoneTy, NULL);
|
StructType *NewTy = StructType::get(Ty, RightRedZoneTy, nullptr);
|
||||||
Constant *NewInitializer = ConstantStruct::get(
|
Constant *NewInitializer = ConstantStruct::get(
|
||||||
NewTy, G->getInitializer(),
|
NewTy, G->getInitializer(),
|
||||||
Constant::getNullValue(RightRedZoneTy), NULL);
|
Constant::getNullValue(RightRedZoneTy), nullptr);
|
||||||
|
|
||||||
// Create a new global variable with enough space for a redzone.
|
// Create a new global variable with enough space for a redzone.
|
||||||
GlobalValue::LinkageTypes Linkage = G->getLinkage();
|
GlobalValue::LinkageTypes Linkage = G->getLinkage();
|
||||||
|
@ -1119,7 +1119,7 @@ bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M) {
|
||||||
ConstantInt::get(IntptrTy, SizeInBytes + RightRedzoneSize),
|
ConstantInt::get(IntptrTy, SizeInBytes + RightRedzoneSize),
|
||||||
ConstantExpr::getPointerCast(Name, IntptrTy),
|
ConstantExpr::getPointerCast(Name, IntptrTy),
|
||||||
ConstantExpr::getPointerCast(ModuleName, IntptrTy),
|
ConstantExpr::getPointerCast(ModuleName, IntptrTy),
|
||||||
ConstantInt::get(IntptrTy, MD.IsDynInit), SourceLoc, NULL);
|
ConstantInt::get(IntptrTy, MD.IsDynInit), SourceLoc, nullptr);
|
||||||
|
|
||||||
if (ClInitializers && MD.IsDynInit)
|
if (ClInitializers && MD.IsDynInit)
|
||||||
HasDynamicallyInitializedGlobals = true;
|
HasDynamicallyInitializedGlobals = true;
|
||||||
|
@ -1190,42 +1190,42 @@ void AddressSanitizer::initializeCallbacks(Module &M) {
|
||||||
AsanErrorCallback[AccessIsWrite][AccessSizeIndex] =
|
AsanErrorCallback[AccessIsWrite][AccessSizeIndex] =
|
||||||
checkInterfaceFunction(
|
checkInterfaceFunction(
|
||||||
M.getOrInsertFunction(kAsanReportErrorTemplate + Suffix,
|
M.getOrInsertFunction(kAsanReportErrorTemplate + Suffix,
|
||||||
IRB.getVoidTy(), IntptrTy, NULL));
|
IRB.getVoidTy(), IntptrTy, nullptr));
|
||||||
AsanMemoryAccessCallback[AccessIsWrite][AccessSizeIndex] =
|
AsanMemoryAccessCallback[AccessIsWrite][AccessSizeIndex] =
|
||||||
checkInterfaceFunction(
|
checkInterfaceFunction(
|
||||||
M.getOrInsertFunction(ClMemoryAccessCallbackPrefix + Suffix,
|
M.getOrInsertFunction(ClMemoryAccessCallbackPrefix + Suffix,
|
||||||
IRB.getVoidTy(), IntptrTy, NULL));
|
IRB.getVoidTy(), IntptrTy, nullptr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AsanErrorCallbackSized[0] = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanErrorCallbackSized[0] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanReportLoadN, IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
kAsanReportLoadN, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
AsanErrorCallbackSized[1] = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanErrorCallbackSized[1] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanReportStoreN, IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
kAsanReportStoreN, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
|
|
||||||
AsanMemoryAccessCallbackSized[0] = checkInterfaceFunction(
|
AsanMemoryAccessCallbackSized[0] = checkInterfaceFunction(
|
||||||
M.getOrInsertFunction(ClMemoryAccessCallbackPrefix + "loadN",
|
M.getOrInsertFunction(ClMemoryAccessCallbackPrefix + "loadN",
|
||||||
IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
AsanMemoryAccessCallbackSized[1] = checkInterfaceFunction(
|
AsanMemoryAccessCallbackSized[1] = checkInterfaceFunction(
|
||||||
M.getOrInsertFunction(ClMemoryAccessCallbackPrefix + "storeN",
|
M.getOrInsertFunction(ClMemoryAccessCallbackPrefix + "storeN",
|
||||||
IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
|
|
||||||
AsanMemmove = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanMemmove = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
ClMemoryAccessCallbackPrefix + "memmove", IRB.getInt8PtrTy(),
|
ClMemoryAccessCallbackPrefix + "memmove", IRB.getInt8PtrTy(),
|
||||||
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy, NULL));
|
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy, nullptr));
|
||||||
AsanMemcpy = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanMemcpy = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
ClMemoryAccessCallbackPrefix + "memcpy", IRB.getInt8PtrTy(),
|
ClMemoryAccessCallbackPrefix + "memcpy", IRB.getInt8PtrTy(),
|
||||||
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy, NULL));
|
IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy, nullptr));
|
||||||
AsanMemset = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanMemset = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
ClMemoryAccessCallbackPrefix + "memset", IRB.getInt8PtrTy(),
|
ClMemoryAccessCallbackPrefix + "memset", IRB.getInt8PtrTy(),
|
||||||
IRB.getInt8PtrTy(), IRB.getInt32Ty(), IntptrTy, NULL));
|
IRB.getInt8PtrTy(), IRB.getInt32Ty(), IntptrTy, nullptr));
|
||||||
|
|
||||||
AsanHandleNoReturnFunc = checkInterfaceFunction(
|
AsanHandleNoReturnFunc = checkInterfaceFunction(
|
||||||
M.getOrInsertFunction(kAsanHandleNoReturnName, IRB.getVoidTy(), NULL));
|
M.getOrInsertFunction(kAsanHandleNoReturnName, IRB.getVoidTy(), nullptr));
|
||||||
|
|
||||||
AsanPtrCmpFunction = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanPtrCmpFunction = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanPtrCmp, IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
kAsanPtrCmp, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
AsanPtrSubFunction = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanPtrSubFunction = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanPtrSub, IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
kAsanPtrSub, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
// We insert an empty inline asm after __asan_report* to avoid callback merge.
|
// We insert an empty inline asm after __asan_report* to avoid callback merge.
|
||||||
EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
|
EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
|
||||||
StringRef(""), StringRef(""),
|
StringRef(""), StringRef(""),
|
||||||
|
@ -1253,7 +1253,7 @@ bool AddressSanitizer::doInitialization(Module &M) {
|
||||||
// call __asan_init in the module ctor.
|
// call __asan_init in the module ctor.
|
||||||
IRBuilder<> IRB(ReturnInst::Create(*C, AsanCtorBB));
|
IRBuilder<> IRB(ReturnInst::Create(*C, AsanCtorBB));
|
||||||
AsanInitFunction = checkInterfaceFunction(
|
AsanInitFunction = checkInterfaceFunction(
|
||||||
M.getOrInsertFunction(kAsanInitName, IRB.getVoidTy(), NULL));
|
M.getOrInsertFunction(kAsanInitName, IRB.getVoidTy(), nullptr));
|
||||||
AsanInitFunction->setLinkage(Function::ExternalLinkage);
|
AsanInitFunction->setLinkage(Function::ExternalLinkage);
|
||||||
IRB.CreateCall(AsanInitFunction);
|
IRB.CreateCall(AsanInitFunction);
|
||||||
|
|
||||||
|
@ -1426,15 +1426,15 @@ void FunctionStackPoisoner::initializeCallbacks(Module &M) {
|
||||||
std::string Suffix = itostr(i);
|
std::string Suffix = itostr(i);
|
||||||
AsanStackMallocFunc[i] = checkInterfaceFunction(
|
AsanStackMallocFunc[i] = checkInterfaceFunction(
|
||||||
M.getOrInsertFunction(kAsanStackMallocNameTemplate + Suffix, IntptrTy,
|
M.getOrInsertFunction(kAsanStackMallocNameTemplate + Suffix, IntptrTy,
|
||||||
IntptrTy, IntptrTy, NULL));
|
IntptrTy, IntptrTy, nullptr));
|
||||||
AsanStackFreeFunc[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanStackFreeFunc[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanStackFreeNameTemplate + Suffix, IRB.getVoidTy(), IntptrTy,
|
kAsanStackFreeNameTemplate + Suffix, IRB.getVoidTy(), IntptrTy,
|
||||||
IntptrTy, IntptrTy, NULL));
|
IntptrTy, IntptrTy, nullptr));
|
||||||
}
|
}
|
||||||
AsanPoisonStackMemoryFunc = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanPoisonStackMemoryFunc = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanPoisonStackMemoryName, IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
kAsanPoisonStackMemoryName, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
AsanUnpoisonStackMemoryFunc = checkInterfaceFunction(M.getOrInsertFunction(
|
AsanUnpoisonStackMemoryFunc = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kAsanUnpoisonStackMemoryName, IRB.getVoidTy(), IntptrTy, IntptrTy, NULL));
|
kAsanUnpoisonStackMemoryName, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -332,7 +332,7 @@ void MemorySanitizer::initializeCallbacks(Module &M) {
|
||||||
// which is not yet implemented.
|
// which is not yet implemented.
|
||||||
StringRef WarningFnName = ClKeepGoing ? "__msan_warning"
|
StringRef WarningFnName = ClKeepGoing ? "__msan_warning"
|
||||||
: "__msan_warning_noreturn";
|
: "__msan_warning_noreturn";
|
||||||
WarningFn = M.getOrInsertFunction(WarningFnName, IRB.getVoidTy(), NULL);
|
WarningFn = M.getOrInsertFunction(WarningFnName, IRB.getVoidTy(), nullptr);
|
||||||
|
|
||||||
for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes;
|
for (size_t AccessSizeIndex = 0; AccessSizeIndex < kNumberOfAccessSizes;
|
||||||
AccessSizeIndex++) {
|
AccessSizeIndex++) {
|
||||||
|
@ -340,30 +340,30 @@ void MemorySanitizer::initializeCallbacks(Module &M) {
|
||||||
std::string FunctionName = "__msan_maybe_warning_" + itostr(AccessSize);
|
std::string FunctionName = "__msan_maybe_warning_" + itostr(AccessSize);
|
||||||
MaybeWarningFn[AccessSizeIndex] = M.getOrInsertFunction(
|
MaybeWarningFn[AccessSizeIndex] = M.getOrInsertFunction(
|
||||||
FunctionName, IRB.getVoidTy(), IRB.getIntNTy(AccessSize * 8),
|
FunctionName, IRB.getVoidTy(), IRB.getIntNTy(AccessSize * 8),
|
||||||
IRB.getInt32Ty(), NULL);
|
IRB.getInt32Ty(), nullptr);
|
||||||
|
|
||||||
FunctionName = "__msan_maybe_store_origin_" + itostr(AccessSize);
|
FunctionName = "__msan_maybe_store_origin_" + itostr(AccessSize);
|
||||||
MaybeStoreOriginFn[AccessSizeIndex] = M.getOrInsertFunction(
|
MaybeStoreOriginFn[AccessSizeIndex] = M.getOrInsertFunction(
|
||||||
FunctionName, IRB.getVoidTy(), IRB.getIntNTy(AccessSize * 8),
|
FunctionName, IRB.getVoidTy(), IRB.getIntNTy(AccessSize * 8),
|
||||||
IRB.getInt8PtrTy(), IRB.getInt32Ty(), NULL);
|
IRB.getInt8PtrTy(), IRB.getInt32Ty(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
MsanSetAllocaOrigin4Fn = M.getOrInsertFunction(
|
MsanSetAllocaOrigin4Fn = M.getOrInsertFunction(
|
||||||
"__msan_set_alloca_origin4", IRB.getVoidTy(), IRB.getInt8PtrTy(), IntptrTy,
|
"__msan_set_alloca_origin4", IRB.getVoidTy(), IRB.getInt8PtrTy(), IntptrTy,
|
||||||
IRB.getInt8PtrTy(), IntptrTy, NULL);
|
IRB.getInt8PtrTy(), IntptrTy, nullptr);
|
||||||
MsanPoisonStackFn = M.getOrInsertFunction(
|
MsanPoisonStackFn = M.getOrInsertFunction(
|
||||||
"__msan_poison_stack", IRB.getVoidTy(), IRB.getInt8PtrTy(), IntptrTy, NULL);
|
"__msan_poison_stack", IRB.getVoidTy(), IRB.getInt8PtrTy(), IntptrTy, nullptr);
|
||||||
MsanChainOriginFn = M.getOrInsertFunction(
|
MsanChainOriginFn = M.getOrInsertFunction(
|
||||||
"__msan_chain_origin", IRB.getInt32Ty(), IRB.getInt32Ty(), NULL);
|
"__msan_chain_origin", IRB.getInt32Ty(), IRB.getInt32Ty(), nullptr);
|
||||||
MemmoveFn = M.getOrInsertFunction(
|
MemmoveFn = M.getOrInsertFunction(
|
||||||
"__msan_memmove", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
|
"__msan_memmove", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
|
||||||
IRB.getInt8PtrTy(), IntptrTy, NULL);
|
IRB.getInt8PtrTy(), IntptrTy, nullptr);
|
||||||
MemcpyFn = M.getOrInsertFunction(
|
MemcpyFn = M.getOrInsertFunction(
|
||||||
"__msan_memcpy", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
|
"__msan_memcpy", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
|
||||||
IntptrTy, NULL);
|
IntptrTy, nullptr);
|
||||||
MemsetFn = M.getOrInsertFunction(
|
MemsetFn = M.getOrInsertFunction(
|
||||||
"__msan_memset", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt32Ty(),
|
"__msan_memset", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt32Ty(),
|
||||||
IntptrTy, NULL);
|
IntptrTy, nullptr);
|
||||||
|
|
||||||
// Create globals.
|
// Create globals.
|
||||||
RetvalTLS = new GlobalVariable(
|
RetvalTLS = new GlobalVariable(
|
||||||
|
@ -404,7 +404,7 @@ void MemorySanitizer::initializeCallbacks(Module &M) {
|
||||||
AnyFunctionPtrTy =
|
AnyFunctionPtrTy =
|
||||||
PointerType::getUnqual(FunctionType::get(IRB.getVoidTy(), false));
|
PointerType::getUnqual(FunctionType::get(IRB.getVoidTy(), false));
|
||||||
IndirectCallWrapperFn = M.getOrInsertFunction(
|
IndirectCallWrapperFn = M.getOrInsertFunction(
|
||||||
ClWrapIndirectCalls, AnyFunctionPtrTy, AnyFunctionPtrTy, NULL);
|
ClWrapIndirectCalls, AnyFunctionPtrTy, AnyFunctionPtrTy, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WrapIndirectCalls && ClWrapIndirectCallsFast) {
|
if (WrapIndirectCalls && ClWrapIndirectCallsFast) {
|
||||||
|
@ -453,7 +453,7 @@ bool MemorySanitizer::doInitialization(Module &M) {
|
||||||
|
|
||||||
// Insert a call to __msan_init/__msan_track_origins into the module's CTORs.
|
// Insert a call to __msan_init/__msan_track_origins into the module's CTORs.
|
||||||
appendToGlobalCtors(M, cast<Function>(M.getOrInsertFunction(
|
appendToGlobalCtors(M, cast<Function>(M.getOrInsertFunction(
|
||||||
"__msan_init", IRB.getVoidTy(), NULL)), 0);
|
"__msan_init", IRB.getVoidTy(), nullptr)), 0);
|
||||||
|
|
||||||
if (TrackOrigins)
|
if (TrackOrigins)
|
||||||
new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
|
new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
|
||||||
|
|
|
@ -134,11 +134,11 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
|
||||||
appendToGlobalCtors(M, CtorFunc, kSanCtorAndDtorPriority);
|
appendToGlobalCtors(M, CtorFunc, kSanCtorAndDtorPriority);
|
||||||
|
|
||||||
SanCovFunction =
|
SanCovFunction =
|
||||||
checkInterfaceFunction(M.getOrInsertFunction(kSanCovName, VoidTy, NULL));
|
checkInterfaceFunction(M.getOrInsertFunction(kSanCovName, VoidTy, nullptr));
|
||||||
SanCovIndirCallFunction = checkInterfaceFunction(M.getOrInsertFunction(
|
SanCovIndirCallFunction = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kSanCovIndirCallName, VoidTy, IntptrTy, IntptrTy, NULL));
|
kSanCovIndirCallName, VoidTy, IntptrTy, IntptrTy, nullptr));
|
||||||
SanCovModuleInit = checkInterfaceFunction(M.getOrInsertFunction(
|
SanCovModuleInit = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
kSanCovModuleInitName, Type::getVoidTy(*C), IntptrTy, NULL));
|
kSanCovModuleInitName, Type::getVoidTy(*C), IntptrTy, nullptr));
|
||||||
SanCovModuleInit->setLinkage(Function::ExternalLinkage);
|
SanCovModuleInit->setLinkage(Function::ExternalLinkage);
|
||||||
|
|
||||||
for (auto &F : M)
|
for (auto &F : M)
|
||||||
|
|
|
@ -135,33 +135,33 @@ void ThreadSanitizer::initializeCallbacks(Module &M) {
|
||||||
IRBuilder<> IRB(M.getContext());
|
IRBuilder<> IRB(M.getContext());
|
||||||
// Initialize the callbacks.
|
// Initialize the callbacks.
|
||||||
TsanFuncEntry = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanFuncEntry = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"__tsan_func_entry", IRB.getVoidTy(), IRB.getInt8PtrTy(), NULL));
|
"__tsan_func_entry", IRB.getVoidTy(), IRB.getInt8PtrTy(), nullptr));
|
||||||
TsanFuncExit = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanFuncExit = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"__tsan_func_exit", IRB.getVoidTy(), NULL));
|
"__tsan_func_exit", IRB.getVoidTy(), nullptr));
|
||||||
OrdTy = IRB.getInt32Ty();
|
OrdTy = IRB.getInt32Ty();
|
||||||
for (size_t i = 0; i < kNumberOfAccessSizes; ++i) {
|
for (size_t i = 0; i < kNumberOfAccessSizes; ++i) {
|
||||||
const size_t ByteSize = 1 << i;
|
const size_t ByteSize = 1 << i;
|
||||||
const size_t BitSize = ByteSize * 8;
|
const size_t BitSize = ByteSize * 8;
|
||||||
SmallString<32> ReadName("__tsan_read" + itostr(ByteSize));
|
SmallString<32> ReadName("__tsan_read" + itostr(ByteSize));
|
||||||
TsanRead[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanRead[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
ReadName, IRB.getVoidTy(), IRB.getInt8PtrTy(), NULL));
|
ReadName, IRB.getVoidTy(), IRB.getInt8PtrTy(), nullptr));
|
||||||
|
|
||||||
SmallString<32> WriteName("__tsan_write" + itostr(ByteSize));
|
SmallString<32> WriteName("__tsan_write" + itostr(ByteSize));
|
||||||
TsanWrite[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanWrite[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
WriteName, IRB.getVoidTy(), IRB.getInt8PtrTy(), NULL));
|
WriteName, IRB.getVoidTy(), IRB.getInt8PtrTy(), nullptr));
|
||||||
|
|
||||||
Type *Ty = Type::getIntNTy(M.getContext(), BitSize);
|
Type *Ty = Type::getIntNTy(M.getContext(), BitSize);
|
||||||
Type *PtrTy = Ty->getPointerTo();
|
Type *PtrTy = Ty->getPointerTo();
|
||||||
SmallString<32> AtomicLoadName("__tsan_atomic" + itostr(BitSize) +
|
SmallString<32> AtomicLoadName("__tsan_atomic" + itostr(BitSize) +
|
||||||
"_load");
|
"_load");
|
||||||
TsanAtomicLoad[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanAtomicLoad[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
AtomicLoadName, Ty, PtrTy, OrdTy, NULL));
|
AtomicLoadName, Ty, PtrTy, OrdTy, nullptr));
|
||||||
|
|
||||||
SmallString<32> AtomicStoreName("__tsan_atomic" + itostr(BitSize) +
|
SmallString<32> AtomicStoreName("__tsan_atomic" + itostr(BitSize) +
|
||||||
"_store");
|
"_store");
|
||||||
TsanAtomicStore[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanAtomicStore[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
AtomicStoreName, IRB.getVoidTy(), PtrTy, Ty, OrdTy,
|
AtomicStoreName, IRB.getVoidTy(), PtrTy, Ty, OrdTy,
|
||||||
NULL));
|
nullptr));
|
||||||
|
|
||||||
for (int op = AtomicRMWInst::FIRST_BINOP;
|
for (int op = AtomicRMWInst::FIRST_BINOP;
|
||||||
op <= AtomicRMWInst::LAST_BINOP; ++op) {
|
op <= AtomicRMWInst::LAST_BINOP; ++op) {
|
||||||
|
@ -185,33 +185,33 @@ void ThreadSanitizer::initializeCallbacks(Module &M) {
|
||||||
continue;
|
continue;
|
||||||
SmallString<32> RMWName("__tsan_atomic" + itostr(BitSize) + NamePart);
|
SmallString<32> RMWName("__tsan_atomic" + itostr(BitSize) + NamePart);
|
||||||
TsanAtomicRMW[op][i] = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanAtomicRMW[op][i] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
RMWName, Ty, PtrTy, Ty, OrdTy, NULL));
|
RMWName, Ty, PtrTy, Ty, OrdTy, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallString<32> AtomicCASName("__tsan_atomic" + itostr(BitSize) +
|
SmallString<32> AtomicCASName("__tsan_atomic" + itostr(BitSize) +
|
||||||
"_compare_exchange_val");
|
"_compare_exchange_val");
|
||||||
TsanAtomicCAS[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanAtomicCAS[i] = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
AtomicCASName, Ty, PtrTy, Ty, Ty, OrdTy, OrdTy, NULL));
|
AtomicCASName, Ty, PtrTy, Ty, Ty, OrdTy, OrdTy, nullptr));
|
||||||
}
|
}
|
||||||
TsanVptrUpdate = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanVptrUpdate = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"__tsan_vptr_update", IRB.getVoidTy(), IRB.getInt8PtrTy(),
|
"__tsan_vptr_update", IRB.getVoidTy(), IRB.getInt8PtrTy(),
|
||||||
IRB.getInt8PtrTy(), NULL));
|
IRB.getInt8PtrTy(), nullptr));
|
||||||
TsanVptrLoad = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanVptrLoad = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"__tsan_vptr_read", IRB.getVoidTy(), IRB.getInt8PtrTy(), NULL));
|
"__tsan_vptr_read", IRB.getVoidTy(), IRB.getInt8PtrTy(), nullptr));
|
||||||
TsanAtomicThreadFence = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanAtomicThreadFence = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"__tsan_atomic_thread_fence", IRB.getVoidTy(), OrdTy, NULL));
|
"__tsan_atomic_thread_fence", IRB.getVoidTy(), OrdTy, nullptr));
|
||||||
TsanAtomicSignalFence = checkInterfaceFunction(M.getOrInsertFunction(
|
TsanAtomicSignalFence = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"__tsan_atomic_signal_fence", IRB.getVoidTy(), OrdTy, NULL));
|
"__tsan_atomic_signal_fence", IRB.getVoidTy(), OrdTy, nullptr));
|
||||||
|
|
||||||
MemmoveFn = checkInterfaceFunction(M.getOrInsertFunction(
|
MemmoveFn = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"memmove", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
|
"memmove", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
|
||||||
IRB.getInt8PtrTy(), IntptrTy, NULL));
|
IRB.getInt8PtrTy(), IntptrTy, nullptr));
|
||||||
MemcpyFn = checkInterfaceFunction(M.getOrInsertFunction(
|
MemcpyFn = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"memcpy", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
|
"memcpy", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
|
||||||
IntptrTy, NULL));
|
IntptrTy, nullptr));
|
||||||
MemsetFn = checkInterfaceFunction(M.getOrInsertFunction(
|
MemsetFn = checkInterfaceFunction(M.getOrInsertFunction(
|
||||||
"memset", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt32Ty(),
|
"memset", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IRB.getInt32Ty(),
|
||||||
IntptrTy, NULL));
|
IntptrTy, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadSanitizer::doInitialization(Module &M) {
|
bool ThreadSanitizer::doInitialization(Module &M) {
|
||||||
|
@ -224,7 +224,7 @@ bool ThreadSanitizer::doInitialization(Module &M) {
|
||||||
IRBuilder<> IRB(M.getContext());
|
IRBuilder<> IRB(M.getContext());
|
||||||
IntptrTy = IRB.getIntPtrTy(DL);
|
IntptrTy = IRB.getIntPtrTy(DL);
|
||||||
Value *TsanInit = M.getOrInsertFunction("__tsan_init",
|
Value *TsanInit = M.getOrInsertFunction("__tsan_init",
|
||||||
IRB.getVoidTy(), NULL);
|
IRB.getVoidTy(), nullptr);
|
||||||
appendToGlobalCtors(M, cast<Function>(TsanInit), 0);
|
appendToGlobalCtors(M, cast<Function>(TsanInit), 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -50,7 +50,7 @@ Value *llvm::EmitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout *TD,
|
||||||
AS),
|
AS),
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
NULL);
|
nullptr);
|
||||||
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()))
|
||||||
CI->setCallingConv(F->getCallingConv());
|
CI->setCallingConv(F->getCallingConv());
|
||||||
|
@ -79,7 +79,7 @@ Value *llvm::EmitStrNLen(Value *Ptr, Value *MaxLen, IRBuilder<> &B,
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
NULL);
|
nullptr);
|
||||||
CallInst *CI = B.CreateCall2(StrNLen, CastToCStr(Ptr, B), MaxLen, "strnlen");
|
CallInst *CI = B.CreateCall2(StrNLen, CastToCStr(Ptr, B), MaxLen, "strnlen");
|
||||||
if (const Function *F = dyn_cast<Function>(StrNLen->stripPointerCasts()))
|
if (const Function *F = dyn_cast<Function>(StrNLen->stripPointerCasts()))
|
||||||
CI->setCallingConv(F->getCallingConv());
|
CI->setCallingConv(F->getCallingConv());
|
||||||
|
@ -105,7 +105,7 @@ Value *llvm::EmitStrChr(Value *Ptr, char C, IRBuilder<> &B,
|
||||||
Constant *StrChr = M->getOrInsertFunction("strchr",
|
Constant *StrChr = M->getOrInsertFunction("strchr",
|
||||||
AttributeSet::get(M->getContext(),
|
AttributeSet::get(M->getContext(),
|
||||||
AS),
|
AS),
|
||||||
I8Ptr, I8Ptr, I32Ty, NULL);
|
I8Ptr, I8Ptr, I32Ty, nullptr);
|
||||||
CallInst *CI = B.CreateCall2(StrChr, CastToCStr(Ptr, B),
|
CallInst *CI = B.CreateCall2(StrChr, CastToCStr(Ptr, B),
|
||||||
ConstantInt::get(I32Ty, C), "strchr");
|
ConstantInt::get(I32Ty, C), "strchr");
|
||||||
if (const Function *F = dyn_cast<Function>(StrChr->stripPointerCasts()))
|
if (const Function *F = dyn_cast<Function>(StrChr->stripPointerCasts()))
|
||||||
|
@ -134,7 +134,7 @@ Value *llvm::EmitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len,
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
TD->getIntPtrType(Context), NULL);
|
TD->getIntPtrType(Context), nullptr);
|
||||||
CallInst *CI = B.CreateCall3(StrNCmp, CastToCStr(Ptr1, B),
|
CallInst *CI = B.CreateCall3(StrNCmp, CastToCStr(Ptr1, B),
|
||||||
CastToCStr(Ptr2, B), Len, "strncmp");
|
CastToCStr(Ptr2, B), Len, "strncmp");
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ Value *llvm::EmitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
|
||||||
Type *I8Ptr = B.getInt8PtrTy();
|
Type *I8Ptr = B.getInt8PtrTy();
|
||||||
Value *StrCpy = M->getOrInsertFunction(Name,
|
Value *StrCpy = M->getOrInsertFunction(Name,
|
||||||
AttributeSet::get(M->getContext(), AS),
|
AttributeSet::get(M->getContext(), AS),
|
||||||
I8Ptr, I8Ptr, I8Ptr, NULL);
|
I8Ptr, I8Ptr, I8Ptr, nullptr);
|
||||||
CallInst *CI = B.CreateCall2(StrCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
|
CallInst *CI = B.CreateCall2(StrCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
|
||||||
Name);
|
Name);
|
||||||
if (const Function *F = dyn_cast<Function>(StrCpy->stripPointerCasts()))
|
if (const Function *F = dyn_cast<Function>(StrCpy->stripPointerCasts()))
|
||||||
|
@ -186,7 +186,7 @@ Value *llvm::EmitStrNCpy(Value *Dst, Value *Src, Value *Len,
|
||||||
AttributeSet::get(M->getContext(),
|
AttributeSet::get(M->getContext(),
|
||||||
AS),
|
AS),
|
||||||
I8Ptr, I8Ptr, I8Ptr,
|
I8Ptr, I8Ptr, I8Ptr,
|
||||||
Len->getType(), NULL);
|
Len->getType(), nullptr);
|
||||||
CallInst *CI = B.CreateCall3(StrNCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
|
CallInst *CI = B.CreateCall3(StrNCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
|
||||||
Len, "strncpy");
|
Len, "strncpy");
|
||||||
if (const Function *F = dyn_cast<Function>(StrNCpy->stripPointerCasts()))
|
if (const Function *F = dyn_cast<Function>(StrNCpy->stripPointerCasts()))
|
||||||
|
@ -214,7 +214,7 @@ Value *llvm::EmitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
TD->getIntPtrType(Context), NULL);
|
TD->getIntPtrType(Context), nullptr);
|
||||||
Dst = CastToCStr(Dst, B);
|
Dst = CastToCStr(Dst, B);
|
||||||
Src = CastToCStr(Src, B);
|
Src = CastToCStr(Src, B);
|
||||||
CallInst *CI = B.CreateCall4(MemCpy, Dst, Src, Len, ObjSize);
|
CallInst *CI = B.CreateCall4(MemCpy, Dst, Src, Len, ObjSize);
|
||||||
|
@ -242,7 +242,7 @@ Value *llvm::EmitMemChr(Value *Ptr, Value *Val,
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
NULL);
|
nullptr);
|
||||||
CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr");
|
CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr");
|
||||||
|
|
||||||
if (const Function *F = dyn_cast<Function>(MemChr->stripPointerCasts()))
|
if (const Function *F = dyn_cast<Function>(MemChr->stripPointerCasts()))
|
||||||
|
@ -271,7 +271,7 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
TD->getIntPtrType(Context), NULL);
|
TD->getIntPtrType(Context), nullptr);
|
||||||
CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B),
|
CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B),
|
||||||
Len, "memcmp");
|
Len, "memcmp");
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ Value *llvm::EmitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B,
|
||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
Value *Callee = M->getOrInsertFunction(Name, Op->getType(),
|
Value *Callee = M->getOrInsertFunction(Name, Op->getType(),
|
||||||
Op->getType(), NULL);
|
Op->getType(), nullptr);
|
||||||
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()))
|
||||||
|
@ -328,7 +328,7 @@ Value *llvm::EmitBinaryFloatFnCall(Value *Op1, Value *Op2, StringRef Name,
|
||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
Value *Callee = M->getOrInsertFunction(Name, Op1->getType(),
|
Value *Callee = M->getOrInsertFunction(Name, Op1->getType(),
|
||||||
Op1->getType(), Op2->getType(), NULL);
|
Op1->getType(), Op2->getType(), nullptr);
|
||||||
CallInst *CI = B.CreateCall2(Callee, Op1, Op2, Name);
|
CallInst *CI = B.CreateCall2(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()))
|
||||||
|
@ -346,7 +346,7 @@ Value *llvm::EmitPutChar(Value *Char, IRBuilder<> &B, const DataLayout *TD,
|
||||||
|
|
||||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||||
Value *PutChar = M->getOrInsertFunction("putchar", B.getInt32Ty(),
|
Value *PutChar = M->getOrInsertFunction("putchar", B.getInt32Ty(),
|
||||||
B.getInt32Ty(), NULL);
|
B.getInt32Ty(), nullptr);
|
||||||
CallInst *CI = B.CreateCall(PutChar,
|
CallInst *CI = B.CreateCall(PutChar,
|
||||||
B.CreateIntCast(Char,
|
B.CreateIntCast(Char,
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
|
@ -376,7 +376,7 @@ Value *llvm::EmitPutS(Value *Str, IRBuilder<> &B, const DataLayout *TD,
|
||||||
AttributeSet::get(M->getContext(), AS),
|
AttributeSet::get(M->getContext(), AS),
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
NULL);
|
nullptr);
|
||||||
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()))
|
||||||
CI->setCallingConv(F->getCallingConv());
|
CI->setCallingConv(F->getCallingConv());
|
||||||
|
@ -401,12 +401,12 @@ Value *llvm::EmitFPutC(Value *Char, Value *File, IRBuilder<> &B,
|
||||||
AttributeSet::get(M->getContext(), AS),
|
AttributeSet::get(M->getContext(), AS),
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
B.getInt32Ty(), File->getType(),
|
B.getInt32Ty(), File->getType(),
|
||||||
NULL);
|
nullptr);
|
||||||
else
|
else
|
||||||
F = M->getOrInsertFunction("fputc",
|
F = M->getOrInsertFunction("fputc",
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
File->getType(), NULL);
|
File->getType(), nullptr);
|
||||||
Char = B.CreateIntCast(Char, B.getInt32Ty(), /*isSigned*/true,
|
Char = B.CreateIntCast(Char, B.getInt32Ty(), /*isSigned*/true,
|
||||||
"chari");
|
"chari");
|
||||||
CallInst *CI = B.CreateCall2(F, Char, File, "fputc");
|
CallInst *CI = B.CreateCall2(F, Char, File, "fputc");
|
||||||
|
@ -436,11 +436,11 @@ Value *llvm::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B,
|
||||||
AttributeSet::get(M->getContext(), AS),
|
AttributeSet::get(M->getContext(), AS),
|
||||||
B.getInt32Ty(),
|
B.getInt32Ty(),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
File->getType(), NULL);
|
File->getType(), nullptr);
|
||||||
else
|
else
|
||||||
F = M->getOrInsertFunction(FPutsName, B.getInt32Ty(),
|
F = M->getOrInsertFunction(FPutsName, B.getInt32Ty(),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
File->getType(), NULL);
|
File->getType(), nullptr);
|
||||||
CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs");
|
CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs");
|
||||||
|
|
||||||
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
|
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
|
||||||
|
@ -472,13 +472,13 @@ Value *llvm::EmitFWrite(Value *Ptr, Value *Size, Value *File,
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
File->getType(), NULL);
|
File->getType(), nullptr);
|
||||||
else
|
else
|
||||||
F = M->getOrInsertFunction(FWriteName, TD->getIntPtrType(Context),
|
F = M->getOrInsertFunction(FWriteName, TD->getIntPtrType(Context),
|
||||||
B.getInt8PtrTy(),
|
B.getInt8PtrTy(),
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
TD->getIntPtrType(Context),
|
TD->getIntPtrType(Context),
|
||||||
File->getType(), NULL);
|
File->getType(), nullptr);
|
||||||
CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size,
|
CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size,
|
||||||
ConstantInt::get(TD->getIntPtrType(Context), 1), File);
|
ConstantInt::get(TD->getIntPtrType(Context), 1), File);
|
||||||
|
|
||||||
|
|
|
@ -759,8 +759,8 @@ Value *LibCallSimplifier::optimizeStrPBrk(CallInst *CI, IRBuilder<> &B) {
|
||||||
bool HasS1 = getConstantStringInfo(CI->getArgOperand(0), S1);
|
bool HasS1 = getConstantStringInfo(CI->getArgOperand(0), S1);
|
||||||
bool HasS2 = getConstantStringInfo(CI->getArgOperand(1), S2);
|
bool HasS2 = getConstantStringInfo(CI->getArgOperand(1), S2);
|
||||||
|
|
||||||
// strpbrk(s, "") -> NULL
|
// strpbrk(s, "") -> nullptr
|
||||||
// strpbrk("", s) -> NULL
|
// strpbrk("", s) -> nullptr
|
||||||
if ((HasS1 && S1.empty()) || (HasS2 && S2.empty()))
|
if ((HasS1 && S1.empty()) || (HasS2 && S2.empty()))
|
||||||
return Constant::getNullValue(CI->getType());
|
return Constant::getNullValue(CI->getType());
|
||||||
|
|
||||||
|
@ -1238,7 +1238,7 @@ Value *LibCallSimplifier::optimizeExp2(CallInst *CI, IRBuilder<> &B) {
|
||||||
Module *M = Caller->getParent();
|
Module *M = Caller->getParent();
|
||||||
Value *Callee =
|
Value *Callee =
|
||||||
M->getOrInsertFunction(TLI->getName(LdExp), Op->getType(),
|
M->getOrInsertFunction(TLI->getName(LdExp), Op->getType(),
|
||||||
Op->getType(), B.getInt32Ty(), NULL);
|
Op->getType(), B.getInt32Ty(), nullptr);
|
||||||
CallInst *CI = B.CreateCall2(Callee, One, LdExpArg);
|
CallInst *CI = B.CreateCall2(Callee, One, LdExpArg);
|
||||||
if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts()))
|
if (const Function *F = dyn_cast<Function>(Callee->stripPointerCasts()))
|
||||||
CI->setCallingConv(F->getCallingConv());
|
CI->setCallingConv(F->getCallingConv());
|
||||||
|
@ -1463,15 +1463,15 @@ void insertSinCosCall(IRBuilder<> &B, Function *OrigCallee, Value *Arg,
|
||||||
// xmm0 and xmm1, which isn't what a real struct would do.
|
// xmm0 and xmm1, which isn't what a real struct would do.
|
||||||
ResTy = T.getArch() == Triple::x86_64
|
ResTy = T.getArch() == Triple::x86_64
|
||||||
? static_cast<Type *>(VectorType::get(ArgTy, 2))
|
? static_cast<Type *>(VectorType::get(ArgTy, 2))
|
||||||
: static_cast<Type *>(StructType::get(ArgTy, ArgTy, NULL));
|
: static_cast<Type *>(StructType::get(ArgTy, ArgTy, nullptr));
|
||||||
} else {
|
} else {
|
||||||
Name = "__sincospi_stret";
|
Name = "__sincospi_stret";
|
||||||
ResTy = StructType::get(ArgTy, ArgTy, NULL);
|
ResTy = StructType::get(ArgTy, ArgTy, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Module *M = OrigCallee->getParent();
|
Module *M = OrigCallee->getParent();
|
||||||
Value *Callee = M->getOrInsertFunction(Name, OrigCallee->getAttributes(),
|
Value *Callee = M->getOrInsertFunction(Name, OrigCallee->getAttributes(),
|
||||||
ResTy, ArgTy, NULL);
|
ResTy, ArgTy, nullptr);
|
||||||
|
|
||||||
if (Instruction *ArgInst = dyn_cast<Instruction>(Arg)) {
|
if (Instruction *ArgInst = dyn_cast<Instruction>(Arg)) {
|
||||||
// If the argument is an instruction, it must dominate all uses so put our
|
// If the argument is an instruction, it must dominate all uses so put our
|
||||||
|
|
Loading…
Reference in New Issue