[llvm] r236951 - SanitizerCoverage: Use `createSanitizerCtor` to create ctor and call init
Ismail Pazarbasi
ismail.pazarbasi at gmail.com
Sun May 10 06:45:05 PDT 2015
Author: ismailp
Date: Sun May 10 08:45:05 2015
New Revision: 236951
URL: http://llvm.org/viewvc/llvm-project?rev=236951&view=rev
Log:
SanitizerCoverage: Use `createSanitizerCtor` to create ctor and call init
Second attempt; instead of using a named local variable, passing
arguments directly to `createSanitizerCtorAndInitFunctions` worked
on Windows.
Reviewers: kcc, samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D8780
Modified:
llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=236951&r1=236950&r2=236951&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Sun May 10 08:45:05 2015
@@ -156,7 +156,6 @@ class SanitizerCoverageModule : public M
Function *SanCovFunction;
Function *SanCovWithCheckFunction;
Function *SanCovIndirCallFunction;
- Function *SanCovModuleInit;
Function *SanCovTraceEnter, *SanCovTraceBB;
Function *SanCovTraceCmpFunction;
InlineAsm *EmptyAsm;
@@ -184,12 +183,6 @@ bool SanitizerCoverageModule::runOnModul
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::runOnModul
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,19 @@ bool SanitizerCoverageModule::runOnModul
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),
- ConstantInt::get(IntptrTy, N),
- Options.Use8bitCounters
- ? IRB.CreatePointerCast(RealEightBitCounterArray, Int8PtrTy)
- : Constant::getNullValue(Int8PtrTy),
- IRB.CreatePointerCast(ModuleName, Int8PtrTy));
+ Function *CtorFunc;
+ std::tie(CtorFunc, std::ignore) = createSanitizerCtorAndInitFunctions(
+ M, kSanCovModuleCtorName, kSanCovModuleInitName,
+ {Int32PtrTy, IntptrTy, Int8PtrTy, Int8PtrTy},
+ {IRB.CreatePointerCast(RealGuardArray, Int32PtrTy),
+ ConstantInt::get(IntptrTy, N),
+ Options.Use8bitCounters
+ ? IRB.CreatePointerCast(RealEightBitCounterArray, Int8PtrTy)
+ : Constant::getNullValue(Int8PtrTy),
+ IRB.CreatePointerCast(ModuleName, Int8PtrTy)});
+
+ appendToGlobalCtors(M, CtorFunc, kSanCtorAndDtorPriority);
+
return true;
}
More information about the llvm-commits
mailing list