2014-10-17 00:48:02 +02:00
|
|
|
//===- InstrumentationBindings.cpp - instrumentation bindings -------------===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2014-10-17 00:48:02 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines C bindings for the instrumentation component.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "InstrumentationBindings.h"
|
|
|
|
#include "llvm-c/Core.h"
|
2015-02-13 11:01:29 +01:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2014-10-17 00:48:02 +02:00
|
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "llvm/Transforms/Instrumentation.h"
|
[NewPM] Port Msan
Summary:
Keeping msan a function pass requires replacing the module level initialization:
That means, don't define a ctor function which calls __msan_init, instead just
declare the init function at the first access, and add that to the global ctors
list.
Changes:
- Pull the actual sanitizer and the wrapper pass apart.
- Add a newpm msan pass. The function pass inserts calls to runtime
library functions, for which it inserts declarations as necessary.
- Update tests.
Caveats:
- There is one test that I dropped, because it specifically tested the
definition of the ctor.
Reviewers: chandlerc, fedor.sergeev, leonardchan, vitalybuka
Subscribers: sdardis, nemanjai, javed.absar, hiraditya, kbarton, bollu, atanasyan, jsji
Differential Revision: https://reviews.llvm.org/D55647
llvm-svn: 350305
2019-01-03 14:42:44 +01:00
|
|
|
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
|
2019-01-16 10:28:01 +01:00
|
|
|
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
|
2014-10-17 00:48:02 +02:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
void LLVMAddAddressSanitizerFunctionPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createAddressSanitizerFunctionPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createAddressSanitizerModulePass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM) {
|
2019-01-16 10:28:01 +01:00
|
|
|
unwrap(PM)->add(createThreadSanitizerLegacyPassPass());
|
2014-10-17 00:48:02 +02:00
|
|
|
}
|
|
|
|
|
[NewPM] Port Msan
Summary:
Keeping msan a function pass requires replacing the module level initialization:
That means, don't define a ctor function which calls __msan_init, instead just
declare the init function at the first access, and add that to the global ctors
list.
Changes:
- Pull the actual sanitizer and the wrapper pass apart.
- Add a newpm msan pass. The function pass inserts calls to runtime
library functions, for which it inserts declarations as necessary.
- Update tests.
Caveats:
- There is one test that I dropped, because it specifically tested the
definition of the ctor.
Reviewers: chandlerc, fedor.sergeev, leonardchan, vitalybuka
Subscribers: sdardis, nemanjai, javed.absar, hiraditya, kbarton, bollu, atanasyan, jsji
Differential Revision: https://reviews.llvm.org/D55647
llvm-svn: 350305
2019-01-03 14:42:44 +01:00
|
|
|
void LLVMAddMemorySanitizerLegacyPassPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createMemorySanitizerLegacyPassPass());
|
2014-10-17 00:48:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM,
|
2015-02-04 18:39:48 +01:00
|
|
|
int ABIListFilesNum,
|
|
|
|
const char **ABIListFiles) {
|
|
|
|
std::vector<std::string> ABIListFilesVec;
|
|
|
|
for (int i = 0; i != ABIListFilesNum; ++i) {
|
|
|
|
ABIListFilesVec.push_back(ABIListFiles[i]);
|
|
|
|
}
|
|
|
|
unwrap(PM)->add(createDataFlowSanitizerPass(ABIListFilesVec));
|
2014-10-17 00:48:02 +02:00
|
|
|
}
|