Skip to content

Commit 4cd7e70

Browse files
author
git apple-llvm automerger
committed
Merge commit '72dddce6523a' from llvm.org/main into next
2 parents 4771ccf + 72dddce commit 4cd7e70

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ ASanStackFrameLayout ComputeASanStackFrameLayout(
5151
// The array of stack variables. The elements may get reordered and changed.
5252
SmallVectorImpl<ASanStackVariableDescription> &Vars,
5353
// AddressSanitizer's shadow granularity. Usually 8, may also be 16, 32, 64.
54-
size_t Granularity,
54+
uint64_t Granularity,
5555
// The minimal size of the left-most redzone (header).
5656
// At least 4 pointer sizes, power of 2, and >= Granularity.
5757
// The resulting FrameSize should be multiple of MinHeaderSize.
58-
size_t MinHeaderSize);
58+
uint64_t MinHeaderSize);
5959

6060
// Compute frame description, see DescribeAddressIfStack in ASan runtime.
6161
SmallString<64> ComputeASanStackFrameDescription(

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,8 +3325,8 @@ void FunctionStackPoisoner::processStaticAllocas() {
33253325

33263326
// Minimal header size (left redzone) is 4 pointers,
33273327
// i.e. 32 bytes on 64-bit platforms and 16 bytes in 32-bit platforms.
3328-
size_t Granularity = 1ULL << Mapping.Scale;
3329-
size_t MinHeaderSize = std::max((size_t)ASan.LongSize / 2, Granularity);
3328+
uint64_t Granularity = 1ULL << Mapping.Scale;
3329+
uint64_t MinHeaderSize = std::max((uint64_t)ASan.LongSize / 2, Granularity);
33303330
const ASanStackFrameLayout &L =
33313331
ComputeASanStackFrameLayout(SVD, Granularity, MinHeaderSize);
33323332

llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ static const uint64_t kMinAlignment = 16;
3838
// We want to add a full redzone after every variable.
3939
// The larger the variable Size the larger is the redzone.
4040
// The resulting frame size is a multiple of Alignment.
41-
static size_t VarAndRedzoneSize(size_t Size, size_t Granularity,
42-
size_t Alignment) {
43-
size_t Res = 0;
41+
static uint64_t VarAndRedzoneSize(uint64_t Size, uint64_t Granularity,
42+
uint64_t Alignment) {
43+
uint64_t Res = 0;
4444
if (Size <= 4) Res = 16;
4545
else if (Size <= 16) Res = 32;
4646
else if (Size <= 128) Res = Size + 32;
@@ -52,7 +52,7 @@ static size_t VarAndRedzoneSize(size_t Size, size_t Granularity,
5252

5353
ASanStackFrameLayout
5454
ComputeASanStackFrameLayout(SmallVectorImpl<ASanStackVariableDescription> &Vars,
55-
size_t Granularity, size_t MinHeaderSize) {
55+
uint64_t Granularity, uint64_t MinHeaderSize) {
5656
assert(Granularity >= 8 && Granularity <= 64 &&
5757
(Granularity & (Granularity - 1)) == 0);
5858
assert(MinHeaderSize >= 16 && (MinHeaderSize & (MinHeaderSize - 1)) == 0 &&
@@ -67,22 +67,22 @@ ComputeASanStackFrameLayout(SmallVectorImpl<ASanStackVariableDescription> &Vars,
6767
ASanStackFrameLayout Layout;
6868
Layout.Granularity = Granularity;
6969
Layout.FrameAlignment = std::max(Granularity, Vars[0].Alignment);
70-
size_t Offset = std::max(std::max(MinHeaderSize, Granularity),
71-
Vars[0].Alignment);
70+
uint64_t Offset =
71+
std::max(std::max(MinHeaderSize, Granularity), Vars[0].Alignment);
7272
assert((Offset % Granularity) == 0);
7373
for (size_t i = 0; i < NumVars; i++) {
7474
bool IsLast = i == NumVars - 1;
75-
size_t Alignment = std::max(Granularity, Vars[i].Alignment);
75+
uint64_t Alignment = std::max(Granularity, Vars[i].Alignment);
7676
(void)Alignment; // Used only in asserts.
77-
size_t Size = Vars[i].Size;
77+
uint64_t Size = Vars[i].Size;
7878
assert((Alignment & (Alignment - 1)) == 0);
7979
assert(Layout.FrameAlignment >= Alignment);
8080
assert((Offset % Alignment) == 0);
8181
assert(Size > 0);
82-
size_t NextAlignment = IsLast ? Granularity
83-
: std::max(Granularity, Vars[i + 1].Alignment);
84-
size_t SizeWithRedzone = VarAndRedzoneSize(Size, Granularity,
85-
NextAlignment);
82+
uint64_t NextAlignment =
83+
IsLast ? Granularity : std::max(Granularity, Vars[i + 1].Alignment);
84+
uint64_t SizeWithRedzone =
85+
VarAndRedzoneSize(Size, Granularity, NextAlignment);
8686
Vars[i].Offset = Offset;
8787
Offset += SizeWithRedzone;
8888
}
@@ -118,7 +118,7 @@ GetShadowBytes(const SmallVectorImpl<ASanStackVariableDescription> &Vars,
118118
assert(Vars.size() > 0);
119119
SmallVector<uint8_t, 64> SB;
120120
SB.clear();
121-
const size_t Granularity = Layout.Granularity;
121+
const uint64_t Granularity = Layout.Granularity;
122122
SB.resize(Vars[0].Offset / Granularity, kAsanStackLeftRedzoneMagic);
123123
for (const auto &Var : Vars) {
124124
SB.resize(Var.Offset / Granularity, kAsanStackMidRedzoneMagic);
@@ -135,13 +135,13 @@ SmallVector<uint8_t, 64> GetShadowBytesAfterScope(
135135
const SmallVectorImpl<ASanStackVariableDescription> &Vars,
136136
const ASanStackFrameLayout &Layout) {
137137
SmallVector<uint8_t, 64> SB = GetShadowBytes(Vars, Layout);
138-
const size_t Granularity = Layout.Granularity;
138+
const uint64_t Granularity = Layout.Granularity;
139139

140140
for (const auto &Var : Vars) {
141141
assert(Var.LifetimeSize <= Var.Size);
142-
const size_t LifetimeShadowSize =
142+
const uint64_t LifetimeShadowSize =
143143
(Var.LifetimeSize + Granularity - 1) / Granularity;
144-
const size_t Offset = Var.Offset / Granularity;
144+
const uint64_t Offset = Var.Offset / Granularity;
145145
std::fill(SB.begin() + Offset, SB.begin() + Offset + LifetimeShadowSize,
146146
kAsanStackUseAfterScopeMagic);
147147
}

0 commit comments

Comments
 (0)