Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -54,6 +54,7 @@ #include "llvm/Transforms/Utils/ModuleUtils.h" #include "llvm/Transforms/Utils/PromoteMemToReg.h" #include +#include #include #include @@ -111,6 +112,12 @@ static const char *const kAsanGenPrefix = "__asan_gen_"; static const char *const kODRGenPrefix = "__odr_asan_gen_"; static const char *const kSanCovGenPrefix = "__sancov_gen_"; +static const char *const kAsanSetShadow00Func = "__asan_set_shadow_00"; +static const char *const kAsanSetShadowf1Func = "__asan_set_shadow_f1"; +static const char *const kAsanSetShadowf2Func = "__asan_set_shadow_f2"; +static const char *const kAsanSetShadowf3Func = "__asan_set_shadow_f3"; +static const char *const kAsanSetShadowf5Func = "__asan_set_shadow_f5"; +static const char *const kAsanSetShadowf8Func = "__asan_set_shadow_f8"; static const char *const kAsanPoisonStackMemoryName = "__asan_poison_stack_memory"; static const char *const kAsanUnpoisonStackMemoryName = @@ -612,6 +619,7 @@ Function *AsanStackMallocFunc[kMaxAsanStackMallocSizeClass + 1], *AsanStackFreeFunc[kMaxAsanStackMallocSizeClass + 1]; + Function *AsanSetShadowFunc[1 << sizeof(uint8_t)] = {}; Function *AsanPoisonStackMemoryFunc, *AsanUnpoisonStackMemoryFunc; Function *AsanAllocaPoisonFunc, *AsanAllocasUnpoisonFunc; @@ -1919,6 +1927,15 @@ IntptrTy, IntptrTy, nullptr)); } + for (const char *Name : + {kAsanSetShadow00Func, kAsanSetShadowf1Func, kAsanSetShadowf2Func, + kAsanSetShadowf3Func, kAsanSetShadowf5Func, kAsanSetShadowf8Func}) { + char *End = 0; + AsanSetShadowFunc[std::strtoul(Name + strlen(Name) - 2, &End, 16)] = + checkSanitizerInterfaceFunction(M.getOrInsertFunction( + Name, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr)); + } + AsanAllocaPoisonFunc = checkSanitizerInterfaceFunction(M.getOrInsertFunction( kAsanAllocaPoison, IRB.getVoidTy(), IntptrTy, IntptrTy, nullptr)); AsanAllocasUnpoisonFunc =