summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp62
1 files changed, 27 insertions, 35 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
index bb146dab584..14b05662c3e 100644
--- a/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
@@ -202,13 +202,13 @@ private:
// Our slowpath involves callouts to the runtime library.
// Access sizes are powers of two: 1, 2, 4, 8, 16.
static const size_t NumberOfAccessSizes = 5;
- Function *EsanAlignedLoad[NumberOfAccessSizes];
- Function *EsanAlignedStore[NumberOfAccessSizes];
- Function *EsanUnalignedLoad[NumberOfAccessSizes];
- Function *EsanUnalignedStore[NumberOfAccessSizes];
+ FunctionCallee EsanAlignedLoad[NumberOfAccessSizes];
+ FunctionCallee EsanAlignedStore[NumberOfAccessSizes];
+ FunctionCallee EsanUnalignedLoad[NumberOfAccessSizes];
+ FunctionCallee EsanUnalignedStore[NumberOfAccessSizes];
// For irregular sizes of any alignment:
- Function *EsanUnalignedLoadN, *EsanUnalignedStoreN;
- Function *MemmoveFn, *MemcpyFn, *MemsetFn;
+ FunctionCallee EsanUnalignedLoadN, EsanUnalignedStoreN;
+ FunctionCallee MemmoveFn, MemcpyFn, MemsetFn;
Function *EsanCtorFunction;
Function *EsanDtorFunction;
// Remember the counter variable for each struct type to avoid
@@ -249,37 +249,31 @@ void EfficiencySanitizer::initializeCallbacks(Module &M) {
// We'll inline the most common (i.e., aligned and frequent sizes)
// load + store instrumentation: these callouts are for the slowpath.
SmallString<32> AlignedLoadName("__esan_aligned_load" + ByteSizeStr);
- EsanAlignedLoad[Idx] =
- checkSanitizerInterfaceFunction(M.getOrInsertFunction(
- AlignedLoadName, IRB.getVoidTy(), IRB.getInt8PtrTy()));
+ EsanAlignedLoad[Idx] = M.getOrInsertFunction(
+ AlignedLoadName, IRB.getVoidTy(), IRB.getInt8PtrTy());
SmallString<32> AlignedStoreName("__esan_aligned_store" + ByteSizeStr);
- EsanAlignedStore[Idx] =
- checkSanitizerInterfaceFunction(M.getOrInsertFunction(
- AlignedStoreName, IRB.getVoidTy(), IRB.getInt8PtrTy()));
+ EsanAlignedStore[Idx] = M.getOrInsertFunction(
+ AlignedStoreName, IRB.getVoidTy(), IRB.getInt8PtrTy());
SmallString<32> UnalignedLoadName("__esan_unaligned_load" + ByteSizeStr);
- EsanUnalignedLoad[Idx] =
- checkSanitizerInterfaceFunction(M.getOrInsertFunction(
- UnalignedLoadName, IRB.getVoidTy(), IRB.getInt8PtrTy()));
+ EsanUnalignedLoad[Idx] = M.getOrInsertFunction(
+ UnalignedLoadName, IRB.getVoidTy(), IRB.getInt8PtrTy());
SmallString<32> UnalignedStoreName("__esan_unaligned_store" + ByteSizeStr);
- EsanUnalignedStore[Idx] =
- checkSanitizerInterfaceFunction(M.getOrInsertFunction(
- UnalignedStoreName, IRB.getVoidTy(), IRB.getInt8PtrTy()));
+ EsanUnalignedStore[Idx] = M.getOrInsertFunction(
+ UnalignedStoreName, IRB.getVoidTy(), IRB.getInt8PtrTy());
}
- EsanUnalignedLoadN = checkSanitizerInterfaceFunction(
- M.getOrInsertFunction("__esan_unaligned_loadN", IRB.getVoidTy(),
- IRB.getInt8PtrTy(), IntptrTy));
- EsanUnalignedStoreN = checkSanitizerInterfaceFunction(
- M.getOrInsertFunction("__esan_unaligned_storeN", IRB.getVoidTy(),
- IRB.getInt8PtrTy(), IntptrTy));
- MemmoveFn = checkSanitizerInterfaceFunction(
+ EsanUnalignedLoadN = M.getOrInsertFunction(
+ "__esan_unaligned_loadN", IRB.getVoidTy(), IRB.getInt8PtrTy(), IntptrTy);
+ EsanUnalignedStoreN = M.getOrInsertFunction(
+ "__esan_unaligned_storeN", IRB.getVoidTy(), IRB.getInt8PtrTy(), IntptrTy);
+ MemmoveFn =
M.getOrInsertFunction("memmove", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
- IRB.getInt8PtrTy(), IntptrTy));
- MemcpyFn = checkSanitizerInterfaceFunction(
+ IRB.getInt8PtrTy(), IntptrTy);
+ MemcpyFn =
M.getOrInsertFunction("memcpy", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
- IRB.getInt8PtrTy(), IntptrTy));
- MemsetFn = checkSanitizerInterfaceFunction(
+ IRB.getInt8PtrTy(), IntptrTy);
+ MemsetFn =
M.getOrInsertFunction("memset", IRB.getInt8PtrTy(), IRB.getInt8PtrTy(),
- IRB.getInt32Ty(), IntptrTy));
+ IRB.getInt32Ty(), IntptrTy);
}
bool EfficiencySanitizer::shouldIgnoreStructType(StructType *StructTy) {
@@ -510,10 +504,8 @@ void EfficiencySanitizer::createDestructor(Module &M, Constant *ToolInfoArg) {
EsanModuleDtorName, &M);
ReturnInst::Create(*Ctx, BasicBlock::Create(*Ctx, "", EsanDtorFunction));
IRBuilder<> IRB_Dtor(EsanDtorFunction->getEntryBlock().getTerminator());
- Function *EsanExit = checkSanitizerInterfaceFunction(
- M.getOrInsertFunction(EsanExitName, IRB_Dtor.getVoidTy(),
- Int8PtrTy));
- EsanExit->setLinkage(Function::ExternalLinkage);
+ FunctionCallee EsanExit =
+ M.getOrInsertFunction(EsanExitName, IRB_Dtor.getVoidTy(), Int8PtrTy);
IRB_Dtor.CreateCall(EsanExit, {ToolInfoArg});
appendToGlobalDtors(M, EsanDtorFunction, EsanCtorAndDtorPriority);
}
@@ -669,7 +661,7 @@ bool EfficiencySanitizer::instrumentLoadOrStore(Instruction *I,
Type *OrigTy = cast<PointerType>(Addr->getType())->getElementType();
const uint32_t TypeSizeBytes = DL.getTypeStoreSizeInBits(OrigTy) / 8;
- Value *OnAccessFunc = nullptr;
+ FunctionCallee OnAccessFunc = nullptr;
// Convert 0 to the default alignment.
if (Alignment == 0)
OpenPOWER on IntegriCloud