diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp b/contrib/llvm-project/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp index 01912297324a..cbc508bb863a 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp @@ -33,14 +33,14 @@ static inline bool CompareVars(const ASanStackVariableDescription &a, // We also force minimal alignment for all vars to kMinAlignment so that vars // with e.g. alignment 1 and alignment 16 do not get reordered by CompareVars. -static const size_t kMinAlignment = 16; +static const uint64_t kMinAlignment = 16; // We want to add a full redzone after every variable. // The larger the variable Size the larger is the redzone. // The resulting frame size is a multiple of Alignment. -static size_t VarAndRedzoneSize(size_t Size, size_t Granularity, - size_t Alignment) { - size_t Res = 0; +static uint64_t VarAndRedzoneSize(uint64_t Size, uint64_t Granularity, + uint64_t Alignment) { + uint64_t Res = 0; if (Size <= 4) Res = 16; else if (Size <= 16) Res = 32; else if (Size <= 128) Res = Size + 32; @@ -52,7 +52,7 @@ static size_t VarAndRedzoneSize(size_t Size, size_t Granularity, ASanStackFrameLayout ComputeASanStackFrameLayout(SmallVectorImpl<ASanStackVariableDescription> &Vars, - size_t Granularity, size_t MinHeaderSize) { + uint64_t Granularity, uint64_t MinHeaderSize) { assert(Granularity >= 8 && Granularity <= 64 && (Granularity & (Granularity - 1)) == 0); assert(MinHeaderSize >= 16 && (MinHeaderSize & (MinHeaderSize - 1)) == 0 && @@ -67,22 +67,22 @@ ComputeASanStackFrameLayout(SmallVectorImpl<ASanStackVariableDescription> &Vars, ASanStackFrameLayout Layout; Layout.Granularity = Granularity; Layout.FrameAlignment = std::max(Granularity, Vars[0].Alignment); - size_t Offset = std::max(std::max(MinHeaderSize, Granularity), - Vars[0].Alignment); + uint64_t Offset = + std::max(std::max(MinHeaderSize, Granularity), Vars[0].Alignment); assert((Offset % Granularity) == 0); for (size_t i = 0; i < NumVars; i++) { bool IsLast = i == NumVars - 1; - size_t Alignment = std::max(Granularity, Vars[i].Alignment); + uint64_t Alignment = std::max(Granularity, Vars[i].Alignment); (void)Alignment; // Used only in asserts. - size_t Size = Vars[i].Size; + uint64_t Size = Vars[i].Size; assert((Alignment & (Alignment - 1)) == 0); assert(Layout.FrameAlignment >= Alignment); assert((Offset % Alignment) == 0); assert(Size > 0); - size_t NextAlignment = IsLast ? Granularity - : std::max(Granularity, Vars[i + 1].Alignment); - size_t SizeWithRedzone = VarAndRedzoneSize(Size, Granularity, - NextAlignment); + uint64_t NextAlignment = + IsLast ? Granularity : std::max(Granularity, Vars[i + 1].Alignment); + uint64_t SizeWithRedzone = + VarAndRedzoneSize(Size, Granularity, NextAlignment); Vars[i].Offset = Offset; Offset += SizeWithRedzone; } @@ -118,7 +118,7 @@ GetShadowBytes(const SmallVectorImpl<ASanStackVariableDescription> &Vars, assert(Vars.size() > 0); SmallVector<uint8_t, 64> SB; SB.clear(); - const size_t Granularity = Layout.Granularity; + const uint64_t Granularity = Layout.Granularity; SB.resize(Vars[0].Offset / Granularity, kAsanStackLeftRedzoneMagic); for (const auto &Var : Vars) { SB.resize(Var.Offset / Granularity, kAsanStackMidRedzoneMagic); @@ -135,13 +135,13 @@ SmallVector<uint8_t, 64> GetShadowBytesAfterScope( const SmallVectorImpl<ASanStackVariableDescription> &Vars, const ASanStackFrameLayout &Layout) { SmallVector<uint8_t, 64> SB = GetShadowBytes(Vars, Layout); - const size_t Granularity = Layout.Granularity; + const uint64_t Granularity = Layout.Granularity; for (const auto &Var : Vars) { assert(Var.LifetimeSize <= Var.Size); - const size_t LifetimeShadowSize = + const uint64_t LifetimeShadowSize = (Var.LifetimeSize + Granularity - 1) / Granularity; - const size_t Offset = Var.Offset / Granularity; + const uint64_t Offset = Var.Offset / Granularity; std::fill(SB.begin() + Offset, SB.begin() + Offset + LifetimeShadowSize, kAsanStackUseAfterScopeMagic); } |