diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-11-18 02:44:19 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-11-18 02:44:19 +0000 |
commit | a1748564b4b462af6056cbd53e39d2bd0c482c9a (patch) | |
tree | bda71d66e54dc5b19a5ea39a45b8f6b0f898af6c /clang/lib | |
parent | 457c68726cd3f544508a536aa2e53671a38345fb (diff) | |
download | bcm5719-llvm-a1748564b4b462af6056cbd53e39d2bd0c482c9a.tar.gz bcm5719-llvm-a1748564b4b462af6056cbd53e39d2bd0c482c9a.zip |
Make va_arg on x86-64 compute alignment the same way as argument passing.
Fixes <rdar://problem/10463281>.
llvm-svn: 144966
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 88f8579b9aa..33291dd5527 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -1983,19 +1983,17 @@ static llvm::Value *EmitVAArgFromMemory(llvm::Value *VAListAddr, // AMD64-ABI 3.5.7p5: Step 7. Align l->overflow_arg_area upwards to a 16 // byte boundary if alignment needed by type exceeds 8 byte boundary. + // It isn't stated explicitly in the standard, but in practice we use + // alignment greater than 16 where necessary. uint64_t Align = CGF.getContext().getTypeAlign(Ty) / 8; if (Align > 8) { - // Note that we follow the ABI & gcc here, even though the type - // could in theory have an alignment greater than 16. This case - // shouldn't ever matter in practice. - - // overflow_arg_area = (overflow_arg_area + 15) & ~15; + // overflow_arg_area = (overflow_arg_area + align - 1) & -align; llvm::Value *Offset = - llvm::ConstantInt::get(CGF.Int32Ty, 15); + llvm::ConstantInt::get(CGF.Int64Ty, Align - 1); overflow_arg_area = CGF.Builder.CreateGEP(overflow_arg_area, Offset); llvm::Value *AsInt = CGF.Builder.CreatePtrToInt(overflow_arg_area, CGF.Int64Ty); - llvm::Value *Mask = llvm::ConstantInt::get(CGF.Int64Ty, ~15LL); + llvm::Value *Mask = llvm::ConstantInt::get(CGF.Int64Ty, -(uint64_t)Align); overflow_arg_area = CGF.Builder.CreateIntToPtr(CGF.Builder.CreateAnd(AsInt, Mask), overflow_arg_area->getType(), |