[llvm] 589c8d6 - [NFC] Simplify alignment code in MemorySanitizer
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 08:16:08 PDT 2022
Author: Guillaume Chatelet
Date: 2022-06-20T15:15:53Z
New Revision: 589c8d6fb9eb24539a2061b96e4cad130b44a453
URL: https://github.com/llvm/llvm-project/commit/589c8d6fb9eb24539a2061b96e4cad130b44a453
DIFF: https://github.com/llvm/llvm-project/commit/589c8d6fb9eb24539a2061b96e4cad130b44a453.diff
LOG: [NFC] Simplify alignment code in MemorySanitizer
Added:
Modified:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index a9cf61e48fa21..4d72f6c3d1a9b 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4848,8 +4848,8 @@ struct VarArgPowerPC64Helper : public VarArgHelper {
assert(A->getType()->isPointerTy());
Type *RealTy = CB.getParamByValType(ArgNo);
uint64_t ArgSize = DL.getTypeAllocSize(RealTy);
- MaybeAlign ArgAlign = CB.getParamAlign(ArgNo);
- if (!ArgAlign || *ArgAlign < Align(8))
+ Align ArgAlign = CB.getParamAlign(ArgNo).value_or(Align(8));
+ if (ArgAlign < 8)
ArgAlign = Align(8);
VAArgOffset = alignTo(VAArgOffset, ArgAlign);
if (!IsFixed) {
@@ -4865,27 +4865,27 @@ struct VarArgPowerPC64Helper : public VarArgHelper {
kShadowTLSAlignment, ArgSize);
}
}
- VAArgOffset += alignTo(ArgSize, 8);
+ VAArgOffset += alignTo(ArgSize, Align(8));
} else {
Value *Base;
uint64_t ArgSize = DL.getTypeAllocSize(A->getType());
- uint64_t ArgAlign = 8;
+ Align ArgAlign = Align(8);
if (A->getType()->isArrayTy()) {
// Arrays are aligned to element size, except for long double
// arrays, which are aligned to 8 bytes.
Type *ElementTy = A->getType()->getArrayElementType();
if (!ElementTy->isPPC_FP128Ty())
- ArgAlign = DL.getTypeAllocSize(ElementTy);
+ ArgAlign = Align(DL.getTypeAllocSize(ElementTy));
} else if (A->getType()->isVectorTy()) {
// Vectors are naturally aligned.
- ArgAlign = DL.getTypeAllocSize(A->getType());
+ ArgAlign = Align(ArgSize);
}
if (ArgAlign < 8)
- ArgAlign = 8;
+ ArgAlign = Align(8);
VAArgOffset = alignTo(VAArgOffset, ArgAlign);
if (DL.isBigEndian()) {
- // Adjusting the shadow for argument with size < 8 to match the placement
- // of bits in big endian system
+ // Adjusting the shadow for argument with size < 8 to match the
+ // placement of bits in big endian system
if (ArgSize < 8)
VAArgOffset += (8 - ArgSize);
}
@@ -4896,7 +4896,7 @@ struct VarArgPowerPC64Helper : public VarArgHelper {
IRB.CreateAlignedStore(MSV.getShadow(A), Base, kShadowTLSAlignment);
}
VAArgOffset += ArgSize;
- VAArgOffset = alignTo(VAArgOffset, 8);
+ VAArgOffset = alignTo(VAArgOffset, Align(8));
}
if (IsFixed)
VAArgBase = VAArgOffset;
More information about the llvm-commits
mailing list