[asan] Implemented getAddressSanitizerParams used by the ASan callback optimization...
authorKirill Stoimenov <kstoimenov@google.com>
Thu, 19 Aug 2021 18:11:10 +0000 (18:11 +0000)
committerKirill Stoimenov <kstoimenov@google.com>
Fri, 20 Aug 2021 14:17:07 +0000 (14:17 +0000)
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D108397

llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

index 5de80e6..86c6ce4 100644 (file)
@@ -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
index 2b8f5b7..d03538a 100644 (file)
@@ -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.