[asan] Avoid assert failure for non-default shadow scale
authorWalter Lee <waltl@google.com>
Thu, 16 Nov 2017 22:02:58 +0000 (22:02 +0000)
committerWalter Lee <waltl@google.com>
Thu, 16 Nov 2017 22:02:58 +0000 (22:02 +0000)
Rather than assertion failing, we can fall back to the
non-optimized version which works for any shadow scale.

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

llvm-svn: 318460

compiler-rt/lib/asan/asan_fake_stack.cc

index 6a064aa..1c6184e 100644 (file)
@@ -28,9 +28,9 @@ static const u64 kAllocaRedzoneMask = 31UL;
 
 // For small size classes inline PoisonShadow for better performance.
 ALWAYS_INLINE void SetShadow(uptr ptr, uptr size, uptr class_id, u64 magic) {
-  CHECK_EQ(SHADOW_SCALE, 3);  // This code expects SHADOW_SCALE=3.
   u64 *shadow = reinterpret_cast<u64*>(MemToShadow(ptr));
-  if (class_id <= 6) {
+  if (SHADOW_SCALE == 3 && class_id <= 6) {
+    // This code expects SHADOW_SCALE=3.
     for (uptr i = 0; i < (((uptr)1) << class_id); i++) {
       shadow[i] = magic;
       // Make sure this does not become memset.