mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +03:00
Add MSan compiler-rt library to LDC install and add it to linkerline for --fsanitize=memory (#3751)
* Add MSan compiler-rt library to LDC install and add it to linkerline for --fsanitize=memory * MSan: Add support for `-fsanitize-memory-track-origins=`
This commit is contained in:
parent
4e6c9d0ffd
commit
a5025bf83e
6 changed files with 51 additions and 5 deletions
|
@ -114,6 +114,11 @@ static cl::opt<bool>
|
|||
disableSLPVectorization("disable-slp-vectorization", cl::ZeroOrMore,
|
||||
cl::desc("Disable the slp vectorization pass"));
|
||||
|
||||
static cl::opt<int> fSanitizeMemoryTrackOrigins(
|
||||
"fsanitize-memory-track-origins", cl::ZeroOrMore, cl::init(0),
|
||||
cl::desc(
|
||||
"Enable origins tracking in MemorySanitizer (0=disabled, default)"));
|
||||
|
||||
unsigned optLevel() {
|
||||
// Use -O2 as a base for the size-optimization levels.
|
||||
return optimizeLevel >= 0 ? optimizeLevel : 2;
|
||||
|
@ -201,8 +206,14 @@ static void addAddressSanitizerPasses(const PassManagerBuilder &Builder,
|
|||
|
||||
static void addMemorySanitizerPass(const PassManagerBuilder &Builder,
|
||||
PassManagerBase &PM) {
|
||||
#if LDC_LLVM_VER >= 800
|
||||
PM.add(createMemorySanitizerLegacyPassPass());
|
||||
int trackOrigins = fSanitizeMemoryTrackOrigins;
|
||||
bool recover = false;
|
||||
bool kernel = false;
|
||||
#if LDC_LLVM_VER >= 900
|
||||
PM.add(createMemorySanitizerLegacyPassPass(
|
||||
MemorySanitizerOptions{trackOrigins, recover, kernel}));
|
||||
#elif LDC_LLVM_VER >= 800
|
||||
PM.add(createMemorySanitizerLegacyPassPass(trackOrigins, recover, kernel));
|
||||
#else
|
||||
PM.add(createMemorySanitizerPass());
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue