i386 ABI: Offset computation in va_arg was incorrect for sizeof(Ty)>4.

We are down to only failing gcc.dg/compat/vector-[12] (8 tests total).

llvm-svn: 64967
This commit is contained in:
Daniel Dunbar 2009-02-18 22:28:45 +00:00
parent faca7d9842
commit 8cdb9dae45
1 changed files with 3 additions and 6 deletions

View File

@ -360,14 +360,11 @@ llvm::Value *X86_32ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
llvm::PointerType::getUnqual(CGF.ConvertType(Ty));
llvm::Value *AddrTyped = Builder.CreateBitCast(Addr, PTy);
uint64_t SizeInBytes = CGF.getContext().getTypeSize(Ty) / 8;
const unsigned ArgumentSizeInBytes = 4;
if (SizeInBytes < ArgumentSizeInBytes)
SizeInBytes = ArgumentSizeInBytes;
uint64_t Offset =
llvm::RoundUpToAlignment(CGF.getContext().getTypeSize(Ty) / 8, 4);
llvm::Value *NextAddr =
Builder.CreateGEP(Addr,
llvm::ConstantInt::get(llvm::Type::Int32Ty, SizeInBytes),
llvm::ConstantInt::get(llvm::Type::Int32Ty, Offset),
"ap.next");
Builder.CreateStore(NextAddr, VAListAddrAsBPP);