[PATCH] Support for saving an ordered list of compilation units
Laszlo
lszekeres at cs.stonybrook.edu
Tue Feb 17 13:58:57 PST 2015
Hi kcc,
This patch supports the reconstruction of an IR level trace from the "events" file generated by the current tracer. This can be done if we know the ordered list of compilation units. This patch extends the coverage pass to pass the name of the compilation unit to the runtime. The runtime half of the patch is submitted separately.
http://reviews.llvm.org/D7702
Files:
lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Index: lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===================================================================
--- lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -137,6 +137,7 @@
IntptrTy = Type::getIntNTy(*C, DLP->getDataLayout().getPointerSizeInBits());
Type *VoidTy = Type::getVoidTy(*C);
IRBuilder<> IRB(*C);
+ Type *Int8PtrTy = PointerType::getUnqual(IRB.getInt8Ty());
Type *Int32PtrTy = PointerType::getUnqual(IRB.getInt32Ty());
Function *CtorFunc =
@@ -153,7 +154,7 @@
kSanCovIndirCallName, VoidTy, IntptrTy, IntptrTy, nullptr));
SanCovModuleInit = checkInterfaceFunction(
M.getOrInsertFunction(kSanCovModuleInitName, Type::getVoidTy(*C),
- Int32PtrTy, IntptrTy, nullptr));
+ Int32PtrTy, IntptrTy, 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),
@@ -190,11 +191,22 @@
IRB.CreatePointerCast(RealGuardArray, Int32PtrTy));
GuardArray->eraseFromParent();
+ // Create variable for module (compilation unit) name
+ ArrayType *Int8ArrayNTy =
+ ArrayType::get(IRB.getInt8Ty(), M.getName().size() + 1);
+
+ GlobalVariable *ModuleName =
+ new GlobalVariable(M, Int8ArrayNTy, true, GlobalValue::PrivateLinkage, 0);
+
+ ModuleName->setInitializer(
+ ConstantDataArray::getString(M.getContext(), M.getName(), true));
+
// Call __sanitizer_cov_module_init
IRB.SetInsertPoint(CtorFunc->getEntryBlock().getTerminator());
- IRB.CreateCall2(SanCovModuleInit,
+ IRB.CreateCall3(SanCovModuleInit,
IRB.CreatePointerCast(RealGuardArray, Int32PtrTy),
- ConstantInt::get(IntptrTy, SanCovFunction->getNumUses()));
+ ConstantInt::get(IntptrTy, SanCovFunction->getNumUses()),
+ IRB.CreatePointerCast(ModuleName, Int8PtrTy));
return true;
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7702.20106.patch
Type: text/x-patch
Size: 2094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150217/e9253415/attachment.bin>
More information about the llvm-commits
mailing list