[PATCH] SanitizerCoverage: Use `createSanitizerCtor` to create ctor and call init
Ismail Pazarbasi
ismail.pazarbasi at gmail.com
Wed Apr 1 09:53:26 PDT 2015
Hi kcc, samsonov,
http://reviews.llvm.org/D8780
Files:
lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Index: lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -151,12 +151,6 @@
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 = checkInterfaceFunction(
M.getOrInsertFunction(kSanCovName, VoidTy, Int32PtrTy, nullptr));
SanCovWithCheckFunction = checkInterfaceFunction(
@@ -235,15 +229,21 @@
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),
ClUse8bitCounters
? IRB.CreatePointerCast(RealEightBitCounterArray, Int8PtrTy)
: Constant::getNullValue(Int8PtrTy),
- IRB.CreatePointerCast(ModuleName, Int8PtrTy));
+ IRB.CreatePointerCast(ModuleName, Int8PtrTy)};
+
+ Function *CtorFunc =
+ createSanitizerCtor(M, kSanCovModuleCtorName, kSanCovModuleInitName,
+ {Int32PtrTy, IntptrTy, Int8PtrTy, Int8PtrTy},
+ InitArgs, &SanCovModuleInit);
+
+ appendToGlobalCtors(M, CtorFunc, kSanCtorAndDtorPriority);
+
return true;
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8780.23072.patch
Type: text/x-patch
Size: 1886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150401/c5bb32d1/attachment.bin>
More information about the llvm-commits
mailing list