Skip to content

[Runtime] Replace std::max_align_t with MaximumAlignment from MetadataValues.h. #40244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/Reflection/ReflectionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ class ReflectionContext
// For now, we won't try to walk the allocations in the slab, we'll just
// provide the whole thing as one big chunk.
size_t HeaderSize =
llvm::alignTo(sizeof(*Slab), llvm::Align(alignof(std::max_align_t)));
llvm::alignTo(sizeof(*Slab), llvm::Align(MaximumAlignment));
AsyncTaskAllocationChunk Chunk;

Chunk.Start = SlabPtr + HeaderSize;
Expand Down
1 change: 0 additions & 1 deletion stdlib/public/runtime/Casting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@

#if defined(__GLIBCXX__) && __GLIBCXX__ < 20160726
#include <stddef.h>
namespace std { using ::max_align_t; }
#endif

using namespace swift;
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/runtime/DynamicCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ _tryCastFromClassToObjCBridgeable(

// The extra byte is for the tag on the T?
const std::size_t inlineValueSize = 3 * sizeof(void*);
alignas(std::max_align_t) char inlineBuffer[inlineValueSize + 1];
alignas(MaximumAlignment) char inlineBuffer[inlineValueSize + 1];
void *optDestBuffer;
if (destType->getValueWitnesses()->getStride() <= inlineValueSize) {
// Use the inline buffer.
Expand Down
3 changes: 2 additions & 1 deletion stdlib/public/runtime/StackAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//
//===----------------------------------------------------------------------===//

#include "swift/ABI/MetadataValues.h"
#include "swift/Runtime/Debug.h"
#include "llvm/Support/Alignment.h"
#include <cstddef>
Expand Down Expand Up @@ -67,7 +68,7 @@ class StackAllocator {
bool firstSlabIsPreallocated;

/// The minimal alignment of allocated memory.
static constexpr size_t alignment = alignof(std::max_align_t);
static constexpr size_t alignment = MaximumAlignment;

/// If set to true, memory allocations are checked for buffer overflows and
/// use-after-free, similar to guard-malloc.
Expand Down