[llvm] 05a8c0b - [asan] Implemented getAddressSanitizerParams used by the ASan callback optimization code.
Kirill Stoimenov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 20 07:17:24 PDT 2021
Author: Kirill Stoimenov
Date: 2021-08-20T14:17:07Z
New Revision: 05a8c0b5f8c425ada7e0fdc5210be4d456ce7bc0
URL: https://github.com/llvm/llvm-project/commit/05a8c0b5f8c425ada7e0fdc5210be4d456ce7bc0
DIFF: https://github.com/llvm/llvm-project/commit/05a8c0b5f8c425ada7e0fdc5210be4d456ce7bc0.diff
LOG: [asan] Implemented getAddressSanitizerParams used by the ASan callback optimization code.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D108397
Added:
Modified:
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
index 5de80e6b5e50..86c6ce4bc7c5 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 2b8f5b71acb8..d03538a76244 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.
More information about the llvm-commits
mailing list