From: Kirill Stoimenov Date: Thu, 19 Aug 2021 18:11:10 +0000 (+0000) Subject: [asan] Implemented getAddressSanitizerParams used by the ASan callback optimization... X-Git-Tag: upstream/15.0.7~33379 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05a8c0b5f8c425ada7e0fdc5210be4d456ce7bc0;p=platform%2Fupstream%2Fllvm.git [asan] Implemented getAddressSanitizerParams used by the ASan callback optimization code. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D108397 --- diff --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h index 5de80e6..86c6ce4 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h +++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @@ -87,6 +87,11 @@ bool forAllReachableExits(const DominatorTree &DT, const PostDominatorTree &PDT, return true; } +// Get AddressSanitizer parameters. +void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize, + bool IsKasan, uint64_t *ShadowBase, + int *MappingScale, bool *OrShadowOffset); + } // namespace llvm #endif diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 2b8f5b7..d03538a 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -442,7 +442,7 @@ struct ShadowMapping { } // end anonymous namespace -static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize, +static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize, bool IsKasan) { bool IsAndroid = TargetTriple.isAndroid(); bool IsIOS = TargetTriple.isiOS() || TargetTriple.isWatchOS(); @@ -559,6 +559,17 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize, return Mapping; } +namespace llvm { +void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize, + bool IsKasan, uint64_t *ShadowBase, + int *MappingScale, bool *OrShadowOffset) { + auto Mapping = getShadowMapping(TargetTriple, LongSize, IsKasan); + *ShadowBase = Mapping.Offset; + *MappingScale = Mapping.Scale; + *OrShadowOffset = Mapping.OrShadowOffset; +} +} // namespace llvm + static uint64_t getRedzoneSizeForScale(int MappingScale) { // Redzone used for stack and globals is at least 32 bytes. // For scales 6 and 7, the redzone has to be 64 and 128 bytes respectively.