Skip to content

Commit 05a8c0b

Browse files
committed
[asan] Implemented getAddressSanitizerParams used by the ASan callback optimization code.
Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D108397
1 parent a232a48 commit 05a8c0b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ bool forAllReachableExits(const DominatorTree &DT, const PostDominatorTree &PDT,
8787
return true;
8888
}
8989

90+
// Get AddressSanitizer parameters.
91+
void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize,
92+
bool IsKasan, uint64_t *ShadowBase,
93+
int *MappingScale, bool *OrShadowOffset);
94+
9095
} // namespace llvm
9196

9297
#endif

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ struct ShadowMapping {
442442

443443
} // end anonymous namespace
444444

445-
static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
445+
static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
446446
bool IsKasan) {
447447
bool IsAndroid = TargetTriple.isAndroid();
448448
bool IsIOS = TargetTriple.isiOS() || TargetTriple.isWatchOS();
@@ -559,6 +559,17 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize,
559559
return Mapping;
560560
}
561561

562+
namespace llvm {
563+
void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize,
564+
bool IsKasan, uint64_t *ShadowBase,
565+
int *MappingScale, bool *OrShadowOffset) {
566+
auto Mapping = getShadowMapping(TargetTriple, LongSize, IsKasan);
567+
*ShadowBase = Mapping.Offset;
568+
*MappingScale = Mapping.Scale;
569+
*OrShadowOffset = Mapping.OrShadowOffset;
570+
}
571+
} // namespace llvm
572+
562573
static uint64_t getRedzoneSizeForScale(int MappingScale) {
563574
// Redzone used for stack and globals is at least 32 bytes.
564575
// For scales 6 and 7, the redzone has to be 64 and 128 bytes respectively.

0 commit comments

Comments
 (0)