[llvm] 7296811 - [NFC] Simplify alignment code in CoroFrame
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 08:16:06 PDT 2022
Author: Guillaume Chatelet
Date: 2022-06-20T15:15:52Z
New Revision: 72968119100e39ba7960144839abcc5a882c4fbe
URL: https://github.com/llvm/llvm-project/commit/72968119100e39ba7960144839abcc5a882c4fbe
DIFF: https://github.com/llvm/llvm-project/commit/72968119100e39ba7960144839abcc5a882c4fbe.diff
LOG: [NFC] Simplify alignment code in CoroFrame
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 13ed8778ac76d..62620dce61d75 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -495,7 +495,7 @@ class FrameTypeBuilder {
coro::Shape &Shape);
/// Add a field to this structure.
- LLVM_NODISCARD FieldIDType addField(Type *Ty, MaybeAlign FieldAlignment,
+ LLVM_NODISCARD FieldIDType addField(Type *Ty, MaybeAlign MaybeFieldAlignment,
bool IsHeader = false,
bool IsSpillOfValue = false) {
assert(!IsFinished && "adding fields to a finished builder");
@@ -514,23 +514,19 @@ class FrameTypeBuilder {
// to remember the type alignment anyway to build the type.
// If we are spilling values we don't need to worry about ABI alignment
// concerns.
- auto ABIAlign = DL.getABITypeAlign(Ty);
- Align TyAlignment =
- (IsSpillOfValue && MaxFrameAlignment)
- ? (*MaxFrameAlignment < ABIAlign ? *MaxFrameAlignment : ABIAlign)
- : ABIAlign;
- if (!FieldAlignment) {
- FieldAlignment = TyAlignment;
- }
+ Align ABIAlign = DL.getABITypeAlign(Ty);
+ Align TyAlignment = ABIAlign;
+ if (IsSpillOfValue && MaxFrameAlignment && *MaxFrameAlignment < ABIAlign)
+ TyAlignment = *MaxFrameAlignment;
+ Align FieldAlignment = MaybeFieldAlignment.value_or(TyAlignment);
// The field alignment could be bigger than the max frame case, in that case
// we request additional storage to be able to dynamically align the
// pointer.
uint64_t DynamicAlignBuffer = 0;
- if (MaxFrameAlignment &&
- (FieldAlignment.valueOrOne() > *MaxFrameAlignment)) {
+ if (MaxFrameAlignment && (FieldAlignment > *MaxFrameAlignment)) {
DynamicAlignBuffer =
- offsetToAlignment((*MaxFrameAlignment).value(), *FieldAlignment);
+ offsetToAlignment(MaxFrameAlignment->value(), FieldAlignment);
FieldAlignment = *MaxFrameAlignment;
FieldSize = FieldSize + DynamicAlignBuffer;
}
@@ -541,12 +537,12 @@ class FrameTypeBuilder {
Offset = alignTo(StructSize, FieldAlignment);
StructSize = Offset + FieldSize;
- // Everything else has a flexible offset.
+ // Everything else has a flexible offset.
} else {
Offset = OptimizedStructLayoutField::FlexibleOffset;
}
- Fields.push_back({FieldSize, Offset, Ty, 0, *FieldAlignment, TyAlignment,
+ Fields.push_back({FieldSize, Offset, Ty, 0, FieldAlignment, TyAlignment,
DynamicAlignBuffer});
return Fields.size() - 1;
}
More information about the llvm-commits
mailing list