mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-05 11:17:53 +00:00
[sanitizer] when dumping the basic block trace, also dump the module names. Patch by Laszlo Szekeres
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229940 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -137,6 +137,7 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
|
|||||||
IntptrTy = Type::getIntNTy(*C, DLP->getDataLayout().getPointerSizeInBits());
|
IntptrTy = Type::getIntNTy(*C, DLP->getDataLayout().getPointerSizeInBits());
|
||||||
Type *VoidTy = Type::getVoidTy(*C);
|
Type *VoidTy = Type::getVoidTy(*C);
|
||||||
IRBuilder<> IRB(*C);
|
IRBuilder<> IRB(*C);
|
||||||
|
Type *Int8PtrTy = PointerType::getUnqual(IRB.getInt8Ty());
|
||||||
Type *Int32PtrTy = PointerType::getUnqual(IRB.getInt32Ty());
|
Type *Int32PtrTy = PointerType::getUnqual(IRB.getInt32Ty());
|
||||||
|
|
||||||
Function *CtorFunc =
|
Function *CtorFunc =
|
||||||
@@ -153,7 +154,7 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
|
|||||||
kSanCovIndirCallName, VoidTy, IntptrTy, IntptrTy, nullptr));
|
kSanCovIndirCallName, VoidTy, IntptrTy, IntptrTy, nullptr));
|
||||||
SanCovModuleInit = checkInterfaceFunction(
|
SanCovModuleInit = checkInterfaceFunction(
|
||||||
M.getOrInsertFunction(kSanCovModuleInitName, Type::getVoidTy(*C),
|
M.getOrInsertFunction(kSanCovModuleInitName, Type::getVoidTy(*C),
|
||||||
Int32PtrTy, IntptrTy, nullptr));
|
Int32PtrTy, IntptrTy, Int8PtrTy, nullptr));
|
||||||
SanCovModuleInit->setLinkage(Function::ExternalLinkage);
|
SanCovModuleInit->setLinkage(Function::ExternalLinkage);
|
||||||
// We insert an empty inline asm after cov callbacks to avoid callback merge.
|
// We insert an empty inline asm after cov callbacks to avoid callback merge.
|
||||||
EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
|
EmptyAsm = InlineAsm::get(FunctionType::get(IRB.getVoidTy(), false),
|
||||||
@@ -190,11 +191,19 @@ bool SanitizerCoverageModule::runOnModule(Module &M) {
|
|||||||
IRB.CreatePointerCast(RealGuardArray, Int32PtrTy));
|
IRB.CreatePointerCast(RealGuardArray, Int32PtrTy));
|
||||||
GuardArray->eraseFromParent();
|
GuardArray->eraseFromParent();
|
||||||
|
|
||||||
|
// Create variable for module (compilation unit) name
|
||||||
|
Constant *ModNameStrConst =
|
||||||
|
ConstantDataArray::getString(M.getContext(), M.getName(), true);
|
||||||
|
GlobalVariable *ModuleName =
|
||||||
|
new GlobalVariable(M, ModNameStrConst->getType(), true,
|
||||||
|
GlobalValue::PrivateLinkage, ModNameStrConst);
|
||||||
|
|
||||||
// Call __sanitizer_cov_module_init
|
// Call __sanitizer_cov_module_init
|
||||||
IRB.SetInsertPoint(CtorFunc->getEntryBlock().getTerminator());
|
IRB.SetInsertPoint(CtorFunc->getEntryBlock().getTerminator());
|
||||||
IRB.CreateCall2(SanCovModuleInit,
|
IRB.CreateCall3(SanCovModuleInit,
|
||||||
IRB.CreatePointerCast(RealGuardArray, Int32PtrTy),
|
IRB.CreatePointerCast(RealGuardArray, Int32PtrTy),
|
||||||
ConstantInt::get(IntptrTy, SanCovFunction->getNumUses()));
|
ConstantInt::get(IntptrTy, SanCovFunction->getNumUses()),
|
||||||
|
IRB.CreatePointerCast(ModuleName, Int8PtrTy));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user