From b81960a6c858b4d40d64798cac3e56ca8e6383fa Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Fri, 19 Aug 2016 08:33:53 +0000 Subject: [PATCH] [asan] Fix size of shadow incorrectly calculated in r279178 Summary: r279178 generates 8 times more stores than necessary. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23708 llvm-svn: 279222 --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 6 ++---- .../Instrumentation/AddressSanitizer/stack-poisoning.ll | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 67aef34a54b9..4105dd89d85c 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2237,10 +2237,8 @@ void FunctionStackPoisoner::poisonStack() { IRBuilder<> IRBPoison(ThenTerm); if (StackMallocIdx <= 4) { int ClassSize = kMinStackMallocSize << StackMallocIdx; - if ((int)ShadowBytesAfterReturn.size() != ClassSize) { - ShadowBytesAfterReturn.resize(ClassSize, - kAsanStackUseAfterReturnMagic); - } + ShadowBytesAfterReturn.resize(ClassSize >> Mapping.Scale, + kAsanStackUseAfterReturnMagic); poisonRedZones(ShadowBytesAfterReturn, IRBPoison, ShadowBase, true); Value *SavedFlagPtrPtr = IRBPoison.CreateAdd( FakeStack, diff --git a/llvm/test/Instrumentation/AddressSanitizer/stack-poisoning.ll b/llvm/test/Instrumentation/AddressSanitizer/stack-poisoning.ll index a3c852ad04ea..b84a9e74f54d 100644 --- a/llvm/test/Instrumentation/AddressSanitizer/stack-poisoning.ll +++ b/llvm/test/Instrumentation/AddressSanitizer/stack-poisoning.ll @@ -44,6 +44,7 @@ entry: ; CHECK-UAR: store i64 -723401728380766731 ; CHECK-UAR: store i64 -723401728380766731 ; CHECK-UAR: store i64 -723401728380766731 + ; CHECK-UAR-NOT: store i64 ; CHECK-UAR: store i8 0 ; CHECK-UAR-NOT: store ; CHECK-UAR: label