aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-28 18:24:28 +0000
committerChris Lattner <sabre@nondot.org>2010-07-28 18:24:28 +0000
commitdeabde24e1712253e483a46d24c0e10f25ebba99 (patch)
treeb2ab0c6b7fb6ec067a8060325ef87f12c65631e8 /lib/CodeGen/CGCall.cpp
parent2a3a1bd20e62205260eb2ba3f91a2b6b2db3ffb8 (diff)
some cleanups and get alignments correct for various coerce cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
-rw-r--r--lib/CodeGen/CGCall.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 30b2b6e120..32547db7fa 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -311,11 +311,10 @@ void CodeGenTypes::GetExpandedTypes(QualType Ty,
"Cannot expand structure with bit-field members.");
QualType FT = FD->getType();
- if (CodeGenFunction::hasAggregateLLVMType(FT)) {
+ if (CodeGenFunction::hasAggregateLLVMType(FT))
GetExpandedTypes(FT, ArgTys, IsRecursive);
- } else {
+ else
ArgTys.push_back(ConvertType(FT, IsRecursive));
- }
}
}
@@ -759,7 +758,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
if (RetAttrs)
PAL.push_back(llvm::AttributeWithIndex::get(0, RetAttrs));
- // FIXME: we need to honour command line settings also...
+ // FIXME: we need to honor command line settings also.
// FIXME: RegParm should be reduced in case of nested functions and/or global
// register variable.
signed RegParm = FI.getRegParm();
@@ -945,11 +944,16 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
continue;
case ABIArgInfo::Coerce: {
- // FIXME: This is very wasteful; EmitParmDecl is just going to drop the
- // result in a new alloca anyway, so we could just store into that
- // directly if we broke the abstraction down more.
llvm::AllocaInst *Alloca = CreateMemTemp(Ty, "coerce");
- Alloca->setAlignment(getContext().getDeclAlign(Arg).getQuantity());
+
+ // The alignment we need to use is the max of the requested alignment for
+ // the argument plus the alignment required by our access code below.
+ unsigned AlignmentToUse =
+ CGF.CGM.getTargetData().getABITypeAlignment(ArgI.getCoerceToType());
+ AlignmentToUse = std::max(AlignmentToUse,
+ (unsigned)getContext().getDeclAlign(Arg).getQuantity());
+
+ Alloca->setAlignment(AlignmentToUse);
llvm::Value *V = Alloca;
// If the coerce-to type is a first class aggregate, we flatten it and
@@ -1201,7 +1205,10 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
llvm::PointerType::getUnqual(STy));
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
llvm::Value *EltPtr = Builder.CreateConstGEP2_32(SrcPtr, 0, i);
- Args.push_back(Builder.CreateLoad(EltPtr));
+ llvm::LoadInst *LI = Builder.CreateLoad(EltPtr);
+ // We don't know what we're loading from.
+ LI->setAlignment(1);
+ Args.push_back(LI);
}
} else {
// In the simple case, just pass the coerced loaded value.