mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 06:09:05 +00:00
SanitizerCoverage: Use createSanitizerCtor
to create ctor and call init
Reviewers: kcc, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8780 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236780 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
db5cc208f2
commit
57d28fee47
@ -156,7 +156,6 @@ class SanitizerCoverageModule : public ModulePass {
|
||||
Function *SanCovFunction;
|
||||
Function *SanCovWithCheckFunction;
|
||||
Function *SanCovIndirCallFunction;
|
||||
Function *SanCovModuleInit;
|
||||
Function *SanCovTraceEnter, *SanCovTraceBB;
|
||||
Function *SanCovTraceCmpFunction;
|
||||
InlineAsm *EmptyAsm;
|
||||
@ -184,12 +183,6 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
|
||||
Type *Int32PtrTy = PointerType::getUnqual(IRB.getInt32Ty());
|
||||
Int64Ty = IRB.getInt64Ty();
|
||||
|
||||
Function *CtorFunc =
|
||||
Function::Create(FunctionType::get(VoidTy, false),
|
||||
GlobalValue::InternalLinkage, kSanCovModuleCtorName, &M);
|
||||
ReturnInst::Create(*C, BasicBlock::Create(*C, "", CtorFunc));
|
||||
appendToGlobalCtors(M, CtorFunc, kSanCtorAndDtorPriority);
|
||||
|
||||
SanCovFunction = checkSanitizerInterfaceFunction(
|
||||
M.getOrInsertFunction(kSanCovName, VoidTy, Int32PtrTy, nullptr));
|
||||
SanCovWithCheckFunction = checkSanitizerInterfaceFunction(
|
||||
@ -201,10 +194,6 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
|
||||
checkSanitizerInterfaceFunction(M.getOrInsertFunction(
|
||||
kSanCovTraceCmp, VoidTy, Int64Ty, Int64Ty, Int64Ty, nullptr));
|
||||
|
||||
SanCovModuleInit = checkSanitizerInterfaceFunction(M.getOrInsertFunction(
|
||||
kSanCovModuleInitName, VoidTy, Int32PtrTy, IntptrTy,
|
||||
Int8PtrTy, Int8PtrTy, nullptr));
|
||||
SanCovModuleInit->setLinkage(Function::ExternalLinkage);
|
||||
// We insert an empty inline asm after cov callbacks to avoid callback merge.
|
||||
EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
|
||||
StringRef(""), StringRef(""),
|
||||
@ -270,15 +259,21 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
|
||||
new GlobalVariable(M, ModNameStrConst->getType(), true,
|
||||
GlobalValue::PrivateLinkage, ModNameStrConst);
|
||||
|
||||
// Call __sanitizer_cov_module_init
|
||||
IRB.SetInsertPoint(CtorFunc->getEntryBlock().getTerminator());
|
||||
IRB.CreateCall4(
|
||||
SanCovModuleInit, IRB.CreatePointerCast(RealGuardArray, Int32PtrTy),
|
||||
ArrayRef<Value *> InitArgs = {
|
||||
IRB.CreatePointerCast(RealGuardArray, Int32PtrTy),
|
||||
ConstantInt::get(IntptrTy, N),
|
||||
Options.Use8bitCounters
|
||||
? IRB.CreatePointerCast(RealEightBitCounterArray, Int8PtrTy)
|
||||
: Constant::getNullValue(Int8PtrTy),
|
||||
IRB.CreatePointerCast(ModuleName, Int8PtrTy));
|
||||
IRB.CreatePointerCast(ModuleName, Int8PtrTy)};
|
||||
|
||||
Function *CtorFunc;
|
||||
std::tie(CtorFunc, std::ignore) = createSanitizerCtorAndInitFunctions(
|
||||
M, kSanCovModuleCtorName, kSanCovModuleInitName,
|
||||
{Int32PtrTy, IntptrTy, Int8PtrTy, Int8PtrTy}, InitArgs);
|
||||
|
||||
appendToGlobalCtors(M, CtorFunc, kSanCtorAndDtorPriority);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user