diff options
author | Vitaly Buka <vitalybuka@google.com> | 2016-08-20 16:48:24 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2016-08-20 16:48:24 +0000 |
commit | f9fd63ad39936968e5b81a5ad5d269ffa761604c (patch) | |
tree | 0cc7675c2c30acd49051efa8d9a677fd49139f58 /llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp | |
parent | 1bdc716dca2dfcd492191bc4285a8c41baea4da7 (diff) | |
download | bcm5719-llvm-f9fd63ad39936968e5b81a5ad5d269ffa761604c.tar.gz bcm5719-llvm-f9fd63ad39936968e5b81a5ad5d269ffa761604c.zip |
[asan] Add support of lifetime poisoning into ComputeASanStackFrameLayout
Summary:
We are going to combine poisoning of red zones and scope poisoning.
PR27453
Reviewers: kcc, eugenis
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D23623
llvm-svn: 279373
Diffstat (limited to 'llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp b/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp index 7e50d4bb447..8e2ff7f25a2 100644 --- a/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp +++ b/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp @@ -81,19 +81,26 @@ ComputeASanStackFrameLayout(SmallVectorImpl<ASanStackVariableDescription> &Vars, assert(Layout->FrameAlignment >= Alignment); assert((Offset % Alignment) == 0); assert(Size > 0); + assert(Vars[i].LifetimeSize <= Size); StackDescription << " " << Offset << " " << Size << " " << strlen(Name) << " " << Name; size_t NextAlignment = IsLast ? Granularity : std::max(Granularity, Vars[i + 1].Alignment); size_t SizeWithRedzone = VarAndRedzoneSize(Vars[i].Size, NextAlignment); - SB.insert(SB.end(), Size / Granularity, 0); - if (Size % Granularity) - SB.insert(SB.end(), Size % Granularity); + size_t LifetimeShadowSize = + (Vars[i].LifetimeSize + Granularity - 1) / Granularity; + SB.insert(SB.end(), LifetimeShadowSize, kAsanStackUseAfterScopeMagic); + if (Size / Granularity >= LifetimeShadowSize) { + SB.insert(SB.end(), Size / Granularity - LifetimeShadowSize, 0); + if (Size % Granularity) + SB.insert(SB.end(), Size % Granularity); + } SB.insert(SB.end(), (SizeWithRedzone - Size) / Granularity, IsLast ? kAsanStackRightRedzoneMagic : kAsanStackMidRedzoneMagic); Vars[i].Offset = Offset; Offset += SizeWithRedzone; + assert(Offset == SB.size() * Granularity); } if (Offset % MinHeaderSize) { size_t ExtraRedzone = MinHeaderSize - (Offset % MinHeaderSize); |