[llvm] [MSan] Separated PPC32 va_arg helper from PPC64 (PR #131827)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 9 07:19:26 PDT 2025
================
@@ -6601,45 +6576,51 @@ struct VarArgPowerPC32Helper : public VarArgHelperBase {
kShadowTLSAlignment, ArgSize);
}
}
- VAArgOffset += alignTo(ArgSize, Align(8));
+ VAArgOffset += alignTo(ArgSize, Align(IntptrSize));
} else {
Value *Base;
- uint64_t ArgSize = DL.getTypeAllocSize(A->getType());
- 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 = Align(DL.getTypeAllocSize(ElementTy));
- } else if (A->getType()->isVectorTy()) {
- // Vectors are naturally aligned.
- ArgAlign = Align(ArgSize);
- }
- if (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
- if (ArgSize < 8)
- VAArgOffset += (8 - ArgSize);
- }
- if (!IsFixed) {
- Base =
- getShadowPtrForVAArgument(IRB, VAArgOffset - VAArgBase, ArgSize);
- if (Base)
- IRB.CreateAlignedStore(MSV.getShadow(A), Base, kShadowTLSAlignment);
+ Type *ArgTy = A->getType();
+
+ // On PPC 32 floating point variable arguments are stored in separate
+ // area: fp_save_area = reg_save_area + 4*8. We do not copy shaodow for
+ // them as they will be found when checking call arguments.
+ if (!ArgTy->isFloatingPointTy()) {
+ uint64_t ArgSize = DL.getTypeAllocSize(ArgTy);
+ Align ArgAlign = Align(IntptrSize);
+ if (ArgTy->isArrayTy()) {
+ // Arrays are aligned to element size, except for long double
+ // arrays, which are aligned to 8 bytes.
+ Type *ElementTy = ArgTy->getArrayElementType();
+ if (!ElementTy->isPPC_FP128Ty())
+ ArgAlign = Align(DL.getTypeAllocSize(ElementTy));
+ } else if (ArgTy->isVectorTy()) {
+ // Vectors are naturally aligned.
+ ArgAlign = Align(ArgSize);
+ }
+ if (ArgAlign < IntptrSize)
+ ArgAlign = Align(IntptrSize);
+ VAArgOffset = alignTo(VAArgOffset, ArgAlign);
+ if (DL.isBigEndian()) {
+ // Adjusting the shadow for argument with size < IntptrSize to match
+ // the placement of bits in big endian system
+ if (ArgSize < IntptrSize)
+ VAArgOffset += (IntptrSize - ArgSize);
+ }
+ if (!IsFixed) {
+ Base = getShadowPtrForVAArgument(IRB, VAArgOffset - VAArgBase,
+ ArgSize);
+ if (Base)
+ IRB.CreateAlignedStore(MSV.getShadow(A), Base,
+ kShadowTLSAlignment);
+ }
+ VAArgOffset += ArgSize;
+ VAArgOffset = alignTo(VAArgOffset, Align(IntptrSize));
}
- VAArgOffset += ArgSize;
- VAArgOffset = alignTo(VAArgOffset, Align(8));
}
- if (IsFixed)
- VAArgBase = VAArgOffset;
}
Constant *TotalVAArgSize =
- ConstantInt::get(MS.IntptrTy, VAArgOffset - VAArgBase);
+ ConstantInt::get(IRB.getInt32Ty(), VAArgOffset - VAArgBase);
----------------
k-kashapov wrote:
Oh, i've found the answer. The problem was data layout:
```bash
target datalayout = "e-m:e-i32:32-n32"
```
I've changed it to
```bash
target datalayout = "e-m:e-p:32:32-Fn32-i64:64-n32"
```
and now it does use 32-bit pointers.
This was obvious, i guess.
I will now update the Helper and the tests.
https://github.com/llvm/llvm-project/pull/131827
More information about the llvm-commits
mailing list