43 if (Size <= 4) Res = 16;
44 else if (Size <= 16) Res = 32;
45 else if (Size <= 128) Res = Size + 32;
46 else if (Size <= 512) Res = Size + 64;
47 else if (Size <= 4096) Res = Size + 128;
48 else Res = Size + 256;
54 size_t Granularity,
size_t MinHeaderSize) {
55 assert(Granularity >= 8 && Granularity <= 64 &&
56 (Granularity & (Granularity - 1)) == 0);
57 assert(MinHeaderSize >= 16 && (MinHeaderSize & (MinHeaderSize - 1)) == 0 &&
58 MinHeaderSize >= Granularity);
59 const size_t NumVars = Vars.
size();
61 for (
size_t i = 0;
i < NumVars;
i++)
68 Layout.FrameAlignment = std::max(Granularity, Vars[0].Alignment);
69 size_t Offset = std::max(std::max(MinHeaderSize, Granularity),
71 assert((Offset % Granularity) == 0);
72 for (
size_t i = 0;
i < NumVars;
i++) {
73 bool IsLast =
i == NumVars - 1;
74 size_t Alignment = std::max(Granularity, Vars[
i].Alignment);
76 size_t Size = Vars[
i].Size;
77 assert((Alignment & (Alignment - 1)) == 0);
78 assert(Layout.FrameAlignment >= Alignment);
79 assert((Offset % Alignment) == 0);
81 size_t NextAlignment = IsLast ? Granularity
82 : std::max(Granularity, Vars[
i + 1].Alignment);
85 Offset += SizeWithRedzone;
87 if (Offset % MinHeaderSize) {
88 Offset += MinHeaderSize - (Offset % MinHeaderSize);
91 assert((Layout.FrameSize % MinHeaderSize) == 0);
99 StackDescription << Vars.
size();
101 for (
const auto &Var : Vars) {
102 std::string
Name = Var.Name;
107 StackDescription <<
" " << Var.Offset <<
" " << Var.Size <<
" "
108 << Name.size() <<
" " <<
Name;
110 return StackDescription.
str();
113 SmallVector<uint8_t, 64>
121 for (
const auto &Var : Vars) {
124 SB.resize(SB.size() + Var.Size / Granularity, 0);
125 if (Var.Size % Granularity)
126 SB.push_back(Var.Size % Granularity);
138 for (
const auto &Var : Vars) {
139 assert(Var.LifetimeSize <= Var.Size);
140 const size_t LifetimeShadowSize =
141 (Var.LifetimeSize + Granularity - 1) / Granularity;
142 const size_t Offset = Var.Offset / Granularity;
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
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 const int kAsanStackRightRedzoneMagic
INITIALIZE_PASS(HexagonEarlyIfConversion,"hexagon-eif","Hexagon early if conversion", false, false) bool HexagonEarlyIfConversion MachineBasicBlock * SB
static size_t VarAndRedzoneSize(size_t Size, size_t Alignment)
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()
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
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)