45 if (Size <= 4) Res = 16;
46 else if (Size <= 16) Res = 32;
47 else if (Size <= 128) Res = Size + 32;
48 else if (Size <= 512) Res = Size + 64;
49 else if (Size <= 4096) Res = Size + 128;
50 else Res = Size + 256;
56 size_t Granularity,
size_t MinHeaderSize) {
57 assert(Granularity >= 8 && Granularity <= 64 &&
58 (Granularity & (Granularity - 1)) == 0);
59 assert(MinHeaderSize >= 16 && (MinHeaderSize & (MinHeaderSize - 1)) == 0 &&
60 MinHeaderSize >= Granularity);
61 const size_t NumVars = Vars.
size();
63 for (
size_t i = 0; i < NumVars; i++)
64 Vars[i].Alignment =
std::max(Vars[i].Alignment, kMinAlignment);
70 Layout.FrameAlignment =
std::max(Granularity, Vars[0].Alignment);
73 assert((Offset % Granularity) == 0);
74 for (
size_t i = 0; i < NumVars; i++) {
75 bool IsLast = i == NumVars - 1;
76 size_t Alignment =
std::max(Granularity, Vars[i].Alignment);
79 assert((Alignment & (Alignment - 1)) == 0);
80 assert(Layout.FrameAlignment >= Alignment);
81 assert((Offset % Alignment) == 0);
83 size_t NextAlignment = IsLast ? Granularity
84 :
std::max(Granularity, Vars[i + 1].Alignment);
88 Offset += SizeWithRedzone;
90 if (Offset % MinHeaderSize) {
91 Offset += MinHeaderSize - (Offset % MinHeaderSize);
94 assert((Layout.FrameSize % MinHeaderSize) == 0);
102 StackDescription << Vars.
size();
104 for (
const auto &Var : Vars) {
105 std::string
Name = Var.Name;
110 StackDescription <<
" " << Var.Offset <<
" " << Var.Size <<
" " 111 << Name.size() <<
" " <<
Name;
113 return StackDescription.
str();
124 for (
const auto &Var : Vars) {
127 SB.resize(SB.size() + Var.Size / Granularity, 0);
128 if (Var.Size % Granularity)
129 SB.push_back(Var.Size % Granularity);
141 for (
const auto &Var : Vars) {
142 assert(Var.LifetimeSize <= Var.Size);
143 const size_t LifetimeShadowSize =
144 (Var.LifetimeSize + Granularity - 1) / Granularity;
145 const size_t Offset = Var.Offset / Granularity;
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
static const int kAsanStackMidRedzoneMagic
A raw_ostream that writes to an SmallVector or SmallString.
SmallString< 64 > ComputeASanStackFrameDescription(const SmallVectorImpl< ASanStackVariableDescription > &Vars)
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
static const int kAsanStackLeftRedzoneMagic
amdgpu Simplify well known AMD library false Value Value const Twine & Name
static bool CompareVars(const ASanStackVariableDescription &a, const ASanStackVariableDescription &b)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
SmallVector< uint8_t, 64 > GetShadowBytesAfterScope(const SmallVectorImpl< ASanStackVariableDescription > &Vars, const ASanStackFrameLayout &Layout)
static size_t VarAndRedzoneSize(size_t Size, size_t Granularity, size_t Alignment)
static const int kAsanStackRightRedzoneMagic
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
ASanStackFrameLayout ComputeASanStackFrameLayout(SmallVectorImpl< ASanStackVariableDescription > &Vars, size_t Granularity, size_t MinHeaderSize)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static const int kAsanStackUseAfterScopeMagic
StringRef str()
Return a StringRef for the vector contents.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
const std::string to_string(const T &Value)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const size_t kMinAlignment
SmallVector< uint8_t, 64 > GetShadowBytes(const SmallVectorImpl< ASanStackVariableDescription > &Vars, const ASanStackFrameLayout &Layout)