44 if (Size <= 4) Res = 16;
45 else if (Size <= 16) Res = 32;
46 else if (Size <= 128) Res = Size + 32;
47 else if (Size <= 512) Res = Size + 64;
48 else if (Size <= 4096) Res = Size + 128;
49 else Res = Size + 256;
55 size_t Granularity,
size_t MinHeaderSize) {
56 assert(Granularity >= 8 && Granularity <= 64 &&
57 (Granularity & (Granularity - 1)) == 0);
58 assert(MinHeaderSize >= 16 && (MinHeaderSize & (MinHeaderSize - 1)) == 0 &&
59 MinHeaderSize >= Granularity);
60 const size_t NumVars = Vars.
size();
62 for (
size_t i = 0; i < NumVars; i++)
63 Vars[i].Alignment =
std::max(Vars[i].Alignment, kMinAlignment);
72 assert((Offset % Granularity) == 0);
73 for (
size_t i = 0; i < NumVars; i++) {
74 bool IsLast = i == NumVars - 1;
75 size_t Alignment =
std::max(Granularity, Vars[i].Alignment);
78 assert((Alignment & (Alignment - 1)) == 0);
80 assert((Offset % Alignment) == 0);
82 size_t NextAlignment = IsLast ? Granularity
83 :
std::max(Granularity, Vars[i + 1].Alignment);
87 Offset += SizeWithRedzone;
89 if (Offset % MinHeaderSize) {
90 Offset += MinHeaderSize - (Offset % MinHeaderSize);
101 StackDescription << Vars.
size();
103 for (
const auto &Var : Vars) {
104 std::string
Name = Var.Name;
109 StackDescription <<
" " << Var.Offset <<
" " << Var.Size <<
" " 110 << Name.size() <<
" " <<
Name;
112 return StackDescription.
str();
123 for (
const auto &Var : Vars) {
126 SB.resize(SB.size() + Var.Size / Granularity, 0);
127 if (Var.Size % Granularity)
128 SB.push_back(Var.Size % Granularity);
140 for (
const auto &Var : Vars) {
141 assert(Var.LifetimeSize <= Var.Size);
142 const size_t LifetimeShadowSize =
143 (Var.LifetimeSize + Granularity - 1) / Granularity;
144 const size_t Offset = Var.Offset / Granularity;
This class represents lattice values for constants.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static const int kAsanStackMidRedzoneMagic
A raw_ostream that writes to an SmallVector or SmallString.
SmallString< 64 > ComputeASanStackFrameDescription(const SmallVectorImpl< ASanStackVariableDescription > &Vars)
static const int kAsanStackLeftRedzoneMagic
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
ASanStackFrameLayout ComputeASanStackFrameLayout(SmallVectorImpl< ASanStackVariableDescription > &Vars, size_t Granularity, size_t MinHeaderSize)
Align max(MaybeAlign Lhs, Align Rhs)
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.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
const std::string to_string(const T &Value)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void stable_sort(R &&Range)
static const size_t kMinAlignment
SmallVector< uint8_t, 64 > GetShadowBytes(const SmallVectorImpl< ASanStackVariableDescription > &Vars, const ASanStackFrameLayout &Layout)