Lines Matching +full:max +full:- +full:size

1 //===-- ASanStackFrameLayout.cpp - helper for AddressSanitizer ------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
23 // It is tempting to also sort variables by size so that larger variables
38 // The larger the variable Size the larger is the redzone.
39 // The resulting frame size is a multiple of Alignment.
40 static uint64_t VarAndRedzoneSize(uint64_t Size, uint64_t Granularity, in VarAndRedzoneSize() argument
43 if (Size <= 4) Res = 16; in VarAndRedzoneSize()
44 else if (Size <= 16) Res = 32; in VarAndRedzoneSize()
45 else if (Size <= 128) Res = Size + 32; in VarAndRedzoneSize()
46 else if (Size <= 512) Res = Size + 64; in VarAndRedzoneSize()
47 else if (Size <= 4096) Res = Size + 128; in VarAndRedzoneSize()
48 else Res = Size + 256; in VarAndRedzoneSize()
49 return alignTo(std::max(Res, 2 * Granularity), Alignment); in VarAndRedzoneSize()
56 (Granularity & (Granularity - 1)) == 0); in ComputeASanStackFrameLayout()
57 assert(MinHeaderSize >= 16 && (MinHeaderSize & (MinHeaderSize - 1)) == 0 && in ComputeASanStackFrameLayout()
59 const size_t NumVars = Vars.size(); in ComputeASanStackFrameLayout()
62 Vars[i].Alignment = std::max(Vars[i].Alignment, kMinAlignment); in ComputeASanStackFrameLayout()
68 Layout.FrameAlignment = std::max(Granularity, Vars[0].Alignment); in ComputeASanStackFrameLayout()
70 std::max(std::max(MinHeaderSize, Granularity), Vars[0].Alignment); in ComputeASanStackFrameLayout()
73 bool IsLast = i == NumVars - 1; in ComputeASanStackFrameLayout()
74 uint64_t Alignment = std::max(Granularity, Vars[i].Alignment); in ComputeASanStackFrameLayout()
76 uint64_t Size = Vars[i].Size; in ComputeASanStackFrameLayout() local
77 assert((Alignment & (Alignment - 1)) == 0); in ComputeASanStackFrameLayout()
80 assert(Size > 0); in ComputeASanStackFrameLayout()
82 IsLast ? Granularity : std::max(Granularity, Vars[i + 1].Alignment); in ComputeASanStackFrameLayout()
84 VarAndRedzoneSize(Size, Granularity, NextAlignment); in ComputeASanStackFrameLayout()
89 Offset += MinHeaderSize - (Offset % MinHeaderSize); in ComputeASanStackFrameLayout()
100 StackDescription << Vars.size(); in ComputeASanStackFrameDescription()
108 StackDescription << " " << Var.Offset << " " << Var.Size << " " in ComputeASanStackFrameDescription()
109 << Name.size() << " " << Name; in ComputeASanStackFrameDescription()
117 assert(Vars.size() > 0); in GetShadowBytes()
125 SB.resize(SB.size() + Var.Size / Granularity, 0); in GetShadowBytes()
126 if (Var.Size % Granularity) in GetShadowBytes()
127 SB.push_back(Var.Size % Granularity); in GetShadowBytes()
140 assert(Var.LifetimeSize <= Var.Size); in GetShadowBytesAfterScope()
142 (Var.LifetimeSize + Granularity - 1) / Granularity; in GetShadowBytesAfterScope()