[llvm] 72dddce - More size_t -> uint64_t fixes after 05392466
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 6 15:13:58 PDT 2021
Author: Arthur Eubanks
Date: 2021-10-06T15:13:47-07:00
New Revision: 72dddce6523a1f1ace61a89e99c0c5866063b32f
URL: https://github.com/llvm/llvm-project/commit/72dddce6523a1f1ace61a89e99c0c5866063b32f
DIFF: https://github.com/llvm/llvm-project/commit/72dddce6523a1f1ace61a89e99c0c5866063b32f.diff
LOG: More size_t -> uint64_t fixes after 05392466
Fixes some bots where the two differ.
Added:
Modified:
llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h b/llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h
index 3659e64527b9..24e33686964f 100644
--- a/llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h
+++ b/llvm/include/llvm/Transforms/Utils/ASanStackFrameLayout.h
@@ -51,11 +51,11 @@ ASanStackFrameLayout ComputeASanStackFrameLayout(
// The array of stack variables. The elements may get reordered and changed.
SmallVectorImpl<ASanStackVariableDescription> &Vars,
// AddressSanitizer's shadow granularity. Usually 8, may also be 16, 32, 64.
- size_t Granularity,
+ uint64_t Granularity,
// The minimal size of the left-most redzone (header).
// At least 4 pointer sizes, power of 2, and >= Granularity.
// The resulting FrameSize should be multiple of MinHeaderSize.
- size_t MinHeaderSize);
+ uint64_t MinHeaderSize);
// Compute frame description, see DescribeAddressIfStack in ASan runtime.
SmallString<64> ComputeASanStackFrameDescription(
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 74f5d8476277..ce6fded63399 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -3323,8 +3323,8 @@ void FunctionStackPoisoner::processStaticAllocas() {
// Minimal header size (left redzone) is 4 pointers,
// i.e. 32 bytes on 64-bit platforms and 16 bytes in 32-bit platforms.
- size_t Granularity = 1ULL << Mapping.Scale;
- size_t MinHeaderSize = std::max((size_t)ASan.LongSize / 2, Granularity);
+ uint64_t Granularity = 1ULL << Mapping.Scale;
+ uint64_t MinHeaderSize = std::max((uint64_t)ASan.LongSize / 2, Granularity);
const ASanStackFrameLayout &L =
ComputeASanStackFrameLayout(SVD, Granularity, MinHeaderSize);
diff --git a/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp b/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp
index d987d7189552..cbc508bb863a 100644
--- a/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp
+++ b/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp
@@ -38,9 +38,9 @@ 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);
}
More information about the llvm-commits
mailing list